[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: HELP! $(wildcard ) function failed very strangely

From: Chen(陈)Jun(军)
Subject: RE: HELP! $(wildcard ) function failed very strangely
Date: Sun, 30 Sep 2007 13:39:47 +0000

> On 2007-09-30 16:54:28 (+0800), Chen Jun (????) <address@hidden> wrote:
> > Result of the first run is strange. When target prj_count is being made,
> > out.txt should have been generated on my disk(because $(outfile) had been made
> > before), then WHY $(wildcard out.txt) gives me null result ?
> The $(wildcard ) is evaluated when the rule is parsed, not when it's
> executed. At that point the out.txt file doesn't exist yet so it doesn't
> match anything.
> Try something like this:
> MATCH = $(wildcard out.txt)
> rule: out.txt
> echo $(MATCH)
> out.txt:
> touch $@
> Also note that it's a bad idea to rely on the order or your
> prerequisites, as you seem to do in first_target. If make is executed
> with -j it's possible the prj_count target will be executed before the
> $(outfile) target. If prj_count requires $(outfile) to be built it
> should be listed as a prerequisite.
> Regards,
> Kristof

Thanks Kristof, and I tried your suggestion(introducing the MATCH variable) but it behaves the same as my original makefile.

The makefile( according to your suggestion is in the mail attachment.
Further more, you said "The $(wildcard ) is evaluated when the rule is parsed", while I find the gnu official manual does not say that. According to "3.9 How make Reads a Makefile", expansion of the $(wildcard ) function, like other functions, is deferred when the commands for the rule(prj_count) are to be executed. 
Can you or someone give further explain?

用 Windows Live Spaces 展示个性自我,与好友分享生活! 了解更多信息!

Description: Text document

reply via email to

[Prev in Thread] Current Thread [Next in Thread]