2 * Copyright (c) 1988, 1989, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1989 by Berkeley Softworks
7 * This code is derived from software contributed to Berkeley by
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * @(#) Copyright (c) 1988, 1989, 1990, 1993 The Regents of the University of California. All rights reserved.
39 * @(#)main.c 8.3 (Berkeley) 3/19/94
40 * $FreeBSD: src/usr.bin/make/main.c,v 1.118 2005/02/13 13:33:56 harti Exp $
41 * $DragonFly: src/usr.bin/make/main.c,v 1.119 2005/06/19 14:31:03 okumoto Exp $
46 * The main file for this entire program. Exit routines etc
49 * Utility functions defined in this file:
51 * Takes a line of arguments, breaks them and
52 * treats them as if they were given when first
53 * invoked. Used by the parse module to implement
58 #include <sys/utsname.h>
60 #include <sys/param.h>
63 #include <sys/queue.h>
64 #include <sys/resource.h>
80 #include "pathnames.h"
88 extern char **environ; /* XXX what header declares this variable? */
92 * This control the default concurrency. On no occasion will more
93 * than DEFMAXJOBS targets be created at once.
97 typedef struct MakeFlags {
98 /** ordered list of makefiles to read */
101 /** list of variables to print */
104 /** Targets to be made */
107 /** directories to search when looking for includes */
108 struct Path parseIncPath;
110 /** directories to search when looking for system includes */
111 struct Path sysIncPath;
113 Boolean expandVars; /* fully expand printed variables */
114 Boolean builtins; /* -r flag */
115 Boolean forceJobs; /* -j argument given */
119 * TRUE if we aren't supposed to really make anything, just
120 * see if the targets are out-of-date
125 /* (-E) vars to override from env */
126 Lst envFirstVars = Lst_Initializer(envFirstVars);
128 Boolean allPrecious; /* .PRECIOUS given on line by itself */
129 Boolean beSilent; /* -s flag */
130 Boolean beVerbose; /* -v flag */
131 Boolean compatMake; /* -B argument */
132 Boolean debug; /* -d flag */
133 Boolean ignoreErrors; /* -i flag */
134 int jobLimit; /* -j argument */
135 Boolean jobsRunning; /* TRUE if the jobs might be running */
136 Boolean keepgoing; /* -k flag */
137 Boolean noExecute; /* -n flag */
138 Boolean touchFlag; /* -t flag */
139 Boolean usePipes; /* !-P flag */
140 uint32_t warn_cmd; /* command line warning flags */
141 uint32_t warn_flags; /* actual warning flags */
142 uint32_t warn_nocmd; /* command line no-warning flags */
144 time_t now; /* Time at start of make */
145 struct GNode *DEFAULT; /* .DEFAULT node */
149 * Exit with usage message.
155 "usage: make [-BPSXeiknqrstv] [-C directory] [-D variable]\n"
156 "\t[-d flags] [-E variable] [-f makefile] [-I directory]\n"
157 "\t[-j max_jobs] [-m directory] [-V variable]\n"
158 "\t[variable=value] [target ...]\n");
164 * Append a flag with an optional argument to MAKEFLAGS and MFLAGS
167 MFLAGS_append(const char *flag, char *arg)
171 Var_Append(".MAKEFLAGS", flag, VAR_GLOBAL);
173 str = MAKEFLAGS_quote(arg);
174 Var_Append(".MAKEFLAGS", str, VAR_GLOBAL);
178 Var_Append("MFLAGS", flag, VAR_GLOBAL);
180 str = MAKEFLAGS_quote(arg);
181 Var_Append("MFLAGS", str, VAR_GLOBAL);
187 * Open and parse the given makefile.
190 * TRUE if ok. FALSE if couldn't open file.
193 ReadMakefile(Parser *parser, MakeFlags *mf, const char file[], const char curdir[], const char objdir[])
195 char path[MAXPATHLEN];
200 if (!strcmp(file, "-")) {
201 Parse_File(parser, mf, "(stdin)", stdin);
202 Var_SetGlobal("MAKEFILE", "");
206 if (strcmp(curdir, objdir) == 0 || file[0] == '/') {
210 * we've chdir'd, rebuild the path name
212 snprintf(path, MAXPATHLEN, "%s/%s", curdir, file);
214 #if THIS_BREAKS_THINGS
216 * XXX The realpath stuff breaks relative includes
217 * XXX in some cases. The problem likely is in
218 * XXX parse.c where it does special things in
219 * XXX ParseDoInclude if the file is relateive
220 * XXX or absolute and not a system file. There
221 * XXX it assumes that if the current file that's
222 * XXX being included is absolute, that any files
223 * XXX that it includes shouldn't do the -I path
224 * XXX stuff, which is inconsistant with historical
225 * XXX behavior. However, I can't pentrate the mists
226 * XXX further, so I'm putting this workaround in
227 * XXX here until such time as the underlying bug
230 if (realpath(path, path) == NULL) {
233 stream = fopen(path, "r");
236 stream = fopen(path, "r");
238 if (stream != NULL) {
239 if (strcmp(file, ".depend") != 0)
240 Var_SetGlobal("MAKEFILE", file);
241 Parse_File(parser, mf, path, stream);
246 /* look in -I and system include directories. */
247 fname = estrdup(file);
250 name = Path_FindFile(fname, &mf->parseIncPath);
252 name = Path_FindFile(fname, &mf->sysIncPath);
255 stream = fopen(name, "r");
256 if (stream != NULL) {
258 * set the MAKEFILE variable desired by System V fans
259 * -- the placement of the setting here means it gets
260 * set to the last makefile specified, as it is set
263 if (strcmp(file, ".depend") != 0)
264 Var_SetGlobal("MAKEFILE", name);
265 Parse_File(parser, mf, name, stream);
271 return (FALSE); /* no makefile found */
275 * Read in the built-in rules first, followed by the specified
276 * makefiles or the one of the default makefiles. Finally .depend
280 ReadInputFiles(Parser *parser, MakeFlags *mf, const char curdir[], const char objdir[])
284 Lst sysMkPath = Lst_Initializer(sysMkPath);
286 char defsysmk[] = PATH_DEFSYSMK;
288 Path_Expand(defsysmk, &mf->sysIncPath, &sysMkPath);
289 if (Lst_IsEmpty(&sysMkPath))
290 Fatal("make: no system rules (%s).", PATH_DEFSYSMK);
291 LST_FOREACH(ln, &sysMkPath) {
292 if (!ReadMakefile(parser, mf, Lst_Datum(ln), curdir, objdir))
296 Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
297 Lst_Destroy(&sysMkPath, free);
300 if (!Lst_IsEmpty(&mf->makefiles)) {
303 LST_FOREACH(ln, &mf->makefiles) {
304 if (!ReadMakefile(parser, mf, Lst_Datum(ln), curdir, objdir))
308 Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
309 } else if (ReadMakefile(parser, mf, "BSDmakefile", curdir, objdir)) {
310 /* read BSDmakefile */
311 } else if (ReadMakefile(parser, mf, "makefile", curdir, objdir)) {
313 } else if (ReadMakefile(parser, mf, "Makefile", curdir, objdir)) {
316 /* No Makefile found */
319 ReadMakefile(parser, mf, ".depend", curdir, objdir);
325 * Handle argument to warning option.
328 Main_ParseWarn(const char *arg, int iscmd)
332 static const struct {
336 { "dirsyntax", WARN_DIRSYNTAX },
341 if (arg[0] == 'n' && arg[1] == 'o') {
346 for (i = 0; options[i].option != NULL; i++)
347 if (strcmp(arg, options[i].option) == 0)
350 if (options[i].option == NULL)
356 warn_cmd |= options[i].flag;
357 warn_nocmd &= ~options[i].flag;
358 warn_flags |= options[i].flag;
360 warn_nocmd |= options[i].flag;
361 warn_cmd &= ~options[i].flag;
362 warn_flags &= ~options[i].flag;
366 warn_flags |= (options[i].flag & ~warn_nocmd);
368 warn_flags &= ~(options[i].flag | warn_cmd);
376 * Parse a given argument vector. Called from main() and from
377 * Main_ParseArgLine() when the .MAKEFLAGS target is used.
379 * XXX: Deal with command line overriding .MAKEFLAGS in makefile
382 * Various global and local flags will be set depending on the flags
386 MainParseArgs(MakeFlags *mf, int argc, char **argv)
389 Boolean found_dd = FALSE;
392 optind = 1; /* since we're called more than once */
394 #define OPTFLAGS "ABC:D:E:I:PSV:Xd:ef:ij:km:nqrstvx:"
396 if ((optind < argc) && strcmp(argv[optind], "--") == 0) {
399 if ((c = getopt(argc, argv, OPTFLAGS)) == -1) {
406 MFLAGS_append("-A", NULL);
409 if (chdir(optarg) == -1)
410 err(1, "chdir %s", optarg);
413 Var_SetGlobal(optarg, "1");
414 MFLAGS_append("-D", optarg);
417 Path_AddDir(&mf->parseIncPath, optarg);
418 MFLAGS_append("-I", optarg);
421 Lst_AtEnd(&mf->variables, estrdup(optarg));
422 MFLAGS_append("-V", optarg);
425 mf->expandVars = FALSE;
429 MFLAGS_append("-B", NULL);
430 unsetenv("MAKE_JOBS_FIFO");
434 MFLAGS_append("-P", NULL);
438 MFLAGS_append("-S", NULL);
441 char *modules = optarg;
443 for (; *modules; ++modules)
461 if (modules[1] == '1') {
462 debug |= DEBUG_GRAPH1;
465 else if (modules[1] == '2') {
466 debug |= DEBUG_GRAPH2;
489 warnx("illegal argument to d option "
493 MFLAGS_append("-d", optarg);
497 Lst_AtEnd(&envFirstVars, estrdup(optarg));
498 MFLAGS_append("-E", optarg);
501 checkEnvFirst = TRUE;
502 MFLAGS_append("-e", NULL);
505 Lst_AtEnd(&mf->makefiles, estrdup(optarg));
509 MFLAGS_append("-i", NULL);
514 mf->forceJobs = TRUE;
515 jobLimit = strtol(optarg, &endptr, 10);
516 if (jobLimit <= 0 || *endptr != '\0') {
517 warnx("illegal number, -j argument -- %s",
521 MFLAGS_append("-j", optarg);
526 MFLAGS_append("-k", NULL);
529 Path_AddDir(&mf->sysIncPath, optarg);
530 MFLAGS_append("-m", optarg);
534 MFLAGS_append("-n", NULL);
537 mf->queryFlag = TRUE;
538 /* Kind of nonsensical, wot? */
539 MFLAGS_append("-q", NULL);
542 mf->builtins = FALSE;
543 MFLAGS_append("-r", NULL);
547 MFLAGS_append("-s", NULL);
551 MFLAGS_append("-t", NULL);
555 MFLAGS_append("-v", NULL);
558 if (Main_ParseWarn(optarg, 1) != -1)
559 MFLAGS_append("-x", optarg);
572 * Parse the rest of the arguments.
573 * o Check for variable assignments and perform them if so.
574 * o Check for more flags and restart getopt if so.
575 * o Anything else is taken to be a target and added
576 * to the end of the "create" list.
578 for (; *argv != NULL; ++argv, --argc) {
579 if (Parse_IsVar(*argv)) {
580 char *ptr = MAKEFLAGS_quote(*argv);
582 Var_Append(".MAKEFLAGS", ptr, VAR_GLOBAL);
583 Parse_DoVar(*argv, VAR_CMD);
586 } else if ((*argv)[0] == '-') {
587 if ((*argv)[1] == '\0') {
589 * (*argv) is a single dash, so we
592 } else if (found_dd) {
594 * Double dash has been found, ignore
595 * any more options. But what do we do
596 * with it? For now treat it like a target.
598 Lst_AtEnd(&mf->create, estrdup(*argv));
601 * (*argv) is a -flag, so backup argv and
602 * argc. getopt() expects options to start
603 * in the 2nd position.
610 } else if ((*argv)[0] == '\0') {
611 Punt("illegal (null) argument.");
614 Lst_AtEnd(&mf->create, estrdup(*argv));
621 * Used by the parse module when a .MFLAGS or .MAKEFLAGS target
622 * is encountered and by main() when reading the .MAKEFLAGS envariable.
623 * Takes a line of arguments and breaks it into its
624 * component words and passes those words and the number of them to the
625 * MainParseArgs function.
626 * The line should have all its leading whitespace removed.
629 * Only those that come from the various arguments.
632 Main_ParseArgLine(MakeFlags *mf, char line[], int mflags)
638 for (; *line == ' '; ++line)
644 MAKEFLAGS_break(&aa, line);
646 brk_string(&aa, line, TRUE);
648 MainParseArgs(mf, aa.argc, aa.argv);
653 * Try to change the current working directory to path, and return
654 * the whole path using getcwd().
656 * @note for amd managed mount points we really should use pawd(1).
659 chdir_verify_path(const char path[], char newdir[])
664 * Check if the path is a directory. If not fail without reporting
667 if (stat(path, &sb) < 0) {
670 if (S_ISDIR(sb.st_mode) == 0) {
675 * The path refers to a directory, so we try to change into it. If we
676 * fail, or we fail to obtain the path from root to the directory,
677 * then report an error and fail.
679 if (chdir(path) < 0) {
680 warn("warning: %s", path);
683 if (getcwd(newdir, MAXPATHLEN) == NULL) {
684 warn("warning: %s", path);
691 determine_objdir(const char machine[], char curdir[], char objdir[])
694 char newdir[MAXPATHLEN];
695 char mdpath[MAXPATHLEN];
699 * Find a path to where we are... [-C directory] might have changed
700 * our current directory.
702 if (getcwd(curdir, MAXPATHLEN) == NULL)
705 if (stat(curdir, &sa) == -1)
706 err(2, "%s", curdir);
709 * The object directory location is determined using the
710 * following order of preference:
712 * 1. MAKEOBJDIRPREFIX`cwd`
714 * 3. PATH_OBJDIR.${MACHINE}
716 * 5. PATH_OBJDIRPREFIX`cwd`
718 * If one of the first two fails, use the current directory.
719 * If the remaining three all fail, use the current directory.
721 if ((env = getenv("MAKEOBJDIRPREFIX")) != NULL) {
722 snprintf(mdpath, MAXPATHLEN, "%s%s", env, curdir);
723 if (chdir_verify_path(mdpath, newdir)) {
724 strcpy(objdir, newdir);
727 strcpy(objdir, curdir);
731 if ((env = getenv("MAKEOBJDIR")) != NULL) {
732 if (chdir_verify_path(env, newdir)) {
733 strcpy(objdir, newdir);
736 strcpy(objdir, curdir);
740 snprintf(mdpath, MAXPATHLEN, "%s.%s", PATH_OBJDIR, machine);
741 if (chdir_verify_path(mdpath, newdir)) {
742 strcpy(objdir, newdir);
746 if (chdir_verify_path(PATH_OBJDIR, newdir)) {
747 strcpy(objdir, newdir);
751 snprintf(mdpath, MAXPATHLEN, "%s%s", PATH_OBJDIRPREFIX, curdir);
752 if (chdir_verify_path(mdpath, newdir)) {
753 strcpy(objdir, newdir);
757 strcpy(objdir, curdir);
761 * Initialize various make variables.
762 * MAKE also gets this name, for compatibility
763 * .MAKEFLAGS gets set to the empty string just in case.
764 * MFLAGS also gets initialized empty, for compatibility.
767 InitVariables(MakeFlags *mf, int argc, char *argv[], char curdir[], char objdir[])
770 const char *machine_arch;
771 const char *machine_cpu;
776 Var_SetGlobal("MAKE", argv[0]);
777 Var_SetGlobal(".MAKEFLAGS", "");
778 Var_SetGlobal("MFLAGS", "");
780 Var_SetGlobal(".DIRECTIVE_MAKEENV", "YES");
781 Var_SetGlobal(".ST_EXPORTVAR", "YES");
783 Var_SetGlobal("MAKE_VERSION", MAKE_VERSION);
787 * Get the name of this type of MACHINE from utsname
788 * so we can share an executable for similar machines.
789 * (i.e. m68k: amiga hp300, mac68k, sun3, ...)
791 * Note that while MACHINE is decided at run-time,
792 * MACHINE_ARCH is always known at compile time.
794 if ((machine = getenv("MACHINE")) == NULL) {
798 static struct utsname utsname;
799 if (uname(&utsname) == -1)
801 machine = utsname.machine;
805 if ((machine_arch = getenv("MACHINE_ARCH")) == NULL) {
807 machine_arch = MACHINE_ARCH;
809 machine_arch = "unknown";
814 * Set machine_cpu to the minumum supported CPU revision based
815 * on the target architecture, if not already set.
817 if ((machine_cpu = getenv("MACHINE_CPU")) == NULL) {
818 if (!strcmp(machine_arch, "i386"))
819 machine_cpu = "i386";
820 else if (!strcmp(machine_arch, "alpha"))
823 machine_cpu = "unknown";
826 Var_SetGlobal("MACHINE", machine);
827 Var_SetGlobal("MACHINE_ARCH", machine_arch);
828 Var_SetGlobal("MACHINE_CPU", machine_cpu);
831 * First snag things out of the MAKEFLAGS environment
832 * variable. Then parse the command line arguments.
834 Main_ParseArgLine(mf, getenv("MAKEFLAGS"), 1);
836 MainParseArgs(mf, argc, argv);
838 determine_objdir(machine, curdir, objdir);
839 Var_SetGlobal(".CURDIR", curdir);
840 Var_SetGlobal(".OBJDIR", objdir);
843 * Set up the .TARGETS variable to contain the list of targets to be
844 * created. If none specified, make the variable empty -- the parser
845 * will fill the thing in with the default or .MAIN target.
847 if (Lst_IsEmpty(&mf->create)) {
848 Var_SetGlobal(".TARGETS", "");
852 for (ln = Lst_First(&mf->create); ln != NULL; ln = Lst_Succ(ln)) {
853 char *name = Lst_Datum(ln);
855 Var_Append(".TARGETS", name, VAR_GLOBAL);
861 build_stuff(MakeFlags *mf)
863 Boolean outOfDate; /* FALSE if all targets up to date */
868 * We have read the entire graph and need to make
869 * a list of targets to create. If none were given
870 * on the command line, we consult the parsing
871 * module to find the main target(s) to create.
873 Lst targs = Lst_Initializer(targs);
875 if (Lst_IsEmpty(&mf->create))
876 Parse_MainName(&targs);
878 Targ_FindList(&targs, &mf->create, TARG_CREATE);
880 /* Traverse the graph, checking on all the targets */
882 outOfDate = Compat_Run(&targs, mf->queryFlag);
884 outOfDate = Make_Run(&targs, mf->queryFlag);
886 Lst_Destroy(&targs, NOFREE);
888 return (mf->queryFlag && outOfDate) ? 1 : 0;
893 * The main function, for obvious reasons. Initializes variables
894 * and a few modules, then parses the arguments give it in the
895 * environment and on the command line. Reads the system makefile
896 * followed by either Makefile, makefile or the file given by the
897 * -f argument. Sets the .MAKEFLAGS PMake variable based on all the
898 * flags it has received by then uses either the Make or the Compat
899 * module to create the initial list of targets.
902 * If -q was given, exits -1 if anything was out-of-date. Else it exits
906 * The program exits when done. Targets are created. etc. etc. etc.
909 main(int argc, char **argv)
913 int status; /* exit status */
914 char curdir[MAXPATHLEN]; /* startup directory */
915 char objdir[MAXPATHLEN]; /* where we chdir'ed to */
917 /*------------------------------------------------------------*
918 * This section initializes variables that require no input.
919 *------------------------------------------------------------*/
921 * Initialize program global variables.
923 beSilent = FALSE; /* Print commands as executed */
924 ignoreErrors = FALSE; /* Pay attention to non-zero returns */
925 noExecute = FALSE; /* Execute all commands */
926 keepgoing = FALSE; /* Stop on error */
927 allPrecious = FALSE; /* Remove targets when interrupted */
928 touchFlag = FALSE; /* Actually update targets */
929 usePipes = TRUE; /* Catch child output in pipes */
930 debug = 0; /* No debug verbosity, please. */
933 jobLimit = DEFMAXJOBS;
934 compatMake = FALSE; /* No compat mode */
937 * Initialize make flags variable.
939 Lst_Init(&mf.makefiles);
940 Lst_Init(&mf.variables);
941 Lst_Init(&mf.create);
942 TAILQ_INIT(&mf.parseIncPath);
943 TAILQ_INIT(&mf.sysIncPath);
945 mf.expandVars = TRUE;
946 mf.builtins = TRUE; /* Read the built-in rules */
947 mf.queryFlag = FALSE;
949 /*------------------------------------------------------------*
950 * This section initializes variables that depend on things
951 * in the enviornment, command line, or a input file.
952 *------------------------------------------------------------*/
953 if (getenv("MAKE_JOBS_FIFO") == NULL)
954 mf.forceJobs = FALSE;
958 parser.create = &mf.create;
959 parser.parseIncPath = &mf.parseIncPath;
960 parser.sysIncPath = &mf.sysIncPath;
963 * Initialize the parsing, directory and variable modules to prepare
964 * for the reading of inclusion paths and variable settings on the
968 Shell_Init(DEFSHELLNAME);
970 InitVariables(&mf, argc, argv, curdir, objdir);
973 * Once things are initialized, add the original directory to the
974 * search path. The current directory is also placed as a variable
979 Dir_InitDot(); /* Initialize the "." directory */
981 if (strcmp(objdir, curdir) != 0)
982 Path_AddDir(&dirSearchPath, curdir);
985 * Be compatible if user did not specify -j and did not explicitly
986 * turned compatibility on
988 if (!compatMake && !mf.forceJobs)
992 * Initialize target and suffix modules in preparation for
993 * parsing the makefile(s)
1002 * If no user-supplied system path was given (through the -m option)
1003 * add the directories from the DEFSYSPATH (more than one may be given
1004 * as dir1:...:dirn) to the system include path.
1006 if (TAILQ_EMPTY(&mf.sysIncPath)) {
1007 char syspath[] = PATH_DEFSYSPATH;
1011 for (start = syspath; *start != '\0'; start = cp) {
1012 for (cp = start; *cp != '\0' && *cp != ':'; cp++)
1015 Path_AddDir(&mf.sysIncPath, start);
1018 Path_AddDir(&mf.sysIncPath, start);
1023 ReadInputFiles(&parser, &mf, curdir, objdir);
1025 /*------------------------------------------------------------*
1026 * We are finished processing inputs.
1027 *------------------------------------------------------------*/
1029 /* Install all the flags into the MAKE envariable. */
1033 if (((p = Var_Value(".MAKEFLAGS", VAR_GLOBAL)) != NULL) && *p)
1034 setenv("MAKEFLAGS", p, 1);
1038 * For compatibility, look at the directories in the VPATH variable
1039 * and add them to the search path, if the variable is defined. The
1040 * variable's value is in the same format as the PATH envariable, i.e.
1041 * <directory>:<directory>:<directory>...
1043 if (Var_Exists("VPATH", VAR_CMD)) {
1048 buf = Var_Subst("${VPATH}", VAR_CMD, FALSE);
1049 vpath = Buf_Data(buf);
1052 /* skip to end of directory */
1053 for (ptr = vpath; *ptr != ':' && *ptr != '\0'; ptr++)
1056 /* Save terminator character so know when to stop */
1060 /* Add directory to search path */
1061 Path_AddDir(&dirSearchPath, vpath);
1064 } while (savec != '\0');
1066 Buf_Destroy(buf, TRUE);
1070 * Now that all search paths have been read for suffixes et al, it's
1071 * time to add the default search path to their lists...
1075 /* print the initial graph, if the user requested it */
1079 if (Lst_IsEmpty(&mf.variables)) {
1080 status = build_stuff(&mf);
1082 /* Print the values of variables requested by the user. */
1083 Var_Print(&mf.variables, mf.expandVars);
1087 * This should be a "don't care", we do not check
1088 * the status of any files. It might make sense to
1089 * modify Var_Print() to indicate that one of the
1090 * requested variables did not exist, and use that
1091 * as the return status.
1094 status = mf.queryFlag ? 1 : 0;
1097 /* print the graph now it's been processed if the user requested it */
1102 TAILQ_DESTROY(&mf.sysIncPath);
1103 TAILQ_DESTROY(&mf.parseIncPath);
1105 Lst_Destroy(&mf.create, free);
1106 Lst_Destroy(&mf.makefiles, free);
1107 Lst_Destroy(&mf.variables, free);