diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2018-10-06 14:00:31 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2018-10-06 14:00:31 +0000 |
commit | 961f3c2701919bc3c6a8d76908ef5c0ea58cb25b (patch) | |
tree | bbd039f1eb92ad988ca187289b78e63b8b1f02e8 /usr.bin/make | |
parent | 1f768f20032e7612ec05d4df25c2838f9169c0d3 (diff) |
fix problem reported by markweston@cock.li
specifically:
- suffix rules for the empty suffix shouldn't be prevented from triggering
by having dependencies.
but this exhibits another issue:
- .PHONY targets shouldn't trigger suffix rules.
(also clean up an utility function)
NetBSD make has got similar modernizations, but the code is entirely
different by now.
okay kn@, millert@
Diffstat (limited to 'usr.bin/make')
-rw-r--r-- | usr.bin/make/suff.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index 347b29404d6..4974ab1083f 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: suff.c,v 1.92 2017/07/24 12:07:46 espie Exp $ */ +/* $OpenBSD: suff.c,v 1.93 2018/10/06 14:00:30 espie Exp $ */ /* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */ /* @@ -180,7 +180,7 @@ static Suff *add_suffixi(const char *, const char *); static void SuffInsert(Lst, Suff *); static void SuffAddSrc(void *, void *); -static int SuffRemoveSrc(Lst); +static bool SuffRemoveSrc(Lst); static void SuffAddLevel(Lst, Src *); static Src *SuffFindThem(Lst, Lst); static Src *SuffFindCmds(Src *, Lst); @@ -730,21 +730,16 @@ SuffAddLevel( /*- *---------------------------------------------------------------------- * SuffRemoveSrc -- - * Free all src structures in list that don't have a reference count + * Free Src structure with a zero reference count in a list * - * Results: - * Ture if an src was removed - * - * Side Effects: - * The memory is free'd. + * returns true if a src was removed *---------------------------------------------------------------------- */ -static int +static bool SuffRemoveSrc(Lst l) { LstNode ln; Src *s; - int t = 0; #ifdef DEBUG_SRC printf("cleaning %lx: ", (unsigned long)l); @@ -773,7 +768,6 @@ SuffRemoveSrc(Lst l) #endif Lst_Remove(l, ln); free(s); - t |= 1; return true; } #ifdef DEBUG_SRC @@ -785,7 +779,7 @@ SuffRemoveSrc(Lst l) #endif } - return t; + return false; } /*- @@ -1385,7 +1379,9 @@ SuffFindNormalDeps( Src *src; /* General Src pointer */ char *prefix; /* Prefix to use */ Src *targ; /* General Src target pointer */ + bool phony; + phony = (gn->type & OP_PHONY) == OP_PHONY; Lst_Init(&srcs); Lst_Init(&targs); @@ -1408,9 +1404,10 @@ SuffFindNormalDeps( * Should we find one, we discard the one we found before. */ - record_possible_suffixes(gn, &srcs, &targs); + if (!phony) + record_possible_suffixes(gn, &srcs, &targs); /* Handle target of unknown suffix... */ - if (Lst_IsEmpty(&srcs)) { + if (!phony && Lst_IsEmpty(&srcs)) { if (DEBUG(SUFF)) printf("\tNo known suffix on %s. Using empty suffix\n", gn->name); @@ -1428,7 +1425,7 @@ SuffFindNormalDeps( /* Only use the default suffix rules if we don't have commands * or dependencies defined for this gnode. */ - if (Lst_IsEmpty(&gn->commands) && Lst_IsEmpty(&gn->children)) + if (Lst_IsEmpty(&gn->commands)) SuffAddLevel(&srcs, targ); else { if (DEBUG(SUFF)) |