]> icculus.org git repositories - mikachu/openbox.git/blob - m4/python.m4
otk using ustring for shit that draws. expended its inferface yet some more.
[mikachu/openbox.git] / m4 / python.m4
1 # PYTHON_DEVEL()
2 #
3 # Checks for Python and tries to get the include path to 'Python.h', and
4 # the libpython library.
5 # It provides the $(PYTHON_CFLAGS) $(PYTHON_LIBS) output variables.
6 AC_DEFUN([PYTHON_DEVEL],
7 [
8   AC_REQUIRE([AM_PATH_PYTHON])
9
10   python_prefix=${PYTHON%/bin*}
11
12   # Check for Python include path
13   AC_MSG_CHECKING([for python include path])
14   for i in "$python_prefix/include/python$PYTHON_VERSION/" \
15            "$python_prefix/include/python/" "$python_prefix/"
16   do
17     python_path=`find $i -type f -name Python.h -print 2> /dev/null`
18     test "$python_path" && break
19   done
20   for i in $python_path
21   do
22     python_path=${python_path%/Python.h}
23     break
24   done
25   if test "$python_path"
26   then
27     AC_MSG_RESULT([$python_path])
28   else
29     AC_MSG_ERROR([cannot find python include path])
30   fi
31   AC_SUBST([PYTHON_CFLAGS], [-I$python_path])
32
33   # Check for a Python library
34   AC_MSG_CHECKING([for python library])
35   PYLIB=""
36   for i in "$python_prefix/lib" \
37            "$python_prefix/lib/python$PYTHON_VERSION/config" \
38            "$python_prefix/lib/python$PYTHON_VERSION/lib" \
39            "$python_prefix/lib/python/lib"
40   do
41     if test -r "$i/libpython$PYTHON_VERSION.so"; then
42       PYLIB="$i/libpython$PYTHON_VERSION.so"
43       PYTHON_LIBS="-L$i -lpython$PYTHON_VERSION"
44       break
45     else
46       if test -r "$i/libpython$PYTHON_VERSION.a"; then
47         PYLIB="$i/libpython$PYTHON_VERSION.a"
48         PYTHON_LIBS="-L$i -lpython$PYTHON_VERSION -lpthread -ldl -lutil -lm"
49         break
50       else
51         # look for really old versions
52         if test -r "$i/libPython.a"; then
53           PYLIB="$i/libPython.a"
54           PYTHON_LIBS="-L$i -lModules -lPython -lObjects -lParser"
55           break
56         fi
57       fi
58     fi
59   done
60   if test "$PYLIB"
61   then
62     AC_MSG_RESULT([$PYLIB])
63   else
64     AC_MSG_ERROR([cannot find python library])
65   fi
66   AC_SUBST([PYTHON_LIBS])
67 ])