Enable build info rebuild upon HEAD commit ID change
authorDavide Libenzi <dlibenzi@google.com>
Mon, 21 Dec 2015 19:24:36 +0000 (11:24 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 11 Feb 2016 15:52:01 +0000 (10:52 -0500)
Enable build info rebuild upon HEAD commit ID change.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
.gitignore
kern/src/Kbuild

index 20c022f..2c8ba61 100644 (file)
@@ -19,7 +19,7 @@ ros-project.tmproj
 kern/boot
 kern/include/arch
 kern/src/arch
-kern/src/build_info.c
+kern/src/build_info.*
 kern/src/error.c
 user/parlib/include/arch
 Documentation/doxygen/rosdoc
index c3af054..f4cb602 100644 (file)
@@ -7,7 +7,14 @@ $(src)/error.c: $(AKAROS_ROOT)/include/ros/errno.h
        @echo "};"                             >> $(@)
        @echo "const int MAX_ERRNO = sizeof(errno_strings)/sizeof(errno_strings[0]);" >> $(@)
 
-$(src)/build_info.c:
+$(src)/build_info.cid:
+       @echo `git rev-parse HEAD` > $(src)/build_info.cid.tmp
+       @if [ ! -f $(src)/build_info.cid ] || \
+               [ `cmp -s $(src)/build_info.cid $(src)/build_info.cid.tmp` -ne 0 ]; then \
+                       cp $(src)/build_info.cid.tmp $(src)/build_info.cid; fi;
+       @rm -f $(src)/build_info.cid.tmp
+
+$(src)/build_info.c: $(src)/build_info.cid
 ifeq ($(BUILD_INFO_FILE),)
                @echo "/* Automatically generated. DO NOT EDIT! */" > $(@)
                @echo "" >> $(@)
@@ -17,17 +24,17 @@ ifeq ($(BUILD_INFO_FILE),)
                        >> $(@)
                @echo "const char build_info_host[] = { \"`hostname`\" };"\
                        >> $(@)
-               @echo "const char build_info_commitid[] = { \"`git rev-parse HEAD`\" };"\
+               @echo "const char build_info_commitid[] = { \"`cat $(src)/build_info.cid`\" };"\
                        >> $(@)
                @echo "const char build_info_version[] = { \"$(KERNELVERSION)\" };"\
                        >> $(@)
                @echo "const char build_info_version_name[] = { \"$(VERNAME)\" };"\
                        >> $(@)
 else
-               @cp $(BUILD_INFO_FILE) $(@)
+               cp $(BUILD_INFO_FILE) $(@)
 endif
 
-clean-files += build_info.c error.c
+clean-files += build_info.c build_info.cid error.c
 
 obj-y                                          += alarm.o
 obj-y                                          += apipe.o