autotools - Build tests depending on program sources -
i want build tests foo program. root makefile.am looks like:
subdirs = src tests makefile.am src contains:
bin_programs = foo foo_cxxflags = # lot of $(xxx_cflags) foo_ldadd = # lot of $(xxx_libs) foo_sources = # lot of source files makefile.am tests contains:
check_programs = footesta footestb tests = footesta footestb footesta_sources = footesta.cpp footestb_sources = footestb.cpp these tests depend on foo symbols , consider create convenience library using foo_libadd = libfoo.la on top , place noinst_ltlibraries = libfoo.la in makefile.am's src. on right way solve this?
you on right way, suggest couple of different options too.
first of all, i'd suggest using non-recursive automake instead of 3 makefile.am have 1 keep date, , reduces nasty factor of autotools.
in particular, using convenience library method across separate makefile.am makes dependency tracking terribly complicated, means may or may not re-run tests if you're changing, say, header file. dependency tracking done when using single, non-recursive, makefile.am.
the other option, again using non-recursive build system, declare variables group of sources, have
self_contained_srcs = foo.h foo1.c foo2.c foo3.c foo_sources = $(self_contained_srcs) main.c other.c footest_sources = footesta.c $(self_contained_srcs) this avoids intra-step of running archiver generate .a file , linker unpack it, while still sharing compiled sources (as long don't use per-target cflags).
if plan on using per-target cflags (say want have test-specific code in foo3.c), not able share compiled object files between 2 targets, possible when using variable-expansion, , not possible convenience library, why that's preferred option.
Comments
Post a Comment