> > On 2007-09-30 16:54:28 (+0800), Chen Jun (????) <[EMAIL PROTECTED]> 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(t.mk) 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 中最年轻的成员!
http://miaomiaogarden2007.spaces.live.com/
all: first_target
outfile = out.txt
match = $(wildcard $(outfile))
$(outfile):
@echo nnn > $@
.PHONY: prj_count
prj_count:
@echo "[[$(outfile)]] <<$(match)>> "
.PHONY: first_target
first_target: $(outfile) prj_count
@echo "[DONE]"
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make