delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/11/11:29:54

From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Trouble with make
Date: Tue, 11 Jan 2000 15:05:51 +0200
Organization: NetVision Israel
Lines: 41
Message-ID: <Pine.SUN.3.91.1000111150355.19064C-100000@is>
References: <387976d3 DOT 341661358 AT news DOT globalserve DOT net> <Pine DOT SUN DOT 3 DOT 91 DOT 1000110132359 DOT 6993F-100000 AT is> <3879cdb8 DOT 363909713 AT news DOT globalserve DOT net>
NNTP-Posting-Host: is.elta.co.il
Mime-Version: 1.0
X-Trace: news.netvision.net.il 947596150 770 199.203.121.2 (11 Jan 2000 13:09:10 GMT)
X-Complaints-To: abuse AT netvision DOT net DOT il
NNTP-Posting-Date: 11 Jan 2000 13:09:10 GMT
X-Sender: eliz AT is
In-Reply-To: <3879cdb8.363909713@news.globalserve.net>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
Errors-To: dj-admin AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Mon, 10 Jan 2000, SpamKiLr wrote:

> all: $(CODEJAR) $(DOCSJAR) $(SOURCEJAR)
> 
> The output indicates that it seems to have seen
> 
> all:
> 
> instead, as though all three variables expanded into whitespace.

Yes.

> But
> an echo statement as the command for "all" reveals that $(CODEJAR) is
> 
> ../program/protomatter.jar
> 
> so that is impossible!

It's possible.  Move your all: line to the end of the Makefile, and it
will work.

For the explanation of this seemingly counter-intuitive behavior,
refer to the Make manual, which says in node "Using Variables":

    Variables and functions in all parts of a makefile are expanded when
    read, except for the shell commands in rules, the right-hand sides of
    variable definitions using `=', and the bodies of variable definitions
    using the `define' directive.

In other words, Make expands the variables in your prerequisite list
as soon as it sees them, and by that time these variables were not yet
defined.  (This is one reason why each Makefile begins by defining all
the variables.)  In contrast, variables in rules' commands are only
expanded when that rule's commands are run, that's why `echo' prints
the variables correctly.

Btw, your Makefile arrived severely butchered by your mailer (long lines 
were wrapped), which required a non-trivial amount of editing before I 
could try it.  Please try to avoid this in the future.

- Raw text -


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