Re: Autoconf building, linking across multiple source directories?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Eric, John,

* John Calcote wrote on Tue, Jul 08, 2008 at 05:03:30PM CEST:
> Eric Jonas wrote:
> > 
> > What I'd like to be able to do is build "testrunner" from testrunner.o,
> > foo_test.o, bar_test.o, and crucially, foo.o and bar.o. But I can't
> > figure out how to specify in the tests/Makefile.am that it depends on
> > object files outside of it's particular directory subtree. Ideally I'd
> > be able to avoid explicitly referencing each-and-every source file in
> > src/, as I hope to soon have a lot of them. Is this possible? 
> 
> You could create a static convenience library in src/Makefile.am as follows:
[...]
> Of course, this could just as easily have been done without Libtool by
> using the LIBRARIES primary, and a few other syntactical differences,
> but I prefer Libtool, as the syntax is simpler.

For what little it's worth, I'd write that as

src/Makefile.am:
noinst_LIBRARIES = libtest.a
libtest_a_SOURCES = foo.cc bar.cc
bin_PROGRAMS = myprog
myprog_SOURCES = main.cc
myprog_LDADD = libtest.a

tests/Makefile.am:
check_PROGRAMS = testrunner
testrunner_SOURCES = testrunner.cc foo_test.cc bar_test.cc
testrunner_LDADD = ../src/libtest.a

But your way works as well.  Both will also keep dependencies up to
date.  Toplevel Makefile.am should list src before tests in SUBDIRS.

FYI, this is rather an Automake question than an Autoconf one.

Cheers,
Ralf


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux