2 dnl Copyright 2003,2004,2005 Free Software Foundation, Inc.
4 dnl This file is part of GNU Radio
6 dnl GNU Radio is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 2, or (at your option)
11 dnl GNU Radio is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 dnl GNU General Public License for more details.
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with GNU Radio; see the file COPYING. If not, write to
18 dnl the Free Software Foundation, Inc., 51 Franklin Street,
19 dnl Boston, MA 02110-1301, USA.
24 # Checks for Python and tries to get the include path to 'Python.h'.
25 # It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) output variables.
27 AC_DEFUN([PYTHON_DEVEL],[
28 AC_REQUIRE([AM_PATH_PYTHON])
29 AC_REQUIRE([AC_CANONICAL_HOST])
31 # Check for Python include path
32 AC_MSG_CHECKING([for Python include path])
33 if test -z "$PYTHON" ; then
34 AC_MSG_ERROR([cannot find Python path])
37 # ask distutils which include path we should use
39 import distutils.sysconfig
41 path = distutils.sysconfig.get_python_inc(plat_specific=False)
43 path = path.replace("\\", "/")
46 python_path=`$PYTHON -c "$python_cmd"`
47 AC_MSG_RESULT([$python_path])
48 if test -z "$python_path" ; then
49 AC_MSG_ERROR([cannot find Python include path])
52 AC_SUBST(PYTHON_CPPFLAGS,[-I$python_path])
54 # Check for Python headers usability
55 python_save_CPPFLAGS=$CPPFLAGS
56 CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
57 AC_CHECK_HEADERS([Python.h], [],
58 [AC_MSG_ERROR([cannot find usable Python headers])])
59 CPPFLAGS="$python_save_CPPFLAGS"
61 # Only set this on mingw and cygwin hosts, (only implemented
62 # for mingw host, for crosscompiling you need to trick this)
67 AC_MSG_CHECKING([for Python LDFLAGS])
70 import distutils.sysconfig
72 path = distutils.sysconfig.get_config_var("LIBPL")
74 path = distutils.sysconfig.PREFIX + "/libs"
76 path = path.replace("\\", "/")
79 python_stdlib_path=`$PYTHON -c "$python_cmd"`
81 python_version_nodot=`echo $PYTHON_VERSION | sed "s,\.,,"`
82 libpython_name="python$PYTHON_VERSION"
84 # Standard install of python for win32 has libpython24.a
85 # instead of libpython2.4.a so we check for the library
86 # without the dot in the version number.
88 python_stdlib_filename=`find $python_stdlib_path -type f -name libpython$python_version_nodot.* -print | sed "1q"`
89 if test -n "$python_stdlib_filename" ; then
90 libpython_name="python$python_version_nodot"
93 PYTHON_LDFLAGS="-L$python_stdlib_path -l$libpython_name"
94 AC_MSG_RESULT($PYTHON_LDFLAGS)
95 # Replace all backslashes in PYTHON Paths with forward slashes
96 AC_MSG_CHECKING([for pythondir])
97 pythondir=`echo $pythondir |sed 's,\\\\,/,g'`
98 AC_MSG_RESULT($pythondir)
100 AC_MSG_CHECKING([for pkgpythondir])
101 pkgpythondir=`echo $pkgpythondir |sed 's,\\\\,/,g'`
102 AC_MSG_RESULT($pkgpythondir)
103 AC_SUBST([pkgpythondir])
104 AC_MSG_CHECKING([for pyexecdir])
105 pyexecdir=`echo $pyexecdir |sed 's,\\\\,/,g'`
106 AC_MSG_RESULT($pyexecdir)
107 AC_SUBST([pyexecdir])
108 AC_MSG_CHECKING([for pkgpyexecdir])
109 pkgpyexecdir=`echo $pkgpyexecdir |sed 's,\\\\,/,g'`
110 AC_MSG_RESULT($pkgpyexecdir)
111 AC_SUBST([pkgpyexecdir])
115 AC_SUBST([PYTHON_LDFLAGS])