Salome HOME
updated copyright message
[modules/yacs.git] / src / wrappergen / bin / Cpp_Template__SRC / adm / unix / config_files / ac_python_devel.m4
1 dnl Copyright (C) 2006-2023  CEA/DEN, EDF R&D
2 dnl
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, or (at your option) any later version.
7 dnl
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.
12 dnl
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
16 dnl
17 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 dnl
19
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>.
26 dnl
27 AC_DEFUN([AC_PYTHON_DEVEL],[
28         #
29         # should allow for checking of python version here...
30         #
31         AC_REQUIRE([AM_PATH_PYTHON])
32
33         # Check for Python include path
34         AC_MSG_CHECKING([for Python include path])
35         python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
36         for i in "$python_path/include/python$PYTHON_VERSION/" "$python_path/include/python/" "$python_path/" ; do
37                 python_path=`find $i -type f -name Python.h -print | sed "1q"`
38                 if test -n "$python_path" ; then
39                         break
40                 fi
41         done
42         python_path=`echo $python_path | sed "s,/Python.h$,,"`
43         AC_MSG_RESULT([$python_path])
44         if test -z "$python_path" ; then
45                 AC_MSG_ERROR([cannot find Python include path])
46         fi
47         AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path])
48
49         # Check for Python library path
50         AC_MSG_CHECKING([for Python library path])
51         python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
52         for i in "$python_path/lib/python$PYTHON_VERSION/config/" "$python_path/lib/python$PYTHON_VERSION/" "$python_path/lib/python/config/" "$python_path/lib/python/" "$python_path/" ; do
53                 python_path=`find $i -type f -name libpython$PYTHON_VERSION.* -print | sed "1q"`
54                 if test -n "$python_path" ; then
55                         break
56                 fi
57         done
58         python_path=`echo $python_path | sed "s,/libpython.*$,,"`
59         AC_MSG_RESULT([$python_path])
60         if test -z "$python_path" ; then
61                 AC_MSG_ERROR([cannot find Python library path])
62         fi
63         AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$PYTHON_VERSION"])
64         #
65         python_site=`echo $python_path | sed "s/config/site-packages/"`
66         AC_SUBST([PYTHON_SITE_PKG],[$python_site])
67         #
68         # libraries which must be linked in when embedding
69         #
70         AC_MSG_CHECKING(python extra libraries)
71         PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
72                 conf = distutils.sysconfig.get_config_var; \
73                 print(conf('LOCALMODLIBS')+' '+conf('LIBS'))"
74         AC_MSG_RESULT($PYTHON_EXTRA_LIBS)`
75         AC_SUBST(PYTHON_EXTRA_LIBS)
76 ])