aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miscutils/make.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/miscutils/make.c b/miscutils/make.c
index 25e3cc15a..08b9d806e 100644
--- a/miscutils/make.c
+++ b/miscutils/make.c
@@ -207,6 +207,10 @@ struct macro {
207# define P_WINDOWS 0x20 207# define P_WINDOWS 0x20
208#endif 208#endif
209 209
210// Status of make()
211#define MAKE_FAILURE 0x01
212#define MAKE_DIDSOMETHING 0x02
213
210#define HTABSIZE 39 214#define HTABSIZE 39
211 215
212struct globals { 216struct globals {
@@ -279,16 +283,13 @@ static int make(struct name *np, int level);
279 * Print message, with makefile and line number if possible. 283 * Print message, with makefile and line number if possible.
280 */ 284 */
281static void 285static void
282vwarning(const char *msg, va_list list) 286vwarning(FILE *stream, const char *msg, va_list list)
283{ 287{
284 const char *old_applet_name = applet_name; 288 fprintf(stream, "%s: ", applet_name);
285 289 if (makefile)
286 if (makefile) { 290 fprintf(stream, "(%s:%d): ", makefile, dispno);
287 fprintf(stderr, "%s: (%s:%d)", applet_name, makefile, dispno); 291 vfprintf(stream, msg, list);
288 applet_name = ""; 292 fputc('\n', stream);
289 }
290 bb_verror_msg(msg, list, NULL);
291 applet_name = old_applet_name;
292} 293}
293 294
294/* 295/*
@@ -301,7 +302,7 @@ error(const char *msg, ...)
301 va_list list; 302 va_list list;
302 303
303 va_start(list, msg); 304 va_start(list, msg);
304 vwarning(msg, list); 305 vwarning(stderr, msg, list);
305 va_end(list); 306 va_end(list);
306 exit(2); 307 exit(2);
307} 308}
@@ -326,7 +327,7 @@ warning(const char *msg, ...)
326 va_list list; 327 va_list list;
327 328
328 va_start(list, msg); 329 va_start(list, msg);
329 vwarning(msg, list); 330 vwarning(stdout, msg, list);
330 va_end(list); 331 va_end(list);
331} 332}
332 333
@@ -2120,7 +2121,7 @@ remove_target(void)
2120static int 2121static int
2121docmds(struct name *np, struct cmd *cp) 2122docmds(struct name *np, struct cmd *cp)
2122{ 2123{
2123 int estat = 0; // 0 exit status is success 2124 int estat = 0;
2124 char *q, *command; 2125 char *q, *command;
2125 2126
2126 for (; cp; cp = cp->c_next) { 2127 for (; cp; cp = cp->c_next) {
@@ -2164,6 +2165,7 @@ docmds(struct name *np, struct cmd *cp)
2164 target = np; 2165 target = np;
2165 status = system(cmd); 2166 status = system(cmd);
2166 target = NULL; 2167 target = NULL;
2168 estat = MAKE_DIDSOMETHING;
2167 // If this command was being run to create an include file 2169 // If this command was being run to create an include file
2168 // or bring it up-to-date errors should be ignored and a 2170 // or bring it up-to-date errors should be ignored and a
2169 // failure status returned. 2171 // failure status returned.
@@ -2177,7 +2179,7 @@ docmds(struct name *np, struct cmd *cp)
2177#endif 2179#endif
2178 remove_target(); 2180 remove_target();
2179 if (errcont || doinclude) 2181 if (errcont || doinclude)
2180 estat = 1; // 1 exit status is failure 2182 estat |= MAKE_FAILURE;
2181 else 2183 else
2182 exit(status); 2184 exit(status);
2183 } 2185 }
@@ -2217,7 +2219,7 @@ static int
2217make1(struct name *np, struct cmd *cp, char *oodate, char *allsrc, 2219make1(struct name *np, struct cmd *cp, char *oodate, char *allsrc,
2218 char *dedup, struct name *implicit) 2220 char *dedup, struct name *implicit)
2219{ 2221{
2220 int estat = 0; // 0 exit status is success 2222 int estat;
2221 char *name, *member = NULL, *base; 2223 char *name, *member = NULL, *base;
2222 2224
2223 name = splitlib(np->n_name, &member); 2225 name = splitlib(np->n_name, &member);
@@ -2285,8 +2287,7 @@ make(struct name *np, int level)
2285 char *allsrc = NULL; 2287 char *allsrc = NULL;
2286 char *dedup = NULL; 2288 char *dedup = NULL;
2287 struct timespec dtim = {1, 0}; 2289 struct timespec dtim = {1, 0};
2288 bool didsomething = 0; 2290 int estat = 0;
2289 bool estat = 0; // 0 exit status is success
2290 2291
2291 if (np->n_flag & N_DONE) 2292 if (np->n_flag & N_DONE)
2292 return 0; 2293 return 0;
@@ -2389,10 +2390,10 @@ make(struct name *np, int level)
2389 if ((np->n_flag & N_DOUBLE)) { 2390 if ((np->n_flag & N_DOUBLE)) {
2390 if (!quest && ((np->n_flag & N_PHONY) || 2391 if (!quest && ((np->n_flag & N_PHONY) ||
2391 timespec_le(&np->n_tim, &dtim))) { 2392 timespec_le(&np->n_tim, &dtim))) {
2392 if (estat == 0) { 2393 if (!(estat & MAKE_FAILURE)) {
2393 estat = make1(np, rp->r_cmd, oodate, allsrc, dedup, locdep); 2394 estat |= make1(np, rp->r_cmd, oodate, allsrc,
2395 dedup, locdep);
2394 dtim = (struct timespec){1, 0}; 2396 dtim = (struct timespec){1, 0};
2395 didsomething = 1;
2396 } 2397 }
2397 free(oodate); 2398 free(oodate);
2398 oodate = NULL; 2399 oodate = NULL;
@@ -2414,26 +2415,25 @@ make(struct name *np, int level)
2414 2415
2415 if (quest) { 2416 if (quest) {
2416 if (timespec_le(&np->n_tim, &dtim)) { 2417 if (timespec_le(&np->n_tim, &dtim)) {
2417 didsomething = 1; 2418 // MAKE_FAILURE means rebuild is needed
2418 estat = 1; // 1 means rebuild is needed 2419 estat = MAKE_FAILURE | MAKE_DIDSOMETHING;
2419 } 2420 }
2420 } else if (!(np->n_flag & N_DOUBLE) && 2421 } else if (!(np->n_flag & N_DOUBLE) &&
2421 ((np->n_flag & N_PHONY) || (timespec_le(&np->n_tim, &dtim)))) { 2422 ((np->n_flag & N_PHONY) || (timespec_le(&np->n_tim, &dtim)))) {
2422 if (estat == 0) { 2423 if (!(estat & MAKE_FAILURE)) {
2423 if (sc_cmd) 2424 if (sc_cmd)
2424 estat = make1(np, sc_cmd, oodate, allsrc, dedup, impdep); 2425 estat |= make1(np, sc_cmd, oodate, allsrc, dedup, impdep);
2425 else if (!doinclude) 2426 else if (!doinclude && level == 0 && !(estat & MAKE_DIDSOMETHING))
2426 warning("nothing to be done for %s", np->n_name); 2427 warning("nothing to be done for %s", np->n_name);
2427 didsomething = 1;
2428 } else if (!doinclude) { 2428 } else if (!doinclude) {
2429 warning("'%s' not built due to errors", np->n_name); 2429 warning("'%s' not built due to errors", np->n_name);
2430 } 2430 }
2431 free(oodate); 2431 free(oodate);
2432 } 2432 }
2433 2433
2434 if (didsomething) 2434 if (estat & MAKE_DIDSOMETHING)
2435 clock_gettime(CLOCK_REALTIME, &np->n_tim); 2435 clock_gettime(CLOCK_REALTIME, &np->n_tim);
2436 else if (!quest && level == 0) 2436 else if (!quest && level == 0 && !timespec_le(&np->n_tim, &dtim))
2437 printf("%s: '%s' is up to date\n", applet_name, np->n_name); 2437 printf("%s: '%s' is up to date\n", applet_name, np->n_name);
2438 2438
2439 free(allsrc); 2439 free(allsrc);
@@ -2918,5 +2918,5 @@ int make_main(int argc UNUSED_PARAM, char **argv)
2918 llist_free(dirs, NULL); 2918 llist_free(dirs, NULL);
2919#endif 2919#endif
2920 2920
2921 return estat; 2921 return estat & MAKE_FAILURE;
2922} 2922}