1 dnl Copyright (C) 2006-2013 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.
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 dnl @synopsis AC_PYTHON_DEVEL()
21 dnl Checks for Python and tries to get the include path to 'Python.h'.
22 dnl It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) output variable.
23 dnl @authors Sebastian Huber <address@hidden>, Alan W. Irwin
24 dnl <address@hidden>, Rafael Laboissiere <address@hidden> and
25 dnl Andrew Collier <address@hidden>.
27 AC_DEFUN([CHECK_PYTHON],[
29 # should allow for checking of python version here...
31 AC_REQUIRE([AM_PATH_PYTHON])
38 # Check for Python include path
39 AC_MSG_CHECKING([for Python include path])
40 python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
41 for i in "$python_path/include/python$PYTHON_VERSION/" "$python_path/include/python/" "$python_path/" ; do
42 python_path=`find $i -type f -name Python.h -print | sed "1q"`
43 if test -n "$python_path" ; then
47 python_path=`echo $python_path | sed "s,/Python.h$,,"`
48 AC_MSG_RESULT([$python_path])
49 if test -z "$python_path" ; then
50 AC_MSG_ERROR([cannot find Python include path])
52 AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path])
54 # Check for Python library path
55 AC_MSG_CHECKING([for Python library path])
56 python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
57 for i in "$python_path/lib${LIB}/python$PYTHON_VERSION/config/" "$python_path/lib${LIB}/python$PYTHON_VERSION/" "$python_path/lib{LIB}/python/config/" "$python_path/lib${LIB}/python/" "$python_path/" ; do
58 python_path=`find $i -type f -name libpython$PYTHON_VERSION.* -print | sed "1q"`
59 if test -n "$python_path" ; then
63 python_path=`echo $python_path | sed "s,/libpython.*$,,"`
64 AC_MSG_RESULT([$python_path])
65 if test -z "$python_path" ; then
66 AC_MSG_ERROR([cannot find Python library path])
68 AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$PYTHON_VERSION"])
70 python_site=`echo $python_path | sed "s/config/site-packages/"`
71 AC_SUBST([PYTHON_SITE_PKG],[$python_site])
73 # libraries which must be linked in when embedding
75 AC_MSG_CHECKING(python extra libraries)
76 PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
77 conf = distutils.sysconfig.get_config_var; \
78 print conf('LOCALMODLIBS')+' '+conf('LIBS')"
79 AC_MSG_RESULT($PYTHON_EXTRA_LIBS)`
80 AC_SUBST(PYTHON_EXTRA_LIBS)