2015-07-19 03:43:34

by Richard Yao

[permalink] [raw]
Subject: [PATCH] perf tools: Do not require /bin/sh be bash

Commit fcfd6611fbccdbf2593bd949097a5c0e45cd96da truncated
.config-detected by piping echo -n to it. On systems where /bin/sh is
not bash and echo is a builtin, echo -n prints "-n", which breaks the
build:

.config-detected:1: *** missing separator. Stop.

This broke builds on my Gentoo systems where /bin/sh is dash and
possibly other systems where /bin/sh is not bash as well. It is easily
solved by piping cat /dev/null. Piping an empty command should have been
a suitable substitute, but zsh hangs when asked to do that.

This method of truncating a file works on bash, busybox ash, dash and
zsh. Other shells were not tested.

Signed-off-by: Richard Yao <[email protected]>
Reviewed-by: Emilio López <[email protected]>
---
tools/perf/config/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 094ddae..70426d6 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -11,7 +11,7 @@ ifneq ($(obj-perf),)
obj-perf := $(abspath $(obj-perf))/
endif

-$(shell echo -n > $(OUTPUT).config-detected)
+$(shell cat /dev/null > $(OUTPUT).config-detected)
detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)

--
2.3.6