1 dnl Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 dnl This library is free software; you can redistribute it and/or
7 dnl modify it under the terms of the GNU Lesser General Public
8 dnl License as published by the Free Software Foundation; either
9 dnl version 2.1 of the License.
11 dnl This library is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 dnl Lesser General Public License for more details.
16 dnl You should have received a copy of the GNU Lesser General Public
17 dnl License along with this library; if not, write to the Free Software
18 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 dnl ------------------------------------------------------------------------
24 dnl Adds the --with-qt=path
26 AC_DEFUN([OPTIONS_QT], [
28 [AC_HELP_STRING([--with-qt], [Possible usage:
29 "Qt_Install_Path" - prefix to path where Qt was installd;
30 "" or "yes" or "auto" - means seaching installed Qt product in the system (checking $QTDIR and then - standard system paths );
31 "no" - not use Qt product (is not supported)
32 By default "" option is used)])],
33 [with_qt=$withval], [with_qt=""])
37 AC_REQUIRE([AC_PROG_CC])dnl
38 AC_REQUIRE([AC_PROG_CXX])dnl
39 AC_REQUIRE([AC_PROG_CPP])dnl
40 AC_REQUIRE([AC_PROG_CXXCPP])dnl
41 AC_REQUIRE([CHECK_OPENGL])dnl
42 AC_REQUIRE([AC_LINKER_OPTIONS])dnl
44 AC_REQUIRE([OPTIONS_QT])dnl
48 if test "x$OpenGL_ok" != "xyes" ; then
49 AC_MSG_WARN(Qt needs OpenGL correct configuration, check configure output)
54 QTDIR=$(echo $QTDIR | sed 's%[/]\+$%%')
60 if test -z $with_qt ; then
63 if test "x$with_qt" = "xyes" ; then
64 dnl in case user wrote --with-qt=yes
67 if test "x$with_qt" = "xauto" ; then
68 dnl in case user wrote --with-qt=auto
71 if test "x$with_qt" = "xno" ; then
72 dnl in case user wrote --with-qt=no
74 AC_MSG_WARN(Value no, specified for option --with-qt, is not supported)
77 if test "x$with_qt" != "x" ; then
78 dnl Using "--with-qt" prefix path
80 elif test "$QTDIR" = "/usr/lib/qt3" ; then
81 dnl Using QTDIR environment variable
82 AC_MSG_RESULT(current QTDIR is $QTDIR)
84 if test -d /usr/lib/qt4 ; then
85 AC_MSG_RESULT(it is strange for a qt4 installation !)
86 AC_MSG_RESULT(/usr/lib/qt4 is present)
87 AC_MSG_RESULT(replacing QTDIR by /usr/lib/qt4)
90 elif test -z $QTDIR ; then
91 AC_MSG_WARN(undefined QTDIR variable which specify where Qt product was installed)
92 for d in /usr/local/lib/qt4 /usr/lib/qt4 /usr ; do
93 if test -f ${d}/lib/libQtCore.so ; then
94 AC_MSG_RESULT(trying ${d})
97 elif test -f ${d}/lib64/libQtCore.so ; then
98 AC_MSG_RESULT(trying ${d})
101 elif test -f ${d}/libQtCore.so ; then
102 AC_MSG_RESULT(trying ${d})
110 # check QTDIR environment variable
112 if test "x$QTDIR" = "x"
114 AC_MSG_RESULT(Please define correct path in "--with-qt" option or use correct $QTDIR variable)
121 if test "x$qt_ok" = "xyes"
125 AC_CHECK_FILE(${QTDIR}/include/qt4/QtCore/qglobal.h,QTINC="/qt4",QTINC="")
126 if test "x$QTINC" = "x"
128 AC_CHECK_FILE(${QTDIR}/include${QTINC}/QtCore/qglobal.h,qt_inc_ok=yes,qt_inc_ok=no)
132 if test "x$qt_inc_ok" = "xyes"
134 AC_MSG_CHECKING(whether Qt version >= 4.0)
135 QT_VERSION=`grep "QT_VERSION_STR" ${QTDIR}/include${QTINC}/QtCore/qglobal.h | sed -e 's%^#define QT_VERSION_STR[[:space:]]*\"\([[:digit:]\.]*\)\"%\1%g'`
136 QT_VERSION_ID=`echo $QT_VERSION | awk -F. '{v=$[1]*10000+$[2]*100+$[3];print v}'`
137 if test $QT_VERSION_ID -ge 40000
144 AC_MSG_CHECKING(Qt version)
145 AC_MSG_RESULT($QT_VERSION)
152 # check moc presence (meta-object compiler)
154 if test "x$qt_ok" = "xyes"
156 if test -f ${QTDIR}/bin/moc
160 AC_PATH_PROG(MOC, moc)
162 if test "x$MOC" = "x"
165 AC_MSG_RESULT(moc (Qt meta-object compiler) is not in the PATH variable)
168 AC_MSG_RESULT(moc (Qt meta-object compiler) is found)
171 if test "x$qt_ok" = "xyes"
173 dnl check moc version
174 AC_MSG_CHECKING(cheching equality Qt and moc tool version)
175 MOC_VERSION=`$MOC -v 2>&1 | awk 'BEGIN{FS="[[ ()]]"};{print $(NF-1)}'`
176 if test "x$QT_VERSION" = "x$MOC_VERSION"
181 AC_MSG_RESULT(moc tool and Qt product are incompatible $MOC_VERSION)
188 # check uic presence (user interface compiler)
190 if test "x$qt_ok" = "xyes"
192 if test -f ${QTDIR}/bin/uic
196 AC_PATH_PROG(UIC, uic)
198 if test "x$UIC" = "x"
201 AC_MSG_RESULT(uic (Qt user interface compiler) is not in the PATH variable)
204 AC_MSG_RESULT(uic (Qt user interface compiler) is found)
209 # check rcc presence (resources compiler)
211 if test "x$qt_ok" = "xyes"
213 if test -f ${QTDIR}/bin/rcc
215 QRCC=${QTDIR}/bin/rcc
217 AC_PATH_PROG(QRCC, rcc)
219 if test "x$QRCC" = "x"
222 AC_MSG_RESULT(rcc (Qt resources compiler) is not in the PATH variable)
225 AC_MSG_RESULT(rcc (Qt resources compiler) is found)
228 if test "x$qt_ok" = "xyes"
230 dnl check rcc version
231 AC_MSG_CHECKING(cheching equality Qt and rcc tool version)
232 QRCC_VERSION=`$QRCC -v 2>&1 | awk '{print $NF}'`
233 if test "x$QT_VERSION" = "x$QRCC_VERSION"
238 AC_MSG_RESULT(rcc tool and Qt product are incompatible)
245 # check lrelease presence (translation files compiler)
247 if test "x$qt_ok" = "xyes"
249 if test -f ${QTDIR}/bin/lrelease
251 LRELEASE=${QTDIR}/bin/lrelease
253 AC_PATH_PROG(LRELEASE, lrelease)
255 if test "x$LRELEASE" = "x"
258 AC_MSG_RESULT(lrelease (Qt translation files compiler) is not in the PATH variable)
261 AC_MSG_RESULT(lrelease (Qt translation files compiler) is found)
264 if test "x$qt_ok" = "xyes"
266 dnl check lrelease version
267 AC_MSG_CHECKING( equality of Qt and lrelease tool version)
268 LRELEASE_VERSION=`$LRELEASE -version 2>&1 | awk '{print $NF}'`
269 if test "x$QT_VERSION" = "x$LRELEASE_VERSION"
274 AC_MSG_RESULT(lrelease tool and Qt product are incompatible)
283 # check Qt header files
285 if test "x$qt_ok" = "xyes"
287 AC_CHECKING(include Qt header files)
289 CPPFLAGS_old=$CPPFLAGS
290 CPPFLAGS="$CPPFLAGS -I${QTDIR}/include${QTINC} -I${QTDIR}/include${QTINC}/QtCore"
291 AC_CHECK_HEADER(QObject,qt_ok=yes,qt_ok=no)
292 CPPFLAGS=$CPPFLAGS_old
294 if test "x$qt_ok" = "xno"
296 AC_MSG_RESULT(qt header files are not found in $QTDIR/include${QTINC}/QtCore)
297 AC_MSG_RESULT(QTDIR environment variable may be wrong (probably too old Qt version))
299 AC_MSG_RESULT(qt header files seem to be OK)
300 QT_INCLUDES="-I${QTDIR}/include${QTINC}"
302 QT_INCLUDES="${QT_INCLUDES} -I${QTDIR}/include${QTINC}/QtCore"
303 QT_INCLUDES="${QT_INCLUDES} -I${QTDIR}/include${QTINC}/QtGui"
304 QT_INCLUDES="${QT_INCLUDES} -I${QTDIR}/include${QTINC}/QtOpenGL"
305 QT_INCLUDES="${QT_INCLUDES} -I${QTDIR}/include${QTINC}/QtXml"
306 # not used currently header files (uncomment if required)
307 #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtAssistant"
308 #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtDBus"
309 #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtDesigner"
310 #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtNetwork"
311 #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtSql"
312 #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtSvg"
313 #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtTest"
314 #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtUiTools"
316 QT_ASSISTANT_INCLUDES="${QT_ASSISTANT_INCLUDES} -I${QTDIR}/include${QTINC}/QtAssistant"
317 QT_ASSISTANT_INCLUDES="${QT_ASSISTANT_INCLUDES} -I${QTDIR}/include${QTINC}/QtNetwork"
319 # this flag is obsolete with Qt 4
320 QT_MT_INCLUDES="$QT_INCLUDES"
327 if test "x$qt_ok" = "xyes"
329 AC_MSG_CHECKING(linking against Qt library)
331 CXXFLAGS_old=$CXXFLAGS
332 CXXFLAGS="$CXXFLAGS $QT_INCLUDES"
335 if test "x$QTDIR" = "x/usr" ; then
337 elif test -d ${QTDIR}/lib; then
338 QT_LIB_DIR="-L$QTDIR/lib"
339 elif test -d ${QTDIR}/lib64; then
340 QT_LIB_DIR="-L$QTDIR/lib64"
341 elif test "x$QTDIR" = "x/usr/lib/qt4" ; then
344 AC_MSG_ERROR(Can't detect of Qt library directory )
347 LIBS="$LIBS $QT_LIB_DIR -lQtCore"
349 AC_CACHE_VAL(salome_cv_lib_qt,[
351 #include <QCoreApplication>
354 QCoreApplication a(n, s);
356 eval "salome_cv_lib_qt=yes",eval "salome_cv_lib_qt=no")
358 qt_ok="$salome_cv_lib_qt"
360 # BEGIN: for CCRT (installation of qt have only a "lib" directory)
361 if test "x$qt_ok" = "xno"
363 QT_LIB_DIR="-L$QTDIR/lib"
364 LIBS="$LIBS_old $QT_LIB_DIR -lQtCore"
366 AC_CACHE_VAL(salome_cv_lib_qt,[
368 #include <QCoreApplication>
371 QCoreApplication a(n, s);
373 eval "salome_cv_lib_qt=yes",eval "salome_cv_lib_qt=no")
375 qt_ok="$salome_cv_lib_qt"
379 if test "x$qt_ok" = "xno"
382 AC_MSG_RESULT(unable to link with qt library)
383 AC_MSG_RESULT(QTDIR environment variable may be wrong (probably too old Qt version))
387 QT_CORE_LIBS="$QT_LIB_DIR -lQtCore -lQtXml"
389 QT_GUI_LIBS="$QT_LIB_DIR -lQtGui -lQtOpenGL"
390 # other libs (currently not used)
391 QT_OTHER_LIBS="$QT_LIB_DIR"
392 # other libs (can be used if necessary)
393 #QT_OTHER_LIBS="$QT_LIB_DIR -lQt3Support -lQtAssistantClient -lQtDesigner -lQtNetwork -lQtSql -lQtSvg -lQtTest -ltQtUiTools"
394 QT_ASSISTANT_LIBS="$QT_LIB_DIR -lQtAssistantClient -lQtNetwork"
396 QT_LIBS="$QT_CORE_LIBS $QT_GUI_LIBS $QT_OTHER_LIBS"
397 # this flag is obsolete with Qt 4
398 QT_MT_LIBS="$QT_LIBS"
401 CXXFLAGS=$CXXFLAGS_old
411 AC_SUBST(QT_INCLUDES)
412 AC_SUBST(QT_MT_INCLUDES)
413 AC_SUBST(QT_ASSISTANT_INCLUDES)
415 AC_SUBST(QT_CORE_LIBS)
416 AC_SUBST(QT_GUI_LIBS)
417 AC_SUBST(QT_OTHER_LIBS)
420 AC_SUBST(QT_ASSISTANT_LIBS)
422 AC_SUBST(QT_VERSION_ID)
426 AC_MSG_RESULT(for Qt: $qt_ok)