]> xenbits.xensource.com Git - xen.git/commitdiff
autoconf: check for Python.h header and -lpython* lib
authorRoger Pau Monne <roger.pau@entel.upc.edu>
Wed, 14 Mar 2012 14:08:04 +0000 (14:08 +0000)
committerRoger Pau Monne <roger.pau@entel.upc.edu>
Wed, 14 Mar 2012 14:08:04 +0000 (14:08 +0000)
Check that the package usually called python-dev is present.

Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/configure
tools/m4/python_devel.m4

index 57fdf86ea18af015c1a3e62f2c80b5cc9e0e9523..50426f10aa76f3022505f47df102b5618ae8db80 100755 (executable)
@@ -6141,27 +6141,89 @@ else
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 fi
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for python devel" >&5
-$as_echo_n "checking for python devel... " >&6; }
 
-`$PYTHON -c '
-import os.path, sys
-for p in sys.path:
-    if os.path.exists(p + "/config/Makefile"):
-        sys.exit(0)
-sys.exit(1)
-' > /dev/null 2>&1`
+ac_previous_cppflags=$CPPFLAGS
+CPPFLAGS="$CFLAGS `$PYTHON-config --includes`"
+ac_previous_ldflags=$LDFLAGS
+for flag in `$PYTHON-config --ldflags`
+do
+    case $flag in
+    -L*)
+        LDFLAGS="$LDLFAGS $flag"
+        ;;
+    -lpython*)
+        python_lib=`echo $flag | sed 's/^-l//'`
+        ;;
+    -l*)
+        # Ignore other libraries, we are only interested in testing python-dev
+        ;;
+    *)
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Strange ldflag found in $PYTHON-config output: $flag" >&5
+$as_echo "$as_me: WARNING: Strange ldflag found in $PYTHON-config output: $flag" >&2;}
+        ;;
+    esac
+done
+ac_fn_c_check_header_mongrel "$LINENO" "Python.h" "ac_cv_header_Python_h" "$ac_includes_default"
+if test "x$ac_cv_header_Python_h" = x""yes; then :
 
-if test "$?" != "0"
-then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-    as_fn_error $? "Python devel package not found" "$LINENO" 5
 else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+  as_fn_error $? "Unable to find Python development headers" "$LINENO" 5
+fi
+
+
+as_ac_Lib=`$as_echo "ac_cv_lib_$python_lib''_PyArg_ParseTuple" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PyArg_ParseTuple in -l$python_lib" >&5
+$as_echo_n "checking for PyArg_ParseTuple in -l$python_lib... " >&6; }
+if eval "test \"\${$as_ac_Lib+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-l$python_lib  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char PyArg_ParseTuple ();
+int
+main ()
+{
+return PyArg_ParseTuple ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  eval "$as_ac_Lib=yes"
+else
+  eval "$as_ac_Lib=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+eval ac_res=\$$as_ac_Lib
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_LIB$python_lib" | $as_tr_cpp` 1
+_ACEOF
+
+  LIBS="-l$python_lib $LIBS"
+
+else
+  as_fn_error $? "Unable to find a suitable python development library" "$LINENO" 5
 fi
 
+CPPFLAGS=$ac_previous_cppflags
+LDLFAGS=$ac_previous_ldflags
+
+
 fi
 # Extract the first word of "xgettext", so it can be a program name with args.
 set dummy xgettext; ac_word=$2
index a041c4a1e3fd320abea2e0f58e9e6727e44938ee..3bcca7be9e5d125f7961b75306f8e2e01a8e40dd 100644 (file)
@@ -1,18 +1,28 @@
-AC_DEFUN([AX_CHECK_PYTHON_DEVEL],
-[AC_MSG_CHECKING([for python devel])
-
-`$PYTHON -c '
-import os.path, sys
-for p in sys.path:
-    if os.path.exists(p + "/config/Makefile"):
-        sys.exit(0)
-sys.exit(1)
-' > /dev/null 2>&1`
-
-if test "$?" != "0"
-then
-    AC_MSG_RESULT([no])
-    AC_MSG_ERROR([Python devel package not found])
-else
-    AC_MSG_RESULT([yes])
-fi])
+AC_DEFUN([AX_CHECK_PYTHON_DEVEL], [
+ac_previous_cppflags=$CPPFLAGS
+CPPFLAGS="$CFLAGS `$PYTHON-config --includes`"
+ac_previous_ldflags=$LDFLAGS
+for flag in `$PYTHON-config --ldflags`
+do
+    case $flag in
+    -L*)
+        LDFLAGS="$LDLFAGS $flag"
+        ;;
+    -lpython*)
+        python_lib=`echo $flag | sed 's/^-l//'`
+        ;;
+    -l*)
+        # Ignore other libraries, we are only interested in testing python-dev
+        ;;
+    *)
+        AC_MSG_WARN([Strange ldflag found in $PYTHON-config output: $flag])
+        ;;
+    esac
+done
+AC_CHECK_HEADER([Python.h], [],
+    [AC_MSG_ERROR([Unable to find Python development headers])],)
+AC_CHECK_LIB($python_lib, PyArg_ParseTuple, [],
+    [AC_MSG_ERROR([Unable to find a suitable python development library])])
+CPPFLAGS=$ac_previous_cppflags
+LDLFAGS=$ac_previous_ldflags
+])