Makefile.inc: Ensure update of build.h
There were so many pitfalls that I wrote my own version of this even- tually. This version is inspired by the procedure of Alex Thiessen[1]. Instead of generating a `build.h` on demand, we always generate a tem- porary version that, if it differs from the current one, is added as a dependency. As we use .SECONDEXPANSION on the prerequisites, special care is taken that we won't generate the file twice. As it would be too late to add the dependency if we'd run `genbuild_h.sh` inside a recipe, we have to run it through the `$(shell)` function. But that brings us to the next issue: The make variables used by `genbuild_h.sh` are not expor- ted to this shell like they would be in a recipe. So we export them manually. We could also make these variables explicit parameters of `genbuild_h.sh` instead. An alternative to always creating the temporary `build.h` would be to add a phony target as dependency instead, and finally calling `genbuild_h.sh` again in case we need an update. But, um, we create so many files anyway... [1] https://review.coreboot.org/25685 Change-Id: I311cf610eabae873c70f2985fc7a09acec8061f0 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/28197 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Rudolph <siro@das-labor.org>
This commit is contained in:
parent
20df17cc65
commit
5d790e3f52
21
Makefile.inc
21
Makefile.inc
|
@ -464,11 +464,24 @@ export $(COREBOOT_EXPORTS)
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# generate build support files
|
# generate build support files
|
||||||
$(obj)/build.h: .xcompile
|
|
||||||
|
build_h := $(obj)/build.h
|
||||||
|
|
||||||
|
# We have to manually export variables that `genbuild_h.sh` uses
|
||||||
|
# when we call it through the `$(shell)` function. This is fragile
|
||||||
|
# but as variables newly added to `genbuild_h.sh` would just not
|
||||||
|
# work, we'd notice that instantly at least.
|
||||||
|
build_h_exports := BUILD_TIMELESS KERNELVERSION COREBOOT_EXTRA_VERSION
|
||||||
|
|
||||||
|
# Report new `build.ht` as dependency if `build.h` differs.
|
||||||
|
build_h_check := \
|
||||||
|
export $(foreach exp,$(build_h_exports),$(exp)="$($(exp))"); \
|
||||||
|
util/genbuild_h/genbuild_h.sh >$(build_h)t 2>/dev/null; \
|
||||||
|
cmp -s $(build_h)t $(build_h) >/dev/null 2>&1 || echo $(build_h)t
|
||||||
|
|
||||||
|
$(build_h): $$(shell $$(build_h_check))
|
||||||
@printf " GEN build.h\n"
|
@printf " GEN build.h\n"
|
||||||
rm -f $(obj)/build.h
|
mv $< $@
|
||||||
util/genbuild_h/genbuild_h.sh > $(obj)/build.ht
|
|
||||||
mv $(obj)/build.ht $(obj)/build.h
|
|
||||||
|
|
||||||
build-dirs:
|
build-dirs:
|
||||||
mkdir -p $(objcbfs) $(objgenerated)
|
mkdir -p $(objcbfs) $(objgenerated)
|
||||||
|
|
Loading…
Reference in New Issue