Commit 7424145f30c9ce9c40151765bd08029af7550f1d

Authored by Masahiro Yamada
Committed by Tom Rini
1 parent 5b1f1f4aff

kbuild: consolidate version and timestamp headers generation

- Generate include/generated/{timestamp.h, version.h}
   more simply by using filechk rule.

 - Add $(UBOOTRELEASE) variable and re-write u-boot.imx rule
   more simply.

 - Rename U_BOOT_VERSION in Makefile to UBOOTVERSION

   Before this commit, the same variable name, "U_BOOT_VERSION"
   was used for two different strings.

   One of them was defined in Makefile.
   It takes the form like "2014.01-rc1" and used in
   makefiles and script files.

   The other is defined in include/generated/version.h
   It takes the form like "U-Boot 2014.01-rc1-00010-gbe6d426-dirty"
   and used in C and Aseembler.

   It is confusing when grepping the source tree. So, this commit
   renames the former to UBOOTVERSION.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>

Showing 3 changed files with 49 additions and 40 deletions Side-by-side Diff

... ... @@ -180,9 +180,6 @@
180 180  
181 181 #########################################################################
182 182  
183   -TIMESTAMP_FILE = include/generated/timestamp_autogenerated.h
184   -VERSION_FILE = include/generated/version_autogenerated.h
185   -
186 183 HOSTARCH := $(shell uname -m | \
187 184 sed -e s/i.86/x86/ \
188 185 -e s/sun4u/sparc64/ \
189 186  
... ... @@ -356,9 +353,11 @@
356 353 -fno-builtin -ffreestanding
357 354 KBUILD_AFLAGS := -D__ASSEMBLY__
358 355  
359   -U_BOOT_VERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
  356 +# Read UBOOTRELEASE from include/config/uboot.release (if it exists)
  357 +UBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null)
  358 +UBOOTVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
360 359  
361   -export VERSION PATCHLEVEL SUBLEVEL U_BOOT_VERSION
  360 +export VERSION PATCHLEVEL SUBLEVEL UBOOTRELEASE UBOOTVERSION
362 361 export ARCH CPU BOARD VENDOR SOC
363 362 export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
364 363 export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
... ... @@ -411,6 +410,9 @@
411 410 # Detect when mixed targets is specified, and make a second invocation
412 411 # of make so .config is not included in this case either (for *config).
413 412  
  413 +version_h := include/generated/version_autogenerated.h
  414 +timestamp_h := include/generated/timestamp_autogenerated.h
  415 +
414 416 no-dot-config-targets := clean clobber mrproper distclean \
415 417 help %docs check% coccicheck \
416 418 backup
... ... @@ -582,8 +584,6 @@
582 584 cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
583 585 c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
584 586  
585   -.PHONY : $(VERSION_FILE) $(TIMESTAMP_FILE)
586   -
587 587 #########################################################################
588 588 # U-Boot objects....order is important (i.e. start must be first)
589 589  
... ... @@ -786,8 +786,7 @@
786 786 tools/mkimage -A $(ARCH) -T firmware -C none \
787 787 -O u-boot -a $(CONFIG_SYS_TEXT_BASE) \
788 788 -e $(CONFIG_SYS_UBOOT_START) \
789   - -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
790   - sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
  789 + -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" \
791 790 -d $< $@
792 791  
793 792 u-boot.imx: u-boot.bin
794 793  
... ... @@ -943,13 +942,22 @@
943 942 $(u-boot-dirs): depend prepare scripts
944 943 $(Q)$(MAKE) $(build)=$@
945 944  
946   -tools: $(TIMESTAMP_FILE) $(VERSION_FILE)
  945 +tools: prepare
947 946 # The "tools" are needed early
948 947 $(filter-out tools, $(u-boot-dirs)): tools
949 948 # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
950 949 # is "yes"), so compile examples after U-Boot is compiled.
951 950 examples: $(filter-out examples, $(u-boot-dirs))
952 951  
  952 +define filechk_uboot.release
  953 + echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
  954 +endef
  955 +
  956 +# Store (new) UBOOTRELEASE string in include/config/uboot.release
  957 +include/config/uboot.release: Makefile FORCE
  958 + $(call filechk,uboot.release)
  959 +
  960 +
953 961 # Things we need to do before we recursively start building the kernel
954 962 # or the modules are listed in "prepare".
955 963 # A multi level approach is used. prepareN is processed before prepareN-1.
... ... @@ -962,7 +970,7 @@
962 970 # prepare3 is used to check if we are building in a separate output directory,
963 971 # and if so do:
964 972 # 1) Check that make has not been executed in the kernel src $(srctree)
965   -prepare3:
  973 +prepare3: include/config/uboot.release
966 974 ifneq ($(KBUILD_SRC),)
967 975 @$(kecho) ' Using $(srctree) as source for u-boot'
968 976 $(Q)if [ -f $(srctree)/include/config.mk ]; then \
... ... @@ -975,7 +983,7 @@
975 983 # prepare2 creates a makefile if using a separate output directory
976 984 prepare2: prepare3 outputmakefile
977 985  
978   -prepare1: prepare2
  986 +prepare1: prepare2 $(version_h) $(timestamp_h)
