1 dnl Copyright (C) 2007-2015 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, or (at your option) any later version.
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 AC_MSG_WARN([*** Couldn't find ${PY_MAKEFILE}. Maybe you are
69 *** missing the development portion of the python installation])
73 AC_SUBST(PYTHON_INCLUDES)
76 PYTHON_INCLUDES=-I$PYTHON_PREFIX/include/python$PYTHON_VERSION
77 PYTHON_LIBS="-L${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
78 PYTHON_LIB=$PYTHON_LIBS
79 PYTHON_LIBA=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a
81 dnl At times (like when building shared libraries) you may want
82 dnl to know which OS Python thinks this is.
84 AC_SUBST(PYTHON_PLATFORM)
85 PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"`
88 AC_ARG_WITH(python-site,
89 [AC_HELP_STRING([--with-python-site=DIR],
90 [Use DIR for installing platform independent Python site-packages])],
92 dnl modification : by default, we install python script in salome root tree
94 dnl [PYTHON_SITE="$withval"
95 dnl python_site_given=yes],
96 dnl [PYTHON_SITE=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
97 dnl python_site_given=no]
99 [PYTHON_SITE="$withval"
100 python_site_given=yes],
101 [PYTHON_SITE=${prefix}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
102 python_site_given=no])
104 AC_SUBST(PYTHON_SITE_PACKAGE)
105 PYTHON_SITE_PACKAGE=$PYTHON_SITE/$PACKAGE
108 dnl Get PYTHON_SITE from --with-python-site-exec or from
109 dnl --with-python-site or from running Python
111 AC_SUBST(PYTHON_SITE_EXEC)
112 AC_ARG_WITH(python-site-exec,
113 [AC_HELP_STRING([--with-python-site-exec=DIR],
114 [Use DIR for installing platform dependent Python site-packages])],
115 [PYTHON_SITE_EXEC="$withval"],
116 [if test "$python_site_given" = yes; then
117 PYTHON_SITE_EXEC=$PYTHON_SITE
119 PYTHON_SITE_EXEC=${PYTHON_EXEC_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/site-packages
122 dnl Set up the install directory
124 [PYTHON_SITE_INSTALL=$PYTHON_SITE],
125 [PYTHON_SITE_INSTALL=$PYTHON_SITE_PACKAGE])
126 AC_SUBST(PYTHON_SITE_INSTALL)
128 dnl Also lets automake think PYTHON means something.
130 pythondir=${PYTHON_PREFIX}"/lib${LIB_LOCATION_SUFFIX}/python"${PYTHON_VERSION}/
133 AC_MSG_CHECKING([if we need libdb])
134 PY_NEEDOPENDB=`nm $PYTHON_LIBA | grep dbopen | grep U`
135 if test "x$PY_NEEDOPENDB" != "x"; then
137 AC_CHECK_LIB(db,dbopen,PYTHON_LIBS="$PYTHON_LIBS -ldb",db_ok=no)
142 AC_MSG_CHECKING([if we need libdl])
143 PY_NEEDOPENDL=`nm $PYTHON_LIBA | grep dlopen | grep U`
144 if test "x$PY_NEEDOPENDL" != "x"; then
146 AC_CHECK_LIB(dl,dlopen,PYTHON_LIBS="$PYTHON_LIBS -ldl",dl_ok=no)
151 AC_MSG_CHECKING([if we need libutil])
152 PY_NEEDOPENPTY=`nm $PYTHON_LIBA | grep openpty | grep U`
153 if test "x$PY_NEEDOPENPTY" != "x"; then
155 AC_CHECK_LIB(util,openpty,PYTHON_LIBS="$PYTHON_LIBS -lutil",openpty_ok=no)
160 AC_MSG_CHECKING([if we need tcltk])
161 PY_NEEDTCLTK=`nm $PYTHON_LIBA | grep Tcl_Init | grep U`
162 if test "x$PY_NEEDTCLTK" != "x"; then
164 AC_CHECK_LIB(tcl,Tcl_Init,PYTHON_LIBS="$PYTHON_LIBS -ltcl -ltk",tclinit_ok=no)
169 if test "$python_ok" == "yes"; then
170 AC_MSG_RESULT(looks good)