Subject: bug#34925: Overwriting target_LDFLAGS within conditionals

From: Karl Berry <[email-masked]>
Date: Mon, 22 Feb 2021 19:23:40 -0700

Hi - replying to this automake bug report from almost two years ago
(sorry) (https://bugs.gnu.org/34925):

    AM_LDFLAGS = -flto
    if Z
    a_LDFLAGS = -O3
    endif
    ...
    AM_LDFLAGS is always ignored.

I agree that in the case above it's surprising for AM_LDFLAGS not to be
used. But I worry about changing Automake's behavior at this late date.

The whole question of which ldflags are used is something that different
projects might have carefully tuned to the current behavior for their
needs, and thus newly "inheriting" the AM_LDFLAGS value would cause
unnecessary problems.  For the case above, presumably an else clause
defining a_LDFLAGS would yield the desired result.

So instead of changing the code, I merely changed the manual to warn
about this.

Thanks for the report. --best, karl.

diff --git a/doc/automake.texi b/doc/automake.texi
index 5f70e37..8f5a9fc 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -5839,7 +5839,11 @@ of any library built by your package.  Doing so will ensure that
 
 @item maude_LDFLAGS
 This variable is used to pass extra flags to the link step of a program
-or a shared library.  It overrides the @code{AM_LDFLAGS} variable.
+or a shared library.  It overrides the @code{AM_LDFLAGS} variable,
+even if it is defined only in a false branch of a conditional; in
+other words, if @code{@var{prog}_LDFLAGS} is defined at all,
+@code{AM_LDFLAGS} will not be used.
+@c https://bugs.gnu.org/34925
 
 @item maude_LIBTOOLFLAGS
 This variable is used to pass extra options to @command{libtool}.

compile finished at Mon Feb 22 18:19:56 2021