[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: multiple targets, different build options
From: |
Peter Johansson |
Subject: |
Re: multiple targets, different build options |
Date: |
Wed, 24 Sep 2008 13:24:10 -0400 |
User-agent: |
Thunderbird 2.0.0.16 (X11/20080723) |
John Richetta wrote:
(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>).
I use the following snippet in one my projects:
AC_ARG_ENABLE(debug,
[AS_HELP_STRING([--enable-debug],[turn on debug options and code])],
[SD_CXXFLAGS="$SD_CXXFLAGS -g -O"],
[SD_CPPFLAGS="-DNDEBUG" SD_CXXFLAGS="$SD_CXXFLAGS -O3"])
# Export flags
AC_SUBST([SVNDIGEST_CPPFLAGS], $SD_CPPFLAGS)
AC_SUBST([SVNDIGEST_CXXFLAGS], $SD_CXXFLAGS)
and then in each Makefile.am:
AM_CPPFLAGS = $(SVNDIGEST_CPPFLAGS)
AM_CXXFLAGS = $(SVNDIGEST_CXXFLAGS)
This will add a switch to configure so we can call ./configure
--enable-debug when we wanna build in debug mode, and else ignore the
option. Their is no dependency, so if I switch between the modes in the
same builddir I need to issue make clean.
Hope this helps.
Cheers,
Peter