<p>Alex Thiessen has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/25685">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Makefile.inc: Update `build.h` when needed<br><br>Update `build.h` when its content is out of date. This condition depends<br>on a few parameters, e.g. TIMELESS_BUILD variable or `git` status, so<br>it's not easy to track the dependencies by means of the usual `make`<br>prerequisite mechanism. Re-creating `build.h` needlessly every time<br>would cause a cascade of target updates, which is undesirable.<br><br>Create a new temporary `build.h` and check if its content has changed<br>compared to the existing one. If so, rename the file to `build.h`, else<br>don't touch `build.h` at all.<br><br>Change-Id: Iabd1a1ef78b38dab124944fbc837838daee6155e<br>Signed-off-by: Alex Thiessen <alex.thiessen.de+coreboot@gmail.com><br>---<br>M Makefile.inc<br>A util/genbuild_h/genbuild_h_update.sh<br>2 files changed, 50 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/85/25685/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 b11f6e2..264faa1 100644</span><br><span>--- a/Makefile.inc</span><br><span>+++ b/Makefile.inc</span><br><span>@@ -456,11 +456,10 @@</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%);">+$(obj)/build.h: $(shell util/genbuild_h/genbuild_h_update.sh $(obj)/build.h) \</span><br><span style="color: hsl(120, 100%, 40%);">+                     .xcompile</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>diff --git a/util/genbuild_h/genbuild_h_update.sh b/util/genbuild_h/genbuild_h_update.sh</span><br><span>new file mode 100644</span><br><span>index 0000000..33aa7ac</span><br><span>--- /dev/null</span><br><span>+++ b/util/genbuild_h/genbuild_h_update.sh</span><br><span>@@ -0,0 +1,47 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#!/bin/sh</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+##</span><br><span style="color: hsl(120, 100%, 40%);">+## This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+##</span><br><span style="color: hsl(120, 100%, 40%);">+## Copyright (C) 2018 Alex Thiessen <alex.thiessen.de+coreboot@gmail.com></span><br><span style="color: hsl(120, 100%, 40%);">+##</span><br><span style="color: hsl(120, 100%, 40%);">+## This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+## it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+## the Free Software Foundation; version 3 or later of the License.</span><br><span style="color: hsl(120, 100%, 40%);">+##</span><br><span style="color: hsl(120, 100%, 40%);">+## This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+## but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+## GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+##</span><br><span style="color: hsl(120, 100%, 40%);">+## SPDX-License-Identifier: GPL-3.0-or-later</span><br><span style="color: hsl(120, 100%, 40%);">+## <https://spdx.org/licenses/GPL-3.0-or-later.html></span><br><span style="color: hsl(120, 100%, 40%);">+##</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# Purpose of this script is to check if `build.h` is out of date by running</span><br><span style="color: hsl(120, 100%, 40%);">+# `genbuild_h.sh` and comparing its outcome with the existing `build.h`. In case</span><br><span style="color: hsl(120, 100%, 40%);">+# there was a change, file name of the new `build.h` is output so that it can be</span><br><span style="color: hsl(120, 100%, 40%);">+# used as a `make` target prerequisite. Case of missing `build.h` is handled</span><br><span style="color: hsl(120, 100%, 40%);">+# implicitly.</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+# Usage: genbuild_h_update.sh FILE</span><br><span style="color: hsl(120, 100%, 40%);">+#        where `FILE` is the name of `build.h`</span><br><span style="color: hsl(120, 100%, 40%);">+#        e.g. `genbuild_h_update.sh build/build.h`</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+set -e # errexit</span><br><span style="color: hsl(120, 100%, 40%);">+set -u # nounset</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+BUILD_H=${1}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+TMP_BUILD_H=$(mktemp -t "$(basename "${BUILD_H}").XXXXXXXX")</span><br><span style="color: hsl(120, 100%, 40%);">+util/genbuild_h/genbuild_h.sh > "${TMP_BUILD_H}"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+if cmp --quiet "${BUILD_H}" "${TMP_BUILD_H}"</span><br><span style="color: hsl(120, 100%, 40%);">+then</span><br><span style="color: hsl(120, 100%, 40%);">+  # same</span><br><span style="color: hsl(120, 100%, 40%);">+        rm "${TMP_BUILD_H}"</span><br><span style="color: hsl(120, 100%, 40%);">+ exit 0</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# different</span><br><span style="color: hsl(120, 100%, 40%);">+echo "${TMP_BUILD_H}"</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/25685">change 25685</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/25685"/><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: Iabd1a1ef78b38dab124944fbc837838daee6155e </div>
<div style="display:none"> Gerrit-Change-Number: 25685 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Alex Thiessen <alex.thiessen.de+coreboot@gmail.com> </div>