dale@vicorp.UUCP (Dale Nielsen) (09/01/89)
I have a problem with the way gnu-make-3.55 identifies
implied phony targets. A target with no dependencies that
has rules associated with it is assumed to be a phony target
even though it is not declared as one.
I use file targets without dependencies in my makefiles to
create directories that only need to exist, not "updated".
Consider the following makefile:
#######################
.PHONY : all
all : dir/foo dir/bar
dir/foo : dir
touch $@
dir/bar : dir
touch $@
dir :
mkdir $@
#######################
The first time this is run we get:
mkdir dir
touch dir/foo
touch dir/bar
Which is ok.
The second time we get:
mkdir dir
mkdir: dir: File exists
Why should make update dir? It isn't a phony target and it
does exist so it shouldn't be remade.
Here is the diff -c output for what I changed in order to
fix it:
############################################################################
*** remake.c Fri Sep 1 12:05:40 1989
--- remake.c.orig Tue Aug 22 05:21:12 1989
***************
*** 449,464 ****
/* Here depth returns to the value it had when we were called. */
depth--;
- #ifdef IMPLIED_PHONY_TARGETS
if (file->deps == 0 && file->cmds != 0)
{
must_make = 1;
DEBUGPR ("Target `%s' has commands but no dependencies.\n");
}
! else
! #endif IMPLIED_PHONY_TARGETS
!
! if (!deps_changed && file->cmds == 0)
{
must_make = 0;
DEBUGPR ("No commands for `%s' and no dependencies actually changed.\n");
--- 449,460 ----
/* Here depth returns to the value it had when we were called. */
depth--;
if (file->deps == 0 && file->cmds != 0)
{
must_make = 1;
DEBUGPR ("Target `%s' has commands but no dependencies.\n");
}
! else if (!deps_changed && file->cmds == 0)
{
must_make = 0;
DEBUGPR ("No commands for `%s' and no dependencies actually changed.\n");
############################################################################
It seems to me that there should be no
implied PHONY targets, but I want to be sure I'm not
screwing something else up by doing this. Comments?
--
--Dale Nielsen ARPA: dale@vicorp.UU.NET
V. I. Corporation UUCP: uunet!vicorp!dale
Amherst Research Park PHONE: (413) 253-3482
Amherst, Massachusetts 01002 FAX: (413) 256-0574