From 599a98272edbf7df3e919a8b22a3b9ee1d437c15 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Tue, 24 Jun 2014 00:55:17 +0400 Subject: [PATCH] nasm: Handle -MF and -MD options It's been long time since -MF and -MD options were described in docs but actually -MF was not implemented completely and -MD didn't proceed into normal compilation process. Fix it. Because we use bitmask for operating_mode selection I had to move compilation condition one shift left. http://bugzilla.nasm.us/show_bug.cgi?id=3392280 Signed-off-by: Cyrill Gorcunov --- nasm.c | 85 +++++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/nasm.c b/nasm.c index c83f3d0b..ac46afd4 100644 --- a/nasm.c +++ b/nasm.c @@ -369,7 +369,7 @@ int main(int argc, char **argv) /* define some macros dependent of command-line */ define_macros_late(); - depend_ptr = (depend_file || (operating_mode == OP_DEPEND)) ? &depend_list : NULL; + depend_ptr = (depend_file || (operating_mode & OP_DEPEND)) ? &depend_list : NULL; if (!depend_target) depend_target = quote_for_make(outname); @@ -434,51 +434,51 @@ int main(int argc, char **argv) if (ofile && terminate_after_phase) remove(outname); ofile = NULL; - } else if (operating_mode & OP_NORMAL) { - /* - * We must call ofmt->filename _anyway_, even if the user - * has specified their own output file, because some - * formats (eg OBJ and COFF) use ofmt->filename to find out - * the name of the input file and then put that inside the - * file. - */ - ofmt->filename(inname, outname); + } - ofile = fopen(outname, (ofmt->flags & OFMT_TEXT) ? "w" : "wb"); - if (!ofile) { - nasm_error(ERR_FATAL | ERR_NOFILE, - "unable to open output file `%s'", outname); - } + if (operating_mode & OP_NORMAL) { + /* + * We must call ofmt->filename _anyway_, even if the user + * has specified their own output file, because some + * formats (eg OBJ and COFF) use ofmt->filename to find out + * the name of the input file and then put that inside the + * file. + */ + ofmt->filename(inname, outname); - /* - * We must call init_labels() before ofmt->init() since - * some object formats will want to define labels in their - * init routines. (eg OS/2 defines the FLAT group) - */ - init_labels(); + ofile = fopen(outname, (ofmt->flags & OFMT_TEXT) ? "w" : "wb"); + if (!ofile) + nasm_error(ERR_FATAL | ERR_NOFILE, + "unable to open output file `%s'", outname); - ofmt->init(); - dfmt = ofmt->current_dfmt; - dfmt->init(); + /* + * We must call init_labels() before ofmt->init() since + * some object formats will want to define labels in their + * init routines. (eg OS/2 defines the FLAT group) + */ + init_labels(); - assemble_file(inname, depend_ptr); + ofmt->init(); + dfmt = ofmt->current_dfmt; + dfmt->init(); - if (!terminate_after_phase) { - ofmt->cleanup(using_debug_info); - cleanup_labels(); - fflush(ofile); - if (ferror(ofile)) { - nasm_error(ERR_NONFATAL|ERR_NOFILE, - "write error on output file `%s'", outname); - } - } + assemble_file(inname, depend_ptr); - if (ofile) { - fclose(ofile); - if (terminate_after_phase) - remove(outname); - ofile = NULL; - } + if (!terminate_after_phase) { + ofmt->cleanup(using_debug_info); + cleanup_labels(); + fflush(ofile); + if (ferror(ofile)) + nasm_error(ERR_NONFATAL|ERR_NOFILE, + "write error on output file `%s'", outname); + } + + if (ofile) { + fclose(ofile); + if (terminate_after_phase) + remove(outname); + ofile = NULL; + } } if (depend_list && !terminate_after_phase) @@ -898,6 +898,11 @@ set_warning: depend_emit_phony = true; break; case 'D': + operating_mode = OP_DEPEND | OP_NORMAL; + depend_file = q; + advance = true; + break; + case 'F': depend_file = q; advance = true; break; -- 2.11.4.GIT