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,
38 [ --with-python=DIR root directory path of python installation ],
39 [PYTHON="$withval/bin/python"
40 AC_MSG_RESULT("select python distribution in $withval")
42 AC_PATH_PROG(PYTHON, python)
45 AC_CHECKING([local Python configuration])
46 PYTHON_PREFIX=`echo $PYTHON | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
47 PYTHON_PREFIX=`echo $PYTHON_PREFIX | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
48 PYTHONHOME=$PYTHON_PREFIX
50 AC_SUBST(PYTHON_PREFIX)
53 changequote(<<, >>)dnl
54 PYTHON_VERSION=`$PYTHON -c "import sys; print(sys.version[:3])"`
56 AC_SUBST(PYTHON_VERSION)
58 PY_MAKEFILE=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/config/Makefile
59 if test ! -f "$PY_MAKEFILE"; then
60 AC_MSG_ERROR([*** Couldn't find ${PY_MAKEFILE}. Maybe you are
61 *** missing the development portion of the python installation])
64 AC_SUBST(PYTHON_INCLUDES)
67 PYTHON_INCLUDES=-I$PYTHON_PREFIX/include/python$PYTHON_VERSION
68 PYTHON_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
69 PYTHON_LIB=$PYTHON_LIBS
70 PYTHON_LIBA=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a
72 dnl At times (like when building shared libraries) you may want
73 dnl to know which OS Python thinks this is.
75 AC_SUBST(PYTHON_PLATFORM)
76 PYTHON_PLATFORM=`$PYTHON -c "import sys; print(sys.platform)"`
79 AC_ARG_WITH(python-site,
80 [ --with-python-site=DIR Use DIR for installing platform independent
81 Python site-packages],
83 dnl modification : by default, we install python script in salome root tree
85 dnl [PYTHON_SITE="$withval"
86 dnl python_site_given=yes],
87 dnl [PYTHON_SITE=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
88 dnl python_site_given=no])
90 [PYTHON_SITE="$withval"
91 python_site_given=yes],
92 [PYTHON_SITE=$prefix"/lib/python"$PYTHON_VERSION/site-packages
93 python_site_given=no])
95 AC_SUBST(PYTHON_SITE_PACKAGE)
96 PYTHON_SITE_PACKAGE=$PYTHON_SITE/$PACKAGE
99 dnl Get PYTHON_SITE from --with-python-site-exec or from
100 dnl --with-python-site or from running Python
102 AC_SUBST(PYTHON_SITE_EXEC)
103 AC_ARG_WITH(python-site-exec,
104 [ --with-python-site-exec=DIR Use DIR for installing platform dependent
105 Python site-packages],
106 [PYTHON_SITE_EXEC="$withval"],
107 [if test "$python_site_given" = yes; then
108 PYTHON_SITE_EXEC=$PYTHON_SITE
110 PYTHON_SITE_EXEC=$PYTHON_EXEC_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
113 dnl Set up the install directory
115 [PYTHON_SITE_INSTALL=$PYTHON_SITE],
116 [PYTHON_SITE_INSTALL=$PYTHON_SITE_PACKAGE])
117 AC_SUBST(PYTHON_SITE_INSTALL)
119 dnl Also lets automake think PYTHON means something.
121 pythondir=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/
124 AC_MSG_CHECKING([if we need libdb])
125 PY_NEEDOPENDB=`nm $PYTHON_LIBA | grep dbopen | grep U`
126 if test "x$PY_NEEDOPENDB" != "x"; then
127 PYTHON_LIBS="$PYTHON_LIBS -ldb"
133 AC_MSG_CHECKING([if we need libdl])
134 PY_NEEDOPENDL=`nm $PYTHON_LIBA | grep dlopen | grep U`
135 if test "x$PY_NEEDOPENDL" != "x"; then
136 PYTHON_LIBS="$PYTHON_LIBS -ldl"
142 AC_MSG_CHECKING([if we need libutil])
143 PY_NEEDOPENPTY=`nm $PYTHON_LIBA | grep openpty | grep U`
144 if test "x$PY_NEEDOPENPTY" != "x"; then
145 PYTHON_LIBS="$PYTHON_LIBS -lutil"
151 AC_MSG_CHECKING([if we need tcltk])
152 PY_NEEDTCLTK=`nm $PYTHON_LIBA | grep Tcl_Init | grep U`
153 if test "x$PY_NEEDTCLTK" != "x"; then
154 PYTHON_LIBS="$PYTHON_LIBS -ltcl -ltk"
161 AC_MSG_RESULT(looks good)])