Makefile: remove bashism
PATCH 1/1 Makefile: remove bashism
When installing modules (when --enable-modules is specified for ./configure), Makefile uses the following construct to replace all slashes with dashes in module name:
${s//\//-}
This is a bash-specific substitution mechanism. POSIX does not have it, and some operating systems (for example Debian) does not implement this construct in default shell (for example dash).
Use more traditional way to perform the substitution: use `tr' tool.
Makefile +1 -1
@@ -376,7 +376,7 @@ endif ifneq ($(CONFIG_MODULES),) $(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)" for s in $(patsubst %.mo,%$(DSOSUF),$(modules-m)); do \ - $(INSTALL_PROG) $(STRIP_OPT) $$s "$(DESTDIR)$(qemu_moddir)/$${s//\//-}"; \ + $(INSTALL_PROG) $(STRIP_OPT) $$s "$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \ done endif ifneq ($(HELPERS-y),)
Quoted 20 lines · Michael Tokarev
When installing modules (when --enable-modules is specified for ./configure),
Makefileuses the following construct to replace all slashes with dashes in module name:${s//\//-}
This is a bash-specific substitution mechanism. POSIX does not have it, and some operating systems (for example Debian) does not implement this construct in default shell (for example dash).
Use more traditional way to perform the substitution: use `tr' tool.
Signed-off-by Michael Tokarev <[email protected]>Makefile +0
-0
Makefile endif · line 382
Quoted 8 lines
Makefile +1
-1@@ -376,7 +376,7 @@ endif ifneq ($(CONFIG_MODULES),) $(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)" for s in $(patsubst %.mo,%$(DSOSUF),$(modules-m)); do \ - $(INSTALL_PROG) $(STRIP_OPT) $$s "$(DESTDIR)$(qemu_moddir)/$${s//\//-}"; \ + $(INSTALL_PROG) $(STRIP_OPT) $$s "$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \ done endif ifneq ($(HELPERS-y),)
Paolo, Fam: does this patch look ok to you? I propose to apply it for 2.0...
thanks
-- PMM
Quoted 32 lines · Peter Maydell
Quoted 20 lines · Michael Tokarev
When installing modules (when --enable-modules is specified for ./configure),
Makefileuses the following construct to replace all slashes with dashes in module name:${s//\//-}
This is a bash-specific substitution mechanism. POSIX does not have it, and some operating systems (for example Debian) does not implement this construct in default shell (for example dash).
Use more traditional way to perform the substitution: use `tr' tool.
Signed-off-by Michael Tokarev <[email protected]>Makefile +0
-0Makefile endif · line 382
Quoted 8 lines
Makefile +1
-1@@ -376,7 +376,7 @@ endif ifneq ($(CONFIG_MODULES),) $(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)" for s in $(patsubst %.mo,%$(DSOSUF),$(modules-m)); do \ - $(INSTALL_PROG) $(STRIP_OPT) $$s "$(DESTDIR)$(qemu_moddir)/$${s//\//-}"; \ + $(INSTALL_PROG) $(STRIP_OPT) $$s "$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \ done endif ifneq ($(HELPERS-y),)Reviewed-by Peter Maydell <[email protected]>
Quoted 2 lines
Paolo, Fam: does this patch look ok to you? I propose to apply it for 2.0...
I don't understand the quoting in the old version offhand (leaning toothpick syndrome). The new version looks good to me.
Quoted 12 lines · Markus Armbruster
Quoted 10 lines · Peter Maydell
Quoted 8 lines · Michael Tokarev
ifneq ($(CONFIG_MODULES),)
$(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)" for s in $(patsubst %.mo,%$(DSOSUF),$(modules-m)); do \Makefile +1
-1- $(INSTALL_PROG) $(STRIP_OPT) $$s "$(DESTDIR)$(qemu_moddir)/$${s//\//-}"; \ + $(INSTALL_PROG) $(STRIP_OPT) $$s "$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \ done endif ifneq ($(HELPERS-y),)
Quoted 7 lines
Quoted 4 lines
Reviewed-by Peter Maydell <[email protected]>Paolo, Fam: does this patch look ok to you? I propose to apply it for 2.0...
I don't understand the quoting in the old version offhand (leaning toothpick syndrome)
Yeah, it took me a while to figure out too, but:
$${s//\//-}
$$ is quoting a '$' for Make, so the shell sees:
${s//\//-}
and the bash syntax for this substitution is:
${parameter/pattern/string}
where if 'pattern' starts with a '/' it means 'replace all matches', like sed's 'g' modifier
So we have:
parameter: s
pattern: /\/
string: -
and the pattern is the 'global replace' modifier plus an escaped forward slash. So it's $s (the shell variable) with all the forward slashes converted to hyphens.
thanks
-- PMM
Peter Maydell
AppliedQuoted 6 lines · Michael Tokarev
When installing modules (when --enable-modules is specified for ./configure),
Makefileuses the following construct to replace all slashes with dashes in module name:${s//\//-}
Quoted 8 lines
This is a bash-specific substitution mechanism. POSIX does not have it, and some operating systems (for example Debian) does not implement this construct in default shell (for example dash).
Use more traditional way to perform the substitution: use `tr' tool.
Signed-off-by Michael Tokarev <[email protected]>
Applied to master, thanks.
-- PMM