smarter default debug value :)
[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
6 # variables.
7 AC_DEFUN([PYTHON_DEVEL],
8 [
9   AC_REQUIRE([AM_PATH_PYTHON])
10
11   python_prefix=${PYTHON%/bin*}
12
13   # Check for Python include path
14   AC_MSG_CHECKING([for python include path])
15   for i in "$python_prefix/include/python$PYTHON_VERSION/" \
16            "$python_prefix/include/python/" "$python_prefix/"
17   do
18     python_path=`find $i -type f -name Python.h -print 2> /dev/null`
19     test "$python_path" && break
20   done
21   for i in $python_path
22   do
23     python_path=${python_path%/Python.h}
24     break
25   done
26   if test "$python_path"
27   then
28     AC_MSG_RESULT([$python_path])
29   else
30     AC_MSG_ERROR([cannot find python include path])
31   fi
32   AC_SUBST([PYTHON_CFLAGS], [-I$python_path])
33
34   # Check for a Python library
35   AC_MSG_CHECKING([for python library])
36   PYLIB=""
37   for i in "$python_prefix/lib" \
38            "$python_prefix/lib/python$PYTHON_VERSION/config" \
39            "$python_prefix/lib/python$PYTHON_VERSION/lib" \
40            "$python_prefix/lib/python/lib"
41   do
42     if test -r "$i/libpython$PYTHON_VERSION.so"; then
43       PYLIB="$i/libpython$PYTHON_VERSION.so"
44       PYTHON_LIBS="-L$i -lpython$PYTHON_VERSION"
45       break
46     else
47       if test -r "$i/libpython$PYTHON_VERSION.a"; then
48         PYLIB="$i/libpython$PYTHON_VERSION.a"
49         PYTHON_LIBS="-L$i -lpython$PYTHON_VERSION -lpthread -ldl -lutil -lm"
50         break
51       else
52         # look for really old versions
53         if test -r "$i/libPython.a"; then
54           PYLIB="$i/libPython.a"
55           PYTHON_LIBS="-L$i -lModules -lPython -lObjects -lParser"
56           break
57         fi
58       fi
59     fi
60   done
61   if test "$PYLIB"
62   then
63     AC_MSG_RESULT([$PYLIB])
64   else
65     AC_MSG_ERROR([cannot find python library])
66   fi
67   AC_SUBST([PYTHON_LIBS])
68 ])