Look at this makefile.

====

IsFileExist = $(shell if [ -f $1 ]; then echo 1; fi )

outfile = out.txt

$(outfile):
        @echo "STRT: $@ $(if $(call IsFileExist,$@),exist,absent)"
        @touch $@
        @echo "DONE: $@ $(if $(call IsFileExist,$@),exist,absent)"

====

When outfile does not exist and we make it, make outputs

------

STRT: out.txt absent
DONE: out.txt absent

------

So we know all make-vars are expanded for all commands in a rule before the first command of that rule is really executed. But if I really like the example makefile to output

-------

STRT: out.txt absent
DONE: out.txt exist

-------

How can I do it? I know I can add another rule to accomplish that, e.g.

==========

IsFileExist = $(shell if [ -f $1 ]; then echo 1; fi )

outfile = out.txt

all: $(outfile)
        @echo "DONE: $(outfile) $(if $(call 
IsFileExist,$(outfile)),exist,absent)"

$(outfile):
        @echo "STRT: $@ $(if $(call IsFileExist,$@),exist,absent)"
        @touch $@


==========

But that complicates the makefile. Is there a way that I can do it with only one rule?

Thank you in advance.
begin:vcard
fn;quoted-printable:Chen Jun=EF=BC=88=E9=99=88=E5=86=9B=EF=BC=89
n:Chen;Jun
org:Fujian Newland Auto-ID Tech. Co,.Ltd.;Technical Department
adr:;;Newland Science & Technology Park, No.1 Rujiang Avenue, Mawei District, Fuzhou, China;Fuzhou;Fujian;350015;China
email;internet:[EMAIL PROTECTED]
title:Software Engineer
x-mozilla-html:TRUE
url:www.nlscan.com
version:2.1
end:vcard

_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to