diff options
author | Ron Yorston <rmy@pobox.com> | 2025-01-22 15:09:11 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2025-01-22 15:09:11 +0000 |
commit | 820ade383860692d0b5abbba00a3e428f21b88e4 (patch) | |
tree | d77db3bff40f94f491c58cfc7bd8d882ec1f6a41 | |
parent | 89b641cbb52bdc29e7e078c7f1ebcfbe7364ba18 (diff) | |
download | busybox-w32-820ade383860692d0b5abbba00a3e428f21b88e4.tar.gz busybox-w32-820ade383860692d0b5abbba00a3e428f21b88e4.tar.bz2 busybox-w32-820ade383860692d0b5abbba00a3e428f21b88e4.zip |
make: fix detection of target rule with inline command
Commit f9d10b2b6 (make: fix detection of target rules (take 2))
added code to handle the case where a target rule had an inline
command with a ';' separator in a macro. This required all macros
on the line to be expanded, including those in the inline command.
The ';' should first be searched for in the original line (without
any macro expansion) and only if that fails should macros be
expanded.
This matches the behaviour of GNU and Unix V7 make. BSD and Schily
make don't handle the case where the ';' is in a macro.
(pdpmake GitHub issue 73)
-rw-r--r-- | miscutils/make.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/miscutils/make.c b/miscutils/make.c index 39c0081ab..a165274aa 100644 --- a/miscutils/make.c +++ b/miscutils/make.c | |||
@@ -2171,6 +2171,20 @@ pragmas_from_env(void) | |||
2171 | #endif | 2171 | #endif |
2172 | 2172 | ||
2173 | /* | 2173 | /* |
2174 | * Determine if a line is a target rule with an inline command. | ||
2175 | * Return a pointer to the semicolon separator if it is, else NULL. | ||
2176 | */ | ||
2177 | static char * | ||
2178 | inline_command(char *line) | ||
2179 | { | ||
2180 | char *p = find_char(line, ':'); | ||
2181 | |||
2182 | if (p) | ||
2183 | p = strchr(p, ';'); | ||
2184 | return p; | ||
2185 | } | ||
2186 | |||
2187 | /* | ||
2174 | * Parse input from the makefile and construct a tree structure of it. | 2188 | * Parse input from the makefile and construct a tree structure of it. |
2175 | */ | 2189 | */ |
2176 | static void | 2190 | static void |
@@ -2389,9 +2403,9 @@ input(FILE *fd, int ilevel) | |||
2389 | cp = NULL; | 2403 | cp = NULL; |
2390 | s = strchr(q, ';'); | 2404 | s = strchr(q, ';'); |
2391 | if (s) { | 2405 | if (s) { |
2392 | // Retrieve command from expanded copy of line | 2406 | // Retrieve command from original or expanded copy of line |
2393 | char *copy3 = expand_macros(copy, FALSE); | 2407 | char *copy3 = expand_macros(copy, FALSE); |
2394 | if ((p = find_colon(copy3)) && (p = strchr(p, ';'))) | 2408 | if ((p = inline_command(copy)) || (p = inline_command(copy3))) |
2395 | newcmd(&cp, process_command(p + 1)); | 2409 | newcmd(&cp, process_command(p + 1)); |
2396 | free(copy3); | 2410 | free(copy3); |
2397 | *s = '\0'; | 2411 | *s = '\0'; |