aboutsummaryrefslogtreecommitdiff
path: root/miscutils/make.c
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils/make.c')
-rw-r--r--miscutils/make.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/miscutils/make.c b/miscutils/make.c
index d554a5f7f..8feec1202 100644
--- a/miscutils/make.c
+++ b/miscutils/make.c
@@ -293,6 +293,19 @@ vwarning(FILE *stream, const char *msg, va_list list)
293} 293}
294 294
295/* 295/*
296 * Diagnostic handler. Print message to standard error.
297 */
298static void
299diagnostic(const char *msg, ...)
300{
301 va_list list;
302
303 va_start(list, msg);
304 vwarning(stderr, msg, list);
305 va_end(list);
306}
307
308/*
296 * Error handler. Print message and exit. 309 * Error handler. Print message and exit.
297 */ 310 */
298static void error(const char *msg, ...) NORETURN; 311static void error(const char *msg, ...) NORETURN;
@@ -2111,7 +2124,7 @@ remove_target(void)
2111 if (!dryrun && !print && !precious && 2124 if (!dryrun && !print && !precious &&
2112 target && !(target->n_flag & (N_PRECIOUS | N_PHONY)) && 2125 target && !(target->n_flag & (N_PRECIOUS | N_PHONY)) &&
2113 unlink(target->n_name) == 0) { 2126 unlink(target->n_name) == 0) {
2114 warning("'%s' removed", target->n_name); 2127 diagnostic("'%s' removed", target->n_name);
2115 } 2128 }
2116} 2129}
2117 2130
@@ -2164,23 +2177,35 @@ docmds(struct name *np, struct cmd *cp)
2164 2177
2165 target = np; 2178 target = np;
2166 status = system(cmd); 2179 status = system(cmd);
2167 target = NULL;
2168 // If this command was being run to create an include file 2180 // If this command was being run to create an include file
2169 // or bring it up-to-date errors should be ignored and a 2181 // or bring it up-to-date errors should be ignored and a
2170 // failure status returned. 2182 // failure status returned.
2171 if (status == -1 && !doinclude) { 2183 if (status == -1 && !doinclude) {
2172 error("couldn't execute '%s'", q); 2184 error("couldn't execute '%s'", q);
2173 } else if (status != 0 && !signore) { 2185 } else if (status != 0 && !signore) {
2174 if (!doinclude) 2186 if (!posix && WIFSIGNALED(status))
2175 warning("failed to build '%s'", np->n_name);
2176#if !ENABLE_PLATFORM_MINGW32
2177 if (status == SIGINT || status == SIGQUIT)
2178#endif
2179 remove_target(); 2187 remove_target();
2180 if (errcont || doinclude) 2188 if (errcont || doinclude) {
2189 warning("failed to build '%s'", np->n_name);
2181 estat |= MAKE_FAILURE; 2190 estat |= MAKE_FAILURE;
2182 else 2191 } else {
2183 exit(status); 2192 const char *err_type = NULL;
2193 int err_value;
2194
2195 if (WIFEXITED(status)) {
2196 err_type = "exit";
2197 err_value = WEXITSTATUS(status);
2198 } else if (WIFSIGNALED(status)) {
2199 err_type = "signal";
2200 err_value = WTERMSIG(status);
2201 }
2202
2203 if (err_type)
2204 error("failed to build '%s' %s %d", np->n_name,
2205 err_type, err_value);
2206 else
2207 error("failed to build '%s'", np->n_name);
2208 }
2184 } 2209 }
2185 } 2210 }
2186 if (sdomake || dryrun || dotouch) 2211 if (sdomake || dryrun || dotouch)