The equivalent of an AM_LDADD
variable is simply LDADD
. e.g.,
LDADD = -llibrary
test1_SOURCES = ...
...
test20_SOURCES = ...
If you need to override LDADD
for a particular program: prog
, then prog_LDADD
will always take precedence.
I always assumed that since there was no LDADD
standard environment variable passed to configure
- as you can see with configure --help
- there is no real reason for an AM_LDADD
. This kind of makes sense, as the configure
script, and any options, e.g., --with-foo=<path>
should (ideally) work out the library dependencies.
On the other hand, passing CFLAGS
via configure
might still need an AM_CFLAGS
that combines CFLAGS
and with other compiler flags determined by the configure script; or even a foo_CFLAGS
override. Since configure
must be informed of your custom CFLAGS
.
Also, I don't know if the test<n>
programs only take a single C++ source file, but if so, you can simplify the Makefile.am
with:
LDADD = -llibrary
check_PROGRAMS = test1 test2 ... test20
AM_DEFAULT_SOURCE_EXT = .cc # or .cpp
as described here.
In regards to your comment, your can use a convenience library for that purpose - which is particularly useful for common code used by test programs:
noinst_LIBRARIES = libfoo.a # or noinst_LTLIBRARIES = libfoo.la
libfoo_a_SOURCES = MyClass.hh MyClass.cc # or libfoo_la_SOURCES
LDADD = ./libfoo.a -llibrary # or libfoo.la if using libtool.
... etc ...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…