1 dnl Copyright (C) 2007-2023 CEA, EDF, 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, or (at your option) any later version.
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 AC_DEFUN([CHECK_PYQT],[
24 AC_REQUIRE([CHECK_PYTHON])dnl
25 AC_REQUIRE([CHECK_QT])dnl
26 AC_REQUIRE([CHECK_SIP])dnl
27 AC_REQUIRE([AC_LINKER_OPTIONS])dnl
33 [ --with-pyqt=DIR root directory path to PyQt installation ],
35 AC_MSG_RESULT([Try $withval as path to the PyQt])
38 AC_ARG_WITH(pyqt_sips,
39 [ --with-pyqt_sips=DIR a directory path to PyQt sips installation ],
41 AC_MSG_RESULT([Try $withval as path to the PyQt sip files])
45 [ --with-pyuic4=EXEC pyuic4 executable ],
47 AC_MSG_RESULT([Try $withval as pyuic4 executable])
51 [ --with-pyrcc4=EXEC pyrcc4 executable ],
53 AC_MSG_RESULT([Try $withval as pyrcc4 executable])
61 if test "x${PYQTDIR}" != "x" ; then
62 TEST_BIN_DIRS="${TEST_BIN_DIRS} ${PYQTDIR} ${PYQTDIR}/bin"
64 TEST_BIN_DIRS="${TEST_BIN_DIRS} __CHECK__PATH__"
65 if test "x${SIPDIR}" != "x" ; then
66 TEST_BIN_DIRS="${TEST_BIN_DIRS} ${SIPDIR} ${SIPDIR}/bin"
68 if test "x${PYTHONHOME}" != "x" ; then
69 TEST_BIN_DIRS="${TEST_BIN_DIRS} ${PYTHONHOME}/bin"
71 TEST_BIN_DIRS="${TEST_BIN_DIRS} /usr/bin"
74 if test "x$PYUIC" != "x" ; then
75 dnl try $withval value
76 AC_CHECK_FILE($PYUIC,pyqt_ok=yes,pyqt_ok=no)
80 for d in ${TEST_BIN_DIRS} ; do
81 if test "x${d}" = "x__CHECK__PATH__" ; then
82 AC_PATH_PROG(TEMP, pyuic4)
83 if test "x${TEMP}" != "x" ; then
85 if test "x$PYQTDIR" = "x" ; then
86 PYQTDIR=`dirname ${PYUIC}`
87 PYQTDIR=`dirname ${PYQTDIR}`
94 AC_CHECK_FILE(${d}/pyuic4,pyqt_ok=yes,pyqt_ok=no)
95 if test "x$pyqt_ok" == "xyes" ; then
104 dnl check PyQt version
105 if test "x$pyqt_ok" == "xyes" ; then
106 AC_MSG_CHECKING(whether PyQt version >= 4.2)
107 PYQT_VERSION=`${PYUIC} --version 2>&1 | grep "Python User Interface Compiler"`
108 if test "$?" != "0" ; then
109 PYQT_VERSION=`${PYUIC} -version 2>&1 | grep "Python User Interface Compiler"`
111 if test "x${PYQT_VERSION}" != "x" ; then
112 PYQT_VERSION=`echo $PYQT_VERSION | sed -e 's%[[[:alpha:][:space:]]]*\([[[:digit:].]]*\).*%\1%g'`
113 PYQT_VERSION_ID=`echo $PYQT_VERSION | awk -F. '{v=$[1]*10000+$[2]*100+$[3];print v}'`
115 PYQT_VERSION="<unknown>"
118 if test $PYQT_VERSION_ID -ge 40200 ; then
120 AC_MSG_RESULT(PyQt version is $PYQT_VERSION)
123 AC_MSG_RESULT(WARNING! PyQt version $PYQT_VERSION is not supported (at least 4.2 is required)!)
127 AC_MSG_RESULT(Warning! pyuic4 is not found!)
131 if test "x$PYRCC" != "x" ; then
132 dnl try $withval value
133 AC_CHECK_FILE($PYRCC,pyqt_ok=yes,pyqt_ok=no)
137 for d in ${TEST_BIN_DIRS} ; do
138 if test "x${d}" = "x__CHECK__PATH__" ; then
139 AC_PATH_PROG(TEMP, pyrcc4)
140 if test "x${TEMP}" != "x" ; then
142 if test "x$PYQTDIR" = "x" ; then
143 PYQTDIR=`dirname ${PYRCC}`
144 PYQTDIR=`dirname ${PYQTDIR}`
151 AC_CHECK_FILE(${d}/pyrcc4,pyqt_ok=yes,pyqt_ok=no)
152 if test "x$pyqt_ok" == "xyes" ; then
161 if test "x$pyqt_ok" == "xyes" ; then
162 TESTLIBFILE=QtCore.so
163 TESTSIPFILE=QtCore/QtCoremod.sip
166 if test "x${PYQT_SIPS}" != "x" ; then
167 TEST_SIPS_DIRS="${TEST_SIPS_DIRS} ${PYQT_SIPS}"
169 if test "x${PYQTDIR}" != "x" ; then
170 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${PYQTDIR} ${PYQTDIR}/lib ${PYQTDIR}/PyQt4"
171 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${PYQTDIR}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages"
172 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${PYQTDIR}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages/PyQt4"
173 TEST_SIPS_DIRS="${TEST_SIPS_DIRS} ${PYQTDIR} ${PYQTDIR}/sip"
174 TEST_SIPS_DIRS="${TEST_SIPS_DIRS} ${PYQTDIR}/share ${PYQTDIR}/share/sip"
176 if test "x${SIPDIR}" != "x" ; then
177 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${SIPDIR} ${SIPDIR}/lib ${SIPDIR}/PyQt4"
178 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${SIPDIR}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages"
179 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${SIPDIR}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages/PyQt4"
180 TEST_SIPS_DIRS="${TEST_SIPS_DIRS} ${SIPDIR} ${SIPDIR}/sip"
181 TEST_SIPS_DIRS="${TEST_SIPS_DIRS} ${SIPDIR}/share ${SIPDIR}/share/sip ${SIPDIR}/share/sip/PyQt4"
183 if test "x${PYTHONHOME}" != "x" ; then
184 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${PYTHONHOME}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages"
185 TEST_LIB_DIRS="${TEST_LIB_DIRS} ${PYTHONHOME}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages/PyQt4"
187 TEST_LIB_DIRS="${TEST_LIB_DIRS} /usr/lib${LIB_LOCATION_SUFFIX} /usr/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages"
188 TEST_LIB_DIRS="${TEST_LIB_DIRS} /usr/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages/PyQt4"
189 TEST_LIB_DIRS="${TEST_LIB_DIRS} /usr/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/dist-packages/PyQt4"
190 TEST_LIB_DIRS="${TEST_LIB_DIRS} /usr/lib${LIB_LOCATION_SUFFIX}/pymodules/python${PYTHON_VERSION}/PyQt4"
191 if test "${build_cpu::6}" = "x86_64" ; then
192 TEST_LIB_DIRS="${TEST_LIB_DIRS} /usr/lib64/python2.6/site-packages/PyQt4"
194 TEST_SIPS_DIRS="${TEST_SIPS_DIRS} /usr/share/sip"
195 TEST_SIPS_DIRS="${TEST_SIPS_DIRS} /usr/share/sip/PyQt4"
199 for d in ${TEST_LIB_DIRS} ; do
201 AC_CHECK_FILE(${d}/${TESTLIBFILE},pyqt_ok=yes,pyqt_ok=no)
202 if test "x$pyqt_ok" == "xyes" ; then
203 if test "x${d}" = "x/usr/lib${LIB_LOCATION_SUFFIX}" ; then
214 if test "x$pyqt_ok" == "xyes" ; then
216 for d in ${TEST_SIPS_DIRS} ; do
218 AC_CHECK_FILE(${d}/${TESTSIPFILE},pyqt_ok=yes,pyqt_ok=no)
219 if test "x$pyqt_ok" == "xyes" ; then
221 PYQT_INCLUDES="-I ${d}"
222 PYQT_INCLUDES="${PYQT_INCLUDES} -I ${d}/QtCore -I ${d}/QtGui"
223 PYQT_INCLUDES="${PYQT_INCLUDES} -I ${d}/QtXml -I ${d}/QtOpenGL"
224 PYQT_INCLUDES="${PYQT_INCLUDES} -I ${d}/QtAssistant -I ${d}/QtDesigner"
225 PYQT_INCLUDES="${PYQT_INCLUDES} -I ${d}/QtNetwork -I ${d}/QtSql"
226 PYQT_INCLUDES="${PYQT_INCLUDES} -I ${d}/QtSvg -I ${d}/QtTest"
228 # check compatibility with Qt
229 #SUPPORTED=`grep -e "[[[:space:]]]*Qt_[[[:digit:]_]]\+}" ${PYQT_SIPS}/QtCore/QtCoremod.sip | sed -e "s/\(.*\)[[[:space:]]]*\(Qt_[[[:digit:]_]]\+\)}/\2/g"`
230 #SUPPORTED=`echo $SUPPORTED | sed -e "s/Qt_//g" -e "s/_/./g"`
231 #SUPPORTED_ID=`echo $SUPPORTED | awk -F. '{v=$[1]*10000+$[2]*100+$[3];print v}'`
232 #if test $SUPPORTED_ID -lt $QT_VERSION_ID ; then
233 # AC_MSG_RESULT(Warning! Used Qt version ($QT_VERSION) is not supported by PyQt)
234 # AC_MSG_RESULT(Latest supported Qt version is ${SUPPORTED})
236 # SUPPORTED=${QT_VERSION}
238 #SUPPORTED="Qt_`echo ${SUPPORTED} | sed -e 's/\./_/g'`"
239 PYQT_SIPFLAGS=`python -c "from PyQt4 import pyqtconfig; print(pyqtconfig.Configuration().pyqt_sip_flags)"`
240 PYQT_SIPFLAGS="${PYQT_SIPFLAGS} -s .cc -c . ${PYQT_INCLUDES}"
248 AC_SUBST(PYQT_INCLUDES)
253 AC_SUBST(PYQT_SIPFLAGS)
257 AC_MSG_RESULT(for pyqt: $pyqt_ok)