source: trunk/cf/rpLangPython.m4 @ 2209

Last change on this file since 2209 was 2209, checked in by gah, 13 years ago
File size: 2.7 KB
Line 
1
2AC_DEFUN([RP_LANG_PYTHON],[
3PYTHON=""
4PYTHON_CFLAGS=""
5PYTHON_CPPFLAGS=""
6PYTHON_DISTUTILS=""
7PYTHON_INCLUDES=""
8PYTHON_LDFLAGS=""
9PYTHON_LIB=""
10PYTHON_LIBDIR=""
11PYTHON_SITE_DIR=""
12PYTHON_SITE_PACKAGES=""
13PYTHON_VERSION=""
14pythondir=""
15rp_with_python="yes"
16AC_ARG_WITH([python],
17    [AS_HELP_STRING([--with-python[=DIR]],[location of python @<:@default=yes@:>@])],
18    [rp_with_python=$withval],
19    [rp_with_python=yes])
20
21if test "$rp_with_python" != "no" ; then
22  if test "$rp_with_python" = "yes" ; then
23    AC_PATH_PROG(PYTHON, python python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5)
24  else
25    AC_PATH_PROG(PYTHON, python, [], [${rp_with_python}/bin:${rp_with_python}])
26  fi
27  AC_MSG_CHECKING([for Python version])
28  if test "x${PYTHON}" != "x"; then
29    PYTHON_VERSION=`${PYTHON} -c "import sys; print sys.version[[0:3]]"`
30  fi
31  AC_MSG_RESULT([$PYTHON_VERSION])
32fi
33
34if test "x${PYTHON_VERSION}" != "x"; then
35  PYTHON_INCLUDES=$incdir
36  AC_MSG_CHECKING([for Python distutils])
37  PYTHON_DISTUTILS=""
38  ${PYTHON} -c "from distutils.core import setup; setup(name='test')" \
39        build build_ext 2>&1 > /dev/null
40  if test $? = 0 ; then
41    PYTHON_DISTUTILS="yes"
42  fi
43  AC_MSG_RESULT([$PYTHON_DISTUTILS])
44  if test "${PYTHON_DISTUTILS}" = "yes" ; then
45    PYTHON_SITE_PACKAGES=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib()"`
46    #
47    # Check for Python include path
48    #
49    AC_MSG_CHECKING([path to Python headers])
50    PYTHON_INCDIR=`${PYTHON} -c "import distutils.sysconfig; \
51     print distutils.sysconfig.get_python_inc();"`
52    AC_MSG_RESULT([$PYTHON_INCDIR])
53    #
54    # Python distutils found, get settings from python directly
55    #
56    PYTHON_SITE_DIR="`${PYTHON} -c 'from distutils import sysconfig; print sysconfig.get_python_lib(0);'`"
57   
58    PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; flags = [[\"-I\" + sysconfig.get_python_inc(0), \"-I\" + sysconfig.get_python_inc(1), \" \".join(sysconfig.get_config_var(\"CFLAGS\").split())]]; print \" \".join(flags);'`"
59    PYTHON_LDFLAGS="`$PYTHON -c 'from distutils import sysconfig; libs = sysconfig.get_config_var(\"LIBS\").split() + sysconfig.get_config_var(\"SYSLIBS\").split(); libs.append(\"-lpython\"+sysconfig.get_config_var(\"VERSION\")); print \" \".join(libs);'`"
60    PYTHON_LIB="`$PYTHON -c 'from distutils import sysconfig; print \"python\" + sysconfig.get_config_var(\"VERSION\");'`"
61    PYTHON_LIBDIR="`$PYTHON -c 'from distutils import sysconfig; print sysconfig.get_config_var(\"LIBDIR\");'`"
62    save_CPPFLAGS=$CPPFLAGS
63    CPPFLAGS="$CPPFLAGS -I${PYTHON_INCDIR}"
64    AC_CHECK_HEADERS([Python.h], [found=yes], [found=no])
65    CPPFLAGS=$save_CPPFLAGS
66    if test "$found" = "no" ; then
67      PYTHON_DISTUTILS=""
68    fi
69  fi
70fi
71])
Note: See TracBrowser for help on using the repository browser.