Mail Archives: djgpp/2000/01/11/11:29:54
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 -