help-make
[Top][All Lists]
Advanced

[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
shell.

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
rules.

Here:

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

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:
 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]