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