1 dnl Copyright (C) 2007-2008 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.
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
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],
42 [AC_HELP_STRING([--with-python=DIR],[root directory path of python installation])],
43 [PYTHON="$withval/bin/python"
44 AC_MSG_RESULT("select python distribution in $withval")
46 AC_PATH_PROG(PYTHON, python)
49 AC_CHECKING([local Python configuration])
51 AC_REQUIRE([AC_LINKER_OPTIONS])dnl
53 PYTHON_PREFIX=`echo $PYTHON | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
54 PYTHON_PREFIX=`echo $PYTHON_PREFIX | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
55 PYTHONHOME=$PYTHON_PREFIX
57 AC_SUBST(PYTHON_PREFIX)
60 changequote(<<, >>)dnl
61 PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[:3]"`
63 AC_SUBST(PYTHON_VERSION)
65 PY_MAKEFILE=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/Makefile
66 if test ! -f "$PY_MAKEFILE"; then
67 AC_MSG_WARN([*** Couldn't find ${PY_MAKEFILE}. Maybe you are
68 *** missing the development portion of the python installation])
72 AC_SUBST(PYTHON_INCLUDES)
75 PYTHON_INCLUDES=-I$PYTHON_PREFIX/include/python$PYTHON_VERSION
76 PYTHON_LIBS="-L${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
77 PYTHON_LIB=$PYTHON_LIBS
78 PYTHON_LIBA=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a
80 dnl At times (like when building shared libraries) you may want
81 dnl to know which OS Python thinks this is.
83 AC_SUBST(PYTHON_PLATFORM)
84 PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"`
87 AC_ARG_WITH(python-site,
88 [AC_HELP_STRING([--with-python-site=DIR],
89 [Use DIR for installing platform independent Python site-packages])],
91 dnl modification : by default, we install python script in salome root tree
93 dnl [PYTHON_SITE="$withval"
94 dnl python_site_given=yes],
95 dnl [PYTHON_SITE=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
96 dnl python_site_given=no]
98 [PYTHON_SITE="$withval"
99 python_site_given=yes],
100 [PYTHON_SITE=${prefix}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
101 python_site_given=no])
103 AC_SUBST(PYTHON_SITE_PACKAGE)
104 PYTHON_SITE_PACKAGE=$PYTHON_SITE/$PACKAGE
107 dnl Get PYTHON_SITE from --with-python-site-exec or from
108 dnl --with-python-site or from running Python
110 AC_SUBST(PYTHON_SITE_EXEC)
111 AC_ARG_WITH(python-site-exec,
112 [AC_HELP_STRING([--with-python-site-exec=DIR],
113 [Use DIR for installing platform dependent Python site-packages])],
114 [PYTHON_SITE_EXEC="$withval"],
115 [if test "$python_site_given" = yes; then
116 PYTHON_SITE_EXEC=$PYTHON_SITE
118 PYTHON_SITE_EXEC=${PYTHON_EXEC_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
121 dnl Set up the install directory
123 [PYTHON_SITE_INSTALL=$PYTHON_SITE],
124 [PYTHON_SITE_INSTALL=$PYTHON_SITE_PACKAGE])
125 AC_SUBST(PYTHON_SITE_INSTALL)
127 dnl Also lets automake think PYTHON means something.
129 pythondir=${PYTHON_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/
132 AC_MSG_CHECKING([if we need libdb])
133 PY_NEEDOPENDB=`nm $PYTHON_LIBA | grep dbopen | grep U`
134 if test "x$PY_NEEDOPENDB" != "x"; then
136 AC_CHECK_LIB(db,dbopen,PYTHON_LIBS="$PYTHON_LIBS -ldb",db_ok=no)
141 AC_MSG_CHECKING([if we need libdl])
142 PY_NEEDOPENDL=`nm $PYTHON_LIBA | grep dlopen | grep U`
143 if test "x$PY_NEEDOPENDL" != "x"; then
145 AC_CHECK_LIB(dl,dlopen,PYTHON_LIBS="$PYTHON_LIBS -ldl",dl_ok=no)
150 AC_MSG_CHECKING([if we need libutil])
151 PY_NEEDOPENPTY=`nm $PYTHON_LIBA | grep openpty | grep U`
152 if test "x$PY_NEEDOPENPTY" != "x"; then
154 AC_CHECK_LIB(util,openpty,PYTHON_LIBS="$PYTHON_LIBS -lutil",openpty_ok=no)
159 AC_MSG_CHECKING([if we need tcltk])
160 PY_NEEDTCLTK=`nm $PYTHON_LIBA | grep Tcl_Init | grep U`
161 if test "x$PY_NEEDTCLTK" != "x"; then
163 AC_CHECK_LIB(tcl,Tcl_Init,PYTHON_LIBS="$PYTHON_LIBS -ltcl -ltk",tclinit_ok=no)
168 if test "$python_ok" == "yes"; then
169 AC_MSG_RESULT(looks good)