Coccinelle release-1.0.0-rc11
[bpt/coccinelle.git] / pycaml / configure.in
CommitLineData
34e49164
C
1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(pycaml_ml.c)
3
4dnl Checks for programs.
5
6dnl Checks for libraries.
7dnl Replace `main' with a function in -lpython:
8AC_CHECK_LIB(python, main)
9
10dnl Checks for header files.
11AC_CHECK_HEADERS(unistd.h)
12
13dnl Checks for typedefs, structures, and compiler characteristics.
14AC_C_CONST
15
16dnl Checks for library functions.
17AC_HEADER_STDC
18
19dnl ********************
20dnl Check for Python.
21dnl ********************
22
23AM_PATH_PYTHON()
24
25dnl Find Python executable
26AC_PATH_PROGS(PYPACKAGE, python)
27
28dnl Extract the version using Python, check against 1.5+
29
30changequote(<<, >>)
31PY_PREFIX=`$PYPACKAGE getprefix.py`
32PY_VERSION=`$PYPACKAGE getversion.py`
33changequote([, ])
34
35if test `echo $PY_VERSION | tr -d .` -lt 15; then
36echo "Sorry, you need to have Python 1.5+ installed - update your version!"
37 AC_MSG_ERROR([*** Python 1.5 or better required])
38fi
39
40dnl Find the Python.h header file
41
42AC_MSG_CHECKING(for Python header files)
43changequote(<<, >>)
44PY_INCLUDE=`$PYPACKAGE -c 'import sys ; print "%s/include/python%s" % (sys.prefix, sys.version[:3])'`
45changequote([, ])
46
47if test -r "$PY_INCLUDE/Python.h"; then
48 PY_CFLAGS="-I$PY_INCLUDE"
49else
50 AC_MSG_ERROR([Could not find Python.h in $PY_INCLUDE])
51fi
52AC_MSG_RESULT(found)
53
54dnl Find the Python library
55
56AC_MSG_CHECKING(for Python library)
57PYLIB=""
58changequote(<<, >>)
59PY_PREFIX=`$PYPACKAGE -c 'import sys; print sys.prefix'`
60PYLIBVER=`$PYPACKAGE -c 'import sys; print sys.version[:3]'`
61changequote([, ])
62
63py_paths="$PY_PREFIX/lib/python$PYLIBVER/config $PYPREFIX/lib"
64py_suffix="$PYLIBVER.so $PYLIBVER.a .so .a"
65
66dnl Try for specific version first, then the generic version, then panic
67
68for 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"
72 break
73 fi
74
75 if test -r "$ppath/libpython.so" -o \
76 -r "$ppath/libpython.a"; then
77 PYLIB="-cclib -L$ppath -cclib -lpython"
78 break
79 fi
80done
81
82if test "x$PYLIB" != x ; then
83 PY_LIBS="$PYLIB $PY_LIBS"
84 AC_MSG_RESULT(found)
85else
86 AC_MSG_ERROR([*** Python library not found])
87fi
88
89dnl Get the libraries that python depends on
90
91AC_PATH_PROG(haveldd, ldd)
92AC_MSG_CHECKING(for Python's dependencies)
93
94if test x$haveldd != x ; then
95 changequote(<<, >>)
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"
100 fi
101 done
102 changequote([, ])
103fi
104
105dnl only GNU ld seems to know -E flag
106
107if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
108 PY_LIBS="-Wl,-E $PY_LIBS $PY_DEPS"
109else
110 PY_LIBS="$PY_LIBS $PY_DEPS"
111fi
112
113export PY_LIBS
114export PY_VERSION
115export PY_PREFIX
116
117AC_SUBST(PY_LIBS)
118AC_SUBST(PY_VERSION)
119AC_SUBST(PY_PREFIX)
120
121AC_OUTPUT(Makefile)