diff options
author | Ron Yorston <rmy@pobox.com> | 2025-01-16 14:07:13 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2025-01-16 14:13:56 +0000 |
commit | 73ca192b94f06c24d9638aebf271eaf2a6bd92d5 (patch) | |
tree | e0a13e650a8f4ad4e2a56178e6bce285d2f5443c | |
parent | 91b6c18d4aa435073e3a6f62dd011b9787103157 (diff) | |
download | busybox-w32-73ca192b94f06c24d9638aebf271eaf2a6bd92d5.tar.gz busybox-w32-73ca192b94f06c24d9638aebf271eaf2a6bd92d5.tar.bz2 busybox-w32-73ca192b94f06c24d9638aebf271eaf2a6bd92d5.zip |
make: phony targets and double colon rules
Commit 770bad1fe (make: disallow inference rules for phony targets)
added the GNU/BSD make feature that inference rules aren't used
for phony targets.
Normally a double-colon rule without associated commands causes
an inference rule search. If the target of the double-colon rule
was phony no search was carried out and the rule failed. As a
result of this perl failed to build (on Linux, I didn't try on
Windows).
When a double-colon rule has no commands and a phony target the
prerequisites should be built and the rule should succeed.
Adds 32 bytes.
(pdpmake GitHub issue #70)
-rw-r--r-- | miscutils/make.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/miscutils/make.c b/miscutils/make.c index 333f8bf12..ceac1d91d 100644 --- a/miscutils/make.c +++ b/miscutils/make.c | |||
@@ -2838,11 +2838,13 @@ make(struct name *np, int level) | |||
2838 | } | 2838 | } |
2839 | } else { | 2839 | } else { |
2840 | // If any double-colon rule has no commands we need | 2840 | // If any double-colon rule has no commands we need |
2841 | // an inference rule (but, as an extension, not for phony targets) | 2841 | // an inference rule. |
2842 | for (rp = np->n_rule; rp; rp = rp->r_next) { | 2842 | for (rp = np->n_rule; rp; rp = rp->r_next) { |
2843 | if (!rp->r_cmd) { | 2843 | if (!rp->r_cmd) { |
2844 | if (posix || !(np->n_flag & N_PHONY)) | 2844 | // Phony targets don't need an inference rule. |
2845 | impdep = dyndep(np, &infrule, &tsuff); | 2845 | if (!posix && (np->n_flag & N_PHONY)) |
2846 | continue; | ||
2847 | impdep = dyndep(np, &infrule, &tsuff); | ||
2846 | if (!impdep) { | 2848 | if (!impdep) { |
2847 | if (doinclude) | 2849 | if (doinclude) |
2848 | return 1; | 2850 | return 1; |
@@ -2868,11 +2870,14 @@ make(struct name *np, int level) | |||
2868 | // Each double-colon rule is handled separately. | 2870 | // Each double-colon rule is handled separately. |
2869 | if ((np->n_flag & N_DOUBLE)) { | 2871 | if ((np->n_flag & N_DOUBLE)) { |
2870 | // If the rule has no commands use the inference rule. | 2872 | // If the rule has no commands use the inference rule. |
2873 | // Unless there isn't one, as allowed for phony targets. | ||
2871 | if (!rp->r_cmd) { | 2874 | if (!rp->r_cmd) { |
2872 | locdep = impdep; | 2875 | if (impdep) { |
2873 | infrule.r_dep->d_next = rp->r_dep; | 2876 | locdep = impdep; |
2874 | rp->r_dep = infrule.r_dep; | 2877 | infrule.r_dep->d_next = rp->r_dep; |
2875 | rp->r_cmd = infrule.r_cmd; | 2878 | rp->r_dep = infrule.r_dep; |
2879 | rp->r_cmd = infrule.r_cmd; | ||
2880 | } | ||
2876 | } | 2881 | } |
2877 | // A rule with no prerequisities is executed unconditionally. | 2882 | // A rule with no prerequisities is executed unconditionally. |
2878 | if (!rp->r_dep) | 2883 | if (!rp->r_dep) |