Salome HOME
217fb1c97ddb98d8dc3f3cd61b3118dae3a7c009
[modules/yacs.git] / src / wrappergen / src / HXX2SALOME_GENERIC_CLASS_NAME_SRC / adm_local / unix / config_files / check_qt.m4
1 dnl  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
2 dnl
3 dnl  This library is free software; you can redistribute it and/or
4 dnl  modify it under the terms of the GNU Lesser General Public
5 dnl  License as published by the Free Software Foundation; either
6 dnl  version 2.1 of the License.
7 dnl
8 dnl  This library is distributed in the hope that it will be useful,
9 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 dnl  Lesser General Public License for more details.
12 dnl
13 dnl  You should have received a copy of the GNU Lesser General Public
14 dnl  License along with this library; if not, write to the Free Software
15 dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 dnl
17 dnl  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 dnl
19 AC_DEFUN([CHECK_QT],[
20 AC_REQUIRE([AC_PROG_CC])dnl
21 AC_REQUIRE([AC_PROG_CXX])dnl
22 AC_REQUIRE([AC_PROG_CPP])dnl
23 AC_REQUIRE([AC_PROG_CXXCPP])dnl
24 AC_REQUIRE([CHECK_OPENGL])dnl
25 AC_REQUIRE([AC_LINKER_OPTIONS])dnl
26
27 AC_CHECKING(for Qt)
28
29 if test "x$OpenGL_ok" != "xyes" ; then
30    AC_MSG_WARN(Qt needs OpenGL correct configuration, check configure output)
31 fi
32
33 qt_ok=yes
34
35 AC_LANG_SAVE
36 AC_LANG_CPLUSPLUS
37
38 if test "x$QTDIR" = "x"
39 then
40    AC_MSG_RESULT(please define QTDIR variable)
41    qt_ok=no
42 else
43    AC_MSG_RESULT(QTDIR is $QTDIR)
44    qt_inc_ok=no
45    QTINC=""
46    AC_CHECK_FILE(${QTDIR}/include/qt3/qglobal.h,QTINC="/qt3",QTINC="")
47    QT_VERS=`grep "QT_VERSION_STR" ${QTDIR}/include${QTINC}/qglobal.h | sed -e 's%^#define QT_VERSION_STR\([[:space:]]*\)%%g' -e 's%\"%%g'`
48    AC_MSG_RESULT(Qt version is $QT_VERS)
49    QT_VERS="Qt_"`echo $QT_VERS | sed -e 's%\"%%g' -e 's%\.%_%g'`
50 fi
51
52 if  test "x$qt_ok" = "xyes"
53 then
54   if test -f ${QTDIR}/bin/moc
55   then
56     MOC=${QTDIR}/bin/moc
57   else
58     AC_PATH_PROG(MOC, moc)
59   fi
60   if test "x$MOC" = "x"
61   then
62     qt_ok=no
63     AC_MSG_RESULT(moc qt-compiler not in PATH variable)
64   else
65     qt_ok=yes
66     AC_MSG_RESULT(moc found)
67   fi
68 fi
69
70 if  test "x$qt_ok" = "xyes"
71 then
72   if test -f ${QTDIR}/bin/uic
73   then
74     UIC=${QTDIR}/bin/uic
75   else
76     AC_PATH_PROG(UIC, uic)
77   fi
78   if test "x$UIC" = "x"
79   then
80     qt_ok=no
81     AC_MSG_RESULT(uic qt-interface compiler not in PATH variable)
82   else
83     qt_ok=yes
84     AC_MSG_RESULT(uic found)
85   fi
86 fi
87
88 AC_SUBST(QTDIR)
89 QT_ROOT=$QTDIR
90
91 if  test "x$qt_ok" = "xyes"
92 then
93   CPPFLAGS_old=$CPPFLAGS
94   CPPFLAGS="$CPPFLAGS -I$QTDIR/include${QTINC}"
95
96   AC_LANG_CPLUSPLUS
97   AC_CHECK_HEADER(qaction.h,qt_ok=yes ,qt_ok=no)
98
99   CPPFLAGS=$CPPFLAGS_old
100
101   AC_MSG_CHECKING(include of qt headers)
102
103   if  test "x$qt_ok" = "xno"
104   then
105     AC_MSG_RESULT(qt headers not found, or too old qt version, in $QTDIR/include)
106     AC_MSG_RESULT(QTDIR environment variable may be wrong)
107   else
108     AC_MSG_RESULT(yes)
109     QT_INCLUDES="-I${QT_ROOT}/include${QTINC} -DQT_THREAD_SUPPORT -DQT_CLEAN_NAMESPACE"
110     QT_MT_INCLUDES="-I${QT_ROOT}/include${QTINC} -DQT_THREAD_SUPPORT -DQT_CLEAN_NAMESPACE"
111   fi
112 fi
113
114 if  test "x$qt_ok" = "xyes"
115 then
116   AC_MSG_CHECKING(linking qt library)
117   LIBS_old=$LIBS
118   if test "x$QTDIR" = "x/usr"
119   then
120     LIBS="$LIBS -lqt-mt $OGL_LIBS"
121   else
122     LIBS="$LIBS -L$QTDIR/lib${LIB_LOCATION_SUFFIX} -lqt-mt $OGL_LIBS"
123   fi
124
125   CXXFLAGS_old=$CXXFLAGS
126   CXXFLAGS="$CXXFLAGS $QT_INCLUDES"
127
128   AC_CACHE_VAL(salome_cv_lib_qt,[
129     AC_TRY_LINK(
130 #include <qapplication.h>
131 ,   int n;
132     char **s;
133     QApplication a(n, s);
134     a.exec();,
135     eval "salome_cv_lib_qt=yes",eval "salome_cv_lib_qt=no")
136   ])
137   qt_ok="$salome_cv_lib_qt"
138
139   if  test "x$qt_ok" = "xno"
140   then
141     AC_MSG_RESULT(unable to link with qt library)
142     AC_MSG_RESULT(QTDIR environment variable may be wrong)
143   else
144     AC_MSG_RESULT(yes)
145     if test "x$QTDIR" = "x/usr"
146     then
147          QT_LIBS=" -lqt-mt"
148       QT_MT_LIBS=" -lqt-mt"
149     else
150          QT_LIBS="-L$QTDIR/lib${LIB_LOCATION_SUFFIX} -lqt-mt"
151       QT_MT_LIBS="-L$QTDIR/lib${LIB_LOCATION_SUFFIX} -lqt-mt"
152     fi
153   fi
154
155   LIBS=$LIBS_old
156   CXXFLAGS=$CXXFLAGS_old
157
158 fi
159
160 AC_SUBST(MOC)
161 AC_SUBST(UIC)
162
163 AC_SUBST(QT_ROOT)
164 AC_SUBST(QT_INCLUDES)
165 AC_SUBST(QT_MT_INCLUDES)
166 AC_SUBST(QT_LIBS)
167 AC_SUBST(QT_MT_LIBS)
168 AC_SUBST(QT_VERS)
169
170 AC_LANG_RESTORE
171
172 AC_MSG_RESULT(for Qt: $qt_ok)
173
174 # Save cache
175 AC_CACHE_SAVE
176
177 ])dnl
178 dnl