1 dnl Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 dnl This library is free software; you can redistribute it and/or
5 dnl modify it under the terms of the GNU Lesser General Public
6 dnl License as published by the Free Software Foundation; either
7 dnl version 2.1 of the License.
9 dnl This library is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 dnl Lesser General Public License for more details.
14 dnl You should have received a copy of the GNU Lesser General Public
15 dnl License along with this library; if not, write to the Free Software
16 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 dnl See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 ## ------------------------
23 ## Python file handling
25 ## Modified by Marc Tajchman (06/2001)
26 ## ------------------------
28 dnl CHECK_PYTHON([module, classes])
30 dnl Adds support for distributing Python modules or classes.
31 dnl Python library files distributed as a `module' are installed
32 dnl under PYTHON_SITE_PACKAGE (eg, ./python1.5/site-package/package-name)
33 dnl while those distributed as `classes' are installed under PYTHON_SITE
34 dnl (eg, ./python1.5/site-packages). The default is to install as
37 AC_DEFUN(CHECK_PYTHON,
40 [ --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])
48 PYTHON_PREFIX=`echo $PYTHON | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
49 PYTHON_PREFIX=`echo $PYTHON_PREFIX | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
50 PYTHONHOME=$PYTHON_PREFIX
52 AC_SUBST(PYTHON_PREFIX)
55 changequote(<<, >>)dnl
56 PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[:3]"`
58 AC_SUBST(PYTHON_VERSION)
60 PY_MAKEFILE=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/config/Makefile
61 if test ! -f "$PY_MAKEFILE"; then
62 AC_MSG_ERROR([*** Couldn't find ${PY_MAKEFILE}. Maybe you are
63 *** missing the development portion of the python installation])
66 AC_SUBST(PYTHON_INCLUDES)
69 PYTHON_INCLUDES=-I$PYTHON_PREFIX/include/python$PYTHON_VERSION
70 PYTHON_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
71 PYTHON_LIB=$PYTHON_LIBS
72 PYTHON_LIBA=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a
74 dnl At times (like when building shared libraries) you may want
75 dnl to know which OS Python thinks this is.
77 AC_SUBST(PYTHON_PLATFORM)
78 PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"`
81 AC_ARG_WITH(python-site,
82 [ --with-python-site=DIR Use DIR for installing platform independent
83 Python site-packages],
85 dnl modification : by default, we install python script in salome root tree
87 dnl [PYTHON_SITE="$withval"
88 dnl python_site_given=yes],
89 dnl [PYTHON_SITE=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
90 dnl python_site_given=no])
92 [PYTHON_SITE="$withval"
93 python_site_given=yes],
94 [PYTHON_SITE=$prefix"/lib/python"$PYTHON_VERSION/site-packages
95 python_site_given=no])
97 AC_SUBST(PYTHON_SITE_PACKAGE)
98 PYTHON_SITE_PACKAGE=$PYTHON_SITE/$PACKAGE
101 dnl Get PYTHON_SITE from --with-python-site-exec or from
102 dnl --with-python-site or from running Python
104 AC_SUBST(PYTHON_SITE_EXEC)
105 AC_ARG_WITH(python-site-exec,
106 [ --with-python-site-exec=DIR Use DIR for installing platform dependent
107 Python site-packages],
108 [PYTHON_SITE_EXEC="$withval"],
109 [if test "$python_site_given" = yes; then
110 PYTHON_SITE_EXEC=$PYTHON_SITE
112 PYTHON_SITE_EXEC=$PYTHON_EXEC_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
115 dnl Set up the install directory
117 [PYTHON_SITE_INSTALL=$PYTHON_SITE],
118 [PYTHON_SITE_INSTALL=$PYTHON_SITE_PACKAGE])
119 AC_SUBST(PYTHON_SITE_INSTALL)
121 dnl Also lets automake think PYTHON means something.
123 pythondir=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/
126 AC_MSG_CHECKING([if we need libdb])
127 PY_NEEDOPENDB=`nm $PYTHON_LIBA | grep dbopen | grep U`
128 if test "x$PY_NEEDOPENDB" != "x"; then
129 PYTHON_LIBS="$PYTHON_LIBS -ldb"
135 AC_MSG_CHECKING([if we need libdl])
136 PY_NEEDOPENDL=`nm $PYTHON_LIBA | grep dlopen | grep U`
137 if test "x$PY_NEEDOPENDL" != "x"; then
138 PYTHON_LIBS="$PYTHON_LIBS -ldl"
144 AC_MSG_CHECKING([if we need libutil])
145 PY_NEEDOPENPTY=`nm $PYTHON_LIBA | grep openpty | grep U`
146 if test "x$PY_NEEDOPENPTY" != "x"; then
147 PYTHON_LIBS="$PYTHON_LIBS -lutil"
153 AC_MSG_CHECKING([if we need tcltk])
154 PY_NEEDTCLTK=`nm $PYTHON_LIBA | grep Tcl_Init | grep U`
155 if test "x$PY_NEEDTCLTK" != "x"; then
156 PYTHON_LIBS="$PYTHON_LIBS -ltcl -ltk"
163 AC_MSG_RESULT(looks good)])