diff mbox

[U-Boot,1/3] scripts: add scripts/gnu_make to not hard-code make command

Message ID 1405588682-10724-2-git-send-email-yamada.m@jp.panasonic.com
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Masahiro Yamada July 17, 2014, 9:18 a.m. UTC
U-Boot is expected to be built on various platforms
but makefiles are written for GNU Make.

We should keep in mind that the command 'make' is not always 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.

Instead, they should call the make command via this helper script
to make sure it is GNU Make.

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

 scripts/gnu_make | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100755 scripts/gnu_make

Comments

Jeroen Hofstee July 18, 2014, 6:19 p.m. UTC | #1
Hello Masahiro,

On 17-07-14 11:18, Masahiro Yamada wrote:
> U-Boot is expected to be built on various platforms
> but makefiles are written for GNU Make.
>
> We should keep in mind that the command 'make' is not always 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.

indeed, not a good idea.
> Instead, they should call the make command via this helper script
> to make sure it is GNU Make.

yup, or the name of the executable could be displayed, so
it only needs to be checked once at startup (and error out
if no GNU make is found at all).

> +++ b/scripts/gnu_make

nitpicking, most script use a dash instead of an underscore.

> @@ -0,0 +1,30 @@
> +#!/bin/sh
> +#
> +# Call 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 'make'
> +# in scripts where where GNU Make is expected.
> +# In that case, call this helper script to make sure to invoke 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
> +		gnu_make=$m
> +		break
> +	fi
> +done
> +
> +if [ -z "$gnu_make" ]; then
> +	echo "GNU Make not found" >&2
> +	exit 1
> +fi
> +
> +$gnu_make "$@"
>

I guess, it could use exec here, since the script itself
is no longer needed.

Regards,
Jeroen
Masahiro Yamada July 22, 2014, 3:54 a.m. UTC | #2
Hi Jeroen,


On Fri, 18 Jul 2014 20:19:52 +0200
Jeroen Hofstee <jeroen@myspectrum.nl> wrote:

> > Instead, they should call the make command via this helper script
> > to make sure it is GNU Make.
> 
> yup, or the name of the executable could be displayed, so
> it only needs to be checked once at startup (and error out
> if no GNU make is found at all).

Good idea!

MAKEALL and buildman generally invoke make for a lot of boards.
Searching it once at startup seems better.




> > +++ b/scripts/gnu_make
> 
> nitpicking, most script use a dash instead of an underscore.

Renamed in v2.



Best Regards
Masahiro Yamada
diff mbox

Patch

diff --git a/scripts/gnu_make b/scripts/gnu_make
new file mode 100755
index 0000000..2eeafbb
--- /dev/null
+++ b/scripts/gnu_make
@@ -0,0 +1,30 @@ 
+#!/bin/sh
+#
+# Call 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 'make'
+# in scripts where where GNU Make is expected.
+# In that case, call this helper script to make sure to invoke 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
+		gnu_make=$m
+		break
+	fi
+done
+
+if [ -z "$gnu_make" ]; then
+	echo "GNU Make not found" >&2
+	exit 1
+fi
+
+$gnu_make "$@"