automake
[Top][All Lists]
Advanced

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

Re: AM_CONDITIONAL to choose between building library or linking directl


From: Fabrício Zimmerer Murta
Subject: Re: AM_CONDITIONAL to choose between building library or linking directly
Date: Tue, 11 Sep 2012 17:11:01 -0300

"these prerequisites look very odd as they say that object files depend on other object files" Blame fortran for that. Is 'b' is a module, I have to assure 'a' is compiled only when 'b' is compiled (so the .mod file is created). With this rule, I can assure make -jN would not result in error.

I think your noinst_ suggestion really does the trick, although I thought it was an incosistent error. If I am not building any library, it shouldn't think I am building one (as long as I sepparated it correctly with conditionals). :/

But thank you, I was really wondering if that noinst_ approach would fit, it turns that it's the only solution.

-----Original Message----- From: Nick Bowler
Sent: Tuesday, September 11, 2012 4:42 PM
To: FabrícioZimmerer Murta
Cc: Automake Mailing List
Subject: Re: AM_CONDITIONAL to choose between building library or linking directly

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/)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]