tech-toolchain archive

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

make: wilcard targets and .PHONY



Back in 2000, the callpath through Suff_FindDeps was skipped for .PHONY
targets.
It turns out though that that is the only place where wildcard targets
are expanded.
Assuming there is something in ./sub/ the makefile:

.MAIN: all
all: subs

SUBS= sub/*
subs:   ${SUBS}
        @echo yay ${SUBS}

.ifdef PHONY
.PHONY: subs
.endif

works so long as PHONY isn't defined.

The patch below (sans fixing the indentation) pushes the PHONY check
lower so that wildcards can be expanded correctly, while still skipping 
most of the suffix related effort.

Index: suff.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/suff.c,v
retrieving revision 1.69
diff -u -p -r1.69 suff.c
--- suff.c      29 Sep 2011 23:38:04 -0000      1.69
+++ suff.c      16 May 2013 18:34:29 -0000
@@ -2058,6 +2058,10 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
      * children, then look for any overriding transformations they imply.
      * Should we find one, we discard the one we found before.
      */
+    bottom = NULL;
+    targ = NULL;
+
+    if (!(gn->type & OP_PHONY)) {
 
     while (ln != NULL) {
        /*
@@ -2171,6 +2175,7 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
        for (targ = bottom; targ->parent != NULL; targ = targ->parent)
            continue;
     }
+    }
 
     Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
 
@@ -2419,12 +2424,7 @@ SuffFindDeps(GNode *gn, Lst slst)
      */
     Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
     Var_Set(PREFIX, gn->name, gn, 0);
-    if (gn->type & OP_PHONY) {
-       /*
-        * If this is a .PHONY target, we do not apply suffix rules.
-        */
-       return;
-    }
+
     if (DEBUG(SUFF)) {
        fprintf(debug_file, "SuffFindDeps (%s)\n", gn->name);
     }


Home | Main Index | Thread Index | Old Index