[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 00:22:56 -0500

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

  cjb> i'm trying to do a recursive make, but the variables i export are
  cjb> not being seen by the sub makes.

  cjb> SUBDIRS = blah...

  cjb> $(SUBDIRS):
  cjb>  @if [ $(ARCH) = LINUX ]; then \
  cjb>          export MYVAR = DEBUG; \
  cjb>  fi
  cjb>  cd $@ && $(MAKE)

  cjb> when the sub make runs, MYVAR is not defined.  what am i doing wrong?

You are confusing shell syntax, which is what command scripts are
written in, with makefile syntax.  You can't mix shell commands and make
commands together in the same command like that.

Every line (well, there are some exceptions but it's best to not take
advantage of them) that begins with a TAB is not interpreted by make at
all, except to expand variable references; instead it's passed to the

Every line that does not begin with a TAB is considered a make command
line, and is interpreted by make before make starts to process any


        @if [ $(ARCH) = LINUX ]; then \
                export MYVAR = DEBUG; \

you are trying to stick a make command (the export) into the middle of a
shell script (the if statement).  You can't do that.

 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]