version 1.129, 2023/01/17 13:03:22 |
version 1.130, 2023/05/30 04:42:21 |
|
|
bool beSilent; /* -s flag */ |
bool beSilent; /* -s flag */ |
bool dumpData; /* -p flag */ |
bool dumpData; /* -p flag */ |
|
|
|
static LIST unreadable; |
|
|
struct dirs { |
struct dirs { |
char *current; |
char *current; |
char *object; |
char *object; |
|
|
return 0; |
return 0; |
} |
} |
|
|
|
struct unreadable { |
|
char *fname; |
|
int errcode; |
|
}; |
|
|
|
void |
|
dump_unreadable(void) |
|
{ |
|
struct unreadable *u; |
|
|
|
if (Lst_IsEmpty(&unreadable)) |
|
return; |
|
|
|
fprintf(stderr, "Makefile(s) that couldn't be read:\n"); |
|
|
|
while ((u = Lst_Pop(&unreadable))) { |
|
fprintf(stderr, "\t%s: %s\n", u->fname, strerror(u->errcode)); |
|
free(u->fname); |
|
free(u); |
|
} |
|
} |
|
|
|
static FILE * |
|
open_makefile(const char *fname) |
|
{ |
|
FILE *stream; |
|
struct unreadable *u; |
|
|
|
stream = fopen(fname, "r"); |
|
if (stream != NULL) |
|
return stream; |
|
|
|
if (errno != ENOENT) { |
|
u = emalloc(sizeof *u); |
|
u->fname = estrdup(fname); |
|
u->errcode = errno; |
|
Lst_AtEnd(&unreadable, u); |
|
} |
|
|
|
return NULL; |
|
} |
|
|
/*- |
/*- |
* ReadMakefile -- |
* ReadMakefile -- |
* Open and parse the given makefile. |
* Open and parse the given makefile. |
|
|
Var_Set("MAKEFILE", ""); |
Var_Set("MAKEFILE", ""); |
Parse_File(estrdup("(stdin)"), stdin); |
Parse_File(estrdup("(stdin)"), stdin); |
} else { |
} else { |
if ((stream = fopen(fname, "r")) != NULL) |
if ((stream = open_makefile(fname)) != NULL) |
goto found; |
goto found; |
/* if we've chdir'd, rebuild the path name */ |
/* if we've chdir'd, rebuild the path name */ |
if (d->current != d->object && *fname != '/') { |
if (d->current != d->object && *fname != '/') { |
char *path; |
char *path; |
|
|
path = Str_concat(d->current, fname, '/'); |
path = Str_concat(d->current, fname, '/'); |
if ((stream = fopen(path, "r")) == NULL) |
if ((stream = open_makefile(path)) == NULL) |
free(path); |
free(path); |
else { |
else { |
fname = path; |
fname = path; |
|
|
name = Dir_FindFile(fname, userIncludePath); |
name = Dir_FindFile(fname, userIncludePath); |
if (!name) |
if (!name) |
name = Dir_FindFile(fname, systemIncludePath); |
name = Dir_FindFile(fname, systemIncludePath); |
if (!name || !(stream = fopen(name, "r"))) |
if (!name) |
|
return false; |
|
/* do not try to open a file we already have, so that |
|
* dump_unreadable() yields non-confusing results. |
|
*/ |
|
if (strcmp(name, fname) == 0) |
|
return false; |
|
if ((stream = open_makefile(name)) == NULL) |
return false; |
return false; |
fname = name; |
fname = name; |
/* |
/* |