diff options
Diffstat (limited to 'asm/nasm.c')
-rw-r--r-- | asm/nasm.c | 29 |
1 files changed, 19 insertions, 10 deletions
@@ -136,9 +136,9 @@ static const struct forwrefinfo *forwref; static const struct preproc_ops *preproc; static StrList *include_path; -#define OP_NORMAL (1u << 0) -#define OP_PREPROCESS (1u << 1) -#define OP_DEPEND (1u << 2) +#define OP_NORMAL (1U << 0) +#define OP_PREPROCESS (1U << 1) +#define OP_DEPEND (1U << 2) static unsigned int operating_mode; @@ -509,9 +509,17 @@ int main(int argc, char **argv) /* Save away the default state of warnings */ memcpy(warning_state_init, warning_state, sizeof warning_state); + /* Dependency filename if we are also doing other things */ + if (!depend_file && (operating_mode & ~OP_DEPEND)) { + if (outname) + depend_file = nasm_strcat(outname, ".d"); + else + depend_file = filename_set_extension(inname, ".d"); + } + /* * If no output file name provided and this - * is a preprocess mode, we're perfectly + * is preprocess mode, we're perfectly * fine to output into stdout. */ if (!outname && !(operating_mode & OP_PREPROCESS)) { @@ -524,13 +532,12 @@ int main(int argc, char **argv) } } - depend_ptr = (depend_file || (operating_mode & OP_DEPEND)) - ? &depend_list : NULL; + depend_ptr = (operating_mode & OP_DEPEND) ? &depend_list : NULL; if (!depend_target) depend_target = quote_for_make(outname); - if (operating_mode & OP_DEPEND) { + if (!(operating_mode & (OP_PREPROCESS|OP_NORMAL))) { char *line; if (depend_missing_ok) @@ -1077,9 +1084,11 @@ static bool process_arg(char *p, char *q, int pass) depend_emit_phony = true; break; case 'D': - operating_mode = OP_NORMAL; - depend_file = q; - advance = true; + operating_mode |= OP_DEPEND; + if (q && (q[0] != '-' || q[1] == '\0')) { + depend_file = q; + advance = true; + } break; case 'F': depend_file = q; |