automake
[Top][All Lists]
Advanced

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

Re: dynamic include in Makefile.am


From: Ralf Wildenhues
Subject: Re: dynamic include in Makefile.am
Date: Fri, 2 Apr 2010 11:45:42 +0200
User-agent: Mutt/1.5.20 (2009-10-28)

Hello Tim,

* Tim Just wrote on Fri, Apr 02, 2010 at 10:04:13AM CEST:
> We use one central Makefile.am to avoid the recursive use of make. This
> central Makefile.am contains all information related to app/ and lib/.
> However each module defines its build system information in an own
> Makefile.am that is located in modules/.
[...]
> By default each module Makefile.am should be included to the central
> Makefile.am. Furthermore it should be possible to disable modules per
> configure option. That is to not include the corresponding module
> Makefile.am.

One thing you need to know about the automake 'include' feature is that
it works at 'automake' run time: it literally copies the text of the
included fragment files into the resulting toplevel Makefile.in file.
That explains why things wouldn't work with your intermediate include
file.

Another thing to know is that automake flattens
  foo += bar

statements, because += is not portable to non-GNU make.

That being said, automake conditionals can come to the rescue for you.
You can put something like
  AM_CONDITIONAL([MODULE_FOO], [test "$enable_module_foo" = yes])

in configure.ac (if you've ensured enable_module_foo to be set before),
and use something like
  if MODULE_FOO
  include modules/foo/Makefile.am
  endif

in your toplevel Makefile.am, or alternatively wrap the if/endif around
all text within modules/foo/Makefile.am.

You may still run into issues; conditionals don't work with arbitrary
makefile constructs, but those you have showed in the example should be
fine.  Also, the resulting Makefile.in file can grow quite large.

Hope that helps.

Cheers,
Ralf




reply via email to

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