1 dnl Process this file with autoconf to produce a configure script.
4 dnl Checks for programs.
6 dnl Checks for libraries.
7 dnl Replace `main' with a function in -lpython:
8 AC_CHECK_LIB(python, main)
10 dnl Checks for header files.
11 AC_CHECK_HEADERS(unistd.h)
13 dnl Checks for typedefs, structures, and compiler characteristics.
16 dnl Checks for library functions.
19 dnl ********************
21 dnl ********************
25 dnl Find Python executable
26 AC_PATH_PROGS(PYPACKAGE, python)
28 dnl Extract the version using Python, check against 1.5+
31 PY_PREFIX=`$PYPACKAGE getprefix.py`
32 PY_VERSION=`$PYPACKAGE getversion.py`
35 if test `echo $PY_VERSION | tr -d .` -lt 15; then
36 echo "Sorry, you need to have Python 1.5+ installed - update your version!"
37 AC_MSG_ERROR([*** Python 1.5 or better required])
40 dnl Find the Python.h header file
42 AC_MSG_CHECKING(for Python header files)
44 PY_INCLUDE=`$PYPACKAGE -c 'import sys ; print "%s/include/python%s" % (sys.prefix, sys.version[:3])'`
47 if test -r "$PY_INCLUDE/Python.h"; then
48 PY_CFLAGS="-I$PY_INCLUDE"
50 AC_MSG_ERROR([Could not find Python.h in $PY_INCLUDE])
54 dnl Find the Python library
56 AC_MSG_CHECKING(for Python library)
59 PY_PREFIX=`$PYPACKAGE -c 'import sys; print sys.prefix'`
60 PYLIBVER=`$PYPACKAGE -c 'import sys; print sys.version[:3]'`
63 py_paths="$PY_PREFIX/lib/python$PYLIBVER/config $PYPREFIX/lib"
64 py_suffix="$PYLIBVER.so $PYLIBVER.a .so .a"
66 dnl Try for specific version first, then the generic version, then panic
68 for ppath in $py_paths ; do
69 if test -r "$ppath/libpython$PYLIBVER.so" -o \
70 -r "$ppath/libpython$PYLIBVER.a"; then
71 PYLIB="-cclib -L$ppath -cclib -lpython$PYLIBVER"
75 if test -r "$ppath/libpython.so" -o \
76 -r "$ppath/libpython.a"; then
77 PYLIB="-cclib -L$ppath -cclib -lpython"
82 if test "x$PYLIB" != x ; then
83 PY_LIBS="$PYLIB $PY_LIBS"
86 AC_MSG_ERROR([*** Python library not found])
89 dnl Get the libraries that python depends on
91 AC_PATH_PROG(haveldd, ldd)
92 AC_MSG_CHECKING(for Python's dependencies)
94 if test x$haveldd != x ; then
96 py_deps=`ldd $PYPACKAGE | sed 's/\( *lib\([^\/]*\)\.so.*=.*$\)/-cclib\ \"-l\2\"/p; d'`
97 for py_lib in $py_deps ; do
98 if test "$py_lib" != "-lm" && test "$py_lib" != "-lc" ; then
99 PY_DEPS="$PY_DEPS $py_lib"
105 dnl only GNU ld seems to know -E flag
107 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
108 PY_LIBS="-Wl,-E $PY_LIBS $PY_DEPS"
110 PY_LIBS="$PY_LIBS $PY_DEPS"