]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Correctly detect working python when using gcc
authorNick Porter <nick@portercomputing.co.uk>
Tue, 1 Nov 2022 18:41:47 +0000 (18:41 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Wed, 2 Nov 2022 11:39:00 +0000 (11:39 +0000)
gcc wants -l options after the source file - so populate $LIBS

src/modules/rlm_python/configure
src/modules/rlm_python/configure.ac

index 12583cf82e7f4e1a1ff1a669264366d445c10b61..19f44b6139300f5a54bc3c0883aa527b4327705e 100755 (executable)
@@ -2863,9 +2863,11 @@ fail="$fail python-config"
 else
                                old_CFLAGS="$CFLAGS"
        old_LDFLAGS="$LDFLAGS"
+       old_LIBS="$LIBS"
 
        unset CFLAGS
        unset LDFLAGS
+       unset LIBS
 
                                                if ${PYTHON_CONFIG_BIN} --help 2>&1 | grep '\-\-embed'; then
                PYTHON_CONFIG_EMBED="--embed"
@@ -2906,6 +2908,10 @@ $as_echo "$as_me: ${PYTHON_CONFIG_BIN}'s ldflags were \"${python_ldflags}\"" >&6
        { $as_echo "$as_me:${as_lineno-$LINENO}: Sanitized ldflags were \"${mod_ldflags}\"" >&5
 $as_echo "$as_me: Sanitized ldflags were \"${mod_ldflags}\"" >&6;}
 
+               mod_lib=`echo "${mod_ldflags}" | grep -o -E ' \-l\S+' | tr '\n' ' '`
+       { $as_echo "$as_me:${as_lineno-$LINENO}: Sanitized libs were \"${mod_lib}\"" >&5
+$as_echo "$as_me: Sanitized libs were \"${mod_lib}\"" >&6;}
+
        python_lib=`echo "${mod_ldflags}" | grep -o -E '\-lpython[0-9.]+' | sed -e 's/-l//'`
 
        { $as_echo "$as_me:${as_lineno-$LINENO}: Python library is \"${python_lib}\"" >&5
@@ -2916,6 +2922,7 @@ $as_echo_n "checking we can link to python libraries... " >&6; }
 
        CFLAGS=${mod_cflags}
        LDFLAGS=${mod_ldflags}
+       LIBS=${mod_lib}
 
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -2951,6 +2958,7 @@ fail="$fail working python libraries"
 
        CFLAGS=$old_CFLAGS
        LDFLAGS=$old_LDFLAGS
+       LIBS=$old_LIBS
 fi
 
 
index d30532bda9f6cacd24cc6c5ca6fe908222016f3e..ec28a485b25788ec3bdcebcc2587b40c2cbed10d 100644 (file)
@@ -37,9 +37,11 @@ else
        dnl #
        old_CFLAGS="$CFLAGS"
        old_LDFLAGS="$LDFLAGS"
+       old_LIBS="$LIBS"
 
        unset CFLAGS
        unset LDFLAGS
+       unset LIBS
 
        dnl #
        dnl # Not all python3-config versions have --embed.  If doesn't
@@ -98,6 +100,10 @@ else
                '`
        AC_MSG_NOTICE([Sanitized ldflags were "${mod_ldflags}"])
 
+       dnl # Extract -l options - they should be in LIBS not LDFLAGS for gcc
+       mod_lib=`echo "${mod_ldflags}" | grep -o -E ' \-l\S+' | tr '\n' ' '`
+       AC_MSG_NOTICE([Sanitized libs were "${mod_lib}"])
+
        python_lib=`echo "${mod_ldflags}" | grep -o -E '\-lpython[[0-9.]]+' | sed -e 's/-l//'`
 
        AC_MSG_NOTICE([Python library is "${python_lib}"])
@@ -106,6 +112,7 @@ else
 
        CFLAGS=${mod_cflags}
        LDFLAGS=${mod_ldflags}
+       LIBS=${mod_lib}
        AC_LINK_IFELSE(
                [AC_LANG_PROGRAM([[
                        #include <Python.h>
@@ -124,6 +131,7 @@ else
 
        CFLAGS=$old_CFLAGS
        LDFLAGS=$old_LDFLAGS
+       LIBS=$old_LIBS
 fi
 
 FR_MODULE_END_TESTS