help-make
[Top][All Lists]
Advanced

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

Re: include or variable assignment in conditional


From: Paul D. Smith
Subject: Re: include or variable assignment in conditional
Date: Mon, 12 Jul 2004 00:25:39 -0400

%% "Frank Spies" <address@hidden> writes:

  fs> i got a question which i can't figure out from the manual (well
  fs> actually it seems like it's not possible from the manual and my
  fs> trials but i wanted to ask someone to make sure since it seems it
  fs> should work)

No, it shouldn't.

  fs> i want to be able to include another makefile and assign a variable
  fs> from the conditional part of a target like this:

  fs> debug:
  fs>   include address@hidden
  fs>   DebugVar = some_value

  fs> but apparently i can not do that ???

No, you cannot.

  fs> or am i missing something ???

Yes indeed!

What you are missing is this: the text that appears in the command
section are _SHELL SCRIPTS_.  They are passed directly to shell, with no
processing by make whatsoever, except to expand variable references.

So, you cannot put make operations like include, or set make variables,
etc. inside a command, because it's not interpreted by make: it's passed
to the shell and interpreted by the shell.


Moreover, the particular text above makes no sense because make is not a
procedural language.  Make operates in two distinct phases: first it
reads in all the makefiles, resolves all include files, etc. etc.  After
after all makefiles are internalized, only then does it go back and
start trying to figure out which targets are out of date and rebuilding
them.  So, having an "include" inside a target command script doesn't
make sense since all the dependency graph information has already been
created, etc.


Maybe if you stepped back from the implementation and told us, in words,
what you are trying to do we could help you do that.  But you can't use
anything like what you are doing above.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "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]