~ubuntu-branches/debian/squeeze/sword/squeeze

« back to all changes in this revision

Viewing changes to bindings/swig/package/python.m4

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Glassey
  • Date: 2004-01-15 15:50:07 UTC
  • Revision ID: james.westby@ubuntu.com-20040115155007-n9mz4x0zxrs1isd3
Tags: upstream-1.5.7
ImportĀ upstreamĀ versionĀ 1.5.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#----------------------------------------------------------------
 
2
# Look for Python
 
3
#----------------------------------------------------------------
 
4
 
 
5
AC_DEFUN(SW_FIND_PYTHON,
 
6
[
 
7
 
 
8
PYINCLUDE=
 
9
PYLIB=
 
10
PYPACKAGE=
 
11
PYTHONBUILD=
 
12
 
 
13
# I don't think any of this commented stuff works anymore
 
14
 
 
15
#PYLINK="-lModules -lPython -lObjects -lParser"
 
16
 
 
17
#AC_ARG_WITH(py,[  --with-py=path          Set location of Python],[
 
18
#       PYPACKAGE="$withval"], [PYPACKAGE=])
 
19
#AC_ARG_WITH(pyincl,[  --with-pyincl=path      Set location of Python include directory],[
 
20
#       PYINCLUDE="$withval"], [PYINCLUDE=])
 
21
#AC_ARG_WITH(pylib,[  --with-pylib=path       Set location of Python library directory],[
 
22
#       PYLIB="$withval"], [PYLIB=])
 
23
 
 
24
#if test -z "$PYINCLUDE"; then
 
25
#   if test -n "$PYPACKAGE"; then
 
26
#       PYINCLUDE="$PYPACKAGE/include"
 
27
#   fi
 
28
#fi
 
29
 
 
30
#if test -z "$PYLIB"; then
 
31
#   if test -n "$PYPACKAGE"; then
 
32
#       PYLIB="$PYPACKAGE/lib"
 
33
#   fi
 
34
#fi
 
35
 
 
36
AC_ARG_WITH(python,[  --with-python=path       Set location of Python executable],[ PYBIN="$withval"], [PYBIN=])
 
37
 
 
38
# First figure out the name of the Python executable
 
39
 
 
40
if test -z "$PYBIN"; then
 
41
AC_PATH_PROGS(PYTHON, $prefix/bin/python python python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python1.4 python)
 
42
else
 
43
PYTHON="$PYBIN"
 
44
fi
 
45
 
 
46
if test -n "$PYTHON"; then
 
47
    AC_MSG_CHECKING(for Python prefix)
 
48
    PYPREFIX=`($PYTHON -c "import sys; print sys.prefix") 2>/dev/null`
 
49
    AC_MSG_RESULT($PYPREFIX)
 
50
    AC_MSG_CHECKING(for Python exec-prefix)
 
51
    PYEPREFIX=`($PYTHON -c "import sys; print sys.exec_prefix") 2>/dev/null`
 
52
    AC_MSG_RESULT($PYEPREFIX)
 
53
 
 
54
 
 
55
    # Note: I could not think of a standard way to get the version string from different versions.
 
56
    # This trick pulls it out of the file location for a standard library file.
 
57
 
 
58
    AC_MSG_CHECKING(for Python version)
 
59
 
 
60
    # Need to do this hack since autoconf replaces __file__ with the name of the configure file
 
61
    filehack="file__"
 
62
    PYVERSION=`($PYTHON -c "import string,operator; print operator.getitem(string.split(string.__$filehack,'/'),-2)")`
 
63
    AC_MSG_RESULT($PYVERSION)
 
64
 
 
65
    # Set the include directory
 
66
 
 
67
    AC_MSG_CHECKING(for Python header files)            
 
68
    if test -r $PYPREFIX/include/$PYVERSION/Python.h; then
 
69
        PYINCLUDE="-I$PYPREFIX/include/$PYVERSION -I$PYEPREFIX/lib/$PYVERSION/config"
 
70
    fi
 
71
    if test -z "$PYINCLUDE"; then
 
72
        if test -r $PYPREFIX/include/Py/Python.h; then
 
73
            PYINCLUDE="-I$PYPREFIX/include/Py -I$PYEPREFIX/lib/python/lib"
 
74
        fi
 
75
    fi
 
76
    AC_MSG_RESULT($PYINCLUDE)
 
77
 
 
78
    # Set the library directory blindly.   This probably won't work with older versions
 
79
    AC_MSG_CHECKING(for Python library)
 
80
    dirs="$PYVERSION/config $PYVERSION/lib python/lib"
 
81
    for i in $dirs; do
 
82
        if test -d $PYEPREFIX/lib/$i; then
 
83
           PYLIB="$PYEPREFIX/lib/$i"
 
84
           PYTHONBUILD=python_make
 
85
           break
 
86
        fi
 
87
    done
 
88
    if test -z "$PYLIB"; then
 
89
        AC_MSG_RESULT(Not found)
 
90
    else
 
91
        AC_MSG_RESULT($PYLIB)
 
92
    fi
 
93
 
 
94
    # Check for really old versions
 
95
    if test -r $PYLIB/libPython.a; then
 
96
         PYLINK="-lModules -lPython -lObjects -lParser"
 
97
    else
 
98
         PYLINK="-l$PYVERSION"
 
99
    fi
 
100
fi
 
101
 
 
102
# Only cygwin (Windows) needs the library for dynamic linking
 
103
case $ac_sys_system/$ac_sys_release in
 
104
CYGWIN*) PYTHONDYNAMICLINKING="-L$PYLIB $PYLINK"
 
105
         PYINCLUDE="-DUSE_DL_IMPORT $PYINCLUDE"
 
106
         ;;
 
107
*)PYTHONDYNAMICLINKING="";;
 
108
esac
 
109
 
 
110
 
 
111
AC_SUBST(PYINCLUDE)
 
112
AC_SUBST(PYLIB)
 
113
AC_SUBST(PYLINK)
 
114
AC_SUBST(PYTHONBUILD)
 
115
AC_SUBST(PYTHONDYNAMICLINKING)
 
116
 
 
117
])