GEOSPolygonize_full [RT-SIGTA]
[geos.git] / macros / ac_python_devel.m4
blobd67842b6940e27d59181dd24269a8a1ba50d769e
1 AC_DEFUN([AC_PYTHON_DEVEL],[
2         #
3         # should allow for checking of python version here...
4         #
5         AC_REQUIRE([AM_PATH_PYTHON])
7         base_python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
8                                 
9         # Need to fix up a couple of problems on Windows/MingW:
10         # 1.  python lib is named with MAJOR.VERSION collapsed in a single value,
11         #     so libpython2.4 versus libpython24
12         #       2.  Directory names have the same issue as item 1 so
13         #                       python2.4 versus python24
14         # 3.  Change paths from c:\python\include to c:/python/include.
16         if test $am_cv_python_platform = "win32" ; then
17                 # Fix python path
18                 base_python_path=`echo $PYTHON | sed "s,/[[^/]]*$,,"`
20                 PYTHON_VERSION=`echo $PYTHON_VERSION | sed "s/\.//"`
21                 AC_SUBST([PYTHON_VERSION], [$PYTHON_VERSION])
22                 
23                 pythondir=`echo $pythondir | sed 's,\\\,/,g'`
24                 AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
26                 pyexecdir=`echo $pyexecdir | sed 's,\\\,/,g'`
27                 AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
28         fi
30         # Check for Python include path
31         AC_MSG_CHECKING([for Python include path])
32         for i in "$base_python_path/include/python$PYTHON_VERSION/" "$base_python_path/include/python/" "$base_python_path/include/" "$base_python_path/" ; do
33                 python_path=`find $i -type f -name Python.h -print 2> /dev/null | sed "1q"`
34                 if test -n "$python_path" ; then
35                         break
36                 fi
37         done
38         python_path=`echo $python_path | sed "s,/Python.h$,,"`
39         AC_MSG_RESULT([$python_path])
40         if test -z "$python_path" ; then
41                 AC_MSG_ERROR([cannot find Python include path])
42         fi
43         AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path])
45         # Check for Python library path
46         AC_MSG_CHECKING([for Python library path])
47         for i in "$base_python_path/lib/python$PYTHON_VERSION/config/" "$base_python_path/lib/python$PYTHON_VERSION/" "$base_python_path/lib/python/config/" "$base_python_path/lib/python/" "$base_python_path/" "$base_python_path/libs/" ; do
48                 python_path=`find $i -name libpython$PYTHON_VERSION.* -print 2> /dev/null | sed "1q"`
49                 if test -n "$python_path" ; then
50                         break
51                 fi
52         done
53         python_path=`echo $python_path | sed "s,/libpython.*$,,"`
54         AC_MSG_RESULT([$python_path])
55         if test -z "$python_path" ; then
56                 AC_MSG_ERROR([cannot find Python library path])
57         fi
58         AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$PYTHON_VERSION"])
59         #
60         python_site=`echo $base_python_path | sed "s/config/site-packages/"`
61         AC_SUBST([PYTHON_SITE_PKG],[$python_site])
62         #
63         # libraries which must be linked in when embedding
64         #
65         AC_MSG_CHECKING(python extra libraries)
66         PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
67                 conf = distutils.sysconfig.get_config_var; \
68                 print (conf('LOCALMODLIBS') or '')+' '+(conf('LIBS') or '')"
69         AC_MSG_RESULT($PYTHON_EXTRA_LIBS)`
70         AC_SUBST(PYTHON_EXTRA_LIBS)