]> granicus.if.org Git - postgresql/blob - config/python.m4
Infrastructure for upgraded error reporting mechanism. elog.c is
[postgresql] / config / python.m4
1 #
2 # Autoconf macros for configuring the build of Python extension modules
3 #
4 # $Header: /cvsroot/pgsql/config/python.m4,v 1.5 2002/09/04 22:54:18 petere Exp $
5 #
6
7 # PGAC_PATH_PYTHON
8 # ----------------
9 # Look for Python and set the output variable 'PYTHON'
10 # to 'python' if found, empty otherwise.
11 AC_DEFUN([PGAC_PATH_PYTHON],
12 [AC_PATH_PROG(PYTHON, python)
13 if test x"$PYTHON" = x""; then
14   AC_MSG_ERROR([Python not found])
15 fi
16 ])
17
18
19 # _PGAC_CHECK_PYTHON_DIRS
20 # -----------------------
21 # Determine the name of various directory of a given Python installation.
22 AC_DEFUN([_PGAC_CHECK_PYTHON_DIRS],
23 [AC_REQUIRE([PGAC_PATH_PYTHON])
24 AC_MSG_CHECKING([Python installation directories])
25 python_version=`${PYTHON} -c "import sys; print sys.version[[:3]]"`
26 python_prefix=`${PYTHON} -c "import sys; print sys.prefix"`
27 python_execprefix=`${PYTHON} -c "import sys; print sys.exec_prefix"`
28 python_configdir="${python_execprefix}/lib/python${python_version}/config"
29 python_moduledir="${python_prefix}/lib/python${python_version}/site-packages"
30 python_moduleexecdir="${python_execprefix}/lib/python${python_version}/site-packages"
31 python_includespec="-I${python_prefix}/include/python${python_version}"
32 if test "$python_prefix" != "$python_execprefix"; then
33   python_includespec="-I${python_execprefix}/include/python${python_version} $python_includespec"
34 fi
35
36 AC_SUBST(python_version)[]dnl
37 AC_SUBST(python_prefix)[]dnl
38 AC_SUBST(python_execprefix)[]dnl
39 AC_SUBST(python_configdir)[]dnl
40 AC_SUBST(python_moduledir)[]dnl
41 AC_SUBST(python_moduleexecdir)[]dnl
42 AC_SUBST(python_includespec)[]dnl
43 # This should be enough of a message.
44 if test "$python_prefix" != "$python_execprefix"; then
45   AC_MSG_RESULT([$python_prefix/lib/python${python_version} and $python_execprefix/lib/python${python_version}])
46 else
47   AC_MSG_RESULT([$python_prefix/lib/python${python_version}])
48 fi
49 ])# _PGAC_CHECK_PYTHON_DIRS
50
51
52 # PGAC_CHECK_PYTHON_MODULE_SETUP
53 # ------------------------------
54 # Finds things required to build a Python extension module.
55 # This used to do more, that's why it's separate.
56 #
57 # It would be nice if we could check whether the current setup allows
58 # the build of the shared module. Future project.
59 AC_DEFUN([PGAC_CHECK_PYTHON_MODULE_SETUP],
60 [
61   AC_REQUIRE([_PGAC_CHECK_PYTHON_DIRS])
62 ])# PGAC_CHECK_PYTHON_MODULE_SETUP
63
64
65 # PGAC_CHECK_PYTHON_EMBED_SETUP
66 # -----------------------------
67 # Courtesy of the INN 2.3.1 package...
68 AC_DEFUN([PGAC_CHECK_PYTHON_EMBED_SETUP],
69 [AC_REQUIRE([_PGAC_CHECK_PYTHON_DIRS])
70 AC_MSG_CHECKING([how to link an embedded Python application])
71
72 if test ! -f "$python_configdir/Makefile"; then
73   AC_MSG_RESULT(no)
74   AC_MSG_ERROR([Python Makefile not found])
75 fi
76
77 _python_libs=`grep '^LIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
78 _python_libc=`grep '^LIBC=' $python_configdir/Makefile | sed 's/^.*=//'`
79 _python_libm=`grep '^LIBM=' $python_configdir/Makefile | sed 's/^.*=//'`
80 _python_liblocalmod=`grep '^LOCALMODLIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
81 _python_libbasemod=`grep '^BASEMODLIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
82
83 pgac_tab="      " # tab character
84 python_libspec=`echo X"-L$python_configdir $_python_libs $_python_libc $_python_libm -lpython$python_version $_python_liblocalmod $_python_libbasemod" | sed -e 's/^X//' -e "s/[[ $pgac_tab]][[ $pgac_tab]]*/ /g"`
85
86 AC_MSG_RESULT([${python_libspec}])
87
88 AC_SUBST(python_libspec)[]dnl
89 ])# PGAC_CHECK_PYTHON_EMBED_SETUP