<p>Nico Huber has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/28197">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Makefile.inc: Ensure update of build.h<br><br>There were so many pitfalls that I wrote my own version of this even-<br>tually. This version is inspired by the procedure of Alex Thiessen[1].<br>Instead of generating a `build.h` on demand, we always generate a tem-<br>porary version that, if it differs from the current one, is added as<br>a dependency.<br><br>As we use .SECONDEXPANSION on the prerequisites, special care is taken<br>that we won't generate the file twice. As it would be too late to add<br>the dependency if we'd run `genbuild_h.sh` inside a recipe, we have<br>to run it through the `$(shell)` function. But that brings us to the<br>next issue: The make variables used by `genbuild_h.sh` are not expor-<br>ted to this shell like they would be in a recipe. So we export them<br>manually. We could also make these variables explicit parameters of<br>`genbuild_h.sh` instead.<br><br>An alternative to always creating the temporary `build.h` would be<br>to add a phony target as dependency instead, and finally calling<br>`genbuild_h.sh` again in case we need an update. But, um, we create<br>so many files anyway...<br><br>[1] https://review.coreboot.org/25685<br><br>Change-Id: I311cf610eabae873c70f2985fc7a09acec8061f0<br>Signed-off-by: Nico Huber <nico.h@gmx.de><br>---<br>M Makefile.inc<br>1 file changed, 17 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/97/28197/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/Makefile.inc b/Makefile.inc</span><br><span>index 7ce2360..3840505 100644</span><br><span>--- a/Makefile.inc</span><br><span>+++ b/Makefile.inc</span><br><span>@@ -464,11 +464,24 @@</span><br><span> </span><br><span> #######################################################################</span><br><span> # generate build support files</span><br><span style="color: hsl(0, 100%, 40%);">-$(obj)/build.h: .xcompile</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+build_h := $(obj)/build.h</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# We have to manually export variables that `genbuild_h.sh` uses</span><br><span style="color: hsl(120, 100%, 40%);">+# when we call it through the `$(shell)` function. This is fragile</span><br><span style="color: hsl(120, 100%, 40%);">+# but as variables newly added to `genbuild_h.sh` would just not</span><br><span style="color: hsl(120, 100%, 40%);">+# work, we'd notice that instantly at least.</span><br><span style="color: hsl(120, 100%, 40%);">+build_h_exports := BUILD_TIMELESS KERNELVERSION COREBOOT_EXTRA_VERSION</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# Report new `build.ht` as dependency if `build.h` differs.</span><br><span style="color: hsl(120, 100%, 40%);">+build_h_check := \</span><br><span style="color: hsl(120, 100%, 40%);">+      export $(foreach exp,$(build_h_exports),$(exp)="$($(exp))"); \</span><br><span style="color: hsl(120, 100%, 40%);">+      util/genbuild_h/genbuild_h.sh >$(build_h)t 2>/dev/null; \</span><br><span style="color: hsl(120, 100%, 40%);">+       cmp -s $(build_h)t $(build_h) >/dev/null 2>&1 || echo $(build_h)t</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+$(build_h): $$(shell $$(build_h_check))</span><br><span>       @printf "    GEN        build.h\n"</span><br><span style="color: hsl(0, 100%, 40%);">-    rm -f $(obj)/build.h</span><br><span style="color: hsl(0, 100%, 40%);">-    util/genbuild_h/genbuild_h.sh > $(obj)/build.ht</span><br><span style="color: hsl(0, 100%, 40%);">-      mv $(obj)/build.ht $(obj)/build.h</span><br><span style="color: hsl(120, 100%, 40%);">+     mv $< $@</span><br><span> </span><br><span> build-dirs:</span><br><span>       mkdir -p $(objcbfs) $(objgenerated)</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/28197">change 28197</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/28197"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I311cf610eabae873c70f2985fc7a09acec8061f0 </div>
<div style="display:none"> Gerrit-Change-Number: 28197 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Nico Huber <nico.h@gmx.de> </div>