From a212ee64e3622a0af9dc4f9173e3331f20fb94db Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sun, 3 May 2020 12:56:26 -0600 Subject: [PATCH] Use the --embed when running "python3-config --ldflags" if supported. Newer versions of python3-config only include libpython in the output when the --embed is used. Otherwise, "python3-config --libs" and "python3-config --ldflags" only list the libraries python is dependent on and not the python library itself. --- configure | 8 +++++++- configure.ac | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/configure b/configure index ff47a59df..9b44e3d6b 100755 --- a/configure +++ b/configure @@ -19465,9 +19465,15 @@ fi if test -z "$PYTHON_LIBS"; then : + # Newer versions of python3-config need --embed to include libpython + if $PYTHON_CONFIG 2>&1 | grep embed >/dev/null; then + PY_EMBED=--embed + else + PY_EMBED= + fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking python linker flags" >&5 $as_echo_n "checking python linker flags... " >&6; } - PYTHON_LIBS=`$PYTHON_CONFIG --ldflags` + PYTHON_LIBS=`$PYTHON_CONFIG --ldflags $PY_EMBED` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_LIBS" >&5 $as_echo "$PYTHON_LIBS" >&6; } diff --git a/configure.ac b/configure.ac index 12979a153..008f7b5cc 100644 --- a/configure.ac +++ b/configure.ac @@ -2600,8 +2600,14 @@ if test ${USE_PYTHON-'no'} = "yes"; then ]) AS_IF([test -z "$PYTHON_LIBS"], [ + # Newer versions of python3-config need --embed to include libpython + if $PYTHON_CONFIG 2>&1 | grep embed >/dev/null; then + PY_EMBED=--embed + else + PY_EMBED= + fi AC_MSG_CHECKING([python linker flags]) - PYTHON_LIBS=`$PYTHON_CONFIG --ldflags` + PYTHON_LIBS=`$PYTHON_CONFIG --ldflags $PY_EMBED` AC_MSG_RESULT([$PYTHON_LIBS]) ])