979 987 @:
980 988  
981 989 archprepare: prepare1 scripts_basic
... ... @@ -986,6 +994,27 @@
986 994 # All the preparing..
987 995 prepare: prepare0
988 996  
  997 +# Generate some files
  998 +# ---------------------------------------------------------------------------
  999 +
  1000 +define filechk_version.h
  1001 + (echo \#define PLAIN_VERSION \"$(UBOOTRELEASE)\"; \
  1002 + echo \#define U_BOOT_VERSION \"U-Boot \" PLAIN_VERSION; \
  1003 + echo \#define CC_VERSION_STRING \"$$($(CC) --version | head -n 1)\"; \
  1004 + echo \#define LD_VERSION_STRING \"$$($(LD) --version | head -n 1)\"; )
  1005 +endef
  1006 +
  1007 +define filechk_timestamp.h
  1008 + (LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; \
  1009 + LC_ALL=C date +'#define U_BOOT_TIME "%T"')
  1010 +endef
  1011 +
  1012 +$(version_h): $(srctree)/Makefile FORCE
  1013 + $(call filechk,version.h)
  1014 +
  1015 +$(timestamp_h): $(srctree)/Makefile FORCE
  1016 + $(call filechk,timestamp.h)
  1017 +
989 1018 #
990 1019 # Auto-generate the autoconf.mk file (which is included by all makefiles)
991 1020 #
992 1021  
993 1022  
... ... @@ -1009,16 +1038,16 @@
1009 1038 include/autoconf.mk: include/config.h
1010 1039 $(call cmd,autoconf)
1011 1040  
1012   -u-boot.lds: $(LDSCRIPT) depend
  1041 +u-boot.lds: $(LDSCRIPT) depend prepare
1013 1042 $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
1014 1043  
1015   -nand_spl: $(TIMESTAMP_FILE) $(VERSION_FILE) depend prepare
  1044 +nand_spl: depend prepare
1016 1045 $(MAKE) $(build)=nand_spl/board/$(BOARDDIR) all
1017 1046  
1018 1047 u-boot-nand.bin: nand_spl u-boot.bin
1019 1048 cat nand_spl/u-boot-spl-16k.bin u-boot.bin > u-boot-nand.bin
1020 1049  
1021   -spl/u-boot-spl.bin: tools depend prepare
  1050 +spl/u-boot-spl.bin: tools depend prepare
1022 1051 $(MAKE) obj=spl -f $(srctree)/spl/Makefile all
1023 1052  
1024 1053 tpl/u-boot-tpl.bin: tools depend prepare
... ... @@ -1026,7 +1055,7 @@
1026 1055  
1027 1056 # Explicitly make _depend in subdirs containing multiple targets to prevent
1028 1057 # parallel sub-makes creating .depend files simultaneously.
1029   -depend dep: $(TIMESTAMP_FILE) $(VERSION_FILE) \
  1058 +depend dep: \
1030 1059 include/generated/generic-asm-offsets.h \
1031 1060 include/generated/asm-offsets.h
1032 1061  
... ... @@ -1127,27 +1156,7 @@
1127 1156 false; \
1128 1157 fi
1129 1158  
1130   -$(VERSION_FILE):
1131   - @mkdir -p $(dir $(VERSION_FILE))
1132   - @( localvers='$(shell $(TOPDIR)/scripts/setlocalversion $(TOPDIR))' ; \
1133   - printf '#define PLAIN_VERSION "%s%s"\n' \
1134   - "$(U_BOOT_VERSION)" "$${localvers}" ; \
1135   - printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \
1136   - "$(U_BOOT_VERSION)" "$${localvers}" ; \
1137   - ) > $@.tmp
1138   - @( printf '#define CC_VERSION_STRING "%s"\n' \
1139   - '$(shell $(CC) --version | head -n 1)' )>> $@.tmp
1140   - @( printf '#define LD_VERSION_STRING "%s"\n' \
1141   - '$(shell $(LD) -v | head -n 1)' )>> $@.tmp
1142   - @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
1143   -
1144   -$(TIMESTAMP_FILE):
1145   - @mkdir -p $(dir $(TIMESTAMP_FILE))
1146   - @LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@.tmp
1147   - @LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp
1148   - @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
1149   -
1150   -env: depend scripts_basic
  1159 +env: scripts_basic
1151 1160 $(Q)$(MAKE) $(build)=tools/$@
1152 1161  
1153 1162 tools-all: HOST_TOOLS_ALL=y
doc/DocBook/Makefile
... ... @@ -131,7 +131,7 @@
131 131 main_idx = doc/DocBook/$(index)
132 132 build_main_index = rm -rf $(main_idx); \
133 133 echo '<h1>U-Boot Bootloader HTML Documentation</h1>' >> $(main_idx) && \
134   - echo '<h2>U-Boot Version: $(U_BOOT_VERSION)</h2>' >> $(main_idx) && \
  134 + echo '<h2>U-Boot Version: $(UBOOTVERSION)</h2>' >> $(main_idx) && \
135 135 cat $(HTML) >> $(main_idx)
136 136  
137 137 quiet_cmd_db2html = HTML $@
... ... @@ -392,8 +392,8 @@
392 392 sub get_kernel_version() {
393 393 my $version = 'unknown kernel version';
394 394  
395   - if (defined($ENV{'U_BOOT_VERSION'})) {
396   - $version = $ENV{'U_BOOT_VERSION'};
  395 + if (defined($ENV{'UBOOTVERSION'})) {
  396 + $version = $ENV{'UBOOTVERSION'};
397 397 }
398 398 return $version;
399 399 }