* [U-Boot] [PATCH 0/3] Do not hard-code the command name 'make' in upper-level tools
@ 2014-07-17 9:17 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
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Masahiro Yamada @ 2014-07-17 9:17 UTC (permalink / raw)
To: u-boot
Masahiro Yamada (3):
scripts: add scripts/gnu_make to not hard-code make command
MAKEALL: make sure to invoke GNU Make
buildman: make sure to invoke GNU Make
MAKEALL | 8 +++++---
scripts/gnu_make | 30 ++++++++++++++++++++++++++++++
tools/buildman/builder.py | 3 ++-
3 files changed, 37 insertions(+), 4 deletions(-)
create mode 100755 scripts/gnu_make
--
1.9.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 1/3] scripts: add scripts/gnu_make to not hard-code make command
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 ` Masahiro Yamada
2014-07-18 18:19 ` Jeroen Hofstee
2014-07-17 9:18 ` [U-Boot] [PATCH 2/3] MAKEALL: make sure to invoke GNU Make Masahiro Yamada
2014-07-17 9:18 ` [U-Boot] [PATCH 3/3] buildman: " Masahiro Yamada
2 siblings, 1 reply; 10+ messages in thread
From: Masahiro Yamada @ 2014-07-17 9:18 UTC (permalink / raw)
To: u-boot
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
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 "$@"
--
1.9.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 2/3] MAKEALL: make sure to invoke GNU Make
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-17 9:18 ` Masahiro Yamada
2014-07-18 18:29 ` Jeroen Hofstee
2014-07-17 9:18 ` [U-Boot] [PATCH 3/3] buildman: " Masahiro Yamada
2 siblings, 1 reply; 10+ messages in thread
From: Masahiro Yamada @ 2014-07-17 9:18 UTC (permalink / raw)
To: u-boot
Since the command name 'make' is not GNU Make on some platforms
such as FreeBSD, MAKEALL should call the make via scripts/gnu_make.
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---
MAKEALL | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/MAKEALL b/MAKEALL
index 37ef71e..02c2f9f 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -630,14 +630,16 @@ build_target() {
output_dir="${OUTPUT_PREFIX}"
fi
+ GNU_MAKE=scripts/gnu_make
+
target_arch=$(get_target_arch ${target})
eval cross_toolchain=\$CROSS_COMPILE_`echo $target_arch | tr '[:lower:]' '[:upper:]'`
if [ "${cross_toolchain}" ] ; then
- MAKE="make CROSS_COMPILE=${cross_toolchain}"
+ MAKE="$GNU_MAKE CROSS_COMPILE=${cross_toolchain}"
elif [ "${CROSS_COMPILE}" ] ; then
- MAKE="make CROSS_COMPILE=${CROSS_COMPILE}"
+ MAKE="$GNU_MAKE CROSS_COMPILE=${CROSS_COMPILE}"
else
- MAKE=make
+ MAKE=$GNU_MAKE
fi
if [ "${output_dir}" != "." ] ; then
--
1.9.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 3/3] buildman: make sure to invoke GNU Make
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-17 9:18 ` [U-Boot] [PATCH 2/3] MAKEALL: make sure to invoke GNU Make Masahiro Yamada
@ 2014-07-17 9:18 ` Masahiro Yamada
2014-07-19 4:40 ` Simon Glass
2014-07-20 18:13 ` Jeroen Hofstee
2 siblings, 2 replies; 10+ messages in thread
From: Masahiro Yamada @ 2014-07-17 9:18 UTC (permalink / raw)
To: u-boot
Since the command name 'make' is not GNU Make on some platforms
such as FreeBSD, MAKEALL should call the make via scripts/gnu_make.
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---
tools/buildman/builder.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 4a2d753..c68cc8c 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -667,7 +667,8 @@ class Builder:
args: Arguments to pass to make
kwargs: Arguments to pass to command.RunPipe()
"""
- cmd = ['make'] + list(args)
+ gnu_make = os.path.join(self.git_dir, '../scripts/gnu_make')
+ cmd = [gnu_make] + list(args)
result = command.RunPipe([cmd], capture=True, capture_stderr=True,
cwd=cwd, raise_on_error=False, **kwargs)
return result
--
1.9.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 1/3] scripts: add scripts/gnu_make to not hard-code make command
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
2014-07-22 3:54 ` Masahiro Yamada
0 siblings, 1 reply; 10+ messages in thread
From: Jeroen Hofstee @ 2014-07-18 18:19 UTC (permalink / raw)
To: u-boot
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 2/3] MAKEALL: make sure to invoke GNU Make
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
0 siblings, 1 reply; 10+ messages in thread
From: Jeroen Hofstee @ 2014-07-18 18:29 UTC (permalink / raw)
To: u-boot
Hello Masahiro,
On 17-07-14 11:18, Masahiro Yamada wrote:
> Since the command name 'make' is not GNU Make on some platforms
> such as FreeBSD, MAKEALL should call the make via scripts/gnu_make.
>
> Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
> ---
>
> MAKEALL | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/MAKEALL b/MAKEALL
> index 37ef71e..02c2f9f 100755
> --- a/MAKEALL
> +++ b/MAKEALL
> @@ -630,14 +630,16 @@ build_target() {
> output_dir="${OUTPUT_PREFIX}"
> fi
>
> + GNU_MAKE=scripts/gnu_make
> +
> target_arch=$(get_target_arch ${target})
> eval cross_toolchain=\$CROSS_COMPILE_`echo $target_arch | tr '[:lower:]' '[:upper:]'`
> if [ "${cross_toolchain}" ] ; then
> - MAKE="make CROSS_COMPILE=${cross_toolchain}"
> + MAKE="$GNU_MAKE CROSS_COMPILE=${cross_toolchain}"
> elif [ "${CROSS_COMPILE}" ] ; then
> - MAKE="make CROSS_COMPILE=${CROSS_COMPILE}"
> + MAKE="$GNU_MAKE CROSS_COMPILE=${CROSS_COMPILE}"
> else
> - MAKE=make
> + MAKE=$GNU_MAKE
> fi
>
> if [ "${output_dir}" != "." ] ; then
while by itself this might be correct, opt is not a POSIX command
and MAKEALL will not work at all on a BSD host. Perhaps it is
time I have a look at what buildman is....
Regards,
Jeroen
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 3/3] buildman: make sure to invoke GNU Make
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
1 sibling, 0 replies; 10+ messages in thread
From: Simon Glass @ 2014-07-19 4:40 UTC (permalink / raw)
To: u-boot
On 17 July 2014 03:18, Masahiro Yamada <yamada.m@jp.panasonic.com> wrote:
> Since the command name 'make' is not GNU Make on some platforms
> such as FreeBSD, MAKEALL should call the make via scripts/gnu_make.
>
> Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Maybe you will rename the script, but the code looks good.
Acked-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 2/3] MAKEALL: make sure to invoke GNU Make
2014-07-18 18:29 ` Jeroen Hofstee
@ 2014-07-19 4:41 ` Simon Glass
0 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2014-07-19 4:41 UTC (permalink / raw)
To: u-boot
Hi Jeroen,
On 18 July 2014 12:29, Jeroen Hofstee <dasuboot@myspectrum.nl> wrote:
> Hello Masahiro,
>
>
> On 17-07-14 11:18, Masahiro Yamada wrote:
>>
>> Since the command name 'make' is not GNU Make on some platforms
>> such as FreeBSD, MAKEALL should call the make via scripts/gnu_make.
>>
>> Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
>> ---
>>
>> MAKEALL | 8 +++++---
>> 1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/MAKEALL b/MAKEALL
>> index 37ef71e..02c2f9f 100755
>> --- a/MAKEALL
>> +++ b/MAKEALL
>> @@ -630,14 +630,16 @@ build_target() {
>> output_dir="${OUTPUT_PREFIX}"
>> fi
>> + GNU_MAKE=scripts/gnu_make
>> +
>> target_arch=$(get_target_arch ${target})
>> eval cross_toolchain=\$CROSS_COMPILE_`echo $target_arch | tr
>> '[:lower:]' '[:upper:]'`
>> if [ "${cross_toolchain}" ] ; then
>> - MAKE="make CROSS_COMPILE=${cross_toolchain}"
>> + MAKE="$GNU_MAKE CROSS_COMPILE=${cross_toolchain}"
>> elif [ "${CROSS_COMPILE}" ] ; then
>> - MAKE="make CROSS_COMPILE=${CROSS_COMPILE}"
>> + MAKE="$GNU_MAKE CROSS_COMPILE=${CROSS_COMPILE}"
>> else
>> - MAKE=make
>> + MAKE=$GNU_MAKE
>> fi
>> if [ "${output_dir}" != "." ] ; then
>
>
> while by itself this might be correct, opt is not a POSIX command
> and MAKEALL will not work at all on a BSD host. Perhaps it is
> time I have a look at what buildman is....
http://patchwork.ozlabs.org/patch/369788/
:-)
Regards,
Simon
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 3/3] buildman: make sure to invoke GNU Make
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
1 sibling, 0 replies; 10+ messages in thread
From: Jeroen Hofstee @ 2014-07-20 18:13 UTC (permalink / raw)
To: u-boot
Hello Masahiro,
On 17-07-14 11:18, Masahiro Yamada wrote:
> Since the command name 'make' is not GNU Make on some platforms
> such as FreeBSD, MAKEALL should call the make via scripts/gnu_make.
>
> Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
> ---
>
> tools/buildman/builder.py | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
> index 4a2d753..c68cc8c 100644
> --- a/tools/buildman/builder.py
> +++ b/tools/buildman/builder.py
> @@ -667,7 +667,8 @@ class Builder:
> args: Arguments to pass to make
> kwargs: Arguments to pass to command.RunPipe()
> """
> - cmd = ['make'] + list(args)
> + gnu_make = os.path.join(self.git_dir, '../scripts/gnu_make')
> + cmd = [gnu_make] + list(args)
> result = command.RunPipe([cmd], capture=True, capture_stderr=True,
> cwd=cwd, raise_on_error=False, **kwargs)
> return result
with a trick to let buildman call clang, this works
fine on FreeBSD.
Tested-By: Jeroen Hofstee <jeroen@myspectrum.nl>
Regards,
Jeroen
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 1/3] scripts: add scripts/gnu_make to not hard-code make command
2014-07-18 18:19 ` Jeroen Hofstee
@ 2014-07-22 3:54 ` Masahiro Yamada
0 siblings, 0 replies; 10+ messages in thread
From: Masahiro Yamada @ 2014-07-22 3:54 UTC (permalink / raw)
To: u-boot
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
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-07-22 3:54 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox