1 dnl Copyright (C) 2006-2021 CEA/DEN, EDF R&D
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, or (at your option) any later version.
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.
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
17 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 ## ------------------------
21 ## Python file handling
23 ## Modified by Marc Tajchman (06/2001)
24 ## ------------------------
26 dnl CHECK_PYTHON([module, classes])
28 dnl Adds support for distributing Python modules or classes.
29 dnl Python library files distributed as a `module' are installed
30 dnl under PYTHON_SITE_PACKAGE (eg, ./python1.5/site-package/package-name)
31 dnl while those distributed as `classes' are installed under PYTHON_SITE
32 dnl (eg, ./python1.5/site-packages). The default is to install as
35 AC_DEFUN([CHECK_PYTHON],
40 [AC_HELP_STRING([--with-python=DIR],[root directory path of python installation])],
41 [PYTHON="$withval/bin/python"
42 AC_MSG_RESULT("select python distribution in $withval")
44 AC_PATH_PROG(PYTHON, python)
47 AC_CHECKING([local Python configuration])
49 AC_REQUIRE([AC_LINKER_OPTIONS])dnl
51 PYTHON_PREFIX=`echo $PYTHON | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
52 PYTHON_PREFIX=`echo $PYTHON_PREFIX | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
53 PYTHONHOME=$PYTHON_PREFIX
55 AC_SUBST(PYTHON_PREFIX)
58 changequote(<<, >>)dnl
59 PYTHON_VERSION=`$PYTHON -c "import sys; print(sys.version[:3])"`
61 AC_SUBST(PYTHON_VERSION)
63 PY_MAKEFILE=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/Makefile
64 if test ! -f "$PY_MAKEFILE"; then
65 AC_MSG_WARN([*** Couldn't find ${PY_MAKEFILE}. Maybe you are
66 *** missing the development portion of the python installation])
70 AC_SUBST(PYTHON_INCLUDES)
73 PYTHON_INCLUDES=-I$PYTHON_PREFIX/include/python$PYTHON_VERSION
74 PYTHON_LIBS="-L${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
75 PYTHON_LIB=$PYTHON_LIBS
76 PYTHON_LIBA=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a
78 dnl At times (like when building shared libraries) you may want
79 dnl to know which OS Python thinks this is.
81 AC_SUBST(PYTHON_PLATFORM)
82 PYTHON_PLATFORM=`$PYTHON -c "import sys; print(sys.platform)"`
85 AC_ARG_WITH(python-site,
86 [AC_HELP_STRING([--with-python-site=DIR],
87 [Use DIR for installing platform independent Python site-packages])],
89 dnl modification : by default, we install python script in salome root tree
91 dnl [PYTHON_SITE="$withval"
92 dnl python_site_given=yes],
93 dnl [PYTHON_SITE=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
94 dnl python_site_given=no]
96 [PYTHON_SITE="$withval"
97 python_site_given=yes],
98 [PYTHON_SITE=${prefix}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
99 python_site_given=no])
101 AC_SUBST(PYTHON_SITE_PACKAGE)
102 PYTHON_SITE_PACKAGE=$PYTHON_SITE/$PACKAGE
105 dnl Get PYTHON_SITE from --with-python-site-exec or from
106 dnl --with-python-site or from running Python
108 AC_SUBST(PYTHON_SITE_EXEC)
109 AC_ARG_WITH(python-site-exec,
110 [AC_HELP_STRING([--with-python-site-exec=DIR],
111 [Use DIR for installing platform dependent Python site-packages])],
112 [PYTHON_SITE_EXEC="$withval"],
113 [if test "$python_site_given" = yes; then
114 PYTHON_SITE_EXEC=$PYTHON_SITE
116 PYTHON_SITE_EXEC=${PYTHON_EXEC_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
119 dnl Set up the install directory
121 [PYTHON_SITE_INSTALL=$PYTHON_SITE],
122 [PYTHON_SITE_INSTALL=$PYTHON_SITE_PACKAGE])
123 AC_SUBST(PYTHON_SITE_INSTALL)
125 dnl Also lets automake think PYTHON means something.
127 pythondir=${PYTHON_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/
130 AC_MSG_CHECKING([if we need libdb])
131 PY_NEEDOPENDB=`nm $PYTHON_LIBA | grep dbopen | grep U`
132 if test "x$PY_NEEDOPENDB" != "x"; then
134 AC_CHECK_LIB(db,dbopen,PYTHON_LIBS="$PYTHON_LIBS -ldb",db_ok=no)
139 AC_MSG_CHECKING([if we need libdl])
140 PY_NEEDOPENDL=`nm $PYTHON_LIBA | grep dlopen | grep U`
141 if test "x$PY_NEEDOPENDL" != "x"; then
143 AC_CHECK_LIB(dl,dlopen,PYTHON_LIBS="$PYTHON_LIBS -ldl",dl_ok=no)
148 AC_MSG_CHECKING([if we need libutil])
149 PY_NEEDOPENPTY=`nm $PYTHON_LIBA | grep openpty | grep U`
150 if test "x$PY_NEEDOPENPTY" != "x"; then
152 AC_CHECK_LIB(util,openpty,PYTHON_LIBS="$PYTHON_LIBS -lutil",openpty_ok=no)
157 AC_MSG_CHECKING([if we need tcltk])
158 PY_NEEDTCLTK=`nm $PYTHON_LIBA | grep Tcl_Init | grep U`
159 if test "x$PY_NEEDTCLTK" != "x"; then
161 AC_CHECK_LIB(tcl,Tcl_Init,PYTHON_LIBS="$PYTHON_LIBS -ltcl -ltk",tclinit_ok=no)
166 if test "$python_ok" == "yes"; then
167 AC_MSG_RESULT(looks good)