summaryrefslogtreecommitdiff
path: root/init/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'init/Makefile')
-rw-r--r--init/Makefile55
1 files changed, 42 insertions, 13 deletions
diff --git a/init/Makefile b/init/Makefile
index d82623d7fc8e..ba90eb817185 100644
--- a/init/Makefile
+++ b/init/Makefile
@@ -19,20 +19,49 @@ mounts-y := do_mounts.o
mounts-$(CONFIG_BLK_DEV_RAM) += do_mounts_rd.o
mounts-$(CONFIG_BLK_DEV_INITRD) += do_mounts_initrd.o
-# dependencies on generated files need to be listed explicitly
-$(obj)/version.o: include/generated/compile.h
+#
+# UTS_VERSION
+#
+
+smp-flag-$(CONFIG_SMP) := SMP
+preempt-flag-$(CONFIG_PREEMPT_BUILD) := PREEMPT
+preempt-flag-$(CONFIG_PREEMPT_DYNAMIC) := PREEMPT_DYNAMIC
+preempt-flag-$(CONFIG_PREEMPT_RT) := PREEMPT_RT
+
+build-version = $(or $(KBUILD_BUILD_VERSION), $(build-version-auto))
+build-timestamp = $(or $(KBUILD_BUILD_TIMESTAMP), $(build-timestamp-auto))
+
+# Maximum length of UTS_VERSION is 64 chars
+filechk_uts_version = \
+ utsver=$$(echo '$(pound)'"$(build-version)" $(smp-flag-y) $(preempt-flag-y) "$(build-timestamp)" | cut -b -64); \
+ echo '$(pound)'define UTS_VERSION \""$${utsver}"\"
+
+#
+# Build version.c with temporary UTS_VERSION
+#
-# compile.h changes depending on hostname, generation number, etc,
-# so we regenerate it always.
-# mkcompile_h will make sure to only update the
-# actual file if its content has changed.
+$(obj)/utsversion-tmp.h: FORCE
+ $(call filechk,uts_version)
-quiet_cmd_compile.h = CHK $@
- cmd_compile.h = \
- $(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \
- "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT_BUILD)" \
- "$(CONFIG_PREEMPT_DYNAMIC)" "$(CONFIG_PREEMPT_RT)" \
- "$(CONFIG_CC_VERSION_TEXT)" "$(LD)"
+clean-files += utsversion-tmp.h
+
+$(obj)/version.o: include/generated/compile.h $(obj)/utsversion-tmp.h
+CFLAGS_version.o := -include $(obj)/utsversion-tmp.h
+
+filechk_compile.h = $(srctree)/scripts/mkcompile_h \
+ "$(UTS_MACHINE)" "$(CONFIG_CC_VERSION_TEXT)" "$(LD)"
include/generated/compile.h: FORCE
- $(call cmd,compile.h)
+ $(call filechk,compile.h)
+
+#
+# Build version-timestamp.c with final UTS_VERSION
+#
+
+include/generated/utsversion.h: build-version-auto = $(shell $(srctree)/$(src)/build-version)
+include/generated/utsversion.h: build-timestamp-auto = $(shell LC_ALL=C date)
+include/generated/utsversion.h: FORCE
+ $(call filechk,uts_version)
+
+$(obj)/version-timestamp.o: include/generated/utsversion.h
+CFLAGS_version-timestamp.o := -include include/generated/utsversion.h