public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jeroen Hofstee <jeroen@myspectrum.nl>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] scripts: add scripts/gnu_make to not hard-code make command
Date: Fri, 18 Jul 2014 20:19:52 +0200	[thread overview]
Message-ID: <53C96548.5020408@myspectrum.nl> (raw)
In-Reply-To: <1405588682-10724-2-git-send-email-yamada.m@jp.panasonic.com>

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

  reply	other threads:[~2014-07-18 18:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-17  9:17 [U-Boot] [PATCH 0/3] Do not hard-code the command name 'make' in upper-level tools Masahiro Yamada
2014-07-17  9:18 ` [U-Boot] [PATCH 1/3] scripts: add scripts/gnu_make to not hard-code make command Masahiro Yamada
2014-07-18 18:19   ` Jeroen Hofstee [this message]
2014-07-22  3:54     ` Masahiro Yamada
2014-07-17  9:18 ` [U-Boot] [PATCH 2/3] MAKEALL: make sure to invoke GNU Make Masahiro Yamada
2014-07-18 18:29   ` Jeroen Hofstee
2014-07-19  4:41     ` Simon Glass
2014-07-17  9:18 ` [U-Boot] [PATCH 3/3] buildman: " Masahiro Yamada
2014-07-19  4:40   ` Simon Glass
2014-07-20 18:13   ` Jeroen Hofstee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53C96548.5020408@myspectrum.nl \
    --to=jeroen@myspectrum.nl \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox