]> git.proxmox.com Git - mirror_frr.git/commitdiff
build: improve python search pattern
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 22 Aug 2018 04:04:32 +0000 (06:04 +0200)
committerDavid Lamparter <equinox@diac24.net>
Thu, 25 Oct 2018 15:30:21 +0000 (17:30 +0200)
- try pythonN.N-config after pythonN-config
- use "python-config --ldflags" instead of --libs
- add Python 3.6 to explicitly searched versions
- if linking fails, try with "-lz" added

Signed-off-by: David Lamparter <equinox@diac24.net>
configure.ac

index 77f386cdf05747a9ac00fc221ea6d85fd2226adf..b5e9c2514ec2c1766ac5e25a7e2bda6dc05bfecd 100755 (executable)
@@ -531,25 +531,10 @@ AM_CONDITIONAL([FPM], [test "x$enable_fpm" = "xyes"])
 #
 # Python for clippy
 #
-AS_IF([test "$host" = "$build"], [
-  PYTHONCONFIG=""
-
-  # ordering:
-  # 1.  try python3, but respect the user's preference on which minor ver
-  # 2.  try python, which might be py3 or py2 again on the user's preference
-  # 3.  try python2 (can really only be 2.7 but eh)
-  # 4.  try 3.5 > 3.4 > 3.3 > 3.2 > 2.7 through pkg-config (no user pref)
-  #
-  # (AX_PYTHON_DEVEL has no clue about py3 vs py2)
-  # (AX_PYTHON does not do what we need)
-
-  AC_CHECK_TOOLS([PYTHONCONFIG], [python3-config python-config python2-config])
-  if test -n "$PYTHONCONFIG"; then
-    PYTHON_CFLAGS="`\"${PYTHONCONFIG}\" --includes`"
-    PYTHON_LIBS="`\"${PYTHONCONFIG}\" --libs`"
 
-    AC_MSG_CHECKING([whether we found a working Python version])
-    AC_LINK_IFELSE_FLAGS([$PYTHON_CFLAGS], [$PYTHON_LIBS], [AC_LANG_PROGRAM([
+AC_DEFUN([FRR_PYTHON_CHECK_WORKING], [
+  AC_MSG_CHECKING([whether we found a working Python version])
+  AC_LINK_IFELSE_FLAGS([$PYTHON_CFLAGS], [$PYTHON_LIBS], [AC_LANG_PROGRAM([
 #include <Python.h>
 #if PY_VERSION_HEX < 0x02070000
 #error python too old
@@ -562,23 +547,8 @@ int main(void);
   return 0;
 }
 ])], [
-      PYTHONCONFIG=""
-      unset PYTHON_LIBS
-      unset PYTHON_CFLAGS
-    ])
-  fi
-
-  if test -z "$PYTHONCONFIG"; then
-    PKG_CHECK_MODULES([PYTHON], python-3.5, [], [
-      PKG_CHECK_MODULES([PYTHON], python-3.4, [], [
-        PKG_CHECK_MODULES([PYTHON], python-3.3, [], [
-          PKG_CHECK_MODULES([PYTHON], python-3.2, [], [
-            PKG_CHECK_MODULES([PYTHON], python-2.7, [], [
-              AC_MSG_FAILURE([could not find python-config or pkg-config python, please install Python development files from libpython-dev or similar])
-              ])])])])])
-
-
-    AC_MSG_CHECKING([whether we found a working Python version])
+    # some python installs are missing the zlib dependency...
+    PYTHON_LIBS="${PYTHON_LIBS} -lz"
     AC_LINK_IFELSE_FLAGS([$PYTHON_CFLAGS], [$PYTHON_LIBS], [AC_LANG_PROGRAM([
 #include <Python.h>
 #if PY_VERSION_HEX < 0x02070000
@@ -592,6 +562,56 @@ int main(void);
   return 0;
 }
 ])], [
+      m4_if([$1], [], [
+        PYTHONCONFIG=""
+        unset PYTHON_LIBS
+        unset PYTHON_CFLAGS
+      ], [$1])
+    ])
+  ])
+])
+
+AS_IF([test "$host" = "$build"], [
+  PYTHONCONFIG=""
+
+  # ordering:
+  # 1.  try python3, but respect the user's preference on which minor ver
+  # 2.  try python, which might be py3 or py2 again on the user's preference
+  # 3.  try python2 (can really only be 2.7 but eh)
+  # 4.  try 3.6 > 3.5 > 3.4 > 3.3 > 3.2 > 2.7 through pkg-config (no user pref)
+  #
+  # (AX_PYTHON_DEVEL has no clue about py3 vs py2)
+  # (AX_PYTHON does not do what we need)
+
+  AC_CHECK_TOOLS([PYTHONCONFIG], [ \
+       python3-config \
+       python-config \
+       python2-config \
+       python3.6-config \
+       python3.5-config \
+       python3.4-config \
+       python3.3-config \
+       python3.2-config \
+       python2.7-config ])
+  if test -n "$PYTHONCONFIG"; then
+    PYTHON_CFLAGS="`\"${PYTHONCONFIG}\" --includes`"
+    PYTHON_LIBS="`\"${PYTHONCONFIG}\" --ldflags`"
+
+    FRR_PYTHON_CHECK_WORKING([])
+  fi
+
+  if test -z "$PYTHONCONFIG"; then
+    PKG_CHECK_MODULES([PYTHON], python-3.6, [], [
+      PKG_CHECK_MODULES([PYTHON], python-3.5, [], [
+        PKG_CHECK_MODULES([PYTHON], python-3.4, [], [
+          PKG_CHECK_MODULES([PYTHON], python-3.3, [], [
+            PKG_CHECK_MODULES([PYTHON], python-3.2, [], [
+              PKG_CHECK_MODULES([PYTHON], python-2.7, [], [
+                AC_MSG_FAILURE([could not find python-config or pkg-config python, please install Python development files from libpython-dev or similar])
+                ])])])])])])
+
+
+    FRR_PYTHON_CHECK_WORKING([
       AC_MSG_FAILURE([could not find python-config or pkg-config python, please install Python development files from libpython-dev or similar])
     ])
   fi