File: configure.in

package info (click to toggle)
pycaml 0.82-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 572 kB
  • ctags: 430
  • sloc: ansic: 962; ml: 409; makefile: 104; python: 4
file content (121 lines) | stat: -rw-r--r-- 2,963 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
dnl Process this file with autoconf to produce a configure script.
AC_INIT(pycaml_ml.c)

dnl Checks for programs.

dnl Checks for libraries.
dnl Replace `main' with a function in -lpython:
AC_CHECK_LIB(python, main)

dnl Checks for header files.
AC_CHECK_HEADERS(unistd.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

dnl Checks for library functions.
AC_HEADER_STDC

dnl ********************
dnl Check for Python. 
dnl ********************

AM_PATH_PYTHON()

dnl Find Python executable
AC_PATH_PROGS(PYPACKAGE, python)

dnl Extract the version using Python, check against 1.5+

changequote(<<, >>)
PY_PREFIX=`$PYPACKAGE getprefix.py`
PY_VERSION=`$PYPACKAGE getversion.py`
changequote([, ])

if test `echo $PY_VERSION | tr -d .` -lt 15; then
echo "Sorry, you need to have Python 1.5+ installed - update your version!"
    AC_MSG_ERROR([*** Python 1.5 or better required])
fi

dnl Find the Python.h header file

AC_MSG_CHECKING(for Python header files)
changequote(<<, >>)
PY_INCLUDE=`$PYPACKAGE -c 'import sys ; print "%s/include/python%s" % (sys.prefix, sys.version[:3])'`
changequote([, ])

if test -r "$PY_INCLUDE/Python.h"; then
   PY_CFLAGS="-I$PY_INCLUDE"
else
   AC_MSG_ERROR([Could not find Python.h in $PY_INCLUDE])
fi
AC_MSG_RESULT(found)

dnl Find the Python library

AC_MSG_CHECKING(for Python library)
PYLIB=""
changequote(<<, >>)
PY_PREFIX=`$PYPACKAGE -c 'import sys; print sys.prefix'`
PYLIBVER=`$PYPACKAGE -c 'import sys; print sys.version[:3]'`
changequote([, ])

py_paths="$PY_PREFIX/lib/python$PYLIBVER/config $PYPREFIX/lib"
py_suffix="$PYLIBVER.so $PYLIBVER.a .so .a"
   
dnl Try for specific version first, then the generic version, then panic

for ppath in $py_paths ; do
    if test -r "$ppath/libpython$PYLIBVER.so" -o \
	    -r "$ppath/libpython$PYLIBVER.a"; then
        PYLIB="-cclib -L$ppath -cclib -lpython$PYLIBVER"
        break
    fi

    if test -r "$ppath/libpython.so" -o \
            -r "$ppath/libpython.a"; then
        PYLIB="-cclib -L$ppath -cclib -lpython"
    break
    fi
done

if test "x$PYLIB" != x ; then
    PY_LIBS="$PYLIB $PY_LIBS"
    AC_MSG_RESULT(found)
else
    AC_MSG_ERROR([*** Python library not found])
fi

dnl Get the libraries that python depends on

AC_PATH_PROG(haveldd, ldd)
AC_MSG_CHECKING(for Python's dependencies)

if test x$haveldd != x ; then
    changequote(<<, >>)
    py_deps=`ldd $PYPACKAGE | sed 's/\( *lib\([^\/]*\)\.so.*=.*$\)/-cclib\ \"-l\2\"/p; d'`
    for py_lib in $py_deps ; do
        if test "$py_lib" != "-lm" && test "$py_lib" != "-lc" ; then
            PY_DEPS="$PY_DEPS $py_lib"
        fi
    done
      changequote([, ])
fi

dnl only GNU ld seems to know -E flag

if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
    PY_LIBS="-Wl,-E $PY_LIBS $PY_DEPS"
else
    PY_LIBS="$PY_LIBS $PY_DEPS"
fi

export PY_LIBS
export PY_VERSION
export PY_PREFIX

AC_SUBST(PY_LIBS)
AC_SUBST(PY_VERSION)
AC_SUBST(PY_PREFIX)

AC_OUTPUT(Makefile)