1 dnl Copyright (C) 2007-2010 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
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],
43 [AC_HELP_STRING([--with-python=DIR],[root directory path of python installation])],
44 [PYTHON="$withval/bin/python"
45 AC_MSG_RESULT("select python distribution in $withval")
47 AC_PATH_PROG(PYTHON, python)
50 AC_CHECKING([local Python configuration])
52 AC_REQUIRE([AC_LINKER_OPTIONS])dnl
54 PYTHON_PREFIX=`echo $PYTHON | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
55 PYTHON_PREFIX=`echo $PYTHON_PREFIX | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
56 PYTHONHOME=$PYTHON_PREFIX
58 AC_SUBST(PYTHON_PREFIX)
61 changequote(<<, >>)dnl
62 PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[:3]"`
64 AC_SUBST(PYTHON_VERSION)
66 PY_MAKEFILE=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/Makefile
67 if test ! -f "$PY_MAKEFILE"; then
68 if test "${build_cpu::6}" = "x86_64" ; then
69 PY_MAKEFILE=${PYTHON_PREFIX}/lib64/python$PYTHON_VERSION/config/Makefile
72 if test ! -f "$PY_MAKEFILE"; then
73 AC_MSG_WARN([*** Couldn't find ${PY_MAKEFILE}. Maybe you are
74 *** missing the development portion of the python installation])
78 AC_SUBST(PYTHON_INCLUDES)
81 PYTHON_INCLUDES=-I$PYTHON_PREFIX/include/python$PYTHON_VERSION
82 PYTHON_LIBS="-L${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
83 PYTHON_LIB=$PYTHON_LIBS
84 PYTHON_LIBA=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a
85 if test "${build_cpu::6}" = "x86_64" ; then
86 if test "$PY_MAKEFILE" = "${PYTHON_PREFIX}/lib64/python$PYTHON_VERSION/config/Makefile" ; then
87 PYTHON_LIBS="-L${PYTHON_PREFIX}/lib64/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
88 PYTHON_LIB=$PYTHON_LIBS
89 PYTHON_LIBA=${PYTHON_PREFIX}/lib64/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a
93 dnl At times (like when building shared libraries) you may want
94 dnl to know which OS Python thinks this is.
96 AC_SUBST(PYTHON_PLATFORM)
97 PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"`
100 AC_ARG_WITH(python-site,
101 [AC_HELP_STRING([--with-python-site=DIR],
102 [Use DIR for installing platform independent Python site-packages])],
104 dnl modification : by default, we install python script in salome root tree
106 dnl [PYTHON_SITE="$withval"
107 dnl python_site_given=yes],
108 dnl [PYTHON_SITE=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
109 dnl python_site_given=no]
111 [PYTHON_SITE="$withval"
112 python_site_given=yes],
113 [PYTHON_SITE=${prefix}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
114 python_site_given=no])
116 AC_SUBST(PYTHON_SITE_PACKAGE)
117 PYTHON_SITE_PACKAGE=$PYTHON_SITE/$PACKAGE
120 dnl Get PYTHON_SITE from --with-python-site-exec or from
121 dnl --with-python-site or from running Python
123 AC_SUBST(PYTHON_SITE_EXEC)
124 AC_ARG_WITH(python-site-exec,
125 [AC_HELP_STRING([--with-python-site-exec=DIR],
126 [Use DIR for installing platform dependent Python site-packages])],
127 [PYTHON_SITE_EXEC="$withval"],
128 [if test "$python_site_given" = yes; then
129 PYTHON_SITE_EXEC=$PYTHON_SITE
131 PYTHON_SITE_EXEC=${PYTHON_EXEC_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
134 dnl Set up the install directory
136 [PYTHON_SITE_INSTALL=$PYTHON_SITE],
137 [PYTHON_SITE_INSTALL=$PYTHON_SITE_PACKAGE])
138 AC_SUBST(PYTHON_SITE_INSTALL)
140 dnl Also lets automake think PYTHON means something.
142 pythondir=${PYTHON_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/
145 AC_MSG_CHECKING([if we need libdb])
146 PY_NEEDOPENDB=`nm $PYTHON_LIBA | grep dbopen | grep U`
147 if test "x$PY_NEEDOPENDB" != "x"; then
149 AC_CHECK_LIB(db,dbopen,PYTHON_LIBS="$PYTHON_LIBS -ldb",db_ok=no)
154 AC_MSG_CHECKING([if we need libdl])
155 PY_NEEDOPENDL=`nm $PYTHON_LIBA | grep dlopen | grep U`
156 if test "x$PY_NEEDOPENDL" != "x"; then
158 AC_CHECK_LIB(dl,dlopen,PYTHON_LIBS="$PYTHON_LIBS -ldl",dl_ok=no)
163 AC_MSG_CHECKING([if we need libutil])
164 PY_NEEDOPENPTY=`nm $PYTHON_LIBA | grep openpty | grep U`
165 if test "x$PY_NEEDOPENPTY" != "x"; then
167 AC_CHECK_LIB(util,openpty,PYTHON_LIBS="$PYTHON_LIBS -lutil",openpty_ok=no)
172 AC_MSG_CHECKING([if we need tcltk])
173 PY_NEEDTCLTK=`nm $PYTHON_LIBA | grep Tcl_Init | grep U`
174 if test "x$PY_NEEDTCLTK" != "x"; then
176 AC_CHECK_LIB(tcl,Tcl_Init,PYTHON_LIBS="$PYTHON_LIBS -ltcl -ltk",tclinit_ok=no)
181 if test "$python_ok" == "yes"; then
182 AC_MSG_RESULT(looks good)