Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / wrappergen / bin / HXX2SALOME_GENERIC_CLASS_NAME_SRC / adm_local / unix / config_files / python.m4
1 dnl @synopsis AC_PYTHON_DEVEL()
2 dnl
3 dnl Checks for Python and tries to get the include path to 'Python.h'.
4 dnl It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) output variable.
5 dnl
6 dnl @authors Sebastian Huber <address@hidden>, Alan W. Irwin
7 dnl <address@hidden>, Rafael Laboissiere <address@hidden> and
8 dnl Andrew Collier <address@hidden>.
9 dnl
10 dnl
11 AC_DEFUN([CHECK_PYTHON],[
12         #
13         # should allow for checking of python version here...
14         #
15         AC_REQUIRE([AM_PATH_PYTHON])
16
17         case `uname -m` in
18            *64)  LIB="64" ;;
19            *)      LIB="" ;;
20         esac
21
22         # Check for Python include path
23         AC_MSG_CHECKING([for Python include path])
24         python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
25         for i in "$python_path/include/python$PYTHON_VERSION/" "$python_path/include/python/" "$python_path/" ; do
26                 python_path=`find $i -type f -name Python.h -print | sed "1q"`
27                 if test -n "$python_path" ; then
28                         break
29                 fi
30         done
31         python_path=`echo $python_path | sed "s,/Python.h$,,"`
32         AC_MSG_RESULT([$python_path])
33         if test -z "$python_path" ; then
34                 AC_MSG_ERROR([cannot find Python include path])
35         fi
36         AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path])
37
38         # Check for Python library path
39         AC_MSG_CHECKING([for Python library path])
40         python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
41         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
42                 python_path=`find $i -type f -name libpython$PYTHON_VERSION.* -print | sed "1q"`
43                 if test -n "$python_path" ; then
44                         break
45                 fi
46         done
47         python_path=`echo $python_path | sed "s,/libpython.*$,,"`
48         AC_MSG_RESULT([$python_path])
49         if test -z "$python_path" ; then
50                 AC_MSG_ERROR([cannot find Python library path])
51         fi
52         AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$PYTHON_VERSION"])
53         #
54         python_site=`echo $python_path | sed "s/config/site-packages/"`
55         AC_SUBST([PYTHON_SITE_PKG],[$python_site])
56         #
57         # libraries which must be linked in when embedding
58         #
59         AC_MSG_CHECKING(python extra libraries)
60         PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
61                 conf = distutils.sysconfig.get_config_var; \
62                 print conf('LOCALMODLIBS')+' '+conf('LIBS')"
63         AC_MSG_RESULT($PYTHON_EXTRA_LIBS)`
64         AC_SUBST(PYTHON_EXTRA_LIBS)
65 ])