automake
[Top][All Lists]
Advanced

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

multiple targets, different build options


From: John Richetta
Subject: multiple targets, different build options
Date: Wed, 24 Sep 2008 09:49:06 -0700

(I'm an autotools newbie.)

What is the automake sanctioned way of providing different top-level make targets, that build my application with different options?

For example, say I want to build foo_nondebug, and foo_debug, and (luckily) all of my application code resides in the subdirectories of the top level directory containing the top-level Makefile. Obviously, if I invoke make from one of these targets, I can use the traditional trick of passing a sub-make arguments (like FOO_DEBUG=-g or FOO_DEBUG=<empty>).

Indeed, this is the only way I know how to switching parameters to a submake at build time. But it would seem inappropriate, and tricky, to intercept invoking make, in every place it is used by automake, unless that is something that is officially supported (I gather not based on earlier commentary). Is there any other way to achieve this (changing various command line tool options passed to submakes as a function of the chosen build target)?

I only have two ideas about how to achieve this that seem as if they could work acceptably.

Option 1 is to have the top level make targets reinvoke top-level make, with the desired options. For some reason, this doesn't seem to work (seems to be something to do with the targets: either I'm messing up something automake is doing, because I have my ancillary self-calling make targets, or the make target provided to the second recursive make is wrong (seems like I must use all to get anything to work, but that doesn't seem to work, generally concluding that there is nothing that needs to be built).

Outline of scheme:

foo_nondebug:
   ${MAKE} ${AM_MAKEFLAGS} all FOO_DEBUG=

foo_debug:
   ${MAKE} ${AM_MAKEFLAGS} all FOO_DEBUG=-g

The second option is to simply have independent top-level Makefile.ams (with different names, probably) that build the different executables (all beneficially named differently) after setting up the desired options straightforwardly. For example:

FooMakefile.am:

FOO_DEBUG=

FooDebugMakefile.am:

FOO_DEBUG=-g

Some sub-Makefile.am:

foo_CFLAGS = ${FOO_DEBUG}
foo_LDFLAGS = ${FOO_DEBUG}

I fear either approach will potentially be problematic WRT correctly rebuilding when options that affect source compilation change (unless I can find a way to ensure all build intermediates (.o files) are stored in a location tied to the top-level make target). The second approach seems more likely to work (in some basic sense) but is a bit clumsier for the maintainer. But I am sure automake must provide some way of achieving functionality equivalent to this essential make capability - no?

Ideas and input greatly appreciated. If I missed relevant material in the docs, please point me to it, and I'll read some more. Thanks, -jar




reply via email to

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