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:
parent
e9fc88ca11
commit
599a98272e
1 changed files with 45 additions and 40 deletions
85
nasm.c
85
nasm.c
|
@ -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,51 +434,51 @@ 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) {
|
}
|
||||||
/*
|
|
||||||
* 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 (operating_mode & OP_NORMAL) {
|
||||||
if (!ofile) {
|
/*
|
||||||
nasm_error(ERR_FATAL | ERR_NOFILE,
|
* We must call ofmt->filename _anyway_, even if the user
|
||||||
"unable to open output file `%s'", outname);
|
* 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");
|
||||||
* We must call init_labels() before ofmt->init() since
|
if (!ofile)
|
||||||
* some object formats will want to define labels in their
|
nasm_error(ERR_FATAL | ERR_NOFILE,
|
||||||
* init routines. (eg OS/2 defines the FLAT group)
|
"unable to open output file `%s'", outname);
|
||||||
*/
|
|
||||||
init_labels();
|
|
||||||
|
|
||||||
ofmt->init();
|
/*
|
||||||
dfmt = ofmt->current_dfmt;
|
* We must call init_labels() before ofmt->init() since
|
||||||
dfmt->init();
|
* 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) {
|
assemble_file(inname, depend_ptr);
|
||||||
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) {
|
if (!terminate_after_phase) {
|
||||||
fclose(ofile);
|
ofmt->cleanup(using_debug_info);
|
||||||
if (terminate_after_phase)
|
cleanup_labels();
|
||||||
remove(outname);
|
fflush(ofile);
|
||||||
ofile = NULL;
|
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)
|
if (depend_list && !terminate_after_phase)
|
||||||
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue