From: Nick Porter Date: Tue, 1 Nov 2022 18:41:47 +0000 (+0000) Subject: Correctly detect working python when using gcc X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e39f420eaefa2cb9aa95aa83756dd920417d886;p=thirdparty%2Ffreeradius-server.git Correctly detect working python when using gcc gcc wants -l options after the source file - so populate $LIBS --- diff --git a/src/modules/rlm_python/configure b/src/modules/rlm_python/configure index 12583cf82e7..19f44b61393 100755 --- a/src/modules/rlm_python/configure +++ b/src/modules/rlm_python/configure @@ -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 diff --git a/src/modules/rlm_python/configure.ac b/src/modules/rlm_python/configure.ac index d30532bda9f..ec28a485b25 100644 --- a/src/modules/rlm_python/configure.ac +++ b/src/modules/rlm_python/configure.ac @@ -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 @@ -124,6 +131,7 @@ else CFLAGS=$old_CFLAGS LDFLAGS=$old_LDFLAGS + LIBS=$old_LIBS fi FR_MODULE_END_TESTS