1 dnl Copyright (C) 2007-2008 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
22 AC_DEFUN([CHECK_PYQT],[
23 AC_REQUIRE([CHECK_PYTHON])dnl
24 AC_REQUIRE([CHECK_QT])dnl
25 AC_REQUIRE([CHECK_SIP])dnl
26 AC_REQUIRE([AC_LINKER_OPTIONS])dnl
32 [ --with-pyqt=DIR root directory path to PyQt installation ],
34 AC_MSG_RESULT([Try $withval as path to the PyQt])
37 AC_ARG_WITH(pyqt_sips,
38 [ --with-pyqt_sips=DIR a directory path to PyQt sips installation ],
40 AC_MSG_RESULT([Try $withval as path to the PyQt sip files])
44 [ --with-pyuic4=EXEC pyuic4 executable ],
46 AC_MSG_RESULT([Try $withval as pyuic4 executable])
54 if test "x$PYUIC" != "x" ; then
55 dnl try $withval value
56 AC_CHECK_FILE($PYUIC,pyqt_ok=yes,pyqt_ok=no)
59 if test "x${PYQTDIR}" != "x" ; then
60 TEST_BIN_DIRS="${TEST_BIN_DIRS} ${PYQTDIR} ${PYQTDIR}/bin"
62 TEST_BIN_DIRS="${TEST_BIN_DIRS} __CHECK__PATH__"
63 if test "x${SIPDIR}" != "x" ; then
64 TEST_BIN_DIRS="${TEST_BIN_DIRS} ${SIPDIR} ${SIPDIR}/bin"
66 if test "x${PYTHONHOME}" != "x" ; then
67 TEST_BIN_DIRS="${TEST_BIN_DIRS} ${PYTHONHOME}/bin"
69 TEST_BIN_DIRS="${TEST_BIN_DIRS} /usr/bin"
73 for d in ${TEST_BIN_DIRS} ; do
74 if test "x${d}" = "x__CHECK__PATH__" ; then
75 AC_PATH_PROG(TEMP, pyuic4)
76 if test "x${TEMP}" != "x" ; then
78 if test "x$PYQTDIR" = "x" ; then
79 PYQTDIR=`dirname ${PYUIC}`
80 PYQTDIR=`dirname ${PYQTDIR}`
87 AC_CHECK_FILE(${d}/pyuic4,pyqt_ok=yes,pyqt_ok=no)
88 if test "x$pyqt_ok" == "xyes" ; then
97 dnl check PyQt version
98 if test "x$pyqt_ok" == "xyes" ; then
99 AC_MSG_CHECKING(whether PyQt version >= 4.2)
100 PYQT_VERSION=`${PYUIC} --version 2>&1 | grep "Python User Interface Compiler"`
101 if test "$?" != "0" ; then
102 PYQT_VERSION=`${PYUIC} -version 2>&1 | grep "Python User Interface Compiler"`
104 if test "x${PYQT_VERSION}" != "x" ; then
105 PYQT_VERSION=`echo $PYQT_VERSION | sed -e 's%[[[:alpha:][:space:]]]*\([[[:digit:].]]*\).*%\1%g'`
106 PYQT_VERSION_ID=`echo $PYQT_VERSION | awk -F. '{v=$[1]*10000+$[2]*100+$[3];print v}'`
108 PYQT_VERSION="<unknown>"
111 if test $PYQT_VERSION_ID -ge 40200 ; then
113 AC_MSG_RESULT(PyQt version is $PYQT_VERSION)
116 AC_MSG_RESULT(WARNING! PyQt version $PYQT_VERSION is not supported (at least 4.2 is required)!)
120 AC_MSG_RESULT(Warning! pyuic4 is not found!)
123 if test "x$pyqt_ok" == "xyes" ; then
124 TESTLIBFILE=QtCore.so
125 TESTSIPFILE=QtCore/QtCoremod.sip
128 if test "x${PYQT_SIPS}" != "x" ; then
129 TEST_SIPS_DIRS="${TEST_SIPS_DIRS} ${PYQT_SIPS}"
131 if test "x${PYQTDIR}" != "x" ; then
132 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${PYQTDIR} ${PYQTDIR}/lib ${PYQTDIR}/PyQt4"
133 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${PYQTDIR}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages"
134 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${PYQTDIR}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages/PyQt4"
135 TEST_SIPS_DIRS="${TEST_SIPS_DIRS} ${PYQTDIR} ${PYQTDIR}/sip"
136 TEST_SIPS_DIRS="${TEST_SIPS_DIRS} ${PYQTDIR}/share ${PYQTDIR}/share/sip"
138 if test "x${SIPDIR}" != "x" ; then
139 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${SIPDIR} ${SIPDIR}/lib ${SIPDIR}/PyQt4"
140 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${SIPDIR}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages"
141 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${SIPDIR}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages/PyQt4"
142 TEST_SIPS_DIRS="${TEST_SIPS_DIRS} ${SIPDIR} ${SIPDIR}/sip"
143 TEST_SIPS_DIRS="${TEST_SIPS_DIRS} ${SIPDIR}/share ${SIPDIR}/share/sip ${SIPDIR}/share/sip/PyQt4"
145 if test "x${PYTHONHOME}" != "x" ; then
146 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${PYTHONHOME}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages"
147 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${PYTHONHOME}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages/PyQt4"
149 TEST_LIB_DIRS="${TEST_LIB_DIRS} /usr/lib${LIB_LOCATION_SUFFIX} /usr/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages"
150 TEST_LIB_DIRS="${TEST_LIB_DIRS} /usr/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages/PyQt4"
151 TEST_SIPS_DIRS="${TEST_SIPS_DIRS} /usr/share/sip"
152 TEST_SIPS_DIRS="${TEST_SIPS_DIRS} /usr/share/sip/PyQt4"
156 for d in ${TEST_LIB_DIRS} ; do
158 AC_CHECK_FILE(${d}/${TESTLIBFILE},pyqt_ok=yes,pyqt_ok=no)
159 if test "x$pyqt_ok" == "xyes" ; then
160 if test "x${d}" = "x/usr/lib${LIB_LOCATION_SUFFIX}" ; then
171 if test "x$pyqt_ok" == "xyes" ; then
173 for d in ${TEST_SIPS_DIRS} ; do
175 AC_CHECK_FILE(${d}/${TESTSIPFILE},pyqt_ok=yes,pyqt_ok=no)
176 if test "x$pyqt_ok" == "xyes" ; then
178 PYQT_INCLUDES="-I ${d}"
179 PYQT_INCLUDES="${PYQT_INCLUDES} -I ${d}/QtCore -I ${d}/QtGui"
180 PYQT_INCLUDES="${PYQT_INCLUDES} -I ${d}/QtXml -I ${d}/QtOpenGL"
181 PYQT_INCLUDES="${PYQT_INCLUDES} -I ${d}/QtAssistant -I ${d}/QtDesigner"
182 PYQT_INCLUDES="${PYQT_INCLUDES} -I ${d}/QtNetwork -I ${d}/QtSql"
183 PYQT_INCLUDES="${PYQT_INCLUDES} -I ${d}/QtSvg -I ${d}/QtTest"
185 # check compatibility with Qt
186 SUPPORTED=`grep -e "[[[:space:]]]*Qt_[[[:digit:]_]]\+}" ${PYQT_SIPS}/QtCore/QtCoremod.sip | sed -e "s/\(.*\)[[[:space:]]]*\(Qt_[[[:digit:]_]]\+\)}/\2/g"`
187 SUPPORTED=`echo $SUPPORTED | sed -e "s/Qt_//g" -e "s/_/./g"`
188 SUPPORTED_ID=`echo $SUPPORTED | awk -F. '{v=$[1]*10000+$[2]*100+$[3];print v}'`
189 if test $SUPPORTED_ID -lt $QT_VERSION_ID ; then
190 AC_MSG_RESULT(Warning! Used Qt version ($QT_VERSION) is not supported by PyQt)
191 AC_MSG_RESULT(Latest supported Qt version is ${SUPPORTED})
193 SUPPORTED=${QT_VERSION}
195 SUPPORTED="Qt_`echo ${SUPPORTED} | sed -e 's/\./_/g'`"
196 PYQT_SIPFLAGS="-x VendorID -x PyQt_NoPrintRangeBug -t WS_X11 -t ${SUPPORTED} -g -s ".cc" -c . ${PYQT_INCLUDES}"
204 AC_SUBST(PYQT_INCLUDES)
208 AC_SUBST(PYQT_SIPFLAGS)
212 AC_MSG_RESULT(for pyqt: $pyqt_ok)