help-make
[Top][All Lists]
Advanced

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

non-existent prerequisite w/ empty rule makes target out of date


From: gk
Subject: non-existent prerequisite w/ empty rule makes target out of date
Date: Tue, 24 Jun 2003 16:24:17 -0700

I have discovered a behavior that seems a bit odd; would appreciate thoughts on this:
* a rule with prerequisite file that doesn't exist: 'afile'
* an empty rule for 'afile'
=> target is never considered 'up to date'

It would seem to me that, since an empty rule is defined for 'afile', make should know that, since this prerequisite file does not exist and CANNOT be created, it cannot possibly make the target out of date, yet it does.

I want the prerequisite file to affect building target, only if it exists; otherwise target should be considered up to date.
How best to achieve this?
('afile' would be created manually, not by make.)

# Makefile

target: afile
        @echo 'building $@';\
        touch $@
        
afile:;
#eof

address@hidden junk]$ ls afile
ls: afile: No such file or directory
address@hidden junk]$ make target
building target
address@hidden junk]$ make target
building target
address@hidden junk]$ touch afile
address@hidden junk]$ make target
building target
address@hidden junk]$ make target
make: `target' is up to date.
address@hidden junk]$
- Greg Keraunen
http://www.xmake.org





reply via email to

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