[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AM_CONDITIONAL to choose between building library or linking directl
From: |
Nick Bowler |
Subject: |
Re: AM_CONDITIONAL to choose between building library or linking directly |
Date: |
Tue, 11 Sep 2012 15:42:22 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On 2012-09-11 15:41 -0300, Fabrício Zimmerer Murta wrote:
> Is that supposed not to work?
>
> (“LIBRARY_BUILD” AM_CONDITIONAL set accordingly on configre.ac)
> Makefile.am:
>
> if LIBRARY_BUILD
> lib_LTLIBRARIRES = libprog.la
> libprog_la_SOURCES = a.c b.c d.c
> else !LIBRARY_BUILD
> bin_PROGRAMS = driver
> driver_SOURCES = a.c b.c d.c driver.c
> endif !LIBRARY_BUILD
Instead of the pattern above, what will probably work is to use the
conditional to select between an installable libtool library or a
libtool convenience library, so that libtool is used in both cases.
For example (untested):
if LIBRARY_BUILD
lib_LTLIBRARIES = libprog.la
else
noinst_LTLIBRARIES = libprog.la
bin_PROGRAMS = driver
endif
libprog_la_SOURCES = a.c b.c d.c
driver_SOURCES = driver.c
driver_LDADD = libprog.la
> if LIBRARY_BUILD
> a.lo: a.c b.lo
> b.lo: b.c
> d.lo: d.c a.lo b.lo
> else !LIBRARY_BUILD
> a.o: a.c b.o
> b.o: b.c
> d.o: d.c a.o b.o
> driver.o: driver.c a.o b.o d.o
> endif !LIBRARY_BUILD
Then with the above change, the "else" case of this conditional is now
not required. Note that regardless of what you do, these prerequisites
look very odd as they say that object files depend on other object
files (which would imply that b.o is somehow required to update a.o:
very unusual in a C program). Moreover, Automake already provides
prerequisites from object files to their C source files, so listing
the .c files here is redundant.
Cheers,
--
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)