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 # For Fedora Core 5 and 6, see ticket:39 in Trac
32 if test -f '/etc/redhat-release'; then
33 if (echo $pyexecdir | grep -q lib64); then
34 pythondir="$pyexecdir"
38 # Check for Python include path
39 AC_MSG_CHECKING([for Python include path])
40 if test -z "$PYTHON" ; then
41 AC_MSG_ERROR([cannot find Python path])
44 # ask distutils which include path we should use
46 import distutils.sysconfig
48 path = distutils.sysconfig.get_python_inc(plat_specific=False)
50 path = path.replace("\\", "/")
53 python_path=`$PYTHON -c "$python_cmd"`
54 AC_MSG_RESULT([$python_path])
55 if test -z "$python_path" ; then
56 AC_MSG_ERROR([cannot find Python include path])
59 AC_SUBST(PYTHON_CPPFLAGS,[-I$python_path])
61 # Check for Python headers usability
62 python_save_CPPFLAGS=$CPPFLAGS
63 CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
64 AC_CHECK_HEADERS([Python.h], [],
65 [AC_MSG_ERROR([cannot find usable Python headers])])
66 CPPFLAGS="$python_save_CPPFLAGS"
68 # Only set this on mingw and cygwin hosts, (only implemented
69 # for mingw host, for crosscompiling you need to trick this)
74 AC_MSG_CHECKING([for Python LDFLAGS])
77 import distutils.sysconfig
79 path = distutils.sysconfig.get_config_var("LIBPL")
81 path = distutils.sysconfig.PREFIX + "/libs"
83 path = path.replace("\\", "/")
86 python_stdlib_path=`$PYTHON -c "$python_cmd"`
88 python_version_nodot=`echo $PYTHON_VERSION | sed "s,\.,,"`
89 libpython_name="python$PYTHON_VERSION"
91 # Standard install of python for win32 has libpython24.a
92 # instead of libpython2.4.a so we check for the library
93 # without the dot in the version number.
95 python_stdlib_filename=`find $python_stdlib_path -type f -name libpython$python_version_nodot.* -print | sed "1q"`
96 if test -n "$python_stdlib_filename" ; then
97 libpython_name="python$python_version_nodot"
100 PYTHON_LDFLAGS="-L$python_stdlib_path -l$libpython_name"
101 AC_MSG_RESULT($PYTHON_LDFLAGS)
102 # Replace all backslashes in PYTHON Paths with forward slashes
103 pythondir=`echo $pythondir |sed 's,\\\\,/,g'`
104 pkgpythondir=`echo $pkgpythondir |sed 's,\\\\,/,g'`
105 pyexecdir=`echo $pyexecdir |sed 's,\\\\,/,g'`
106 pkgpyexecdir=`echo $pkgpyexecdir |sed 's,\\\\,/,g'`
110 AC_SUBST([PYTHON_LDFLAGS])