When generate dependency names internally, quote filenames

Quote filenames for Make when generated for filenames internally.
Only skip quoting when using the -MT option (rather than -MQ).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2012-09-09 17:09:00 -07:00
parent e55e53db1d
commit 5534099473
3 changed files with 18 additions and 5 deletions

View File

@ -7,6 +7,14 @@
The NASM 2 series supports x86-64, and is the production version of NASM The NASM 2 series supports x86-64, and is the production version of NASM
since 2007. since 2007.
\S{cl-2.10.06} Version 2.10.06
\b Always quote the dependency source names when using the automatic
dependency generation options.
\b If no dependency target name is specified via the \c{-MT} or
\c{-MQ} options, quote the default output name.
\S{cl-2.10.05} Version 2.10.05 \S{cl-2.10.05} Version 2.10.05
\b Add the \c{CLAC} and \c{STAC} instructions. \b Add the \c{CLAC} and \c{STAC} instructions.

View File

@ -626,7 +626,8 @@ specified by the \c{-o} option.
The \c{-MQ} option acts as the \c{-MT} option, except it tries to The \c{-MQ} option acts as the \c{-MT} option, except it tries to
quote characters that have special meaning in Makefile syntax. This quote characters that have special meaning in Makefile syntax. This
is not foolproof, as not all characters with special meaning are is not foolproof, as not all characters with special meaning are
quotable in Make. quotable in Make. The default output (if no \c{-MT} or \c{-MQ} option
is specified) is automatically quoted.
\S{opt-MP} The \i\c{-MP} Option: Emit phony targets \S{opt-MP} The \i\c{-MP} Option: Emit phony targets

12
nasm.c
View File

@ -177,6 +177,8 @@ static bool want_usage;
static bool terminate_after_phase; static bool terminate_after_phase;
int user_nolist = 0; /* fbk 9/2/00 */ int user_nolist = 0; /* fbk 9/2/00 */
static char *quote_for_make(const char *str);
static void nasm_fputs(const char *line, FILE * outfile) static void nasm_fputs(const char *line, FILE * outfile)
{ {
if (outfile) { if (outfile) {
@ -286,13 +288,15 @@ static void emit_dependencies(StrList *list)
linepos = fprintf(deps, "%s:", depend_target); linepos = fprintf(deps, "%s:", depend_target);
list_for_each(l, list) { list_for_each(l, list) {
len = strlen(l->str); char *file = quote_for_make(l->str);
if (linepos + len > 62) { len = strlen(file);
if (linepos + len > 62 && linepos > 1) {
fprintf(deps, " \\\n "); fprintf(deps, " \\\n ");
linepos = 1; linepos = 1;
} }
fprintf(deps, " %s", l->str); fprintf(deps, " %s", file);
linepos += len+1; linepos += len+1;
nasm_free(file);
} }
fprintf(deps, "\n\n"); fprintf(deps, "\n\n");
@ -356,7 +360,7 @@ int main(int argc, char **argv)
depend_ptr = (depend_file || (operating_mode == op_depend)) depend_ptr = (depend_file || (operating_mode == op_depend))
? &depend_list : NULL; ? &depend_list : NULL;
if (!depend_target) if (!depend_target)
depend_target = outname; depend_target = quote_for_make(outname);
switch (operating_mode) { switch (operating_mode) {
case op_depend: case op_depend: