version 1.32, 2000/06/10 01:41:05 |
version 1.33, 2000/06/17 14:38:18 |
|
|
|
|
#define MAKEFLAGS ".MAKEFLAGS" |
#define MAKEFLAGS ".MAKEFLAGS" |
|
|
Lst create; /* Targets to be made */ |
LIST create; /* Targets to be made */ |
time_t now = OUT_OF_DATE;/* Time at start of make */ |
time_t now = OUT_OF_DATE;/* Time at start of make */ |
GNode *DEFAULT; /* .DEFAULT node */ |
GNode *DEFAULT; /* .DEFAULT node */ |
Boolean allPrecious; /* .PRECIOUS given on line by itself */ |
Boolean allPrecious; /* .PRECIOUS given on line by itself */ |
|
|
static Boolean noBuiltins; /* -r flag */ |
static Boolean noBuiltins; /* -r flag */ |
static Lst makefiles; /* ordered list of makefiles to read */ |
static LIST makefiles; /* ordered list of makefiles to read */ |
static Boolean printVars; /* print value of one or more vars */ |
static Boolean printVars; /* print value of one or more vars */ |
static Lst variables; /* list of variables to print */ |
static LIST variables; /* list of variables to print */ |
int maxJobs; /* -j argument */ |
int maxJobs; /* -j argument */ |
static int maxLocal; /* -L argument */ |
static int maxLocal; /* -L argument */ |
Boolean compatMake; /* -B argument */ |
Boolean compatMake; /* -B argument */ |
|
|
break; |
break; |
case 'V': |
case 'V': |
printVars = TRUE; |
printVars = TRUE; |
Lst_AtEnd(variables, optarg); |
Lst_AtEnd(&variables, optarg); |
Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL); |
Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL); |
Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); |
Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); |
break; |
break; |
|
|
Var_Append(MAKEFLAGS, "-e", VAR_GLOBAL); |
Var_Append(MAKEFLAGS, "-e", VAR_GLOBAL); |
break; |
break; |
case 'f': |
case 'f': |
Lst_AtEnd(makefiles, optarg); |
Lst_AtEnd(&makefiles, optarg); |
break; |
break; |
case 'i': |
case 'i': |
ignoreErrors = TRUE; |
ignoreErrors = TRUE; |
|
|
Var_Append(MAKEFLAGS, "-k", VAR_GLOBAL); |
Var_Append(MAKEFLAGS, "-k", VAR_GLOBAL); |
break; |
break; |
case 'm': |
case 'm': |
Dir_AddDir(sysIncPath, optarg); |
Dir_AddDir(&sysIncPath, optarg); |
Var_Append(MAKEFLAGS, "-m", VAR_GLOBAL); |
Var_Append(MAKEFLAGS, "-m", VAR_GLOBAL); |
Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); |
Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); |
break; |
break; |
|
|
optind = 1; /* - */ |
optind = 1; /* - */ |
goto rearg; |
goto rearg; |
} |
} |
Lst_AtEnd(create, estrdup(*argv)); |
Lst_AtEnd(&create, estrdup(*argv)); |
} |
} |
} |
} |
|
|
|
|
char cdpath[MAXPATHLEN + 1]; |
char cdpath[MAXPATHLEN + 1]; |
char *machine = getenv("MACHINE"); |
char *machine = getenv("MACHINE"); |
char *machine_arch = getenv("MACHINE_ARCH"); |
char *machine_arch = getenv("MACHINE_ARCH"); |
Lst sysMkPath; /* Path of sys.mk */ |
|
char *cp = NULL, *start; |
char *cp = NULL, *start; |
/* avoid faults on read-only strings */ |
/* avoid faults on read-only strings */ |
static char syspath[] = _PATH_DEFSYSPATH; |
static char syspath[] = _PATH_DEFSYSPATH; |
|
|
setenv("PWD", objdir, 1); |
setenv("PWD", objdir, 1); |
unsetenv("CDPATH"); |
unsetenv("CDPATH"); |
|
|
create = Lst_Init(); |
Lst_Init(&create); |
makefiles = Lst_Init(); |
Lst_Init(&makefiles); |
printVars = FALSE; |
printVars = FALSE; |
variables = Lst_Init(); |
Lst_Init(&variables); |
beSilent = FALSE; /* Print commands as executed */ |
beSilent = FALSE; /* Print commands as executed */ |
ignoreErrors = FALSE; /* Pay attention to non-zero returns */ |
ignoreErrors = FALSE; /* Pay attention to non-zero returns */ |
noExecute = FALSE; /* Execute all commands */ |
noExecute = FALSE; /* Execute all commands */ |
|
|
Var_Init(); /* As well as the lists of variables for |
Var_Init(); /* As well as the lists of variables for |
* parsing arguments */ |
* parsing arguments */ |
if (objdir != curdir) |
if (objdir != curdir) |
Dir_AddDir(dirSearchPath, curdir); |
Dir_AddDir(&dirSearchPath, curdir); |
Var_Set(".CURDIR", curdir, VAR_GLOBAL); |
Var_Set(".CURDIR", curdir, VAR_GLOBAL); |
Var_Set(".OBJDIR", objdir, VAR_GLOBAL); |
Var_Set(".OBJDIR", objdir, VAR_GLOBAL); |
|
|
|
|
* created. If none specified, make the variable empty -- the parser |
* created. If none specified, make the variable empty -- the parser |
* will fill the thing in with the default or .MAIN target. |
* will fill the thing in with the default or .MAIN target. |
*/ |
*/ |
if (!Lst_IsEmpty(create)) { |
if (!Lst_IsEmpty(&create)) { |
LstNode ln; |
LstNode ln; |
|
|
for (ln = Lst_First(create); ln != NULL; |
for (ln = Lst_First(&create); ln != NULL; |
ln = Lst_Succ(ln)) { |
ln = Lst_Succ(ln)) { |
char *name = (char *)Lst_Datum(ln); |
char *name = (char *)Lst_Datum(ln); |
|
|
|
|
* add the directories from the DEFSYSPATH (more than one may be given |
* add the directories from the DEFSYSPATH (more than one may be given |
* as dir1:...:dirn) to the system include path. |
* as dir1:...:dirn) to the system include path. |
*/ |
*/ |
if (Lst_IsEmpty(sysIncPath)) { |
if (Lst_IsEmpty(&sysIncPath)) { |
for (start = syspath; *start != '\0'; start = cp) { |
for (start = syspath; *start != '\0'; start = cp) { |
for (cp = start; *cp != '\0' && *cp != ':'; cp++) |
for (cp = start; *cp != '\0' && *cp != ':'; cp++) |
continue; |
continue; |
if (*cp == '\0') { |
if (*cp == '\0') { |
Dir_AddDir(sysIncPath, start); |
Dir_AddDir(&sysIncPath, start); |
} else { |
} else { |
*cp++ = '\0'; |
*cp++ = '\0'; |
Dir_AddDir(sysIncPath, start); |
Dir_AddDir(&sysIncPath, start); |
} |
} |
} |
} |
} |
} |
|
|
*/ |
*/ |
if (!noBuiltins) { |
if (!noBuiltins) { |
LstNode ln; |
LstNode ln; |
|
LIST sysMkPath; /* Path of sys.mk */ |
|
|
sysMkPath = Lst_Init(); |
Lst_Init(&sysMkPath); |
Dir_Expand (_PATH_DEFSYSMK, sysIncPath, sysMkPath); |
Dir_Expand(_PATH_DEFSYSMK, &sysIncPath, &sysMkPath); |
if (Lst_IsEmpty(sysMkPath)) |
if (Lst_IsEmpty(&sysMkPath)) |
Fatal("make: no system rules (%s).", _PATH_DEFSYSMK); |
Fatal("make: no system rules (%s).", _PATH_DEFSYSMK); |
ln = Lst_Find(sysMkPath, ReadMakefile, NULL); |
ln = Lst_Find(&sysMkPath, ReadMakefile, NULL); |
if (ln != NULL) |
if (ln != NULL) |
Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); |
Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); |
} |
} |
|
|
if (!Lst_IsEmpty(makefiles)) { |
if (!Lst_IsEmpty(&makefiles)) { |
LstNode ln; |
LstNode ln; |
|
|
ln = Lst_Find(makefiles, ReadMakefile, NULL); |
ln = Lst_Find(&makefiles, ReadMakefile, NULL); |
if (ln != NULL) |
if (ln != NULL) |
Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); |
Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); |
} else if (!ReadMakefile("BSDmakefile", NULL)) |
} else if (!ReadMakefile("BSDmakefile", NULL)) |
|
|
savec = *cp; |
savec = *cp; |
*cp = '\0'; |
*cp = '\0'; |
/* Add directory to search path */ |
/* Add directory to search path */ |
Dir_AddDir(dirSearchPath, path); |
Dir_AddDir(&dirSearchPath, path); |
*cp = savec; |
*cp = savec; |
path = cp + 1; |
path = cp + 1; |
} while (savec == ':'); |
} while (savec == ':'); |
|
|
if (printVars) { |
if (printVars) { |
LstNode ln; |
LstNode ln; |
|
|
for (ln = Lst_First(variables); ln != NULL; |
for (ln = Lst_First(&variables); ln != NULL; |
ln = Lst_Succ(ln)) { |
ln = Lst_Succ(ln)) { |
char *value = Var_Value((char *)Lst_Datum(ln), |
char *value = Var_Value((char *)Lst_Datum(ln), |
VAR_GLOBAL); |
VAR_GLOBAL); |
|
|
* to create. If none was given on the command line, we consult the |
* to create. If none was given on the command line, we consult the |
* parsing module to find the main target(s) to create. |
* parsing module to find the main target(s) to create. |
*/ |
*/ |
if (Lst_IsEmpty(create)) |
if (Lst_IsEmpty(&create)) |
targs = Parse_MainName(); |
targs = Parse_MainName(); |
else |
else |
targs = Targ_FindList(create, TARG_CREATE); |
targs = Targ_FindList(&create, TARG_CREATE); |
|
|
if (!compatMake && !printVars) { |
if (!compatMake && !printVars) { |
/* |
/* |
|
|
Compat_Run(targs); |
Compat_Run(targs); |
} |
} |
|
|
Lst_Destroy(targs, NOFREE); |
Lst_Delete(targs, NOFREE); |
Lst_Destroy(variables, NOFREE); |
Lst_Destroy(&variables, NOFREE); |
Lst_Destroy(makefiles, NOFREE); |
Lst_Destroy(&makefiles, NOFREE); |
Lst_Destroy(create, (SimpleProc)free); |
Lst_Destroy(&create, (SimpleProc)free); |
|
|
/* print the graph now it's been processed if the user requested it */ |
/* print the graph now it's been processed if the user requested it */ |
if (DEBUG(GRAPH2)) |
if (DEBUG(GRAPH2)) |
|
|
void *q; |
void *q; |
{ |
{ |
char *fname = p; /* makefile to read */ |
char *fname = p; /* makefile to read */ |
extern Lst parseIncPath; |
extern LIST parseIncPath; |
FILE *stream; |
FILE *stream; |
char *name, path[MAXPATHLEN + 1]; |
char *name, path[MAXPATHLEN + 1]; |
|
|
|
|
} |
} |
} |
} |
/* look in -I and system include directories. */ |
/* look in -I and system include directories. */ |
name = Dir_FindFile(fname, parseIncPath); |
name = Dir_FindFile(fname, &parseIncPath); |
if (!name) |
if (!name) |
name = Dir_FindFile(fname, sysIncPath); |
name = Dir_FindFile(fname, &sysIncPath); |
if (!name || !(stream = fopen(name, "r"))) |
if (!name || !(stream = fopen(name, "r"))) |
return(FALSE); |
return(FALSE); |
fname = name; |
fname = name; |