[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Autoconf building, linking across multiple source directories?
From: |
John Calcote |
Subject: |
Re: Autoconf building, linking across multiple source directories? |
Date: |
Tue, 08 Jul 2008 09:03:30 -0600 |
User-agent: |
Thunderbird 2.0.0.12 (X11/20071114) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Eric Jonas wrote:
> src/
> foo.cc
> bar.cc
> main.cc
> Makefile.am
>
> tests/
> foo_test.cc
> bar_test.cc
> testrunner.cc
> Makefile.am
>
> 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:
src/Makefile.am:
- -----------------
bin_PROGRAMS = myprog
check_LTLIBRARIES = libtest.la
common_srcs = foo.cc bar.cc
myprog_SOURCES = $(common_srcs) main.cc
libtest_la_SOURCES = $(common_srcs)
tests/Makefile.am
- -----------------
check_PROGRAMS = testrunner
testrunner_SOURCES = testrunner.cc foo_test.cc bar_test.cc
testrunner_LDADD = ../src/libtest.la
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.
Regards,
John
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iEYEARECAAYFAkhzgcIACgkQdcgqmRY/OH9KbgCeOUEbiYAVJfbACjJKMAmW2t7s
/tQAnj+UGkBvVobX7PIxwTumuMbriDsD
=qBFW
-----END PGP SIGNATURE-----