From 09155120cf0ffe6f0c8aba3aa625831405b65996 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Thu, 17 Jun 2010 15:14:58 +0200 Subject: kbuild: Clean up and speed up the localversion logic Now that we run scripts/setlocalversion during every build, it makes sense to move all the localversion logic there. This cleans up the toplevel Makefile and also makes sure that the script is called only once in 'make prepare' (previously, it would be called every time due to a variable expansion in an ifneq statement). No user-visible change is intended, unless one runs the setlocalversion script directly. Reported-by: Dmitry Torokhov Cc: David Rientjes Cc: Greg Thelen Cc: Nico Schottelius Signed-off-by: Michal Marek --- Makefile | 74 +++------------------------------------------------------------- 1 file changed, 3 insertions(+), 71 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index ea5f0bee193..a86ac8c4798 100644 --- a/Makefile +++ b/Makefile @@ -883,80 +883,12 @@ PHONY += $(vmlinux-dirs) $(vmlinux-dirs): prepare scripts $(Q)$(MAKE) $(build)=$@ -# Build the kernel release string -# -# The KERNELRELEASE value built here is stored in the file -# include/config/kernel.release, and is used when executing several -# make targets, such as "make install" or "make modules_install." -# -# The eventual kernel release string consists of the following fields, -# shown in a hierarchical format to show how smaller parts are concatenated -# to form the larger and final value, with values coming from places like -# the Makefile, kernel config options, make command line options and/or -# SCM tag information. -# -# $(KERNELVERSION) -# $(VERSION) eg, 2 -# $(PATCHLEVEL) eg, 6 -# $(SUBLEVEL) eg, 18 -# $(EXTRAVERSION) eg, -rc6 -# $(localver-full) -# $(localver) -# localversion* (files without backups, containing '~') -# $(CONFIG_LOCALVERSION) (from kernel config setting) -# $(LOCALVERSION) (from make command line, if provided) -# $(localver-extra) -# $(scm-identifier) (unique SCM tag, if one exists) -# ./scripts/setlocalversion (only with CONFIG_LOCALVERSION_AUTO) -# .scmversion (only with CONFIG_LOCALVERSION_AUTO) -# + (only without CONFIG_LOCALVERSION_AUTO -# and without LOCALVERSION= and -# repository is at non-tagged commit) -# -# For kernels without CONFIG_LOCALVERSION_AUTO compiled from an SCM that has -# been revised beyond a tagged commit, `+' is appended to the version string -# when not overridden by using "make LOCALVERSION=". This indicates that the -# kernel is not a vanilla release version and has been modified. - -pattern = ".*/localversion[^~]*" -string = $(shell cat /dev/null \ - `find $(objtree) $(srctree) -maxdepth 1 -regex $(pattern) | sort -u`) - -localver = $(subst $(space),, $(string) \ - $(patsubst "%",%,$(CONFIG_LOCALVERSION))) - -# scripts/setlocalversion is called to create a unique identifier if the source -# is managed by a known SCM and the repository has been revised since the last -# tagged (release) commit. The format of the identifier is determined by the -# SCM's implementation. -# -# .scmversion is used when generating rpm packages so we do not loose -# the version information from the SCM when we do the build of the kernel -# from the copied source -ifeq ($(wildcard .scmversion),) - scm-identifier = $(shell $(CONFIG_SHELL) \ - $(srctree)/scripts/setlocalversion $(srctree)) -else - scm-identifier = $(shell cat .scmversion 2> /dev/null) -endif - -ifdef CONFIG_LOCALVERSION_AUTO - localver-extra = $(scm-identifier) -else - ifneq ($(scm-identifier),) - ifeq ($(LOCALVERSION),) - localver-extra = + - endif - endif -endif - -localver-full = $(localver)$(LOCALVERSION)$(localver-extra) - # Store (new) KERNELRELASE string in include/config/kernel.release -kernelrelease = $(KERNELVERSION)$(localver-full) +localversion = $(shell $(CONFIG_SHELL) \ + $(srctree)/scripts/setlocalversion $(srctree)) include/config/kernel.release: include/config/auto.conf FORCE $(Q)rm -f $@ - $(Q)echo $(kernelrelease) > $@ + $(Q)echo $(KERNELVERSION)$(localversion) > $@ # Things we need to do before we recursively start building the kernel -- cgit v1.2.3 From 0a564b2645c8766a669c55bde1f1ef5b0518caec Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Wed, 30 Jun 2010 16:41:23 +0200 Subject: kbuild: Propagate LOCALVERSION= down to scripts/setlocalversion Variables given on the make commandline are not exported to $(shell ...) commands, so run the setlocalversion script in the make rule directly. Signed-off-by: Michal Marek --- Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a86ac8c4798..12ab1751130 100644 --- a/Makefile +++ b/Makefile @@ -884,11 +884,9 @@ $(vmlinux-dirs): prepare scripts $(Q)$(MAKE) $(build)=$@ # Store (new) KERNELRELASE string in include/config/kernel.release -localversion = $(shell $(CONFIG_SHELL) \ - $(srctree)/scripts/setlocalversion $(srctree)) include/config/kernel.release: include/config/auto.conf FORCE $(Q)rm -f $@ - $(Q)echo $(KERNELVERSION)$(localversion) > $@ + $(Q)echo "$(KERNELVERSION)$$($(CONFIG_SHELL) scripts/setlocalversion $(srctree))" > $@ # Things we need to do before we recursively start building the kernel -- cgit v1.2.3