[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: HELP! $(wildcard ) function failed very strangely
From: |
Kristof Provost |
Subject: |
Re: HELP! $(wildcard ) function failed very strangely |
Date: |
Sun, 30 Sep 2007 16:48:02 +0200 |
User-agent: |
Mutt/1.5.15+20070412 (2007-04-11) |
On 2007-09-30 13:39:47 (+0000), Chen??????Jun?????? <address@hidden> wrote:
> 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.
The commands are deferred, but the expansion of the variables is not.
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.
> Can you or someone give further explain?
It looks like I wasn't quite right though. My proposal still doesn't
work, as the $(match) variable is expanded when the rule is parsed, not
when it's executed. SECONDEXPANSION could help, but that only works for
prerequisites.
The only solution I see is to use shell tests:
testrule:
touch test
if [ -f test ] ;\
then \
echo "test exists" ;\
fi
Does anyone else know a better way of handling this?
Regards,
Kristof
signature.asc
Description: Digital signature