delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/01/16/04:04:44

Date: Sun, 16 Jan 2000 10:13:12 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: djgpp-workers AT delorie DOT com
Subject: Re: Problem with make
In-Reply-To: <B0000115805@stargate.astr.lu.lv>
Message-ID: <Pine.SUN.3.91.1000116101253.11666I-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: dj-admin AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Fri, 14 Jan 2000 pavenis AT lanet DOT lv wrote:

> make -k -C 1 all
> make.exe[1]: Entering directory `c:/djgpp/test/makebug/1'
> c:/djgpp/test/makebug/1/foo
> make.exe[1]: *** [check1_curr] Error -1
> bash c:/djgpp/test/makebug/1/foo
> c:/djgpp/test/makebug/1/foo: c:/djgpp/test/makebug/1/foo: No such 
> file or directory (ENOENT)
> make.exe[1]: *** [check2_curr] Error 127
> make.exe[1]: Target `all' not remade because of errors.
> make.exe[1]: Leaving directory `c:/djgpp/test/makebug/1'
> make.exe: *** [check_sub] Error 2

This is expected and documented behavior of GNU Make.  See the section
"Variables/Recursion" in the Make's manual for more details.

First, variables defined by the Makefile are not passed to sub-Make's
unless you explicitly ask for that, like this:

  export FOO = $(shell pwd)/foo

But even this is not enough: you must also instruct the sub-Make to
use variables it got from the environment in precedence to variables
defined in its own Makefile, like this:

  check_sub:
	make -e -k -C 1 all

(the -e switch is what does this).

On balance, I think it is much easier (and more portable) to pass the
variable through Make's command line:

  check_sub:
	make -k -C 1 all FOO=$(FOO)

This will always work, even if you don't use `export'.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019