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 <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov 2014-06-24 00:55:17 +04:00
parent e9fc88ca11
commit 599a98272e

17
nasm.c
View file

@ -369,7 +369,7 @@ int main(int argc, char **argv)
/* define some macros dependent of command-line */ /* define some macros dependent of command-line */
define_macros_late(); 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) if (!depend_target)
depend_target = quote_for_make(outname); depend_target = quote_for_make(outname);
@ -434,7 +434,9 @@ int main(int argc, char **argv)
if (ofile && terminate_after_phase) if (ofile && terminate_after_phase)
remove(outname); remove(outname);
ofile = NULL; ofile = NULL;
} else if (operating_mode & OP_NORMAL) { }
if (operating_mode & OP_NORMAL) {
/* /*
* We must call ofmt->filename _anyway_, even if the user * We must call ofmt->filename _anyway_, even if the user
* has specified their own output file, because some * has specified their own output file, because some
@ -445,10 +447,9 @@ int main(int argc, char **argv)
ofmt->filename(inname, outname); ofmt->filename(inname, outname);
ofile = fopen(outname, (ofmt->flags & OFMT_TEXT) ? "w" : "wb"); ofile = fopen(outname, (ofmt->flags & OFMT_TEXT) ? "w" : "wb");
if (!ofile) { if (!ofile)
nasm_error(ERR_FATAL | ERR_NOFILE, nasm_error(ERR_FATAL | ERR_NOFILE,
"unable to open output file `%s'", outname); "unable to open output file `%s'", outname);
}
/* /*
* We must call init_labels() before ofmt->init() since * We must call init_labels() before ofmt->init() since
@ -467,11 +468,10 @@ int main(int argc, char **argv)
ofmt->cleanup(using_debug_info); ofmt->cleanup(using_debug_info);
cleanup_labels(); cleanup_labels();
fflush(ofile); fflush(ofile);
if (ferror(ofile)) { if (ferror(ofile))
nasm_error(ERR_NONFATAL|ERR_NOFILE, nasm_error(ERR_NONFATAL|ERR_NOFILE,
"write error on output file `%s'", outname); "write error on output file `%s'", outname);
} }
}
if (ofile) { if (ofile) {
fclose(ofile); fclose(ofile);
@ -898,6 +898,11 @@ set_warning:
depend_emit_phony = true; depend_emit_phony = true;
break; break;
case 'D': case 'D':
operating_mode = OP_DEPEND | OP_NORMAL;
depend_file = q;
advance = true;
break;
case 'F':
depend_file = q; depend_file = q;
advance = true; advance = true;
break; break;