summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2018-11-28 12:36:53 -0800
committerH. Peter Anvin <hpa@zytor.com>2018-11-28 12:40:58 -0800
commit3475462ee87fdd59af715fa0c28eecc4672466fb (patch)
tree2e95ce2afaeb212e2214170abf19f0d85a09a6b7
parentc06c87dbb5358b99968fe2348957fca92ae2ef30 (diff)
downloadnasm-3475462ee87fdd59af715fa0c28eecc4672466fb.tar.gz
nasm: fix the combination -E -MD, handle -MD without a filename
-E -MD should work and output a dependency file. -MD can be used without a filename; there is a default filename or -\c{-MF} can be used. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--asm/nasm.c29
-rw-r--r--doc/changes.src6
-rw-r--r--doc/nasmdoc.src9
3 files changed, 34 insertions, 10 deletions
diff --git a/asm/nasm.c b/asm/nasm.c
index 9435f1d3..445bc367 100644
--- a/asm/nasm.c
+++ b/asm/nasm.c
@@ -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;
diff --git a/doc/changes.src b/doc/changes.src
index ffbcda0d..1bc8f2aa 100644
--- a/doc/changes.src
+++ b/doc/changes.src
@@ -25,6 +25,12 @@ or hexadecimal floating-point having at least 32, 11, or 8 mantissa
digits could produce slightly incorrect results under very specific
conditions.
+\b Support \c{-MD} without a filename, for \c{gcc}
+compatibility. \c{-MF} can be used to set the dependencies output
+filename. See \k{opt-MD}.
+
+\b Fix \c{-E} in combination with \c{-MD}. See \k{opt-E}.
+
\S{cl-2.14} Version 2.14
\b Changed \c{-I} option semantics by adding a trailing path separator
diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src
index ebbd29b3..f1abc507 100644
--- a/doc/nasmdoc.src
+++ b/doc/nasmdoc.src
@@ -496,6 +496,15 @@ updated dependencies with every assembly session. For example:
\c nasm -f elf -o myfile.o -MD myfile.dep myfile.asm
+If the argument after \c{-MD} is an option rather than a filename,
+then the output filename is the first applicable one of:
+
+\b the filename set in the \c{-MF} option;
+
+\b the output filename from the \c{-o} option with \c{.d} appended;
+
+\b the input filename with the extension set to \c{.d}.
+
\S{opt-MT} The \i\c{-MT} Option: Dependency Target Name