help-make
[Top][All Lists]
Advanced

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

Re: Target specific variables


From: Paul D. Smith
Subject: Re: Target specific variables
Date: Wed, 21 Mar 2001 11:50:36 -0500

%% Jens Schweikhardt <address@hidden> writes:

  js> However, I also need to set some more variables, e.g. I'd like to say

  js>  foo Foo: CFLAGS = -DMUBMLE, LDFLAGS = -DFROB, YFLAGS = bar baz

Nope.

  js> For now I simply repeat the targets,

  js>   foo Foo: CFLAGS = -DMUMBLE
  js>   foo Foo: LDFLAGS = -DFROB
  js>   foo Foo: YFLAGS = bar baz

Yup.

  js> This does work, but it's somewhat ugly because my list of targets
  js> (foo Foo) actually consists of up to one hundred separate targets
  js> and repeating them leads to considerable Makefile bloat... 

Why not put them in a variable, and use:

  $(100-targets) : CFLAGS = -DMUMBLE
    ...

  js> In the spirit of avoiding redundancy, is there a way to do what I
  js> want or am I SOL?

The latter ;).

  js> I realize there's the problem of "What's the delimiter between
  js> diffenent variable assignments" (comma in my example). But maybe
  js> I've overseen something. If not, Paul may treat this mail as a
  js> feature-request :-)

Well, you've obviously hit on the most devastating problem.  The
right-hand side of a variable assignment has no illegal characters.

The only possible solution would be (and this does _not_ work now so
don't even bother trying it) using define, like this:

  define SET_SOME_VARS
    CFLAGS = -DMUMBLE
    LDFLAGS = -DFROB
    YFLAGS = bar baz
  enddef

  foo Foo: $(SET_SOME_VARS)

Since define preserves newline characters this could possibly be made to
work.  It would be very difficult, though; the code is not structured in
a way to make this easy at all.

Read: don't expect it any time soon :).

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist



reply via email to

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