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 3, 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 sets the $(PYTHON_CPPFLAGS), $(PYTHON_LDFLAGS) and $(pythondir) output variables,
27 AC_DEFUN([PYTHON_DEVEL],[
28 AC_REQUIRE([AM_PATH_PYTHON])
29 AC_REQUIRE([AC_CANONICAL_HOST])
31 AC_ARG_WITH(pythondir,
32 AC_HELP_STRING([--with-pythondir=DIR],
33 [python installation directory (cross-compiling) [[default=$prefix/lib/python2.5/site-packages]]]),
34 [with_pythondir=${withval}],[with_pythondir=${prefix}/lib/python2.5/site-packages])
36 # if we're cross-compiling, asking the host python about any of
37 # this is completely useless...
39 if test x$cross_compiling != xno
41 pythondir=$with_pythondir
42 pyexecdir=$with_pythondir
43 AC_SUBST(PYTHON_CPPFLAGS)
44 AC_SUBST(PYTHON_LDFLAGS)
47 # For Fedora Core 5 and 6, see ticket:39 in Trac
48 if test -f '/etc/redhat-release'; then
49 if (echo $pyexecdir | grep -q lib64); then
50 pythondir="$pyexecdir"
54 # Check for Python include path
55 AC_MSG_CHECKING([for Python include path])
56 if test -z "$PYTHON" ; then
57 AC_MSG_ERROR([cannot find Python path])
60 # ask distutils which include path we should use
62 import distutils.sysconfig
64 path = distutils.sysconfig.get_python_inc(plat_specific=False)
66 path = path.replace("\\", "/")
69 python_path=`$PYTHON -c "$python_cmd"`
70 AC_MSG_RESULT([$python_path])
71 if test -z "$python_path" ; then
72 AC_MSG_ERROR([cannot find Python include path])
75 AC_SUBST(PYTHON_CPPFLAGS,[-I$python_path])
77 # Check for Python headers usability
78 python_save_CPPFLAGS=$CPPFLAGS
79 CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
80 AC_CHECK_HEADERS([Python.h], [],
81 [AC_MSG_ERROR([cannot find usable Python headers])])
82 CPPFLAGS="$python_save_CPPFLAGS"
84 # Only set this on mingw and cygwin hosts, (only implemented
85 # for mingw host, for crosscompiling you need to trick this)
90 AC_MSG_CHECKING([for Python LDFLAGS])
93 import distutils.sysconfig
95 path = distutils.sysconfig.get_config_var("LIBPL")
97 path = distutils.sysconfig.PREFIX + "/libs"
99 path = path.replace("\\", "/")
102 python_stdlib_path=`$PYTHON -c "$python_cmd"`
104 python_version_nodot=`echo $PYTHON_VERSION | sed "s,\.,,"`
105 libpython_name="python$PYTHON_VERSION"
107 # Standard install of python for win32 has libpython24.a
108 # instead of libpython2.4.a so we check for the library
109 # without the dot in the version number.
111 python_stdlib_filename=`find $python_stdlib_path -type f -name libpython$python_version_nodot.* -print | sed "1q"`
112 if test -n "$python_stdlib_filename" ; then
113 libpython_name="python$python_version_nodot"
116 PYTHON_LDFLAGS="-L$python_stdlib_path -l$libpython_name"
117 AC_MSG_RESULT($PYTHON_LDFLAGS)
118 # Replace all backslashes in PYTHON Paths with forward slashes
119 pythondir=`echo $pythondir |sed 's,\\\\,/,g'`
120 pkgpythondir=`echo $pkgpythondir |sed 's,\\\\,/,g'`
121 pyexecdir=`echo $pyexecdir |sed 's,\\\\,/,g'`
122 pkgpyexecdir=`echo $pkgpyexecdir |sed 's,\\\\,/,g'`
128 # Python 2.5 requires ".pyd" instead of ".dll" for extensions
129 PYTHON_LDFLAGS="-shrext .pyd ${PYTHON_LDFLAGS}"
132 AC_SUBST(PYTHON_LDFLAGS)
136 # PYTHON_CHECK_MODULE
138 # Determines if a particular Python module can be imported
141 # $2 - module description
142 # $3 - action if found
143 # $4 - action if not found
146 AC_DEFUN([PYTHON_CHECK_MODULE],[
147 AC_MSG_CHECKING([for $2])
148 dnl ########################################
149 dnl # import and test checking
150 dnl ########################################
156 except ImportError, AssertionError: exit(1)
158 dnl ########################################
159 dnl # import checking only
160 dnl ########################################
164 except ImportError: exit(1)
167 if ! $PYTHON -c "$python_cmd" 2> /dev/null; then