From 89b641cbb52bdc29e7e078c7f1ebcfbe7364ba18 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 21 Jan 2025 09:25:46 +0000 Subject: make: fix single-suffix inference rule regression Commit 85bbce87d (make: support GNU/BSD suffixes and inference rules) added code to handle inference rules with arbitrary suffixes. Unfortunately it failed to check for a single-suffix rule in the case where no known suffix was found. Add the necessary code and a test which would have caught the problem. Adds 48 bytes. (pdpmake GitHub issue 72) --- miscutils/make.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'miscutils') diff --git a/miscutils/make.c b/miscutils/make.c index ceac1d91d..39c0081ab 100644 --- a/miscutils/make.c +++ b/miscutils/make.c @@ -1100,22 +1100,34 @@ dyndep(struct name *np, struct rule *infrule, const char **ptsuff) // targets of the form lib.a(member.o). if (!posix && member == NULL) { struct name *xp = newname(".SUFFIXES"); + int found_suffix = FALSE; + for (struct rule *rp = xp->n_rule; rp; rp = rp->r_next) { for (struct depend *dp = rp->r_dep; dp; dp = dp->d_next) { tsuff = dp->d_name->n_name; base = has_suffix(name, tsuff); if (base) { + found_suffix = TRUE; pp = dyndep0(base, tsuff, infrule); free(base); if (pp) { - if (ptsuff) - *ptsuff = tsuff; goto done; } } } } + if (!found_suffix) { + // The name didn't have a known suffix. Try single-suffix rule. + tsuff = ""; + pp = dyndep0(name, tsuff, infrule); + if (pp) { + done: + if (ptsuff) { + *ptsuff = tsuff; + } + } + } } else { tsuff = xstrdup(suffix(name)); base = member ? member : name; @@ -1124,7 +1136,6 @@ dyndep(struct name *np, struct rule *infrule, const char **ptsuff) pp = dyndep0(base, tsuff, infrule); free((void *)tsuff); } - done: free(name); return pp; -- cgit v1.2.3-55-g6feb