Move generation of build.h into a shell script
Moving the routines that create build.h into a script offers several advantages. We can create more complex functions to run and we don't have to deal with both bash and Make at the same time. This script combines what is currently in Makefile.inc with a couple of updates. - Update how it determines whether to use git for the timestamp - Move the git revision string generation inside the routine that checks to see if we have git. - Add a timeout for the domain name check. Change-Id: I93c131e8d01a0099eb13db720fa865c627985750 Signed-off-by: Martin Roth <gaumless@gmail.com> Reviewed-on: http://review.coreboot.org/8428 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
28
Makefile.inc
28
Makefile.inc
@@ -243,7 +243,7 @@ CBFS_PAYLOAD_COMPRESS_FLAG:=LZMA
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_LOCALVERSION),"")
|
||||
COREBOOT_EXTRA_VERSION := -$(call strip_quotes,$(CONFIG_LOCALVERSION))
|
||||
export COREBOOT_EXTRA_VERSION := -$(call strip_quotes,$(CONFIG_LOCALVERSION))
|
||||
endif
|
||||
|
||||
CPPFLAGS_common := -Isrc -Isrc/include -I$(obj)
|
||||
@@ -274,31 +274,7 @@ additional-dirs := $(objutil)/cbfstool $(objutil)/romcc $(objutil)/ifdtool \
|
||||
$(obj)/build.h: .xcompile
|
||||
@printf " GEN build.h\n"
|
||||
rm -f $(obj)/build.h
|
||||
printf "/* build system definitions (autogenerated) */\n" > $(obj)/build.ht
|
||||
printf "#ifndef __BUILD_H\n" >> $(obj)/build.ht
|
||||
printf "#define __BUILD_H\n\n" >> $(obj)/build.ht
|
||||
printf "#define COREBOOT_VERSION \"$(KERNELVERSION)\"\n" >> $(obj)/build.ht
|
||||
if git update-index -q --refresh >/dev/null; ! git diff-index --quiet HEAD; then \
|
||||
printf "/* `LANG= TZ=UTC git log --date=local --pretty=format:%cd -1` UTC */\n" >> $(obj)/build.ht; \
|
||||
printf "#define COREBOOT_VERSION_TIMESTAMP `LANG= git log --pretty=format:%ct -1`\n" >> $(obj)/build.ht; \
|
||||
else \
|
||||
printf "/* `LANG= TZ=UTC date` */\n" >> $(obj)/build.ht; \
|
||||
printf "#define COREBOOT_VERSION_TIMESTAMP `LANG= date +%s`\n" >> $(obj)/build.ht; \
|
||||
fi
|
||||
printf "#define COREBOOT_ORIGIN_GIT_REVISION \"`LANG= git log remotes/origin/master -1 --format=format:%h`\"\n" >> $(obj)/build.ht
|
||||
printf "#define COREBOOT_EXTRA_VERSION \"$(COREBOOT_EXTRA_VERSION)\"\n" >> $(obj)/build.ht
|
||||
printf "#define COREBOOT_BUILD \"`LANG= date`\"\n" >> $(obj)/build.ht
|
||||
printf "#define COREBOOT_BUILD_YEAR_BCD 0x`LANG= date +"%y"`\n" >> $(obj)/build.ht
|
||||
printf "#define COREBOOT_BUILD_MONTH_BCD 0x`LANG= date +"%m"`\n" >> $(obj)/build.ht
|
||||
printf "#define COREBOOT_BUILD_DAY_BCD 0x`LANG= date +"%d"`\n" >> $(obj)/build.ht
|
||||
printf "#define COREBOOT_BUILD_WEEKDAY_BCD 0x`LANG= date +"%w"`\n" >> $(obj)/build.ht
|
||||
printf "#define COREBOOT_DMI_DATE \"`LANG= date +"%m/%d/%Y"`\"\n" >> $(obj)/build.ht
|
||||
printf "\n" >> $(obj)/build.ht
|
||||
printf "#define COREBOOT_COMPILE_TIME \"`LANG= date +%T`\"\n" >> $(obj)/build.ht
|
||||
printf "#define COREBOOT_COMPILE_BY \"$(subst \,@,$(shell PATH=$$PATH:/usr/ucb whoami))\"\n" >> $(obj)/build.ht
|
||||
printf "#define COREBOOT_COMPILE_HOST \"$(shell hostname -s 2>/dev/null || hostname 2>/dev/null)\"\n" >> $(obj)/build.ht
|
||||
printf "#define COREBOOT_COMPILE_DOMAIN \"$(shell test `uname -s` = "Linux" && dnsdomainname || domainname 2>/dev/null)\"\n" >> $(obj)/build.ht
|
||||
printf "#endif\n" >> $(obj)/build.ht
|
||||
util/genbuild_h/genbuild_h.sh > $(obj)/build.ht
|
||||
mv $(obj)/build.ht $(obj)/build.h
|
||||
|
||||
$(obj)/ldoptions: $(obj)/config.h
|
||||
|
Reference in New Issue
Block a user