[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 3 of 3] autoconf: check for Python.h header and -lpython lib



# HG changeset patch
# User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
# Date 1329928675 -3600
# Node ID d27037d4c8ef217effb9d063db3bb620ba3762aa
# Parent  04c74f6b97ad74ecd3226be5a4c7478859a74aec
autoconf: check for Python.h header and -lpython lib

Check that the usually called python-dev package is present.

Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>

diff -r 04c74f6b97ad -r d27037d4c8ef tools/configure
--- a/tools/configure   Wed Feb 22 17:37:50 2012 +0100
+++ b/tools/configure   Wed Feb 22 17:37:55 2012 +0100
@@ -6270,26 +6270,77 @@ 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`
-
-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; }
-fi
+
+ac_previous_cppflags=$CPPFLAGS
+CPPFLAGS="$CFLAGS `$PYTHON-config --includes`"
+ac_previous_ldflags=$LDFLAGS
+for flag in `$PYTHON-config --ldflags`
+do
+    if test ${flag:0:2} = "-L"; then :
+
+        LDFLAGS="$LDLFAGS $flag"
+
+fi
+    if test ${flag:0:8} = "-lpython"; then :
+
+        python_lib=${flag:2}
+
+fi
+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 :
+
+else
+  as_fn_error $? "Unable to find Python development headers" "$LINENO" 5
+fi
+
+
+as_ac_Lib=`$as_echo "ac_cv_lib_$python_lib''_main" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -l$python_lib" 
>&5
+$as_echo_n "checking for main 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.  */
+
+
+int
+main ()
+{
+return main ();
+  ;
+  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.
diff -r 04c74f6b97ad -r d27037d4c8ef tools/m4/python_devel.m4
--- a/tools/m4/python_devel.m4  Wed Feb 22 17:37:50 2012 +0100
+++ b/tools/m4/python_devel.m4  Wed Feb 22 17:37:55 2012 +0100
@@ -1,18 +1,20 @@
-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
+    AS_IF([test ${flag:0:2} = "-L"], [
+        LDFLAGS="$LDLFAGS $flag"
+    ])
+    AS_IF([test ${flag:0:8} = "-lpython"], [
+        python_lib=${flag:2}
+    ])
+done
+AC_CHECK_HEADER([Python.h], [],
+    [AC_MSG_ERROR([Unable to find Python development headers])],)
+AC_CHECK_LIB($python_lib, main, [],
+    [AC_MSG_ERROR([Unable to find a suitable python development library])])
+CPPFLAGS=$ac_previous_cppflags
+LDLFAGS=$ac_previous_ldflags
+])

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.