- maxJobs = DEFMAXJOBS; /* Set the default maximum concurrency */
- maxLocal = DEFMAXLOCAL; /* Set the default local max concurrency */
-
- /*
- * Deal with disagreement between different getopt's as to what
- * the initial value of optind should be by simply saving the
- * damn thing.
- */
- initOptInd = optind;
-
- /*
- * See what the user calls us. If s/he calls us (yuck) "make", then
- * act like it. Otherwise act like our normal, cheerful self.
- */
- cp = rindex (argv[0], '/');
- if (cp != (char *)NULL) {
- cp += 1;
- } else {
- cp = argv[0];
- }
- progName = cp;
-
- if (strcmp (cp, "make") == 0) {
- amMake = TRUE; /* Be like make */
- backwards = TRUE; /* Do things the old-fashioned way */
- oldVars = TRUE; /* Same with variables */
- } else if (strcmp(cp, "smake") == 0 || strcmp(cp, "vmake") == 0) {
- sysVmake = oldVars = backwards = noLocking = TRUE;
- } else {
- amMake = FALSE;
- backwards = FALSE; /* Do things MY way, not MAKE's */
-#ifdef DEF_OLD_VARS
- oldVars = TRUE;
+ 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);
+ }
+
+
+ /*
+ * if the MAKEOBJDIR (or by default, the _PATH_OBJDIR) directory
+ * exists, change into it and build there. 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 (!(path = getenv("MAKEOBJDIR"))) {
+ path = _PATH_OBJDIR;
+ (void) sprintf(mdpath, "%s.%s", path, MACHINE);
+ }
+ else
+ (void) strncpy(mdpath, path, MAXPATHLEN + 1);
+
+ if (stat(mdpath, &sb) == 0 && S_ISDIR(sb.st_mode)) {
+
+ if (chdir(mdpath)) {
+ (void)fprintf(stderr, "make warning: %s: %s.\n",
+ mdpath, strerror(errno));
+ objdir = curdir;
+ }
+ else {
+ if (mdpath[0] != '/') {
+ (void) sprintf(obpath, "%s/%s", curdir, mdpath);
+ objdir = obpath;
+ }
+ else
+ objdir = mdpath;
+ }
+ }
+ else {
+ if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
+
+ if (chdir(path)) {
+ (void)fprintf(stderr, "make warning: %s: %s.\n",
+ path, strerror(errno));
+ objdir = curdir;
+ }
+ else {
+ if (path[0] != '/') {
+ (void) sprintf(obpath, "%s/%s", curdir,
+ path);
+ objdir = obpath;
+ }
+ else
+ objdir = obpath;
+ }
+ }
+ else
+ objdir = curdir;
+ }
+
+ setenv("PWD", objdir, 1);
+
+ create = Lst_Init(FALSE);
+ makefiles = Lst_Init(FALSE);
+ 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;
+
+ maxJobs = DEFMAXJOBS; /* Set default max concurrency */
+ maxLocal = DEFMAXLOCAL; /* Set default local max concurrency */
+#ifdef notyet
+ compatMake = FALSE; /* No compat mode */