=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/main.c,v retrieving revision 1.126 retrieving revision 1.127 diff -u -r1.126 -r1.127 --- src/usr.bin/make/main.c 2020/01/13 15:19:04 1.126 +++ src/usr.bin/make/main.c 2020/01/13 15:41:53 1.127 @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.126 2020/01/13 15:19:04 espie Exp $ */ +/* $OpenBSD: main.c,v 1.127 2020/01/13 15:41:53 espie Exp $ */ /* $NetBSD: main.c,v 1.34 1997/03/24 20:56:36 gwr Exp $ */ /* @@ -57,15 +57,14 @@ #include "pathnames.h" #include "init.h" #include "job.h" -#include "compat.h" #include "targ.h" #include "suff.h" #include "str.h" #include "main.h" #include "lst.h" #include "memory.h" -#include "make.h" #include "dump.h" +#include "enginechoice.h" #define MAKEFLAGS ".MAKEFLAGS" @@ -629,30 +628,25 @@ Parse_End(); } +static void +run_node(GNode *gn, bool *has_errors, bool *out_of_date) +{ + LIST l; + Lst_Init(&l); + Lst_AtEnd(&l, gn); + engine_run_list(&l, has_errors, out_of_date); + Lst_Destroy(&l, NOFREE); +} + int main(int, char **); -/*- - * main -- - * The main function, for obvious reasons. Initializes variables - * and a few modules, then parses the arguments give it in the - * environment and on the command line. Reads the system makefile - * followed by either Makefile, makefile or the file given by the - * -f argument. Sets the .MAKEFLAGS PMake variable based on all the - * flags it has received by then uses either the Make or the Compat - * module to create the initial list of targets. - * - * Results: - * If -q was given, exits -1 if anything was out-of-date. Else it exits - * 0. - * - * Side Effects: - * The program exits when done. Targets are created. etc. etc. etc. - */ + int main(int argc, char **argv) { static LIST targs; /* target nodes to create */ - bool outOfDate = true; /* false if all targets up to date */ + bool outOfDate = false; /* false if all targets up to date */ + bool errored = false; /* true if errors occurred */ char *machine = figure_out_MACHINE(); char *machine_arch = figure_out_MACHINE_ARCH(); char *machine_cpu = figure_out_MACHINE_CPU(); @@ -671,6 +665,7 @@ Static_Lst_Init(&makefiles); Static_Lst_Init(&varstoprint); Static_Lst_Init(&targs); + Static_Lst_Init(&special); beSilent = false; /* Print commands as executed */ ignoreErrors = false; /* Pay attention to non-zero returns */ @@ -805,24 +800,26 @@ else Targ_FindList(&targs, create); - Job_Init(optj, compatMake); - /* If the user has defined a .BEGIN target, execute the commands - * attached to it. */ - if (!queryFlag) - Job_Begin(); - if (compatMake) - /* Compat_Init will take care of creating all the - * targets as well as initializing the module. */ - outOfDate = Compat_Run(&targs); - else { - /* Traverse the graph, checking on all the targets. */ - outOfDate = Make_Run(&targs); - } + choose_engine(compatMake); + Job_Init(optj); + if (!queryFlag && node_is_real(begin_node)) + run_node(begin_node, &errored, &outOfDate); + + if (!errored) + engine_run_list(&targs, &errored, &outOfDate); + + if (!queryFlag && !errored && node_is_real(end_node)) + run_node(end_node, &errored, &outOfDate); } /* print the graph now it's been processed if the user requested it */ if (DEBUG(GRAPH2)) post_mortem(); + + /* Note that we only hit this code if -k is used, otherwise we + * exited early in case of errors. */ + if (errored) + Fatal("Errors while building"); if (queryFlag && outOfDate) return 1;