summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.rules2
-rwxr-xr-xutil/getversion.sh7
2 files changed, 8 insertions, 1 deletions
diff --git a/Makefile.rules b/Makefile.rules
index 204988036e..80ac99d9b3 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -53,7 +53,7 @@ cmd_c_to_build = $(BUILDCC) $(BUILD_CFLAGS) \
cmd_c_to_host = $(HOSTCC) $(HOST_CFLAGS) -MMD -MF $@.d -o $@ \
$(sort $(foreach c,$($(*F)-objs),util/$(c:%.o=%.c)) $*.c)
cmd_host_test = ./util/run_host_test $* $(silent)
-cmd_date = ./util/getdate.sh > $@
+cmd_date = $(if $(USE_GIT_DATE),cat /dev/null,./util/getdate.sh) > $@
cmd_version = ./util/getversion.sh > $@
cmd_mv_from_tmp = mv $(out)/$*.bin.tmp $(out)/$*.bin
cmd_extractrw-y = dd if=$(out)/$(PROJECT).bin.tmp of=$(out)/$(PROJECT).RW.bin \
diff --git a/util/getversion.sh b/util/getversion.sh
index c1da044690..798bb51448 100755
--- a/util/getversion.sh
+++ b/util/getversion.sh
@@ -31,6 +31,8 @@ fi
ver="${BOARD}_${vbase}"
+gitdate=$(git log -1 --format='%ai' HEAD | cut -d ' ' -f '1 2')
+
echo "/* This file is generated by util/getversion.sh */"
echo "/* Version string for use by common/version.c */"
@@ -47,3 +49,8 @@ echo "/* Sub-fields for use in Makefile.rules and to form build info string"
echo " * in common/version.c. */"
echo "#define VERSION \"${ver}\""
echo "#define BUILDER \"${USER}@`hostname`\""
+
+echo "/* Author date of last commit, in case compile-time is not used. */"
+echo "#ifndef DATE"
+echo "#define DATE \"${gitdate}\""
+echo "#endif"