pyconfigure

(Brandon Invergo)
2012-09-11: add header checking to python.m4

add header checking to python.m4

diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -32,12 +32,7 @@ PC_PYTHON_CHECK_EXECPREFIX
 
 PC_PYTHON_CHECK_INCLUDES
 
-ac_cflags_store = $CPPFLAGS
-CPPFLAGS="$CFLAGS $PYTHON_INCLUDES"
-# check for python.h
-AC_CHECK_HEADER([Python.h], , [AC_MSG_ERROR(could not find Python headers)])
-CPPFLAGS=$ac_cflags_store
-
+PC_PYTHON_CHECK_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
 
 PC_PYTHON_CHECK_LIBS
 
diff --git a/m4/python.m4 b/m4/python.m4
--- a/m4/python.m4
+++ b/m4/python.m4
@@ -231,6 +231,18 @@ AC_CACHE_CHECK([for Python includes], [p
 AC_SUBST([PYTHON_INCLUDES], [$pc_cv_python_includes])])
 
 
+# PC_PYTHON_CHECK_HEADERS([ACTION-IF-PRESENT], [ACTION-IF-ABSENT])
+# -----------------------
+# Check for the presence and usability of Python.h
+AC_DEFUN([PC_PYTHON_CHECK_HEADERS],
+[AC_REQUIRE([PC_PYTHON_CHECK_INCLUDES])[]dnl
+pc_cflags_store=$CPPFLAGS
+CPPFLAGS="$CFLAGS $PYTHON_INCLUDES"
+AC_CHECK_HEADER([Python.h], [$1], [$2])
+CPPFLAGS=$pc_cflags_store
+])
+
+
 # PC_PYTHON_CHECK_LIBS
 # --------------------
 # Find the Python lib flags (ie '-lpython')