help-make
[Top][All Lists]
Advanced

[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 16:51:22 +0000



>
> Try the following test case:
>
> testrule:
> touch test
> echo $(wildcard test)
>
> The echo command will not output anything (at least, if 'test' didn't
> exist when make started.
 
That's because, when deciding to make a rule, make expands ALL variables in ALL commands for that rule prior to executing the first command. Not as you have thought: expand variables in first command, execute first command, then go on for next command.
 
However, I have no idea why the make author chose the first way instead of "expand one command, execute one command". The official make manual seems not to have explained this.

>
>
> testrule:
> touch test
> if [ -f test ] ;\
> then \
> echo "test exists" ;\
> fi
>
 
Yes, I'm now working around like this, thanks again.

> Does anyone else know a better way of handling this?
>
> Regards,
> Kristof



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

reply via email to

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