diff options
-rw-r--r-- | miscutils/make.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/miscutils/make.c b/miscutils/make.c index bd3b23f21..8d953f9fc 100644 --- a/miscutils/make.c +++ b/miscutils/make.c | |||
@@ -2073,23 +2073,27 @@ input(FILE *fd, int ilevel) | |||
2073 | if (ilevel > 16) | 2073 | if (ilevel > 16) |
2074 | error("too many includes"); | 2074 | error("too many includes"); |
2075 | 2075 | ||
2076 | count = 0; | ||
2076 | q = expanded = expand_macros(p + 7, FALSE); | 2077 | q = expanded = expand_macros(p + 7, FALSE); |
2077 | while ((p = gettok(&q)) != NULL) { | 2078 | while ((p = gettok(&q)) != NULL) { |
2078 | FILE *ifd; | 2079 | FILE *ifd; |
2079 | 2080 | ||
2081 | ++count; | ||
2080 | if (!POSIX_2017) { | 2082 | if (!POSIX_2017) { |
2081 | // Try to create include file or bring it up-to-date | 2083 | // Try to create include file or bring it up-to-date |
2082 | opts |= OPT_include; | 2084 | opts |= OPT_include; |
2083 | make(newname(p), 1); | 2085 | make(newname(p), 1); |
2084 | opts &= ~OPT_include; | 2086 | opts &= ~OPT_include; |
2085 | } | 2087 | } |
2086 | makefile = p; | ||
2087 | if ((ifd = fopen(p, "r")) == NULL) { | 2088 | if ((ifd = fopen(p, "r")) == NULL) { |
2088 | if (!minus) | 2089 | if (!minus) |
2089 | error("can't open include file '%s'", p); | 2090 | error("can't open include file '%s'", p); |
2090 | } else { | 2091 | } else { |
2092 | makefile = p; | ||
2091 | input(ifd, ilevel + 1); | 2093 | input(ifd, ilevel + 1); |
2092 | fclose(ifd); | 2094 | fclose(ifd); |
2095 | makefile = old_makefile; | ||
2096 | lineno = old_lineno; | ||
2093 | } | 2097 | } |
2094 | if (POSIX_2017) | 2098 | if (POSIX_2017) |
2095 | break; | 2099 | break; |
@@ -2100,14 +2104,11 @@ input(FILE *fd, int ilevel) | |||
2100 | if (p == NULL || gettok(&q)) { | 2104 | if (p == NULL || gettok(&q)) { |
2101 | error("one include file per line"); | 2105 | error("one include file per line"); |
2102 | } | 2106 | } |
2103 | } else if (makefile == old_makefile) { | 2107 | } else if (count == 0) { |
2104 | // In POSIX 2024 no include file is unspecified behaviour. | 2108 | // In POSIX 2024 no include file is unspecified behaviour. |
2105 | if (posix) | 2109 | if (posix) |
2106 | error("no include file"); | 2110 | error("no include file"); |
2107 | } | 2111 | } |
2108 | |||
2109 | makefile = old_makefile; | ||
2110 | lineno = old_lineno; | ||
2111 | goto end_loop; | 2112 | goto end_loop; |
2112 | } | 2113 | } |
2113 | 2114 | ||