Switch default to version info from Git
We gave an existing `versioninfo.inc` priority over more accurate
version info from Git. Now that we allow checked in version info,
it makes sense to switch the default to Git. This way, we get the
best of both.
Change-Id: If057442a5a52409f35538dc7738ae5da2d03c813
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72445
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
diff --git a/Makefile b/Makefile
index dde09a5..665e96c 100644
--- a/Makefile
+++ b/Makefile
@@ -410,12 +410,11 @@
CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o
-# versioninfo.inc stores metadata required to build a packaged flashrom. It is generated by the export rule and
-# imported below. If versioninfo.inc is not found and the variables are not defined by the user, the info will
-# be obtained using util/getrevision.sh, which is the common case during development.
--include versioninfo.inc
-VERSION ?= $(shell ./util/getrevision.sh --revision)
-MAN_DATE ?= $(shell ./util/getrevision.sh --date $(PROGRAM).8.tmpl 2>/dev/null)
+# By default version information will be fetched from Git if available.
+# Otherwise, versioninfo.inc stores the metadata required to build a
+# packaged flashrom. It is generated by the export, tag and branch rules.
+VERSION := $(shell ./util/getversion.sh --version)
+MAN_DATE := $(shell ./util/getversion.sh --man-date)
SCMDEF := -D'FLASHROM_VERSION="$(VERSION)"'
diff --git a/util/getversion.sh b/util/getversion.sh
index d3810d2..6733af0 100755
--- a/util/getversion.sh
+++ b/util/getversion.sh
@@ -13,29 +13,37 @@
# GNU General Public License for more details.
#
+GETREVISION=$(dirname ${0})/getrevision.sh
+
version() {
- if [ -r versioninfo.inc ]; then
- v=$(sed -n 's/^VERSION = //p' versioninfo.inc)
- else
- v=$($(dirname ${0})/getrevision.sh --revision)
- if [ $? -ne 0 ]; then
- v='unknown'
+ v='unknown'
+ if ${GETREVISION} -c; then
+ tmp=$(${GETREVISION} --revision)
+ if [ $? -eq 0 ]; then
+ v="${tmp}"
fi
fi
+ if [ "$v" = unknown -a -r versioninfo.inc ]; then
+ v=$(sed -n 's/^VERSION = //p' versioninfo.inc)
+ fi
+
echo ${v}
}
mandate() {
- if [ -r versioninfo.inc ]; then
- d=$(sed -n 's/^MAN_DATE = //p' versioninfo.inc)
- else
- d=$($(dirname ${0})/getrevision.sh --date flashrom.8.tmpl)
- if [ $? -ne 0 ]; then
- d='unknown'
+ d='unknown'
+ if ${GETREVISION} -c flashrom.8.tmpl; then
+ tmp=$(${GETREVISION} --date flashrom.8.tmpl)
+ if [ $? -eq 0 ]; then
+ d="${tmp}"
fi
fi
+ if [ "$d" = unknown -a -r versioninfo.inc ]; then
+ d=$(sed -n 's/^MAN_DATE = //p' versioninfo.inc)
+ fi
+
echo ${d}
}