help-make
[Top][All Lists]
Advanced

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

how to (best) pass build options down to subdirectories?


From: Robert P. J. Day
Subject: how to (best) pass build options down to subdirectories?
Date: Thu, 27 Jan 2005 11:56:15 -0500 (EST)

  i asked about this once upon a time and, given that i've had more
time to think about it, i'm still interested in some feedback as to
whether it's a good idea, a so-so idea, or whether real make gurus
recoil in horror at it.  (i suspect the latter.)

  first, i'm going to take paul's advice and delete all of make's
implicit rules and create my own, so that i have full control over the
build at all levels in the recursive structure.  those implicit rules
really mess things up every so often.

  anyway, given a (what else?) multi-level recursive make structure, i
want to be able to tweak the preprocess/build/link/install options at
any level right down to the individual makefile.  and i want to be
able to do all of that from the top makefile.  i want *all* processing
to be configurable at the top, not by hunting down through the
directories to find the corresponding makefile and messing with it.

  what i proposed before was to *start* with initial values for things
like CPPFLAGS, CFLAGS, LDFLAGS, LDLIBS, INCLUDE_DIRS and so on, and
these would be set at the top level.

  now, somewhere *way* down in the structure, there might be a
software component of the build -- call it "fred".  and it would have
its own makefile, of course.  but it might be that "fred" needs
special processing in one of more of those settings above.  so i
thought of supporting the creation of optional variables at the top
level.  for example, just to allow "fred" to have a different value
for CFLAGS, the developer could define (at the top level, remember)
one of:

  fred_CFLAGS
  fred_CFLAGS_APPEND
  fred_CFLAGS_PREPEND
  fred_CFLAGS_REMOVE

all of this could be supported fairly easily with a small number of
macros.  each makefile could have its own "component" name defined at
the top of the makefile, as in:

  ME=fred

and a macro to handle the first case would resemble something like:

  ifneq "${ME}_CFLAGS" ""
    CFLAGS = ${ME}_CFLAGS
  endif

and so on.

  it looks kind of weird, but it *appears* to handle what i'm trying
to do.  in addition, the effect would be cumulative down through the
structure, which is also something that would be handy.

  thoughts?  is there a better way to implement this?


rday




reply via email to

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