diff options
author | H. Peter Anvin <hpa@zytor.com> | 2007-09-24 13:41:58 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2007-09-24 13:41:58 -0700 |
commit | 37a321fbbee22a9f5c022cc3ad43fbf4f522c099 (patch) | |
tree | 785cd36169be86f90028bb3ff860c24215ba4896 /preproc.c | |
parent | dee8eaa96710125a171136ab990a46012a0081ab (diff) | |
download | nasm-37a321fbbee22a9f5c022cc3ad43fbf4f522c099.tar.gz nasm-37a321fbbee22a9f5c022cc3ad43fbf4f522c099.tar.bz2 nasm-37a321fbbee22a9f5c022cc3ad43fbf4f522c099.zip |
Implement the -MG option (SF RFE 1564264)
Implement the -MG option, to generate dependencies in the presence of
generated files. In the end, we probably need to support the full
gamut of GCC-like dependency-generation options.
Diffstat (limited to 'preproc.c')
-rw-r--r-- | preproc.c | 38 |
1 files changed, 28 insertions, 10 deletions
@@ -1178,6 +1178,19 @@ static FILE *inc_fopen(char *file) break; prefix = ip->path; ip = ip->next; + + if (!prefix) { + /* -MG given and file not found */ + if (pass == 0) { + namelen += strlen(file) + 1; + if (namelen > 62) { + printf(" \\\n "); + namelen = 2; + } + printf(" %s", file); + } + return NULL; + } } error(ERR_FATAL, "unable to open include file `%s'", file); @@ -1868,14 +1881,19 @@ static int do_directive(Token * tline) inc->next = istk; inc->conds = NULL; inc->fp = inc_fopen(p); - inc->fname = src_set_fname(p); - inc->lineno = src_set_linnum(0); - inc->lineinc = 1; - inc->expansion = NULL; - inc->mstk = NULL; - istk = inc; - list->uplevel(LIST_INCLUDE); - free_tlist(origline); + if (!inc->fp && pass == 0) { + /* -MG given but file not found */ + nasm_free(inc); + } else { + inc->fname = src_set_fname(p); + inc->lineno = src_set_linnum(0); + inc->lineinc = 1; + inc->expansion = NULL; + inc->mstk = NULL; + istk = inc; + list->uplevel(LIST_INCLUDE); + } + free_tlist(origline); return DIRECTIVE_FOUND; case PP_PUSH: @@ -3897,9 +3915,9 @@ static void pp_cleanup(int pass) void pp_include_path(char *path) { IncPath *i; -/* by alexfru: order of path inclusion fixed (was reverse order) */ + i = nasm_malloc(sizeof(IncPath)); - i->path = nasm_strdup(path); + i->path = path ? nasm_strdup(path) : NULL; i->next = NULL; if (ipath != NULL) { |