[Top][All Lists]

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

Re: export not working...

From: Paul D. Smith
Subject: Re: export not working...
Date: Wed, 21 Jan 2004 14:00:47 -0500

%% Christopher J Bottaro <address@hidden> writes:

  cjb> hmm, how about if i do this then...
  cjb> $(SUBDIRS):
  cjb> ifeq($(ARCH),LINUX)
  cjb> export MYVAR = DEBUG
  cjb> endif
  cjb>  cd $@ && $(MAKE)

  cjb> that doesn't work either.  make says "commands commence before
  cjb> first target".  what am i doing wrong?  the make syntax is not
  cjb> tabbed, only the command is...

Yes, but the definition of a rule in make is that it consists of
target(s) followed by a colon (or double-colon) and optional
prerequisites, followed by the command script for that rule.

The command script is defined to be every line beginning with a TAB up
until the first non-empty line that doesn't begin with a TAB.

As a special case, GNU make preprocessor statements themselves don't
count as ending a command script, but certainly any lines within the
preprocessor statement (assuming it's true) _DO_ count.

Since you put the variable definition right after the target line, that
ends the command script.

Then make sees the next line and it's not a variable setting and it's
not a target definition, so make doesn't know _what_ it is and gives you
that error.

You have to move the make commands outside of the rule: either before it
or after it.  You can't put them in the middle like that.

  cjb> on another note, how would one do a recursive make clean without
  cjb> using a shell for loop?  right now i have it like this:

You don't.  Using a shell for loop is a bad idea; anyway why do that
when this kind of thing is what make was designed to do?

  cjb> clean:
  cjb>  @for d in $(SUBDIRS); do \
  cjb>          cd $dd && $(MAKE) clean || exit 1; \
  cjb>  done

  cjb> but what is the "correct" way to do this?

Look at the GNU make manual section on "Phony Targets" for an example of
another way to do this.

The problem with your attempt above is that it won't obey make options
like -k, etc.

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