mirror of https://github.com/rkd77/elinks.git synced 2024-06-12 23:10:51 +00:00

build: Quote redirections when echoing commands.

Without this, "make --directory=doc V=1 keymap-defaults.txt"
would not display the command it runs, because the command is

LC_ALL=C LANGUAGE=en /home/Kalle/src/elinks-0.12/doc/tools/keys2doc /home/Kalle/src/elinks-0.12/src/config/kbdbind.c keymap-defaults.txt > keymap-defaults.txt

and the build system would run

echo LC_ALL=C LANGUAGE=en /home/Kalle/src/elinks-0.12/doc/tools/keys2doc /home/Kalle/src/elinks-0.12/src/config/kbdbind.c keymap-defaults.txt > keymap-defaults.txt && LC_ALL=C LANGUAGE=en /home/Kalle/src/elinks-0.12/doc/tools/keys2doc /home/Kalle/src/elinks-0.12/src/config/kbdbind.c keymap-defaults.txt > keymap-defaults.txt

so, the initial echo was redirected to keymap-defaults.txt too,
and then overwritten with the intended output.  Now, the build
system instead runs

echo 'LC_ALL=C LANGUAGE=en /home/Kalle/src/elinks-0.12/doc/tools/keys2doc /home/Kalle/src/elinks-0.12/src/config/kbdbind.c keymap-defaults.txt > keymap-defaults.txt' && LC_ALL=C LANGUAGE=en /home/Kalle/src/elinks-0.12/doc/tools/keys2doc /home/Kalle/src/elinks-0.12/src/config/kbdbind.c keymap-defaults.txt > keymap-defaults.txt

which echoes the redirection instead of executing it.  This change
also makes the output correctly preserve quotes in some other rules.
This commit is contained in:
Kalle Olavi Niemitalo 2008-03-22 09:44:12 +02:00 committed by Kalle Olavi Niemitalo
parent 96162a9f74
commit 0d7ff95d72

View File

@ -23,22 +23,33 @@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
# If we are verbose, we will show the "real" cmds instead of
# their quiet versions (which are used in the non-verbose mode).
# Inspired by the Linux kernel build system.
# If real cmds are to be shown, then quoteverbose quotes each as
# a shell word, so that it can be accurately displayed with echo.
# If the quiet versions are to be shown, then they should already
# be sufficiently quoted, so quoteverbose does nothing.
ifdef V
quiet =
mquiet = masq_
quoteverbose = '$(subst ','\'',$(1))'
#'# This line fixes syntax highlighting in Emacs' makefile-mode.
Q =
quiet = quiet_
mquiet = quiet_
quoteverbose = $(1)
Q = @
# Show the command (quiet or non-quiet version based on the assignment
# just above) and then execute it.
ncmd = $(if $($(quiet)cmd_$(1)),echo $($(quiet)cmd_$(1)) &&) $(cmd_$(1))
cmd = @$(if $($(quiet)cmd_$(1)),echo $($(quiet)cmd_$(1)) &&) $(cmd_$(1))
mcmd = @$(if $($(mquiet)cmd_$(1)),echo $($(mquiet)cmd_$(1)) &&) $(cmd_$(1))
ecmd = @$(if $($(mquiet)cmd_$(1)),printf "%-38s " $($(mquiet)cmd_$(1)) &&) $(cmd_$(1))
# Because $(cmd_$(1)) and related variables may contain references to $(2),
# they must be expanded right here; that cannot be delegated to quoteverbose.
ncmd = $(if $($(quiet)cmd_$(1)),echo $(call quoteverbose,$($(quiet)cmd_$(1))) &&) $(cmd_$(1))
cmd = @$(if $($(quiet)cmd_$(1)),echo $(call quoteverbose,$($(quiet)cmd_$(1))) &&) $(cmd_$(1))
mcmd = @$(if $($(mquiet)cmd_$(1)),echo $(call quoteverbose,$($(mquiet)cmd_$(1))) &&) $(cmd_$(1))
ecmd = @$(if $($(mquiet)cmd_$(1)),printf "%-38s " $(call quoteverbose,$($(mquiet)cmd_$(1))) &&) $(cmd_$(1))
quiet_cmd_compile = ' [$(CC_COLOR)CC$(END_COLOR)] $(RELPATH)$@'
masq_cmd_compile = $(COMPILE) -o $(@) -c $< $(2)