=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/main.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- src/usr.bin/make/main.c 1995/10/18 08:45:42 1.1 +++ src/usr.bin/make/main.c 1995/12/14 03:23:33 1.2 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.20 1995/09/27 18:42:21 jtc Exp $ */ +/* $NetBSD: main.c,v 1.23 1995/11/22 17:40:14 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -48,7 +48,7 @@ #if 0 static char sccsid[] = "@(#)main.c 5.25 (Berkeley) 4/1/91"; #else -static char rcsid[] = "$NetBSD: main.c,v 1.20 1995/09/27 18:42:21 jtc Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.23 1995/11/22 17:40:14 christos Exp $"; #endif #endif /* not lint */ @@ -83,11 +83,12 @@ #include #include #include +#include #include #include +#include #include #include -#include #include #if __STDC__ #include @@ -113,7 +114,7 @@ static Boolean noBuiltins; /* -r flag */ static Lst makefiles; /* ordered list of makefiles to read */ -int maxJobs; /* -J argument */ +int maxJobs; /* -j argument */ static int maxLocal; /* -L argument */ Boolean compatMake; /* -B argument */ Boolean debug; /* -d flag */ @@ -156,12 +157,13 @@ extern int optind; extern char *optarg; int c; + int forceJobs = 0; optind = 1; /* since we're called more than once */ -#ifdef notyet +#ifdef REMOTE # define OPTFLAGS "BD:I:L:PSd:ef:ij:knqrst" #else -# define OPTFLAGS "D:I:d:ef:ij:knqrst" +# define OPTFLAGS "BD:I:PSd:ef:ij:knqrst" #endif rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) { switch(c) { @@ -175,15 +177,16 @@ Var_Append(MAKEFLAGS, "-I", VAR_GLOBAL); Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); break; -#ifdef notyet case 'B': compatMake = TRUE; break; +#ifdef REMOTE case 'L': maxLocal = atoi(optarg); Var_Append(MAKEFLAGS, "-L", VAR_GLOBAL); Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); break; +#endif case 'P': usePipes = FALSE; Var_Append(MAKEFLAGS, "-P", VAR_GLOBAL); @@ -192,7 +195,6 @@ keepgoing = FALSE; Var_Append(MAKEFLAGS, "-S", VAR_GLOBAL); break; -#endif case 'd': { char *modules = optarg; @@ -260,7 +262,11 @@ Var_Append(MAKEFLAGS, "-i", VAR_GLOBAL); break; case 'j': + forceJobs = TRUE; maxJobs = atoi(optarg); +#ifndef REMOTE + maxLocal = maxJobs; +#endif Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL); Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); break; @@ -295,6 +301,13 @@ } } + /* + * Be compatible if user did not specify -j and did not explicitly + * turned compatibility on + */ + if (!compatMake && !forceJobs) + compatMake = TRUE; + oldVars = TRUE; /* @@ -384,7 +397,20 @@ struct utsname utsname; char *machine = getenv("MACHINE"); +#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. @@ -416,7 +442,7 @@ * MACHINE_ARCH is always known at compile time. */ if (!machine) { - if (uname(&utsname)) { + if (uname(&utsname) == -1) { perror("make: uname"); exit(2); } @@ -491,13 +517,13 @@ 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 */ +#ifdef REMOTE + maxJobs = DEFMAXJOBS; /* Set default max concurrency */ #else - compatMake = TRUE; /* No compat mode */ + maxJobs = maxLocal; #endif + compatMake = FALSE; /* No compat mode */ /* @@ -657,10 +683,6 @@ else targs = Targ_FindList(create, TARG_CREATE); -/* - * this was original amMake -- want to allow parallelism, so put this - * back in, eventually. - */ if (!compatMake) { /* * Initialize job module before traversing the graph, now that @@ -934,6 +956,26 @@ { (void)fprintf(stderr, "make: %s.\n", strerror(errno)); exit(2); +} + +/* + * enunlink -- + * Remove a file carefully, avoiding directories. + */ +int +eunlink(file) + const char *file; +{ + struct stat st; + + if (lstat(file, &st) == -1) + return -1; + + if (S_ISDIR(st.st_mode)) { + errno = EISDIR; + return -1; + } + return unlink(file); } /*