[cig-commits] r13034 - in cs/cigma/trunk: . config

luis at geodynamics.org luis at geodynamics.org
Wed Oct 15 02:07:19 PDT 2008


Author: luis
Date: 2008-10-15 02:07:19 -0700 (Wed, 15 Oct 2008)
New Revision: 13034

Added:
   cs/cigma/trunk/config/
   cs/cigma/trunk/config/python_module.m4
Log:
Autoconf macro for checking presence of python module

Added: cs/cigma/trunk/config/python_module.m4
===================================================================
--- cs/cigma/trunk/config/python_module.m4	                        (rev 0)
+++ cs/cigma/trunk/config/python_module.m4	2008-10-15 09:07:19 UTC (rev 13034)
@@ -0,0 +1,62 @@
+# AC_CHECK_PYTHON_MODULE Autoconf macro, revision 0
+#
+# Copyright (C) 2008 Stephan Peijnik
+#
+# Copying and distribution of this file, with or without modification,         
+# are permitted in any medium without royalty provided the copyright notice    
+# and this notice are preserved.  
+#
+# Sources:
+#   http://www.sp.or.at/python_module.m4
+#   http://blog.sp.or.at/2008/08/31/autoconf-and-python-checking-for-modules/
+#
+AC_DEFUN([AC_CHECK_PYTHON_MODULE],[
+    # AC_CHECK_PYTHON_MODULE(MODULE_NAME [,VERSION_VARIABLE])
+
+    # the python module name
+    MODULE_NAME=$1
+    # the python variable that contains the module's version
+    # If this is not set the version will not be retrieved from the module.
+    # Example: __version__.
+    VERSION_VARIABLE=$1.$2
+
+    # check for the python binary defined in $PYTHON
+    # fall back to "python"
+    if test -z $PYTHON;
+    then
+        PYTHON="python"
+    fi
+
+    AC_MSG_CHECKING(for python module $MODULE_NAME)
+
+    if test -z "$2"
+    then
+      $PYTHON -c "import $MODULE_NAME" 2>/dev/null
+      if test $? -eq 0
+      then
+        eval PYTHON_${MODULE_NAME}=1
+        AC_MSG_RESULT(found)
+       else
+        eval PYTHON_${MODULE_NAME}=0
+        AC_MSG_RESULT(not found)
+      fi
+      AC_SUBST(PYTHON_${MODULE_NAME})
+    else
+      VERSION=`$PYTHON -c "import $MODULE_NAME; print $VERSION_VARIABLE" 2>/dev/null`
+      if test $? -eq 0
+      then
+        eval PYTHON_${MODULE_NAME}_VERSION=$VERSION
+        eval PYTHON_${MODULE_NAME}=1
+
+        AC_MSG_RESULT([found ($VERSION)])
+      else
+        eval PYTHON_${MODULE_NAME}=0
+        eval PYTHON_${MODULE_NAME}_VERSION=0
+
+        AC_MSG_RESULT(not found)
+      fi
+      AC_SUBST(PYTHON_${MODULE_NAME_VERSION})
+      AC_SUBST(PYTHON_${MODULE_NAME})
+    fi
+])
+# vim: syntax=config foldmethod=marker



More information about the cig-commits mailing list