r26247: Don't allow use of older SWIG versions.
[samba.git] / source / scripting / python / config.m4
1 m4_include(scripting/python/ac_pkg_swig.m4)
2
3 AC_ARG_VAR([PYTHON_VERSION],[The installed Python
4         version to use, for example '2.3'. This string 
5         will be appended to the Python interpreter
6         canonical name.])
7
8 AC_PROG_SWIG(1.3.25)
9
10 AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
11 if test -z "$PYTHON"; then
12         working_python=no
13         AC_MSG_WARN([No python found])
14 fi
15
16 #
17 # Check for a version of Python >= 2.1.0
18 #
19 AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
20 ac_supports_python_ver=`$PYTHON -c "import sys, string; \
21         ver = string.split(sys.version)[[0]]; \
22         print ver >= '2.1.0'"`
23 if test "$ac_supports_python_ver" != "True"; then
24         working_python=no
25         AC_MSG_RESULT([no])
26 else 
27         AC_MSG_RESULT([yes])
28 fi
29
30 #
31 # Check if you have distutils, else fail
32 #
33 AC_MSG_CHECKING([for the distutils Python package])
34 ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
35 if test -z "$ac_distutils_result"; then
36         AC_MSG_RESULT([yes])
37         working_python=yes
38 else
39         AC_MSG_RESULT([no])
40         working_python=no
41 fi
42
43 #
44 # Check for Python include path
45 #
46 AC_MSG_CHECKING([for Python include path])
47 if test -z "$PYTHON_CPPFLAGS"; then
48         python_path=`$PYTHON -c "import distutils.sysconfig; \
49                         print distutils.sysconfig.get_python_inc();"`
50         if test -n "${python_path}"; then
51                 python_path="-I$python_path"
52         fi
53         PYTHON_CPPFLAGS=$python_path
54 fi
55 AC_MSG_RESULT([$PYTHON_CPPFLAGS])
56 AC_SUBST([PYTHON_CPPFLAGS])
57
58 #
59 # Check for Python library path
60 #
61 AC_MSG_CHECKING([for Python library path])
62 if test -z "$PYTHON_LDFLAGS"; then
63         # (makes two attempts to ensure we've got a version number
64         # from the interpreter)
65         py_version=`$PYTHON -c "from distutils.sysconfig import *; \
66                 from string import join; \
67                 print join(get_config_vars('VERSION'))"`
68         if test "$py_version" == "[None]"; then
69                 if test -n "$PYTHON_VERSION"; then
70                         py_version=$PYTHON_VERSION
71                 else
72                         py_version=`$PYTHON -c "import sys; \
73                                 print sys.version[[:3]]"`
74                 fi
75         fi
76
77         PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \
78                 from string import join; \
79                 print '-L' + get_python_lib(0,1), \
80                         '-lpython';"`$py_version
81 fi              
82 AC_MSG_RESULT([$PYTHON_LDFLAGS])
83 AC_SUBST([PYTHON_LDFLAGS])
84
85 #
86 # Check for site packages
87 #
88 AC_MSG_CHECKING([for Python site-packages path])
89 if test -z "$PYTHON_SITE_PKG"; then
90         PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
91                         print distutils.sysconfig.get_python_lib(0,0);"`
92 fi
93 AC_MSG_RESULT([$PYTHON_SITE_PKG])
94 AC_SUBST([PYTHON_SITE_PKG])
95
96 #
97 # libraries which must be linked in when embedding
98 #
99 AC_MSG_CHECKING(python extra libraries)
100 if test -z "$PYTHON_EXTRA_LIBS"; then
101    PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
102                         conf = distutils.sysconfig.get_config_var; \
103                         print conf('LOCALMODLIBS'), conf('LIBS')"`
104 fi
105 AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
106 AC_SUBST(PYTHON_EXTRA_LIBS)
107
108 #
109 # linking flags needed when embedding
110 #
111 AC_MSG_CHECKING(python extra linking flags)
112 if test -z "$PYTHON_EXTRA_LDFLAGS"; then
113         PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
114                 conf = distutils.sysconfig.get_config_var; \
115                 print conf('LINKFORSHARED')"`
116 fi
117 AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
118 AC_SUBST(PYTHON_EXTRA_LDFLAGS)
119
120 SMB_EXT_LIB(LIBPYTHON, [$PYTHON_LDFLAGS], [$PYTHON_CPPFLAGS])
121
122 if test x$working_python = xyes
123 then
124         SMB_ENABLE(LIBPYTHON,YES)
125 else
126         SMB_ENABLE(LIBPYTHON,NO)
127 fi