diff mbox

[U-Boot,v2,1/3] scripts: add scripts/show-gnu-make to get GNU Make command name

Message ID 1405995549-30489-2-git-send-email-yamada.m@jp.panasonic.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Masahiro Yamada July 22, 2014, 2:19 a.m. UTC
U-Boot is expected to be built on various platforms.

We should keep in mind that the command 'make' is not always GNU Make,
while all the makefiles are written for GNU Make.

For example, on Linux, people generally do:

  make <board>_config; make

But FreeBSD folks do

  gmake <board>_config; gmake

(The command 'make' on FreeBSD is BSD Make, not GNU Make)

It is not a good idea to hard-code the command name 'make'
in MAKEALL or buildman.

They should call this helper script and get the command name
for GNU Make.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

Changes in v2:
  - Use dashes for filename
  - Show the command name instead of invoking make.
    It allows us to check the command name once at startup
    (and error out if no GNU Make is found.)

 scripts/show-gnu-make | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100755 scripts/show-gnu-make

Comments

Tom Rini July 29, 2014, 3:57 p.m. UTC | #1
On Tue, Jul 22, 2014 at 11:19:07AM +0900, Masahiro Yamada wrote:

> U-Boot is expected to be built on various platforms.
> 
> We should keep in mind that the command 'make' is not always GNU Make,
> while all the makefiles are written for GNU Make.
> 
> For example, on Linux, people generally do:
> 
>   make <board>_config; make
> 
> But FreeBSD folks do
> 
>   gmake <board>_config; gmake
> 
> (The command 'make' on FreeBSD is BSD Make, not GNU Make)
> 
> It is not a good idea to hard-code the command name 'make'
> in MAKEALL or buildman.
> 
> They should call this helper script and get the command name
> for GNU Make.
> 
> Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/scripts/show-gnu-make b/scripts/show-gnu-make
new file mode 100755
index 0000000..26271b5
--- /dev/null
+++ b/scripts/show-gnu-make
@@ -0,0 +1,25 @@ 
+#!/bin/sh
+#
+# Show the command name for GNU Make
+#
+# U-Boot is supposed to be built on various platforms.
+# One problem is that the command 'make' is not always GNU Make.
+# (For ex. the command name for GNU Make on FreeBSD is usually 'gmake'.)
+# It is not a good idea to hard-code the command name in scripts
+# where where GNU Make is expected.
+# Call this helper script to get the command name for GNU Make.
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+gnu_make=
+
+for m in make gmake
+do
+	if $m --version 2>/dev/null | grep -q GNU; then
+		echo $m
+		exit 0
+	fi
+done
+
+exit 1