1 dnl Copyright (C) 2007-2011 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 installed;
30 "" or "yes" or "auto" - means seaching installed Qt product in the system (checking $QT4_ROOT_DIR or $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 QT_DIR=$(echo $QT4_ROOT_DIR | sed 's%[/]\+$%%')
55 if test -z $QT_DIR ; then
56 QT_DIR=$(echo $QTDIR | sed 's%[/]\+$%%')
63 if test -z $with_qt ; then
66 if test "x$with_qt" = "xyes" ; then
67 dnl in case user wrote --with-qt=yes
70 if test "x$with_qt" = "xauto" ; then
71 dnl in case user wrote --with-qt=auto
74 if test "x$with_qt" = "xno" ; then
75 dnl in case user wrote --with-qt=no
77 AC_MSG_WARN(Value no, specified for option --with-qt, is not supported)
80 if test "x$with_qt" != "x" ; then
81 dnl Using "--with-qt" prefix path
83 elif test "$QT_DIR" = "/usr/lib/qt3" ; then
84 dnl Using QTDIR/QT4_ROOT_DIR environment variable
85 AC_MSG_RESULT(current QTDIR is $QT_DIR)
87 if test -d /usr/lib/qt4 ; then
88 AC_MSG_RESULT(it is strange for a qt4 installation !)
89 AC_MSG_RESULT(/usr/lib/qt4 is present)
90 AC_MSG_RESULT(replacing QTDIR by /usr/lib/qt4)
93 elif test -z $QT_DIR ; then
94 AC_MSG_WARN(undefined both QTDIR and Qt4_ROOT_DIR variables; any of them should specify where Qt product was installed)
95 for d in /usr/local/lib/qt4 /usr/lib/qt4 /usr ; do
96 if test -f ${d}/lib/libQtCore.so ; then
97 AC_MSG_RESULT(trying ${d})
100 elif test -f ${d}/lib64/libQtCore.so ; then
101 AC_MSG_RESULT(trying ${d})
104 elif test -f ${d}/libQtCore.so ; then
105 AC_MSG_RESULT(trying ${d})
113 # check QTDIR environment variable
115 if test "x$QT_DIR" = "x"
117 AC_MSG_RESULT([Please define correct path in "--with-qt" option or use correct $QTDIR (or, alternatively, $QT4_ROOT_DIR) variable])
124 if test "x$qt_ok" = "xyes"
128 AC_CHECK_FILE(${QT_DIR}/include/qt4/QtCore/qglobal.h,QTINC="/qt4",QTINC="")
129 if test "x$QTINC" = "x"
131 AC_CHECK_FILE(${QT_DIR}/include${QTINC}/QtCore/qglobal.h,qt_inc_ok=yes,qt_inc_ok=no)
135 if test "x$qt_inc_ok" = "xyes"
137 AC_MSG_CHECKING(whether Qt version >= 4.0)
138 QT_VERSION=`grep "QT_VERSION_STR" ${QT_DIR}/include${QTINC}/QtCore/qglobal.h | sed -e 's%^#define QT_VERSION_STR[[:space:]]*\"\([[:digit:]\.]*\)\"%\1%g'`
139 QT_VERSION_ID=`echo $QT_VERSION | awk -F. '{v=$[1]*10000+$[2]*100+$[3];print v}'`
140 if test $QT_VERSION_ID -ge 40000
147 AC_MSG_CHECKING(Qt version)
148 AC_MSG_RESULT($QT_VERSION)
155 # check moc presence (meta-object compiler)
157 if test "x$qt_ok" = "xyes"
159 if test -f ${QT_DIR}/bin/moc
161 MOC=${QT_DIR}/bin/moc
163 AC_PATH_PROG(MOC, moc)
165 if test "x$MOC" = "x"
168 AC_MSG_RESULT(moc (Qt meta-object compiler) is not in the PATH variable)
171 AC_MSG_RESULT(moc (Qt meta-object compiler) is found)
174 if test "x$qt_ok" = "xyes"
176 dnl check moc version
177 AC_MSG_CHECKING(cheching equality Qt and moc tool version)
178 MOC_VERSION=`$MOC -v 2>&1 | awk 'BEGIN{FS="[[ ()]]"};{print $(NF-1)}'`
179 if test "x$QT_VERSION" = "x$MOC_VERSION"
184 AC_MSG_RESULT(moc tool and Qt product are incompatible $MOC_VERSION)
191 # check uic presence (user interface compiler)
193 if test "x$qt_ok" = "xyes"
195 if test -f ${QT_DIR}/bin/uic
197 UIC=${QT_DIR}/bin/uic
199 AC_PATH_PROG(UIC, uic)
201 if test "x$UIC" = "x"
204 AC_MSG_RESULT(uic (Qt user interface compiler) is not in the PATH variable)
207 AC_MSG_RESULT(uic (Qt user interface compiler) is found)
212 # check rcc presence (resources compiler)
214 if test "x$qt_ok" = "xyes"
216 if test -f ${QT_DIR}/bin/rcc
218 QRCC=${QT_DIR}/bin/rcc
220 AC_PATH_PROG(QRCC, rcc)
222 if test "x$QRCC" = "x"
225 AC_MSG_RESULT(rcc (Qt resources compiler) is not in the PATH variable)
228 AC_MSG_RESULT(rcc (Qt resources compiler) is found)
231 if test "x$qt_ok" = "xyes"
233 dnl check rcc version
234 AC_MSG_CHECKING(cheching equality Qt and rcc tool version)
235 QRCC_VERSION=`$QRCC -v 2>&1 | awk '{print $NF}'`
236 if test "x$QT_VERSION" = "x$QRCC_VERSION"
241 AC_MSG_RESULT(rcc tool and Qt product are incompatible)
248 # check lrelease presence (translation files compiler)
250 if test "x$qt_ok" = "xyes"
252 if test -f ${QT_DIR}/bin/lrelease
254 LRELEASE=${QT_DIR}/bin/lrelease
256 AC_PATH_PROG(LRELEASE, lrelease)
258 if test "x$LRELEASE" = "x"
261 AC_MSG_RESULT(lrelease (Qt translation files compiler) is not in the PATH variable)
264 AC_MSG_RESULT(lrelease (Qt translation files compiler) is found)
267 if test "x$qt_ok" = "xyes"
269 dnl check lrelease version
270 AC_MSG_CHECKING( equality of Qt and lrelease tool version)
271 LRELEASE_VERSION=`$LRELEASE -version 2>&1 | awk '{print $NF}'`
272 if test "x$QT_VERSION" = "x$LRELEASE_VERSION"
277 AC_MSG_RESULT(lrelease tool and Qt product are incompatible)
286 # check Qt header files
288 if test "x$qt_ok" = "xyes"
290 AC_CHECKING(include Qt header files)
292 CPPFLAGS_old=$CPPFLAGS
293 CPPFLAGS="$CPPFLAGS -I${QT_DIR}/include${QTINC} -I${QT_DIR}/include${QTINC}/QtCore"
294 AC_CHECK_HEADER(QObject,qt_ok=yes,qt_ok=no)
295 CPPFLAGS=$CPPFLAGS_old
297 if test "x$qt_ok" = "xno"
299 AC_MSG_RESULT(qt header files are not found in $QT_DIR/include${QTINC}/QtCore)
300 AC_MSG_RESULT(QTDIR environment variable may be wrong (probably too old Qt version))
302 AC_MSG_RESULT(qt header files seem to be OK)
303 QT_INCLUDES="-I${QT_DIR}/include${QTINC}"
305 QT_INCLUDES="${QT_INCLUDES} -I${QT_DIR}/include${QTINC}/QtCore"
306 QT_INCLUDES="${QT_INCLUDES} -I${QT_DIR}/include${QTINC}/QtGui"
307 QT_INCLUDES="${QT_INCLUDES} -I${QT_DIR}/include${QTINC}/QtOpenGL"
308 QT_INCLUDES="${QT_INCLUDES} -I${QT_DIR}/include${QTINC}/QtXml"
309 # not used currently header files (uncomment if required)
310 #QT_INCLUDES="${QT_INCLUDES} -I$(QT_DIR)/include${QTINC}/QtAssistant"
311 #QT_INCLUDES="${QT_INCLUDES} -I$(QT_DIR)/include${QTINC}/QtDBus"
312 #QT_INCLUDES="${QT_INCLUDES} -I$(QT_DIR)/include${QTINC}/QtDesigner"
313 #QT_INCLUDES="${QT_INCLUDES} -I$(QT_DIR)/include${QTINC}/QtNetwork"
314 #QT_INCLUDES="${QT_INCLUDES} -I$(QT_DIR)/include${QTINC}/QtSql"
315 #QT_INCLUDES="${QT_INCLUDES} -I$(QT_DIR)/include${QTINC}/QtSvg"
316 #QT_INCLUDES="${QT_INCLUDES} -I$(QT_DIR)/include${QTINC}/QtTest"
317 #QT_INCLUDES="${QT_INCLUDES} -I$(QT_DIR)/include${QTINC}/QtUiTools"
319 QT_ASSISTANT_INCLUDES="${QT_ASSISTANT_INCLUDES} -I${QT_DIR}/include${QTINC}/QtAssistant"
320 QT_ASSISTANT_INCLUDES="${QT_ASSISTANT_INCLUDES} -I${QT_DIR}/include${QTINC}/QtNetwork"
322 # this flag is obsolete with Qt 4
323 QT_MT_INCLUDES="$QT_INCLUDES"
330 if test "x$qt_ok" = "xyes"
332 AC_MSG_CHECKING(linking against Qt library)
334 CXXFLAGS_old=$CXXFLAGS
335 CXXFLAGS="$CXXFLAGS $QT_INCLUDES"
338 if test "x$QT_DIR" = "x/usr" ; then
340 elif test -d ${QT_DIR}/lib; then
341 QT_LIB_DIR="-L$QT_DIR/lib"
342 elif test -d ${QT_DIR}/lib64; then
343 QT_LIB_DIR="-L$QT_DIR/lib64"
344 elif test "x$QT_DIR" = "x/usr/lib/qt4" ; then
347 AC_MSG_ERROR(Can't detect of Qt library directory )
350 LIBS="$LIBS $QT_LIB_DIR -lQtCore"
352 AC_CACHE_VAL(salome_cv_lib_qt,[
354 #include <QCoreApplication>
357 QCoreApplication a(n, s);
359 eval "salome_cv_lib_qt=yes",eval "salome_cv_lib_qt=no")
361 qt_ok="$salome_cv_lib_qt"
363 # BEGIN: for CCRT (installation of qt have only a "lib" directory)
364 if test "x$qt_ok" = "xno"
366 QT_LIB_DIR="-L$QT_DIR/lib"
367 LIBS="$LIBS_old $QT_LIB_DIR -lQtCore"
369 AC_CACHE_VAL(salome_cv_lib_qt,[
371 #include <QCoreApplication>
374 QCoreApplication a(n, s);
376 eval "salome_cv_lib_qt=yes",eval "salome_cv_lib_qt=no")
378 qt_ok="$salome_cv_lib_qt"
382 if test "x$qt_ok" = "xno"
385 AC_MSG_RESULT(unable to link with qt library)
386 AC_MSG_RESULT(QTDIR environment variable may be wrong (probably too old Qt version))
390 QT_CORE_LIBS="$QT_LIB_DIR -lQtCore -lQtXml"
392 QT_GUI_LIBS="$QT_LIB_DIR -lQtGui -lQtOpenGL"
393 # other libs (currently not used)
394 QT_OTHER_LIBS="$QT_LIB_DIR"
395 # other libs (can be used if necessary)
396 #QT_OTHER_LIBS="$QT_LIB_DIR -lQt3Support -lQtAssistantClient -lQtDesigner -lQtNetwork -lQtSql -lQtSvg -lQtTest -ltQtUiTools"
397 QT_ASSISTANT_LIBS="$QT_LIB_DIR -lQtAssistantClient -lQtNetwork"
399 QT_LIBS="$QT_CORE_LIBS $QT_GUI_LIBS $QT_OTHER_LIBS"
400 # this flag is obsolete with Qt 4
401 QT_MT_LIBS="$QT_LIBS"
404 CXXFLAGS=$CXXFLAGS_old
414 AC_SUBST(QT_INCLUDES)
415 AC_SUBST(QT_MT_INCLUDES)
416 AC_SUBST(QT_ASSISTANT_INCLUDES)
418 AC_SUBST(QT_CORE_LIBS)
419 AC_SUBST(QT_GUI_LIBS)
420 AC_SUBST(QT_OTHER_LIBS)
423 AC_SUBST(QT_ASSISTANT_LIBS)
425 AC_SUBST(QT_VERSION_ID)
429 AC_MSG_RESULT(for Qt: $qt_ok)