What is the difference between AM_LDFLAGS and LDFLAGS
I want to know what is the difference between AM_LDFLAGS and LDFLAGS as I ran into the error
error: AM_LDFLAGS must be set with '=' before using '+='
when i used AM_LDFLAGS in foreach loop my makefile code as below:
program_INCLUDE_DIRS := /usr/bin/PR__bin
program_LIBRARY_DIRS := /usr/lib/PR__lib
CFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
AM_LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
source to share
If this error complains about what it says it is complaining about (and I'm not at all sure why it should / should be), I would think the solution would be as simple as simply adding
AM_LDFLAGS =
as the line above the foreach loop that uses +=
.
From 8.7 Variables used when building a program
the GNU Automake manual section :
AM_LDFLAGS
This is a variable that the author of Makefile.am can use to pass additional linker flags. In some situations this is not used, it is preferable for each executable (or for the library) _LDFLAGS.
source to share
_ I want to know what is the difference between AM_LDFLAGS and LDFLAGS _
LDFLAGS
is a variable inherited from Autoconf AM_LDFLAGS
is a variable defined by automake.
According to the automania help page ,
This is a variable that the author
Makefile.am
can use to add additional linker flags. In some situations this is not used, preferably for an executable (or for a library)_LDFLAGS
.
However, repeating the error, as per the information provided here , it looks like a problem using a variable. Automake expects a variable to be set to some value before it can be added.
The correct way to address this question would be the same as the one mentioned in another answer provided by Ethan Reisner, just set AM_LDFLAGS
explicitly before the loop, something like
AM_LDFLAGS = // which "sets" the AM_LDFLAGS
and then do
AM_LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
source to share