Salome HOME
Copyright update 2022
[modules/yacs.git] / src / wrappergen / bin / HXX2SALOME_GENERIC_CLASS_NAME_SRC / adm_local / unix / config_files / python.m4
1 dnl Copyright (C) 2006-2022  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([CHECK_PYTHON],[
28         #
29         # should allow for checking of python version here...
30         #
31         AC_REQUIRE([AM_PATH_PYTHON])
32
33         case `uname -m` in
34            *64)  LIB="64" ;;
35            *)      LIB="" ;;
36         esac
37
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
44                         break
45                 fi
46         done
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])
51         fi
52         AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path])
53
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
60                         break
61                 fi
62         done
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])
67         fi
68         AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$PYTHON_VERSION"])
69         #
70         python_site=`echo $python_path | sed "s/config/site-packages/"`
71         AC_SUBST([PYTHON_SITE_PKG],[$python_site])
72         #
73         # libraries which must be linked in when embedding
74         #
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)
81 ])