kbuild/makefile: allow building host tools separately
PATCH 1/1 kbuild/makefile: allow building host tools separately
Sometimes it is required to build only host U-Boot tools without building U-Boot itself for either board.
For example:
* In "buildroot" "uboot-tools" could be built for host just to have an ability to create uImage.
* Linux distributions ship "mkimage" utility as a separate substance.
This patch allows building host U-Boot tools separately from U-Boot itself and what is more important user only needs to have host compiler (gcc).
To build host tools just execute:
=====
make tools HOST_TOOLS_ONLY=yes
=====
Without this patch to generate tools user needs:
1. Configure any existing board with "make XXX_config"
2. Execute tools building but still cross-compiler will be invoked and if there's no proper cross-compiler in PATH compilation will fail.
--- Kbuild | 5 +++++ Makefile | 7 +++++++ 2 files changed, 12 insertions(+)
Kbuild +5 -0
@@ -4,6 +4,9 @@ # 1) Generate generic-asm-offsets.h # 2) Generate asm-offsets.h +# Don't execute target below if building host tools only +ifneq ($(HOST_TOOLS_ONLY),yes) + ##### # 1) Generate generic-asm-offsets.h
@@ -85,3 +88,5 @@ $(CPUDIR)/$(SOC)/asm-offsets.s: $(CPUDIR)/$(SOC)/asm-offsets.c FORCE $(obj)/$(offsets-file): $(CPUDIR)/$(SOC)/asm-offsets.s $(call cmd,offsets) + +endif
Makefile +7 -0
@@ -481,9 +481,12 @@ ifeq ($(dot-config),1) # load other configuration include $(srctree)/config.mk +# Don't check for config.mk presence if building host tools only +ifneq ($(HOST_TOOLS_ONLY),yes) ifeq ($(wildcard include/config.mk),) $(error "System not configured - see README") endif +endif # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use # that (or fail if absent). Otherwise, search for a linker script in a
@@ -994,10 +997,14 @@ ifeq ($(CONFIG_SYS_GENERIC_BOARD),y) @/bin/false endif endif + +# Don't check for ldscript presence if building host tools only +ifneq ($(HOST_TOOLS_ONLY),yes) ifeq ($(wildcard $(LDSCRIPT)),) @echo >&2 " Could not find linker script." @/bin/false endif +endif archprepare: prepare1 scripts_basic
Signature · 1 line
1.8.5.3
PATCH 1/1 kbuild/makefile: allow building host tools separately
Hi Alexey,
Quoted 8 lines
Sometimes it is required to build only host U-Boot tools without building U-Boot itself for either board.
For example:
* In "buildroot" "uboot-tools" could be built for host just to have an ability to create uImage.
* Linux distributions ship "mkimage" utility as a separate substance.
Quoted 7 lines
This patch allows building host U-Boot tools separately from U-Boot itself and what is more important user only needs to have host compiler (gcc).
To build host tools just execute:
=====
make tools HOST_TOOLS_ONLY=yes
=====
This may be the similar discussion to
http://u-boot.10912.n7.nabble.com/U-Boot-could-not-cross-compile-u-boot-tools-td174911.html
Providing a separate make target seems preferable.
Maybe like this?
To build host tools just execute:
=====
make tools-only
=====
And I am not happy about adding ifdef to everywhere.
So, how about a patch like this?
Makefile +4 -1
@@ -409,7 +409,7 @@ timestamp_h := include/generated/timestamp_autogenerated.h no-dot-config-targets := clean clobber mrproper distclean \ help %docs check% coccicheck \ - ubootversion backup + ubootversion backup tools-only config-targets := 0 mixed-targets := 0
@@ -1128,6 +1128,9 @@ checkarmreloc: u-boot env: scripts_basic $(Q)$(MAKE) $(build)=tools/$@ +tools-only: scripts_basic + $(Q)$(MAKE) $(build)=tools + tools-all: export HOST_TOOLS_ALL=y tools-all: env tools ;
Best Regards
Masahiro Yamada
PATCH 1/1 kbuild/makefile: allow building host tools separately
Hi Masahiro-san,
Quoted 4 lines · Masahiro Yamada
Hi Alexey,
This may be the similar discussion to
http://u-boot.10912.n7.nabble.com/U-Boot-could-not-cross-compile-u-boot-tools-td174911.html
It looks not that relevant to me.
For example even before switching U-Boot to Kbuild it was not possible to build host tools simply without patching sources/headers or configuring real target. Or I might be missing something here.
Quoted 8 lines
Providing a separate make target seems preferable.
Maybe like this?
To build host tools just execute:
=====
make tools-only
=====
Fully agree. I thought about it right after I sent you initial patch.
Quoted 1 line
And I am not happy about adding ifdef to everywhere.
So do I. But I don't see other way around unfortunately.
Quoted 20 lines
So, how about a patch like this?
Makefile +1
-1@@ -409,7 +409,7 @@ timestamp_h := include/generated/timestamp_autogenerated.h no-dot-config-targets := clean clobber mrproper distclean \ help %docs check% coccicheck \ - ubootversion backup + ubootversion backup tools-only config-targets := 0 mixed-targets := 0
Makefile checkarmreloc: u-boot · line 1136
Quoted 9 lines
Makefile +3
-0@@ -1128,6 +1128,9 @@ checkarmreloc: u-boot env: scripts_basic $(Q)$(MAKE) $(build)=tools/$@ +tools-only: scripts_basic + $(Q)$(MAKE) $(build)=tools + tools-all: export HOST_TOOLS_ALL=y tools-all: env tools ;
Doesn't work for me:
========
$ make tools-only
HOSTCC scripts/basic/fixdep
HOSTCC tools/aisimage.o
HOSTCC tools/crc32.o
HOSTCC tools/default_image.o
HOSTCC tools/dumpimage.o
In file included from include/version.h:11:0,
from tools/dumpimage.c:11:
include/timestamp.h:11:47: fatal error:
generated/timestamp_autogenerated.h: No such file or directory
#include "generated/timestamp_autogenerated.h"
^
compilation terminated.
make[1]: *** [tools/dumpimage.o] Error 1
make: *** [tools-only] Error 2
========-Alexey
PATCH 1/1 kbuild/makefile: allow building host tools separately
Hi Alexey,
Quoted 8 lines
Quoted 3 lines
This may be the similar discussion to
http://u-boot.10912.n7.nabble.com/U-Boot-could-not-cross-compile-u-boot-tools-td174911.htmlIt looks not that relevant to me.
For example even before switching U-Boot toKbuildit was not possible to build host tools simply without patching sources/headers or configuring real target. Or I might be missing something here.
Sorry, I should have explained it more exactly.
What I wanted you to refer is Wolfgang's comment in that thread.
This part:
Quoted 6 lines · Wolfgang
I'm not really hapy with the additional
CROSS_BUILD_TOOLSparamert - but this may be a matter of taste, so the following is just a thought and a question:Would it make more sense to provide a sparate make target instead?
Quoted 8 lines
Say, something like this:
Build tools for host
make CROSS_COMPILE=<your_gcc_prefix tools
Build tools for target
make CROSS_COMPILE=<your_gcc_prefixcross_tools?
And then we chose a new make target "cross_tools"
rather than a new option "CROSS_BUILD_TOOLS=1".
That is similar to what is happening here.
I wanted to show retionale why a make target "tools-only" is better than "HOST_TOOLS_ONLY=yes".
Quoted 19 lines
Doesn't work for me:
========$ make tools-only HOSTCC scripts/basic/fixdep HOSTCC tools/aisimage.o HOSTCC tools/crc32.o HOSTCC tools/default_image.o HOSTCC tools/dumpimage.o In file included from include/version.h:11:0, from tools/dumpimage.c:11: include/timestamp.h:11:47: fatal error: generated/timestamp_autogenerated.h: No such file or directory #include "generated/timestamp_autogenerated.h" ^ compilation terminated. make[1]: *** [tools/dumpimage.o] Error 1 make: *** [tools-only] Error 2 ========
Oops - My bad.
I was disabling timestamp.
Could you fix like this?
tools-only: scripts_basic $(version_h) $(timestamp_h)
$(Q)$(MAKE) $(build)=tools
It worked for me.
$ make tools-only HOSTCC scripts/basic/fixdep CHK include/config/uboot.release UPD include/config/uboot.release CHK include/generated/version_autogenerated.h UPD include/generated/version_autogenerated.h CHK include/generated/timestamp_autogenerated.h UPD include/generated/timestamp_autogenerated.h HOSTCC tools/aisimage.o HOSTCC tools/crc32.o HOSTCC tools/default_image.o HOSTCC tools/dumpimage.o HOSTCC tools/fdt.o HOSTCC tools/fdt_ro.o HOSTCC tools/fdt_rw.o HOSTCC tools/fdt_strerror.o HOSTCC tools/fdt_wip.o HOSTCC tools/fit_image.o HOSTCC tools/image-fit.o HOSTCC tools/image-host.o HOSTCC tools/image.o HOSTCC tools/imagetool.o HOSTCC tools/imximage.o HOSTCC tools/kwbimage.o HOSTCC tools/md5.o HOSTCC tools/mkenvimage.o HOSTCC tools/mkimage.o HOSTCC tools/mxsimage.o HOSTCC tools/omapimage.o HOSTCC tools/os_support.o HOSTCC tools/pblimage.o HOSTCC tools/sha1.o HOSTCC tools/ublimage.o HOSTLD tools/mkenvimage HOSTLD tools/dumpimage HOSTLD tools/mkimage HOSTCC tools/proftool
Best Regards
Masahiro Yamada
PATCH 1/1 kbuild/makefile: allow building host tools separately
Hi Masahiro-san,
Quoted 2 lines · Masahiro Yamada
I wanted to show retionale why a make target "tools-only" is better than "HOST_TOOLS_ONLY=yes".
Completely agree. I should have think a bit more before sending initial patch because right after the email was sent I thought why didn't I use a new target? :)
New target looks much better than some random variable. It's shorter and easier to use.
Quoted 22 lines
Quoted 19 lines
Doesn't work for me:
========$ make tools-only HOSTCC scripts/basic/fixdep HOSTCC tools/aisimage.o HOSTCC tools/crc32.o HOSTCC tools/default_image.o HOSTCC tools/dumpimage.o In file included from include/version.h:11:0, from tools/dumpimage.c:11: include/timestamp.h:11:47: fatal error: generated/timestamp_autogenerated.h: No such file or directory #include "generated/timestamp_autogenerated.h" ^ compilation terminated. make[1]: *** [tools/dumpimage.o] Error 1 make: *** [tools-only] Error 2 ========
Quoted 9 lines
Oops - My bad.
I was disabling timestamp.Could you fix like this?
tools-only:
scripts_basic$(version_h) $(timestamp_h)$(Q)$(MAKE) $(build)=tools
Works as a charm for me as well.
Do you mind to submit your changes (because it was you who implemented it properly and I don't want to "steal" your credits)?
Or I do it still on your behalf putting you in as an author?
-Alexey
PATCH 1/1 kbuild/makefile: allow building host tools separately
Hi Alexey,
Quoted 9 lines
Quoted 1 line
Works as a charm for me as well.
Do you mind to submit your changes (because it was you who implemented it properly and I don't want to "steal" your credits)?Or I do it still on your behalf putting you in as an author?
-Alexey
OK. I will post it with your Suggested-by credit.
Thanks for your kindness!
Best Regards
Masahiro Yamada