version 1.69, 2004/04/07 13:11:36 |
version 1.70, 2007/01/18 17:49:51 |
|
|
static void ParseFinishDependency(void); |
static void ParseFinishDependency(void); |
static bool ParseIsCond(Buffer, Buffer, char *); |
static bool ParseIsCond(Buffer, Buffer, char *); |
static char *strip_comments(Buffer, const char *); |
static char *strip_comments(Buffer, const char *); |
|
static char *find_include(const char *, bool); |
|
|
static void ParseDoCommands(const char *); |
static void ParseDoCommands(const char *); |
|
|
|
|
ParseLookupIncludeFile(file, cp, true, false); |
ParseLookupIncludeFile(file, cp, true, false); |
} |
} |
|
|
/* Common part to lookup and read an include file. */ |
/* helper function for ParseLookupIncludeFile */ |
static void |
static char * |
ParseLookupIncludeFile(char *spec, char *endSpec, bool isSystem, |
find_include(const char *file, bool isSystem) |
bool errIfNotFound) |
|
{ |
{ |
char *file; |
|
char *fullname; |
char *fullname; |
char endc; |
|
|
/* Look up system files on the system path first */ |
|
if (isSystem) { |
|
fullname = Dir_FindFileNoDot(file, sysIncPath); |
|
if (fullname) |
|
return fullname; |
|
} |
|
|
/* Substitute for any variables in the file name before trying to |
|
* find the thing. */ |
|
endc = *endSpec; |
|
*endSpec = '\0'; |
|
file = Var_Subst(spec, NULL, false); |
|
*endSpec = endc; |
|
|
|
/* Now that we know the file name and its search path, we attempt to |
|
* find the durn thing. NULL indicates the file still hasn't been |
|
* found. */ |
|
fullname = NULL; |
|
|
|
/* Handle non-system non-absolute files... */ |
/* Handle non-system non-absolute files... */ |
if (!isSystem && file[0] != '/') { |
if (!isSystem && file[0] != '/') { |
/* ... by first searching relative to the including file's |
/* ... by first searching relative to the including file's |
|
|
if (fullname == NULL) |
if (fullname == NULL) |
fullname = Dir_FindFile(newName, dirSearchPath); |
fullname = Dir_FindFile(newName, dirSearchPath); |
free(newName); |
free(newName); |
|
if (fullname) |
|
return fullname; |
} |
} |
} |
} |
|
|
/* Now look first on the -I search path, then on the .PATH |
/* Now look first on the -I search path, then on the .PATH |
* search path, if not found in a -I directory. |
* search path, if not found in a -I directory. |
* XXX: Suffix specific? */ |
* XXX: Suffix specific? */ |
if (fullname == NULL) |
fullname = Dir_FindFile(file, parseIncPath); |
fullname = Dir_FindFile(file, parseIncPath); |
if (fullname) |
if (fullname == NULL) |
return fullname; |
fullname = Dir_FindFile(file, dirSearchPath); |
fullname = Dir_FindFile(file, dirSearchPath); |
|
if (fullname) |
|
return fullname; |
|
|
/* Still haven't found the makefile. Look for it on the system |
/* Still haven't found the makefile. Look for it on the system |
* path as a last resort. */ |
* path as a last resort. */ |
if (fullname == NULL) |
if (isSystem) |
fullname = Dir_FindFile(file, sysIncPath); |
return NULL; |
|
else |
|
return Dir_FindFile(file, sysIncPath); |
|
} |
|
|
|
/* Common part to lookup and read an include file. */ |
|
static void |
|
ParseLookupIncludeFile(char *spec, char *endSpec, bool isSystem, |
|
bool errIfNotFound) |
|
{ |
|
char *file; |
|
char *fullname; |
|
char endc; |
|
|
|
/* Substitute for any variables in the file name before trying to |
|
* find the thing. */ |
|
endc = *endSpec; |
|
*endSpec = '\0'; |
|
file = Var_Subst(spec, NULL, false); |
|
*endSpec = endc; |
|
|
|
fullname = find_include(file, isSystem); |
if (fullname == NULL && errIfNotFound) |
if (fullname == NULL && errIfNotFound) |
Parse_Error(PARSE_FATAL, "Could not find %s", file); |
Parse_Error(PARSE_FATAL, "Could not find %s", file); |
|
|
|
|
free(file); |
free(file); |