diff options
-rw-r--r-- | doc/nasmdoc.src | 9 | ||||
-rw-r--r-- | nasm.c | 11 | ||||
-rw-r--r-- | preproc.c | 38 |
3 files changed, 45 insertions, 13 deletions
diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src index cdcb6b92..103f40f7 100644 --- a/doc/nasmdoc.src +++ b/doc/nasmdoc.src @@ -16,6 +16,7 @@ \IR{-F} \c{-F} option \IR{-I} \c{-I} option \IR{-M} \c{-M} option +\IR{-MG} \c{-MG} option \IR{-On} \c{-On} option \IR{-P} \c{-P} option \IR{-U} \c{-U} option @@ -519,6 +520,14 @@ This can be redirected to a file for further processing. For example: \c NASM -M myfile.asm > myfile.dep +\S{opt-MG} The \i\c{-MG} Option: Generate \i{Makefile Dependencies}. + +This option can be used to generate makefile dependencies on stdout. +This differs from the \c{-M} option in that if a nonexisting file is +encountered, it is assumed to be a generated file and is added to the +dependency list without a prefix. + + \S{opt-F} The \i\c{-F} Option: Selecting a \i{Debug Information Format} This option is used to select the format of the debug information emitted @@ -80,7 +80,8 @@ static Preproc *preproc; enum op_type { op_normal, /* Preprocess and assemble */ op_preprocess, /* Preprocess only */ - op_depend /* Generate dependencies */ + op_depend, /* Generate dependencies */ + op_depend_missing_ok, /* Generate dependencies, missing OK */ }; static enum op_type operating_mode; @@ -196,6 +197,9 @@ int main(int argc, char **argv) } switch (operating_mode) { + case op_depend_missing_ok: + pp_include_path(NULL); /* "assume generated" */ + /* fall through */ case op_depend: { char *line; @@ -479,7 +483,8 @@ static int process_arg(char *p, char *q) printf (" -e preprocess only (writes output to stdout by default)\n" " -a don't preprocess (assemble only)\n" - " -M generate Makefile dependencies on stdout\n\n" + " -M generate Makefile dependencies on stdout\n" + " -MG d:o, missing files assumed generated\n\n" " -E<file> redirect error messages to file\n" " -s redirect error messages to stdout\n\n" " -F format select a debugging format\n\n" @@ -553,7 +558,7 @@ static int process_arg(char *p, char *q) } break; case 'M': - operating_mode = op_depend; + operating_mode = p[2] == 'G' ? op_depend_missing_ok : op_depend; break; case '-': @@ -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) { |