for (ln = Lst_First(create); ln != NULL;
for (ln = Lst_First(&create); ln != NULL;
main(argc, argv)	int argc;	char **argv;{	Lst targs;	/* target nodes to create -- passed to Make_Init */	Boolean outOfDate = TRUE; 	/* FALSE if all targets up to date */	struct stat sb, sa;	char *p, *path, *pathp, *pwd;	char mdpath[MAXPATHLEN + 1];	char obpath[MAXPATHLEN + 1];	char cdpath[MAXPATHLEN + 1];    	char *machine = getenv("MACHINE");	char *machine_arch = getenv("MACHINE_ARCH");	Lst sysMkPath;			/* Path of sys.mk */	char *cp = NULL, *start;					/* avoid faults on read-only strings */	static char syspath[] = _PATH_DEFSYSPATH;#ifdef RLIMIT_NOFILE	/*	 * get rid of resource limit on file descriptors	 */	{		struct rlimit rl;		if (getrlimit(RLIMIT_NOFILE, &rl) != -1 &&		    rl.rlim_cur != rl.rlim_max) {			rl.rlim_cur = rl.rlim_max;			(void) setrlimit(RLIMIT_NOFILE, &rl);		}	}#endif	/*	 * Find where we are and take care of PWD for the automounter...	 * All this code is so that we know where we are when we start up	 * on a different machine with pmake.	 */	curdir = cdpath;	if (getcwd(curdir, MAXPATHLEN) == NULL) {		(void)fprintf(stderr, "make: %s.\n", strerror(errno));		exit(2);	}	if (stat(curdir, &sa) == -1) {	    (void)fprintf(stderr, "make: %s: %s.\n",			  curdir, strerror(errno));	    exit(2);	}	if ((pwd = getenv("PWD")) != NULL) {	    if (stat(pwd, &sb) == 0 && sa.st_ino == sb.st_ino &&		sa.st_dev == sb.st_dev)		(void) strcpy(curdir, pwd);	}	/*	 * Get the name of this type of MACHINE from utsname	 * so we can share an executable for similar machines.	 * (i.e. m68k: amiga hp300, mac68k, sun3, ...)	 *	 * Note that both MACHINE and MACHINE_ARCH are decided at	 * run-time.	 */	if (!machine) {#ifndef MAKE_BOOTSTRAP	    struct utsname utsname;	    if (uname(&utsname) == -1) {		    perror("make: uname");		    exit(2);	    }	    machine = utsname.machine;#else	    machine = MACHINE;#endif	}	if (!machine_arch) {#ifndef MACHINE_ARCH	    machine_arch = "unknown";	/* XXX: no uname -p yet */#else	    machine_arch = MACHINE_ARCH;#endif	}	/*	 * If the MAKEOBJDIR (or by default, the _PATH_OBJDIR) directory	 * exists, change into it and build there.  (If a .${MACHINE} suffix	 * exists, use that directory instead).	 * Otherwise check MAKEOBJDIRPREFIX`cwd` (or by default,	 * _PATH_OBJDIRPREFIX`cwd`) and build there if it exists.	 * If all fails, use the current directory to build.	 *	 * Once things are initted,	 * have to add the original directory to the search path,	 * and modify the paths for the Makefiles apropriately.  The	 * current directory is also placed as a variable for make scripts.	 */	if (!(pathp = getenv("MAKEOBJDIRPREFIX"))) {		if (!(path = getenv("MAKEOBJDIR"))) {			path = _PATH_OBJDIR;			pathp = _PATH_OBJDIRPREFIX;			(void) snprintf(mdpath, MAXPATHLEN, "%s.%s",					path, machine);			if (!(objdir = chdir_verify_path(mdpath, obpath)))				if (!(objdir=chdir_verify_path(path, obpath))) {					(void) snprintf(mdpath, MAXPATHLEN,							"%s%s", pathp, curdir);					if (!(objdir=chdir_verify_path(mdpath,								       obpath)))						objdir = curdir;				}		}		else if (!(objdir = chdir_verify_path(path, obpath)))			objdir = curdir;	}	else {		(void) snprintf(mdpath, MAXPATHLEN, "%s%s", pathp, curdir);		if (!(objdir = chdir_verify_path(mdpath, obpath)))			objdir = curdir;	}	setenv("PWD", objdir, 1);	unsetenv("CDPATH");	create = Lst_Init();	makefiles = Lst_Init();	printVars = FALSE;	variables = Lst_Init();	beSilent = FALSE;		/* Print commands as executed */	ignoreErrors = FALSE;		/* Pay attention to non-zero returns */	noExecute = FALSE;		/* Execute all commands */	keepgoing = FALSE;		/* Stop on error */	allPrecious = FALSE;		/* Remove targets when interrupted */	queryFlag = FALSE;		/* This is not just a check-run */	noBuiltins = FALSE;		/* Read the built-in rules */	touchFlag = FALSE;		/* Actually update targets */	usePipes = TRUE;		/* Catch child output in pipes */	debug = 0;			/* No debug verbosity, please. */	jobsRunning = FALSE;	maxLocal = DEFMAXLOCAL;		/* Set default local max concurrency */#ifdef REMOTE	maxJobs = DEFMAXJOBS;		/* Set default max concurrency */#else	maxJobs = maxLocal;#endif	compatMake = FALSE;		/* No compat mode */	/*	 * Initialize the parsing, directory and variable modules to prepare	 * for the reading of inclusion paths and variable settings on the	 * command line	 */	Dir_Init();		/* Initialize directory structures so -I flags				 * can be processed correctly */	Parse_Init();		/* Need to initialize the paths of #include				 * directories */	Var_Init();		/* As well as the lists of variables for				 * parsing arguments */	if (objdir != curdir)		Dir_AddDir(dirSearchPath, curdir);	Var_Set(".CURDIR", curdir, VAR_GLOBAL);	Var_Set(".OBJDIR", objdir, VAR_GLOBAL);	/*	 * Initialize various variables.	 *	MAKE also gets this name, for compatibility	 *	.MAKEFLAGS gets set to the empty string just in case.	 *	MFLAGS also gets initialized empty, for compatibility.	 */	Var_Set("MAKE", argv[0], VAR_GLOBAL);	Var_Set(".MAKE", argv[0], VAR_GLOBAL);	Var_Set(MAKEFLAGS, "", VAR_GLOBAL);	Var_Set("MFLAGS", "", VAR_GLOBAL);	Var_Set("MACHINE", machine, VAR_GLOBAL);	Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL);	/*	 * First snag any flags out of the MAKE environment variable.	 * (Note this is *not* MAKEFLAGS since /bin/make uses that and it's	 * in a different format).	 */#ifdef POSIX	Main_ParseArgLine(getenv("MAKEFLAGS"));#else	Main_ParseArgLine(getenv("MAKE"));#endif	MainParseArgs(argc, argv);	/*	 * Initialize archive, target and suffix modules in preparation for	 * parsing the makefile(s)	 */	Arch_Init();	Targ_Init();	Suff_Init();	DEFAULT = NULL;	(void)time(&now);	/*	 * Set up the .TARGETS variable to contain the list of targets to be	 * created. If none specified, make the variable empty -- the parser	 * will fill the thing in with the default or .MAIN target.	 */	if (!Lst_IsEmpty(create)) {		LstNode ln;		for (ln = Lst_First(create); ln != NULL;		    ln = Lst_Succ(ln)) {			char *name = (char *)Lst_Datum(ln);			Var_Append(".TARGETS", name, VAR_GLOBAL);		}	} else		Var_Set(".TARGETS", "", VAR_GLOBAL);	/*	 * If no user-supplied system path was given (through the -m option)	 * add the directories from the DEFSYSPATH (more than one may be given	 * as dir1:...:dirn) to the system include path.	 */	if (Lst_IsEmpty(sysIncPath)) {		for (start = syspath; *start != '\0'; start = cp) {			for (cp = start; *cp != '\0' && *cp != ':'; cp++)				continue;			if (*cp == '\0') {				Dir_AddDir(sysIncPath, start);			} else {				*cp++ = '\0';				Dir_AddDir(sysIncPath, start);			}		}	}	/*	 * Read in the built-in rules first, followed by the specified	 * makefile, if it was (makefile != (char *) NULL), or the default	 * Makefile and makefile, in that order, if it wasn't.	 */	if (!noBuiltins) {		LstNode ln;		sysMkPath = Lst_Init();		Dir_Expand (_PATH_DEFSYSMK, sysIncPath, sysMkPath);		if (Lst_IsEmpty(sysMkPath))			Fatal("make: no system rules (%s).", _PATH_DEFSYSMK);		ln = Lst_Find(sysMkPath, ReadMakefile, NULL);		if (ln != NULL)			Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));	}	if (!Lst_IsEmpty(makefiles)) {		LstNode ln;		ln = Lst_Find(makefiles, ReadMakefile, NULL);		if (ln != NULL)			Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));	} else if (!ReadMakefile("BSDmakefile", NULL))		if (!ReadMakefile("makefile", NULL))			(void)ReadMakefile("Makefile", NULL);	(void)ReadMakefile(".depend", NULL);	Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL), VAR_GLOBAL);	/* Install all the flags into the MAKE envariable. */	if (((p = Var_Value(MAKEFLAGS, VAR_GLOBAL)) != NULL) && *p)#ifdef POSIX		setenv("MAKEFLAGS", p, 1);#else		setenv("MAKE", p, 1);#endif	/*	 * For compatibility, look at the directories in the VPATH variable	 * and add them to the search path, if the variable is defined. The	 * variable's value is in the same format as the PATH envariable, i.e.	 * <directory>:<directory>:<directory>...	 */	if (Var_Exists("VPATH", VAR_CMD)) {		char *vpath, *path, *cp, savec;		/*		 * GCC stores string constants in read-only memory, but		 * Var_Subst will want to write this thing, so store it		 * in an array		 */		static char VPATH[] = "${VPATH}";		vpath = Var_Subst(VPATH, VAR_CMD, FALSE);		path = vpath;		do {			/* skip to end of directory */			for (cp = path; *cp != ':' && *cp != '\0'; cp++)				continue;			/* Save terminator character so know when to stop */			savec = *cp;			*cp = '\0';			/* Add directory to search path */			Dir_AddDir(dirSearchPath, path);			*cp = savec;			path = cp + 1;		} while (savec == ':');		free(vpath);	}	/*	 * Now that all search paths have been read for suffixes et al, it's	 * time to add the default search path to their lists...	 */	Suff_DoPaths();	/* print the initial graph, if the user requested it */	if (DEBUG(GRAPH1))		Targ_PrintGraph(1);	/* print the values of any variables requested by the user */	if (printVars) {		LstNode ln;		for (ln = Lst_First(variables); ln != NULL;		    ln = Lst_Succ(ln)) {			char *value = Var_Value((char *)Lst_Datum(ln),					  VAR_GLOBAL);			printf("%s\n", value ? value : "");		}	}	/*	 * Have now read the entire graph and need to make a list of targets	 * to create. If none was given on the command line, we consult the	 * parsing module to find the main target(s) to create.	 */	if (Lst_IsEmpty(create))		targs = Parse_MainName();	else		targs = Targ_FindList(create, TARG_CREATE);	if (!compatMake && !printVars) {		/*		 * Initialize job module before traversing the graph, now that		 * any .BEGIN and .END targets have been read.  This is done		 * only if the -q flag wasn't given (to prevent the .BEGIN from		 * being executed should it exist).		 */		if (!queryFlag) {			if (maxLocal == -1)				maxLocal = maxJobs;			Job_Init(maxJobs, maxLocal);			jobsRunning = TRUE;		}		/* Traverse the graph, checking on all the targets */		outOfDate = Make_Run(targs);	} else if (!printVars) {		/*		 * Compat_Init will take care of creating all the targets as		 * well as initializing the module.		 */		Compat_Run(targs);	}	Lst_Destroy(targs, NOFREE);	Lst_Destroy(variables, NOFREE);	Lst_Destroy(makefiles, NOFREE);	Lst_Destroy(create, (SimpleProc)free);	/* print the graph now it's been processed if the user requested it */	if (DEBUG(GRAPH2))		Targ_PrintGraph(2);	Suff_End();        Targ_End();	Arch_End();	Var_End();	Parse_End();	Dir_End();	Job_End();	if (queryFlag && outOfDate)		return(1);	else		return(0);}