summaryrefslogtreecommitdiff
path: root/m4/python.m4
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>1999-11-22 19:22:02 +0000
committerTom Tromey <tromey@redhat.com>1999-11-22 19:22:02 +0000
commitebdbd5b31a1a80675513f2e488af27a16b8209dc (patch)
tree33910e7c88087715eff0fdefaaf21f4b77e941f6 /m4/python.m4
parent619e0ac7a7b2c6be6794c28571e46795a557a48d (diff)
downloadautomake-ebdbd5b31a1a80675513f2e488af27a16b8209dc.tar.gz
Jumbo patch:
First cut at Python support (untested). A few miscellaneous bug fixes.
Diffstat (limited to 'm4/python.m4')
-rw-r--r--m4/python.m4103
1 files changed, 103 insertions, 0 deletions
diff --git a/m4/python.m4 b/m4/python.m4
new file mode 100644
index 000000000..0ee447e2c
--- /dev/null
+++ b/m4/python.m4
@@ -0,0 +1,103 @@
+## ------------------------
+## Python file handling
+## From Andrew Dalke
+## ------------------------
+
+dnl AM_PATH_PYTHON([package, module])
+dnl
+
+dnl Adds support for distributing Python modules or the special form
+dnl of a module called a `package.' Modules of the first type are
+dnl files ending in `.py' with no '__init__.py' file. This must be
+dnl placed on the PYTHONPATH, and the default location is PYTHON_SITE,
+dnl or $(prefix)/lib/python$(PYTHON_VERSION)/site-package
+dnl
+dnl A package module is contained in its own directory. This directory
+dnl is named PACKAGE, which was the name given to automake. The full
+dnl directory path is PYTHON_SITE_PACKAGE or
+dnl $(prefix)/lib/python$(PYTHON_VERSION)/site-package/$(PACKAGE)
+dnl where site-package is on the PYTHONPATH. The `__init__.py' file is
+dnl located in the directory, along with any other submodules which may
+dnl be necessary.
+
+
+AC_DEFUN(AM_PATH_PYTHON,
+ [
+ dnl Find a version of Python. I could check for python versions 1.4
+ dnl or earlier, but the default installation locations changed from
+ dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages
+ dnl in 1.5, and I don't want to maintain that logic.
+
+ AC_PATH_PROG(PYTHON, python python1.5)
+
+ AC_MSG_CHECKING([local Python configuration])
+
+ dnl Query Python for its version number. Getting [:3] seems to be
+ dnl the best way to do this; it's what "site.py" does in the standard
+ dnl library. Need to change quote character because of [:3]
+
+ AC_SUBST(PYTHON_VERSION)
+ changequote(<<, >>)dnl
+ PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[:3]"`
+ changequote([, ])dnl
+
+
+ dnl Use the values of $prefix and $exec_prefix for the corresponding
+ dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made
+ dnl distinct variables so they can be overridden if need be. However,
+ dnl general consensus is that you shouldn't need this ability.
+
+ AC_SUBST(PYTHON_PREFIX)
+ PYTHON_PREFIX='${prefix}'
+
+ AC_SUBST(PYTHON_EXEC_PREFIX)
+ PYTHON_EXEC_PREFIX='${exec_prefix}'
+
+ dnl At times (like when building shared libraries) you may want
+ dnl to know which OS platform Python thinks this is.
+
+ AC_SUBST(PYTHON_PLATFORM)
+ PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"`
+
+
+ dnl Set up 4 directories:
+
+ dnl pythondir -- location of the standard python libraries
+ dnl Also lets automake think PYTHON means something.
+
+ AC_SUBST(pythondir)
+ pythondir=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION
+
+ dnl PYTHON_SITE -- the platform independent site-packages directory
+
+ AC_SUBST(PYTHON_SITE)
+ PYTHON_SITE=$pythondir/site-packages
+
+ dnl PYTHON_SITE_PACKAGE -- the $PACKAGE directory under PYTHON_SITE
+
+ AC_SUBST(PYTHON_SITE_PACKAGE)
+ PYTHON_SITE_PACKAGE=$pythondir/site-packages/$PACKAGE
+
+ dnl PYTHON_SITE_EXEC -- platform dependent site-packages dir (eg, for
+ dnl shared libraries)
+
+ AC_SUBST(PYTHON_SITE_EXEC)
+ PYTHON_SITE_EXEC=$PYTHON_EXEC_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
+
+
+ dnl Configure PYTHON_SITE_INSTALL so it points to either the module
+ dnl directory or the package subdirectory, depending on the $1
+ dnl parameter ("module" or "package").
+
+ AC_SUBST(PYTHON_SITE_INSTALL)
+ ifelse($1, module, [PYTHON_SITE_INSTALL=$PYTHON_SITE],
+ $1, package, [PYTHON_SITE_INSTALL=$PYTHON_SITE_PACKAGE],
+ [errprint([Unknown option `$1' used in call to AM_PATH_PYTHON.
+Valid options are `module' or `package'
+])m4exit(4)])
+
+
+ dnl All done.
+
+ AC_MSG_RESULT(looks good)
+])