diff mbox

[U-Boot,v8,21/31] Makefile: Move SHELL setup to config.mk

Message ID 1362139841-16540-21-git-send-email-benoit.thebaudeau@advansee.com
State Superseded
Delegated to: Stefano Babic
Headers show

Commit Message

Benoît Thébaudeau March 1, 2013, 12:10 p.m. UTC
make never uses the SHELL variable from the environment. Instead, it
uses /bin/sh, or the value assigned to the SHELL variable by the Makefile. This
makes the export of the SHELL variable useless for sub-makes (but still useful
for the environment of recipes). However, we want all makes to use the same
shell.

This patch fixes this issue by moving the SHELL variable setup and export to the
top config.mk, so that all Makefile-s including it use the same shell.

Since BASH is used by default, this makes it possible to use things
like 'echo -e ...' in sub-makes, which would otherwise fail e.g. with /bin/sh
symlinked to /bin/dash on Ubuntu.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
---
Changes in v8:
 - New patch.

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile  |    7 +------
 config.mk |    7 +++++++
 2 files changed, 8 insertions(+), 6 deletions(-)

Comments

Tom Rini March 1, 2013, 9:26 p.m. UTC | #1
On Fri, Mar 01, 2013 at 01:10:30PM +0100, Beno??t Th??baudeau wrote:

> make never uses the SHELL variable from the environment. Instead, it
> uses /bin/sh, or the value assigned to the SHELL variable by the Makefile. This
> makes the export of the SHELL variable useless for sub-makes (but still useful
> for the environment of recipes). However, we want all makes to use the same
> shell.
> 
> This patch fixes this issue by moving the SHELL variable setup and export to the
> top config.mk, so that all Makefile-s including it use the same shell.
> 
> Since BASH is used by default, this makes it possible to use things
> like 'echo -e ...' in sub-makes, which would otherwise fail e.g. with /bin/sh
> symlinked to /bin/dash on Ubuntu.
> 
> Signed-off-by: Beno??t Th??baudeau <benoit.thebaudeau@advansee.com>

Reviewed-by: Tom Rini <trini@ti.com>
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 5bcc914..b1f0ff0 100644
--- a/Makefile
+++ b/Makefile
@@ -46,12 +46,7 @@  HOSTARCH := $(shell uname -m | \
 HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
 	    sed -e 's/\(cygwin\).*/cygwin/')
 
-# Set shell to bash if possible, otherwise fall back to sh
-SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
-	else if [ -x /bin/bash ]; then echo /bin/bash; \
-	else echo sh; fi; fi)
-
-export	HOSTARCH HOSTOS SHELL
+export	HOSTARCH HOSTOS
 
 # Deal with colliding definitions from tcsh etc.
 VENDOR=
diff --git a/config.mk b/config.mk
index b7cd481..21c0844 100644
--- a/config.mk
+++ b/config.mk
@@ -23,6 +23,13 @@ 
 
 #########################################################################
 
+# Set shell to bash if possible, otherwise fall back to sh
+SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
+	else if [ -x /bin/bash ]; then echo /bin/bash; \
+	else echo sh; fi; fi)
+
+export	SHELL
+
 include $(TOPDIR)/helper.mk
 
 ifeq ($(CURDIR),$(SRCTREE))