summaryrefslogtreecommitdiff
path: root/muse2/m4/qt.m4
blob: 5aceb294525c8fa677cb21c453185197d2379281 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
dnl
dnl CONFIGURE_QT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl \author J.E. Hoffmann <je-h@gmx.net>
dnl
AC_DEFUN([CONFIGURE_QT],
[
  qt_error="no"

  QT_CFLAGS=""
  QT_LIBS=""
  MOC="moc"
  UIC="uic"
  qt_includes="/usr/include/qt"
  qt_libraries=""
  qt_binaries=""

  if test "$qt_error" = "no"; then
    AC_MSG_CHECKING([for QT environment variable QTDIR])
    if test -z "$QTDIR"; then
      AC_MSG_RESULT(no)
      AC_MSG_WARN([

    ***************** WARNING *****************

YOU HAVE NOT SET YOUR 'QTDIR' ENVIRONMENT VARIABLE!!!

This is the source of most people's problems when
configuring muse.  If the configuration fails to find
qt, try setting your QTDIR environment variable to
the directory where qt is installed.

    *******************************************

])
      echo -ne "\a"
      echo -ne "\a"
      echo -ne "\a"
      sleep 7
    else
      AC_MSG_RESULT(yes)
      qt_includes="$QTDIR/include"
      qt_libraries="$QTDIR/lib"
      qt_binaries="$QTDIR/bin"
      MOC="$qt_binaries/moc";
      UIC="$qt_binaries/uic";
    fi
  fi

  muse_qttest="yes"
  AC_ARG_ENABLE(qttest,
  [  --disable-qttest        do not try to compile and run a test libqt program],[
    case "$enableval" in
      "yes")
        muse_qttest="yes"
        ;;
      "no")
        muse_qttest="no"
        ;;
      *)
        AC_MSG_ERROR([must use --enable-qttest(=yes/no) or --disable-qttest])
      ;;
    esac
  ])


  AC_ARG_WITH(qt-prefix,
    [  --with-qt-prefix=PFX    where the root of Qt is installed ],
    [
      qt_includes="$withval/include"
      qt_libraries="$withval/lib"
      qt_binaries="$withval/bin"
      MOC="$qt_binaries/moc";
      UIC="$qt_binaries/uic";
    ])

  AC_ARG_WITH(qt-includes,
    [  --with-qt-includes=DIR  where the Qt includes are installed ],
    [
      qt_includes="$withval"
    ])

  AC_ARG_WITH(qt-libraries,
    [  --with-qt-libraries=DIR where the Qt libraries are installed.],
    [
      qt_libraries="$withval"
    ])

  AC_ARG_WITH(qt-binaries,
    [  --with-qt-binaries=DIR  where the Qt binaries are installed.],
    [
      qt_binaries="$withval"
      MOC="$qt_binaries/moc";
      UIC="$qt_binaries/uic";
    ])

  AC_ARG_WITH(qt-moc,
    [  --with-qt-moc=PROG      where the Qt meta object compiler is installed.],
    [
      MOC="$withval"
    ])

  AC_ARG_WITH(qt-uic,
    [  --with-qt-uic=PROG      where the Qt user interface compiler is installed.],
    [
      UIC="$withval"
    ])

  if test "$qt_error" = "no"; then
    saved_CPPFLAGS="$CPPFLAGS"
    saved_LIBS="$LIBS"
    CPPFLAGS="$saved_CPPFLAGS -I$qt_includes"
    if test -n "$qt_libraries"; then
      LIBS="$saved_LIBS -L$qt_libraries -lqt-mt -lqui"
      QT_LIBS="-L$qt_libraries -lqt-mt -lqui"
    else
      LIBS="$saved_LIBS -lqt-mt -lqui -lm $X11_LIBS"
      QT_LIBS="-lqt-mt -lqui"
    fi
    AC_MSG_CHECKING([for QT includes ($qt_includes)])
    AC_CACHE_VAL(qt_includes_found,
    [
      AC_LANG_PUSH(C++)
      AC_TRY_CPP([#include <qapplication.h>],
                 qt_includes_found=yes, qt_includes_found=no)
      AC_LANG_POP(C++)
      if test "$qt_includes_found" = "yes"; then
        QT_CFLAGS="-I$qt_includes"
        AC_MSG_RESULT(yes)
      else
        qt_error=yes
        AC_MSG_RESULT(no)
      fi
    ])

    AC_MSG_CHECKING([for QT libraries ($qt_libraries)])
    AC_CACHE_VAL(qt_libraries_found,
    [
      AC_LANG_SAVE
      AC_LANG_CPLUSPLUS
      saved_CXXFLAGS="$CXXFLAGS"
      saved_LIBS="$LIBS"
      CXXFLAGS="$QT_CFLAGS $LIBS"
      LIBS="$QT_LIBS $LIBS"


      if test "$muse_qttest" = "yes"; then
          AC_TRY_RUN([
              #include <qapplication.h>
              int main(int argc, char **argv)
              {
                QApplication app(argc, argv, false);
	
              }
            ],[
              AC_MSG_RESULT(yes)
            ],[
              AC_MSG_RESULT(no)
              qt_error="yes"
            ],
            AC_MSG_ERROR([cross compiling unsupported])
          )
      else
        AC_MSG_RESULT([yes (assumed due to --disable-qttest)])
      fi

      LIBS="$saved_LIBS"
      CXXFLAGS="$saved_CXXFLAGS"
      AC_LANG_RESTORE
    ])

    AC_MSG_CHECKING([for QT moc ($MOC)])
    output=`eval "$MOC --help 2>&1 | grep Qt"`
    if test -z "$output"; then
      AC_MSG_RESULT(no)
      qt_error="yes"
    else
      AC_MSG_RESULT(yes)
    fi

    AC_MSG_CHECKING([for QT uic ($UIC)])
    output=`eval "$UIC --help 2>&1 | grep Qt"`
    if test -z "$output"; then
      AC_MSG_RESULT(no)
      qt_error="yes"
    else
      AC_MSG_RESULT(yes)
    fi
    CPPFLAGS="$saved_CPPFLAGS"
    LIBS="$saved_LIBS"
  fi

  if test "$qt_error" = "no"; then
    AC_MSG_CHECKING([for QT version >= $1])
    qt_major_version=`echo $1 | \
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
    qt_minor_version=`echo $1 | \
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
    qt_micro_version=`echo $1 | \
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
    qt_version="$qt_major_version$qt_minor_version$qt_micro_version"

    AC_LANG_SAVE
    AC_LANG_CPLUSPLUS
    saved_CXXFLAGS="$CXXFLAGS"
    saved_LIBS="$LIBS"
    CXXFLAGS="$QT_CFLAGS $LIBS"
    LIBS="$QT_LIBS $LIBS"

    if test "$muse_qttest" = "yes"; then
        AC_TRY_RUN([
            #include <qglobal.h>
            int main()
            {
            int version = ($qt_major_version << 16)
               + ($qt_minor_version << 8)
               + $qt_micro_version;
              if (QT_VERSION < version) return(1);
              return(0);
            }
          ],[
            AC_MSG_RESULT(yes)
          ],[
            AC_MSG_RESULT(no)
            qt_error="yes"
          ],
          AC_MSG_ERROR([cross compiling unsupported])
        )
    else
      AC_MSG_RESULT([yes (assumed due to --disable-qttest)])
    fi

    LIBS="$saved_LIBS"
    CXXFLAGS="$saved_CXXFLAGS"
    AC_LANG_RESTORE
  fi

  AC_SUBST(QT_CFLAGS)
  AC_SUBST(QT_LIBS)
  AC_SUBST(MOC)
  AC_SUBST(UIC)
  if test "$qt_error" = "no"; then
     ifelse([$2], , :, [$2])
  else
     ifelse([$3], , :, [$3])
  fi
])