version 1.44, 2000/06/17 14:40:29 |
version 1.45, 2000/06/17 14:43:36 |
|
|
*/ |
*/ |
#define CONTINUE 1 |
#define CONTINUE 1 |
#define DONE 0 |
#define DONE 0 |
static Lst targets; /* targets we're working on */ |
static LIST targets; /* targets we're working on */ |
#ifdef CLEANUP |
#ifdef CLEANUP |
static LIST targCmds; /* command lines for targets */ |
static LIST targCmds; /* command lines for targets */ |
#endif |
#endif |
static Boolean inLine; /* true if currently in a dependency |
static Boolean inLine; /* true if currently in a dependency |
* line or its commands */ |
* line or its commands */ |
typedef struct { |
typedef struct { |
char *str; |
char *str; |
char *ptr; |
char *ptr; |
|
|
/* |
/* |
* Replace the node in the targets list with the new copy |
* Replace the node in the targets list with the new copy |
*/ |
*/ |
ln = Lst_Member(targets, gn); |
ln = Lst_Member(&targets, gn); |
Lst_Replace(ln, cohort); |
Lst_Replace(ln, cohort); |
gn = cohort; |
gn = cohort; |
} |
} |
|
|
if (keywd != -1) { |
if (keywd != -1) { |
int op = parseKeywords[keywd].op; |
int op = parseKeywords[keywd].op; |
if (op != 0) { |
if (op != 0) { |
Lst_Find(targets, ParseDoOp, &op); |
Lst_Find(&targets, ParseDoOp, &op); |
return; |
return; |
} |
} |
if (parseKeywords[keywd].spec == Wait) { |
if (parseKeywords[keywd].spec == Wait) { |
|
|
if (tOp) { |
if (tOp) { |
gn->type |= tOp; |
gn->type |= tOp; |
} else { |
} else { |
Lst_ForEach(targets, ParseLinkSrc, gn); |
Lst_ForEach(&targets, ParseLinkSrc, gn); |
} |
} |
if ((gn->type & OP_OPMASK) == OP_DOUBLEDEP) { |
if ((gn->type & OP_OPMASK) == OP_DOUBLEDEP) { |
register GNode *cohort; |
register GNode *cohort; |
|
|
if (tOp) { |
if (tOp) { |
cohort->type |= tOp; |
cohort->type |= tOp; |
} else { |
} else { |
Lst_ForEach(targets, ParseLinkSrc, cohort); |
Lst_ForEach(&targets, ParseLinkSrc, cohort); |
} |
} |
} |
} |
} |
} |
|
|
GNode *gn; /* a general purpose temporary node */ |
GNode *gn; /* a general purpose temporary node */ |
int op; /* the operator on the line */ |
int op; /* the operator on the line */ |
char savec; /* a place to save a character */ |
char savec; /* a place to save a character */ |
Lst paths; /* List of search paths to alter when parsing |
LIST paths; /* List of search paths to alter when parsing |
* a list of .PATH targets */ |
* a list of .PATH targets */ |
int tOp; /* operator from special target */ |
int tOp; /* operator from special target */ |
LIST curTargs; /* list of target names to be found and added |
LIST curTargs; /* list of target names to be found and added |
|
|
|
|
specType = Not; |
specType = Not; |
waiting = 0; |
waiting = 0; |
paths = (Lst)NULL; |
Lst_Init(&paths); |
|
|
Lst_Init(&curTargs); |
Lst_Init(&curTargs); |
Lst_Init(&curSrcs); |
Lst_Init(&curSrcs); |
|
|
* went well and FAILURE if there was an error in the |
* went well and FAILURE if there was an error in the |
* specification. On error, line should remain untouched. |
* specification. On error, line should remain untouched. |
*/ |
*/ |
if (Arch_ParseArchive (&line, targets, VAR_CMD) != SUCCESS) { |
if (Arch_ParseArchive(&line, &targets, VAR_CMD) != SUCCESS) { |
Parse_Error (PARSE_FATAL, |
Parse_Error (PARSE_FATAL, |
"Error in archive specification: \"%s\"", line); |
"Error in archive specification: \"%s\"", line); |
return; |
return; |
|
|
*/ |
*/ |
switch (specType) { |
switch (specType) { |
case ExPath: |
case ExPath: |
if (paths == NULL) |
Lst_AtEnd(&paths, &dirSearchPath); |
paths = Lst_New(); |
|
Lst_AtEnd(paths, &dirSearchPath); |
|
break; |
break; |
case Main: |
case Main: |
if (!Lst_IsEmpty(&create)) { |
if (!Lst_IsEmpty(&create)) { |
|
|
case Interrupt: |
case Interrupt: |
gn = Targ_FindNode(line, TARG_CREATE); |
gn = Targ_FindNode(line, TARG_CREATE); |
gn->type |= OP_NOTMAIN; |
gn->type |= OP_NOTMAIN; |
Lst_AtEnd(targets, gn); |
Lst_AtEnd(&targets, gn); |
break; |
break; |
case Default: |
case Default: |
gn = Targ_NewGN(".DEFAULT"); |
gn = Targ_NewGN(".DEFAULT"); |
gn->type |= (OP_NOTMAIN|OP_TRANSFORM); |
gn->type |= (OP_NOTMAIN|OP_TRANSFORM); |
Lst_AtEnd(targets, gn); |
Lst_AtEnd(&targets, gn); |
DEFAULT = gn; |
DEFAULT = gn; |
break; |
break; |
case NotParallel: |
case NotParallel: |
|
|
Lst path; |
Lst path; |
|
|
specType = ExPath; |
specType = ExPath; |
path = Suff_GetPath (&line[5]); |
path = Suff_GetPath(&line[5]); |
if (path == NULL) { |
if (path == NULL) { |
Parse_Error (PARSE_FATAL, |
Parse_Error(PARSE_FATAL, |
"Suffix '%s' not defined (yet)", |
"Suffix '%s' not defined (yet)", |
&line[5]); |
&line[5]); |
return; |
return; |
} else { |
} else |
if (paths == NULL) |
Lst_AtEnd(&paths, path); |
paths = Lst_New(); |
|
Lst_AtEnd(paths, path); |
|
} |
|
} |
} |
} |
} |
|
|
|
|
} |
} |
|
|
if (gn != NULL) |
if (gn != NULL) |
Lst_AtEnd(targets, gn); |
Lst_AtEnd(&targets, gn); |
} |
} |
} else if (specType == ExPath && *line != '.' && *line != '\0') { |
} else if (specType == ExPath && *line != '.' && *line != '\0') { |
Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", line); |
Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", line); |
|
|
/* Don't need the list of target names any more */ |
/* Don't need the list of target names any more */ |
Lst_Destroy(&curTargs, NOFREE); |
Lst_Destroy(&curTargs, NOFREE); |
|
|
if (!Lst_IsEmpty(targets)) { |
if (!Lst_IsEmpty(&targets)) { |
switch(specType) { |
switch(specType) { |
default: |
default: |
Parse_Error(PARSE_WARNING, "Special and mundane targets don't mix. Mundane ones ignored"); |
Parse_Error(PARSE_WARNING, "Special and mundane targets don't mix. Mundane ones ignored"); |
|
|
|
|
cp++; /* Advance beyond operator */ |
cp++; /* Advance beyond operator */ |
|
|
Lst_Find(targets, ParseDoOp, &op); |
Lst_Find(&targets, ParseDoOp, &op); |
|
|
/* |
/* |
* Get to the first source |
* Get to the first source |
|
|
beSilent = TRUE; |
beSilent = TRUE; |
break; |
break; |
case ExPath: |
case ExPath: |
Lst_Every(paths, ParseClearPath); |
Lst_Every(&paths, ParseClearPath); |
break; |
break; |
default: |
default: |
break; |
break; |
|
|
Suff_AddSuffix (line); |
Suff_AddSuffix (line); |
break; |
break; |
case ExPath: |
case ExPath: |
Lst_ForEach(paths, ParseAddDir, line); |
Lst_ForEach(&paths, ParseAddDir, line); |
break; |
break; |
case Includes: |
case Includes: |
Suff_AddInclude (line); |
Suff_AddInclude (line); |
|
|
} |
} |
line = cp; |
line = cp; |
} |
} |
if (paths) |
Lst_Destroy(&paths, NOFREE); |
Lst_Delete(paths, NOFREE); |
|
} else { |
} else { |
while (*line) { |
while (*line) { |
/* |
/* |
|
|
* the first dependency line that is actually a real target |
* the first dependency line that is actually a real target |
* (i.e. isn't a .USE or .EXEC rule) to be made. |
* (i.e. isn't a .USE or .EXEC rule) to be made. |
*/ |
*/ |
Lst_Find(targets, ParseFindMain, NULL); |
Lst_Find(&targets, ParseFindMain, NULL); |
} |
} |
|
|
/* Finally, destroy the list of sources. */ |
/* Finally, destroy the list of sources. */ |
|
|
ParseFinishLine() |
ParseFinishLine() |
{ |
{ |
if (inLine) { |
if (inLine) { |
Lst_Every(targets, Suff_EndTransform); |
Lst_Every(&targets, Suff_EndTransform); |
Lst_Delete(targets, ParseHasCommands); |
Lst_Destroy(&targets, ParseHasCommands); |
targets = NULL; |
Lst_Init(&targets); |
inLine = FALSE; |
inLine = FALSE; |
} |
} |
} |
} |
|
|
* in a dependency spec, add the command to the list of |
* in a dependency spec, add the command to the list of |
* commands of all targets in the dependency spec |
* commands of all targets in the dependency spec |
*/ |
*/ |
Lst_ForEach(targets, ParseAddCmd, cp); |
Lst_ForEach(&targets, ParseAddCmd, cp); |
#ifdef CLEANUP |
#ifdef CLEANUP |
Lst_AtEnd(&targCmds, line); |
Lst_AtEnd(&targCmds, line); |
#endif |
#endif |
|
|
free (line); |
free (line); |
line = cp; |
line = cp; |
|
|
/* |
/* Need a new list for the target nodes */ |
* Need a non-circular list for the target nodes |
Lst_Destroy(&targets, NOFREE); |
*/ |
Lst_Init(&targets); |
if (targets) |
|
Lst_Delete(targets, NOFREE); |
|
|
|
targets = Lst_New(); |
|
inLine = TRUE; |
inLine = TRUE; |
|
|
ParseDoDependency (line); |
ParseDoDependency (line); |
|
|
Lst_Init(&parseIncPath); |
Lst_Init(&parseIncPath); |
Lst_Init(&sysIncPath); |
Lst_Init(&sysIncPath); |
Lst_Init(&includes); |
Lst_Init(&includes); |
|
Lst_Init(&targets); |
#ifdef CLEANUP |
#ifdef CLEANUP |
Lst_Init(&targCmds); |
Lst_Init(&targCmds); |
Lst_Init(&fileNames); |
Lst_Init(&fileNames); |
|
|
#ifdef CLEANUP |
#ifdef CLEANUP |
Lst_Destroy(&targCmds, (SimpleProc)free); |
Lst_Destroy(&targCmds, (SimpleProc)free); |
Lst_Destroy(&fileNames, (void (*) __P((ClientData))) free); |
Lst_Destroy(&fileNames, (void (*) __P((ClientData))) free); |
if (targets) |
Lst_Delete(&targets, NOFREE); |
Lst_Delete(targets, NOFREE); |
|
Lst_Destroy(&sysIncPath, Dir_Destroy); |
Lst_Destroy(&sysIncPath, Dir_Destroy); |
Lst_Destroy(&parseIncPath, Dir_Destroy); |
Lst_Destroy(&parseIncPath, Dir_Destroy); |
Lst_Destroy(&includes, NOFREE); /* Should be empty now */ |
Lst_Destroy(&includes, NOFREE); /* Should be empty now */ |
|
|
/*NOTREACHED*/ |
/*NOTREACHED*/ |
else if (mainNode->type & OP_DOUBLEDEP) { |
else if (mainNode->type & OP_DOUBLEDEP) { |
Lst_AtEnd(listmain, mainNode); |
Lst_AtEnd(listmain, mainNode); |
Lst_Concat(listmain, &mainNode->cohorts, LST_CONCNEW); |
Lst_Concat(listmain, &mainNode->cohorts); |
} |
} |
else |
else |
Lst_AtEnd(listmain, mainNode); |
Lst_AtEnd(listmain, mainNode); |