It's not possible to do this using a simple *.a intermediate library. That's because an intermediate library is never linked, so LDFLAGS
is not meaningful for it. The intermediate library is just an ar archive, which is only a collection of object files. The ar archive has no place to record the flags that would need to be used for linking the final object.
The normal solution is to do what William Pursell suggests: add the necessary LDFLAGS
to the final executables or shared libraries that you create in your build process.
Another possibility is to build your intermediate libraries as libtool *.la libraries, even though you are only going to use them as intermediate libraries. When you do this, the build system will generate a shared object (which you will then end up not using, since you'll combine the underlying object files into your actual build artifact), but more importantly it will create a *.la file, which has a place to record this sort of dependency information. The Automake manual calls this a "Libtool Convenience Library". To do this, you have to use libtool, of course, and switch over to calling this libfoo.la
in your Makefile.am
and list it in noinst_LTLIBRARIES
. But unless you're already using libtool, this is probably more trouble than it's worth.