version 1.95, 2010/07/19 19:46:44 |
version 1.96, 2012/09/21 07:55:20 |
|
|
#include "config.h" |
#include "config.h" |
#include "defines.h" |
#include "defines.h" |
#include "var.h" |
#include "var.h" |
|
#include "lowparse.h" |
#include "parse.h" |
#include "parse.h" |
#include "parsevar.h" |
#include "parsevar.h" |
#include "dir.h" |
#include "dir.h" |
|
|
#include "lst.h" |
#include "lst.h" |
#include "memory.h" |
#include "memory.h" |
#include "make.h" |
#include "make.h" |
|
#include "dump.h" |
|
|
#ifndef PATH_MAX |
#ifndef PATH_MAX |
# ifdef MAXPATHLEN |
# ifdef MAXPATHLEN |
|
|
bool touchFlag; /* -t flag */ |
bool touchFlag; /* -t flag */ |
bool ignoreErrors; /* -i flag */ |
bool ignoreErrors; /* -i flag */ |
bool beSilent; /* -s flag */ |
bool beSilent; /* -s flag */ |
|
bool dumpData; /* -p flag */ |
|
|
struct dirs { |
struct dirs { |
char *current; |
char *current; |
|
|
static char *figure_out_MACHINE(void); |
static char *figure_out_MACHINE(void); |
static char *figure_out_MACHINE_ARCH(void); |
static char *figure_out_MACHINE_ARCH(void); |
static char *figure_out_MACHINE_CPU(void); |
static char *figure_out_MACHINE_CPU(void); |
static void no_fd_limits(void); |
|
|
|
static char *chdir_verify_path(const char *, struct dirs *); |
static char *chdir_verify_path(const char *, struct dirs *); |
static char *concat_verify(const char *, const char *, char, struct dirs *); |
static char *concat_verify(const char *, const char *, char, struct dirs *); |
|
|
static void read_makefile_list(Lst, struct dirs *); |
static void read_makefile_list(Lst, struct dirs *); |
static int ReadMakefile(void *, void *); |
static int ReadMakefile(void *, void *); |
|
|
|
|
static void record_option(int c, const char *arg) |
static void record_option(int c, const char *arg) |
{ |
{ |
char opt[3]; |
char opt[3]; |
|
|
case 'n': |
case 'n': |
noExecute = true; |
noExecute = true; |
break; |
break; |
|
case 'p': |
|
dumpData = true; |
|
break; |
case 'q': |
case 'q': |
queryFlag = true; |
queryFlag = true; |
/* Kind of nonsensical, wot? */ |
/* Kind of nonsensical, wot? */ |
|
|
{ |
{ |
int c, optend; |
int c, optend; |
|
|
#define OPTFLAGS "BD:I:PSV:d:ef:ij:km:nqrst" |
#define OPTFLAGS "BD:I:PSV:d:ef:ij:km:npqrst" |
#define OPTLETTERS "BPSiknqrst" |
#define OPTLETTERS "BPSiknpqrst" |
|
|
optind = 1; /* since we're called more than once */ |
optind = 1; /* since we're called more than once */ |
optreset = 1; |
optreset = 1; |
|
|
case 'd': |
case 'd': |
debug |= DEBUG_DIR; |
debug |= DEBUG_DIR; |
break; |
break; |
|
case 'e': |
|
debug |= DEBUG_EXPENSIVE; |
|
break; |
case 'f': |
case 'f': |
debug |= DEBUG_FOR; |
debug |= DEBUG_FOR; |
break; |
break; |
|
|
debug |= DEBUG_JOB; |
debug |= DEBUG_JOB; |
break; |
break; |
case 'J': |
case 'J': |
debug |= DEBUG_JOBBANNER; |
/* ignore */ |
break; |
break; |
case 'l': |
case 'l': |
debug |= DEBUG_LOUD; |
debug |= DEBUG_LOUD; |
|
|
case 'p': |
case 'p': |
debug |= DEBUG_PARALLEL; |
debug |= DEBUG_PARALLEL; |
break; |
break; |
|
case 'q': |
|
debug |= DEBUG_QUICKDEATH; |
|
break; |
case 's': |
case 's': |
debug |= DEBUG_SUFF; |
debug |= DEBUG_SUFF; |
break; |
break; |
|
|
return r; |
return r; |
} |
} |
|
|
/* get rid of resource limit on file descriptors */ |
|
static void |
|
no_fd_limits() |
|
{ |
|
#ifdef RLIMIT_NOFILE |
|
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 |
|
} |
|
|
|
static char * |
static char * |
figure_out_CURDIR() |
figure_out_CURDIR() |
{ |
{ |
|
|
static struct dirs d; |
static struct dirs d; |
bool read_depend = true;/* false if we don't want to read .depend */ |
bool read_depend = true;/* false if we don't want to read .depend */ |
|
|
no_fd_limits(); |
|
setup_CURDIR_OBJDIR(&d, machine); |
setup_CURDIR_OBJDIR(&d, machine); |
|
|
esetenv("PWD", d.object); |
esetenv("PWD", d.object); |
|
|
Dir_AddDir(defaultPath, d.current); |
Dir_AddDir(defaultPath, d.current); |
Var_Set(".CURDIR", d.current); |
Var_Set(".CURDIR", d.current); |
Var_Set(".OBJDIR", d.object); |
Var_Set(".OBJDIR", d.object); |
|
Parse_setcurdir(d.current); |
Targ_setdirs(d.current, d.object); |
Targ_setdirs(d.current, d.object); |
|
|
/* |
/* |
|
|
if (DEBUG(GRAPH1)) |
if (DEBUG(GRAPH1)) |
Targ_PrintGraph(1); |
Targ_PrintGraph(1); |
|
|
|
if (dumpData) { |
|
dump_data(); |
|
exit(0); |
|
} |
/* Print the values of any variables requested by the user. */ |
/* Print the values of any variables requested by the user. */ |
if (!Lst_IsEmpty(&varstoprint)) { |
if (!Lst_IsEmpty(&varstoprint)) { |
LstNode ln; |
LstNode ln; |
|
|
else |
else |
Targ_FindList(&targs, create); |
Targ_FindList(&targs, create); |
|
|
|
Job_Init(maxJobs); |
|
/* If the user has defined a .BEGIN target, execute the commands |
|
* attached to it. */ |
|
if (!queryFlag) |
|
Job_Begin(); |
if (compatMake) |
if (compatMake) |
/* Compat_Init will take care of creating all the |
/* Compat_Init will take care of creating all the |
* targets as well as initializing the module. */ |
* targets as well as initializing the module. */ |
Compat_Run(&targs); |
Compat_Run(&targs); |
else { |
else { |
/* 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) |
|
Job_Init(maxJobs); |
|
|
|
/* Traverse the graph, checking on all the targets. */ |
/* Traverse the graph, checking on all the targets. */ |
outOfDate = Make_Run(&targs); |
outOfDate = Make_Run(&targs); |
} |
} |