configure: do not echo most inherited LDFLAGS to config files

`libcurl.pc` `Libs.private` (since 8.11.0, and in `Libs` before 7.20.0)
and `curl-config` `--static-libs` (since 7.17.1, and in `Libs` between
7.7.2-7.25.0). This included all flags inherited from the environment,
in addition to those coming from dependency detections.

To avoid spilling all linker flags inherited from the environment to
the libcurl config files, this patch omits them all, except `-L`, `-F`,
`--library-path=` and `-framework` options, which are still passed.
The rationale for the exceptions is that `LIBS` is passed as-is, and
`LDFLAGS`, `LIBS` are the canonical way to pass custom libs options
to a build. `LIBS` may not work without a matching custom libpath.

This brings autotools behaviour closer to cmake, and `curl-config`
closer to `libcurl.pc`.

Follow-up to 9f56bb608e #14681
Follow-up to 4c8adc8fee
Reported-by: Peter Marko
Fixes #15533
Closes #15550
This commit is contained in:
Viktor Szakats 2024-11-11 13:21:58 +01:00
parent 2638570241
commit e244d50064
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
14 changed files with 116 additions and 11 deletions

View file

@ -484,6 +484,7 @@ AC_DEFUN([CURL_CHECK_LIB_ARES], [
dnl c-ares library support has been requested
clean_CPPFLAGS="$CPPFLAGS"
clean_LDFLAGS="$LDFLAGS"
clean_LDFLAGSPC="$LDFLAGSPC"
clean_LIBS="$LIBS"
configure_runpath=`pwd`
if test -n "$want_ares_path"; then
@ -525,6 +526,7 @@ AC_DEFUN([CURL_CHECK_LIB_ARES], [
#
CPPFLAGS="$clean_CPPFLAGS $ares_CPPFLAGS"
LDFLAGS="$clean_LDFLAGS $ares_LDFLAGS"
LDFLAGSPC="$clean_LDFLAGSPC $ares_LDFLAGS"
LIBS="$ares_LIBS $clean_LIBS"
#
@ -553,6 +555,7 @@ AC_DEFUN([CURL_CHECK_LIB_ARES], [
dnl restore initial settings
CPPFLAGS="$clean_CPPFLAGS"
LDFLAGS="$clean_LDFLAGS"
LDFLAGSPC="$clean_LDFLAGSPC"
LIBS="$clean_LIBS"
# prevent usage
want_ares="no"