1 dnl Copyright (C) 2007-2022 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, 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 ## ------------------------
24 ## Python file handling
26 ## Modified by Marc Tajchman (06/2001)
27 ## ------------------------
29 dnl CHECK_PYTHON([module, classes])
31 dnl Adds support for distributing Python modules or classes.
32 dnl Python library files distributed as a `module' are installed
33 dnl under PYTHON_SITE_PACKAGE (eg, ./python1.5/site-package/package-name)
34 dnl while those distributed as `classes' are installed under PYTHON_SITE
35 dnl (eg, ./python1.5/site-packages). The default is to install as
38 AC_DEFUN([CHECK_PYTHON],
40 AC_BEFORE([$0],[AM_PATH_PYTHON])
41 AC_REQUIRE([AC_LINKER_OPTIONS])dnl
47 AC_MSG_NOTICE([local Python configuration])
49 AC_SUBST([python_bin],
50 [`basename ${PYTHON}`] )
52 AC_SUBST([PYTHON_ABIFLAGS],
53 [`${PYTHON} -c "import sys; print (sys.abiflags)"`] )
55 AC_SUBST([PYTHON_PREFIX],
56 [`${PYTHON} -c "import sys; print (sys.prefix)"`] )
58 AC_SUBST([PYTHONHOME],
59 [`${PYTHON} -c "import sys; print (sys.prefix)"`] )
61 PY_MAKEFILE=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/Makefile
62 if test ! -f "$PY_MAKEFILE"; then
63 PY_MAKEFILE=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config-${PYTHON_VERSION}${PYTHON_ABIFLAGS}-${build_cpu}-${build_os}/Makefile
65 if test ! -f "$PY_MAKEFILE"; then
67 PY_MAKEFILE=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config-${build_cpu}-${build_os}/Makefile
69 if test ! -f "$PY_MAKEFILE"; then
70 if test "${build_cpu::6}" = "x86_64" ; then
71 PY_MAKEFILE=${PYTHON_PREFIX}/lib64/python$PYTHON_VERSION/config/Makefile
74 if test ! -f "$PY_MAKEFILE"; then
75 AC_MSG_WARN([*** Couldn't find ${PY_MAKEFILE}. Maybe you are
76 *** missing the development portion of the python installation])
80 AC_SUBST(PYTHON_INCLUDES)
83 PYTHON_INCLUDES=-I$PYTHON_PREFIX/include/python$PYTHON_VERSION
84 PYTHON_LIBS="-L${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
85 PYTHON_LIB=$PYTHON_LIBS
86 PYTHON_LIBA=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a
87 if test "${build_cpu::6}" = "x86_64" ; then
88 if test "$PY_MAKEFILE" = "${PYTHON_PREFIX}/lib64/python$PYTHON_VERSION/config/Makefile" ; then
89 PYTHON_LIBS="-L${PYTHON_PREFIX}/lib64/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
90 PYTHON_LIB=$PYTHON_LIBS
91 PYTHON_LIBA=${PYTHON_PREFIX}/lib64/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a
93 if test "$PY_MAKEFILE" = "${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config-${PYTHON_VERSION}${PYTHON_ABIFLAGS}-${build_cpu}-${build_os}/Makefile" ; then
94 PYTHON_LIBS="-L${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/config-${PYTHON_VERSION}${PYTHON_ABIFLAGS}-${build_cpu}-${build_os} -lpython${PYTHON_VERSION}${PYTHON_ABIFLAGS}"
95 PYTHON_LIB=$PYTHON_LIBS
96 PYTHON_LIBA=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config-${PYTHON_VERSION}${PYTHON_ABIFLAGS}-${build_cpu}-${build_os}/libpython${PYTHON_VERSION}${PYTHON_ABIFLAGS}.a
100 dnl At times (like when building shared libraries) you may want
101 dnl to know which OS Python thinks this is.
103 AC_SUBST(PYTHON_PLATFORM)
104 PYTHON_PLATFORM=`$PYTHON -c "import sys; print(sys.platform)"`
106 AC_SUBST(PYTHON_SITE)
107 AC_ARG_WITH(python-site,
108 [AC_HELP_STRING([--with-python-site=DIR],
109 [Use DIR for installing platform independent Python site-packages])],
111 dnl modification : by default, we install python script in salome root tree
113 dnl [PYTHON_SITE="$withval"
114 dnl python_site_given=yes],
115 dnl [PYTHON_SITE=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
116 dnl python_site_given=no]
118 [PYTHON_SITE="$withval"
119 python_site_given=yes],
120 [PYTHON_SITE=${prefix}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
121 python_site_given=no])
123 AC_SUBST(PYTHON_SITE_PACKAGE)
124 PYTHON_SITE_PACKAGE=$PYTHON_SITE/$PACKAGE
127 dnl Get PYTHON_SITE from --with-python-site-exec or from
128 dnl --with-python-site or from running Python
130 AC_SUBST(PYTHON_SITE_EXEC)
131 AC_ARG_WITH(python-site-exec,
132 [AC_HELP_STRING([--with-python-site-exec=DIR],
133 [Use DIR for installing platform dependent Python site-packages])],
134 [PYTHON_SITE_EXEC="$withval"],
135 [if test "$python_site_given" = yes; then
136 PYTHON_SITE_EXEC=$PYTHON_SITE
138 PYTHON_SITE_EXEC=${PYTHON_EXEC_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
141 dnl Set up the install directory
143 [PYTHON_SITE_INSTALL=$PYTHON_SITE],
144 [PYTHON_SITE_INSTALL=$PYTHON_SITE_PACKAGE])
145 AC_SUBST(PYTHON_SITE_INSTALL)
147 dnl Also lets automake think PYTHON means something.
149 pythondir=${PYTHON_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/
152 AC_MSG_CHECKING([if we need libdb])
153 PY_NEEDOPENDB=`nm $PYTHON_LIBA | grep dbopen | grep U`
154 if test "x$PY_NEEDOPENDB" != "x"; then
156 AC_CHECK_LIB(db,dbopen,PYTHON_LIBS="$PYTHON_LIBS -ldb",db_ok=no)
161 AC_MSG_CHECKING([if we need libdl])
162 PY_NEEDOPENDL=`nm $PYTHON_LIBA | grep dlopen | grep U`
163 if test "x$PY_NEEDOPENDL" != "x"; then
165 AC_CHECK_LIB(dl,dlopen,PYTHON_LIBS="$PYTHON_LIBS -ldl",dl_ok=no)
170 AC_MSG_CHECKING([if we need libutil])
171 PY_NEEDOPENPTY=`nm $PYTHON_LIBA | grep openpty | grep U`
172 if test "x$PY_NEEDOPENPTY" != "x"; then
174 AC_CHECK_LIB(util,openpty,PYTHON_LIBS="$PYTHON_LIBS -lutil",openpty_ok=no)
179 AC_MSG_CHECKING([if we need tcltk])
180 PY_NEEDTCLTK=`nm $PYTHON_LIBA | grep Tcl_Init | grep U`
181 if test "x$PY_NEEDTCLTK" != "x"; then
183 AC_CHECK_LIB(tcl,Tcl_Init,PYTHON_LIBS="$PYTHON_LIBS -ltcl -ltk",tclinit_ok=no)
188 if test "$python_ok" == "yes"; then
189 AC_MSG_RESULT(looks good)