diff options
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/make.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/miscutils/make.c b/miscutils/make.c index cc5e7ca92..df810677f 100644 --- a/miscutils/make.c +++ b/miscutils/make.c | |||
@@ -188,6 +188,7 @@ struct name { | |||
188 | #define N_SPECIAL 0x80 // Special target | 188 | #define N_SPECIAL 0x80 // Special target |
189 | #define N_MARK 0x100 // Mark for deduplication | 189 | #define N_MARK 0x100 // Mark for deduplication |
190 | #define N_PHONY 0x200 // Name is a phony target | 190 | #define N_PHONY 0x200 // Name is a phony target |
191 | #define N_INFERENCE 0x400 // Inference rule | ||
191 | 192 | ||
192 | // List of rules to build a target | 193 | // List of rules to build a target |
193 | struct rule { | 194 | struct rule { |
@@ -736,7 +737,10 @@ addrule(struct name *np, struct depend *dp, struct cmd *cp, int flag) | |||
736 | 737 | ||
737 | if (cp && !(np->n_flag & N_DOUBLE) && getcmd(np)) { | 738 | if (cp && !(np->n_flag & N_DOUBLE) && getcmd(np)) { |
738 | // Handle the inference rule redefinition case | 739 | // Handle the inference rule redefinition case |
739 | if ((np->n_flag & N_SPECIAL) && !dp) { | 740 | // .DEFAULT rule can also be redefined (as an extension). |
741 | if ((np->n_flag & N_INFERENCE) | ||
742 | && !(posix && (np->n_flag & N_SPECIAL)) | ||
743 | ) { | ||
740 | freerules(np->n_rule); | 744 | freerules(np->n_rule); |
741 | np->n_rule = NULL; | 745 | np->n_rule = NULL; |
742 | } else { | 746 | } else { |
@@ -2343,12 +2347,19 @@ input(FILE *fd, int ilevel) | |||
2343 | 2347 | ||
2344 | np = newname(files[i]); | 2348 | np = newname(files[i]); |
2345 | if (ttype != T_NORMAL) { | 2349 | if (ttype != T_NORMAL) { |
2346 | if (ttype == T_INFERENCE && posix) { | 2350 | if (ttype == T_INFERENCE) { |
2347 | if (semicolon_cmd) | 2351 | if (posix) { |
2348 | error_in_inference_rule("'; command'"); | 2352 | if (semicolon_cmd) |
2349 | seen_inference = TRUE; | 2353 | error_in_inference_rule("'; command'"); |
2354 | seen_inference = TRUE; | ||
2355 | } | ||
2356 | np->n_flag |= N_INFERENCE; | ||
2357 | } else if (strcmp(p, ".DEFAULT") == 0) { | ||
2358 | // .DEFAULT rule is a special case | ||
2359 | np->n_flag |= N_SPECIAL | N_INFERENCE; | ||
2360 | } else { | ||
2361 | np->n_flag |= N_SPECIAL; | ||
2350 | } | 2362 | } |
2351 | np->n_flag |= N_SPECIAL; | ||
2352 | } else if (!firstname) { | 2363 | } else if (!firstname) { |
2353 | firstname = np; | 2364 | firstname = np; |
2354 | } | 2365 | } |
@@ -2358,7 +2369,7 @@ input(FILE *fd, int ilevel) | |||
2358 | if (files != &p) | 2369 | if (files != &p) |
2359 | globfree(&gd); | 2370 | globfree(&gd); |
2360 | } | 2371 | } |
2361 | if (seen_inference && count != 1) | 2372 | if (posix && seen_inference && count != 1) |
2362 | error_in_inference_rule("multiple targets"); | 2373 | error_in_inference_rule("multiple targets"); |
2363 | 2374 | ||
2364 | // Prerequisites and commands will be unused if there were | 2375 | // Prerequisites and commands will be unused if there were |