Please check if the syntax looks proper to you, the code is somwhat directly from Xfce4 packages and has tested to be working on nearly all arch's, including Prefix ones. But please check if quoting is proper etc.
Created attachment 241779 [details] autoconf+asneeded_check.example
Comment on attachment 241779 [details] autoconf+asneeded_check.example While the above code is working pretty good -- Mike pointed me out to an already existing autoconf macro for checking if LDFLAGS works: http://www.gnu.org/software/autoconf-archive/ax_check_linker_flags.html should make use of that instead.
Yeah the code on the pasted link looks good. Errr, where do you want this autoconf example to go? devmanual?
to xml/htdocs/proj/en/qa/asneeded.xml, i'll attach a patch here against the .xml soon...
Created attachment 242925 [details] as-needed-am_ldflags.example If you want to strictly apply the theory, you should not (re)define an user variable such as LDFLAGS into your configure.ac (or Makefile.am) : developers should use AM_LDFLAGS to define common linker flags and foo_LDFLAGS to define linker flags for the specific target foo. The attached code example works fine (tested in the build system from my own package). It allows the user to define the LDFLAGS variable in last resort on make command line without making disappear the --as-needed definition. http://www.gnu.org/software/autoconf/manual/autoconf.html#Preset-Output-Variables > > Sometimes package developers are tempted to set user variables such > as CFLAGS because it appears to make their job easier. However, the > package itself should never set a user variable, particularly not to > include switches that are required for proper compilation of the package. > [...] > If the package developer needs to add switches without interfering with > the user, the proper way to do that is to introduce an additional > variable. Automake makes this easy by introducing AM_CFLAGS (see Flag > Variables Ordering), but the concept is the same even if Automake is not used. > http://www.gnu.org/software/autoconf/manual/automake.html#Flag-Variables-Ordering > > The reason ‘$(CPPFLAGS)’ appears after ‘$(AM_CPPFLAGS)’ or ‘$(mumble_CPPFLAGS)’ > in the compile command is that *users should always have the last say*. > > [...] > > You should never redefine a user variable such as CPPFLAGS in Makefile.am. > Use ‘automake -Woverride’ to diagnose such mistakes. Even something like > > CPPFLAGS = -DDATADIR=\"$(datadir)\" @CPPFLAGS@ > > is erroneous. Although this preserves configure's value of CPPFLAGS, the > definition of DATADIR will disappear if a user attempts to override CPPFLAGS > from the make command line. > > AM_CPPFLAGS = -DDATADIR=\"$(datadir)\" > > is all that is needed here if no per-target flags are used. > > You should not add options to these user variables within configure either, > for the same reason. >
your example has spurious whitespace all over further, you should be appending AM_LDFLAGS, not clobbering it. use AS_VAR_APPEND().