aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile95
1 files changed, 53 insertions, 42 deletions
diff --git a/Makefile b/Makefile
index 50b07fa665e5..df60aa1bfb53 100644
--- a/Makefile
+++ b/Makefile
@@ -141,24 +141,6 @@ VPATH := $(srctree)
141 141
142export srctree objtree VPATH TOPDIR 142export srctree objtree VPATH TOPDIR
143 143
144nullstring :=
145space := $(nullstring) # end of line
146
147# Take the contents of any files called localversion* and the config
148# variable CONFIG_LOCALVERSION and append them to KERNELRELEASE. Be
149# careful not to include files twice if building in the source
150# directory. LOCALVERSION from the command line override all of this
151
152localver := $(objtree)/localversion* $(srctree)/localversion*
153localver := $(sort $(wildcard $(localver)))
154# skip backup files (containing '~')
155localver := $(foreach f, $(localver), $(if $(findstring ~, $(f)),,$(f)))
156
157LOCALVERSION = $(subst $(space),, \
158 $(shell cat /dev/null $(localver)) \
159 $(patsubst "%",%,$(CONFIG_LOCALVERSION)))
160
161KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(LOCALVERSION)
162 144
163# SUBARCH tells the usermode build what the underlying arch is. That is set 145# SUBARCH tells the usermode build what the underlying arch is. That is set
164# first, and if a usermode build is happening, the "ARCH=um" on the command 146# first, and if a usermode build is happening, the "ARCH=um" on the command
@@ -353,7 +335,10 @@ CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
353 -ffreestanding 335 -ffreestanding
354AFLAGS := -D__ASSEMBLY__ 336AFLAGS := -D__ASSEMBLY__
355 337
356export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION LOCALVERSION KERNELRELEASE \ 338# Read KERNELRELEASE from .kernelrelease (if it exists)
339KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null)
340
341export KERNELRELEASE \
357 ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \ 342 ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
358 CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \ 343 CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \
359 HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS 344 HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
@@ -551,26 +536,6 @@ export KBUILD_IMAGE ?= vmlinux
551# images. Default is /boot, but you can set it to other values 536# images. Default is /boot, but you can set it to other values
552export INSTALL_PATH ?= /boot 537export INSTALL_PATH ?= /boot
553 538
554# If CONFIG_LOCALVERSION_AUTO is set, we automatically perform some tests
555# and try to determine if the current source tree is a release tree, of any sort,
556# or if is a pure development tree.
557#
558# A 'release tree' is any tree with a git TAG associated
559# with it. The primary goal of this is to make it safe for a native
560# git/CVS/SVN user to build a release tree (i.e, 2.6.9) and also to
561# continue developing against the current Linus tree, without having the Linus
562# tree overwrite the 2.6.9 tree when installed.
563#
564# Currently, only git is supported.
565# Other SCMs can edit scripts/setlocalversion and add the appropriate
566# checks as needed.
567
568
569ifdef CONFIG_LOCALVERSION_AUTO
570 localversion-auto := $(shell $(PERL) $(srctree)/scripts/setlocalversion $(srctree))
571 LOCALVERSION := $(LOCALVERSION)$(localversion-auto)
572endif
573
574# 539#
575# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory 540# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
576# relocations required by build roots. This is not defined in the 541# relocations required by build roots. This is not defined in the
@@ -782,6 +747,50 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ;
782$(vmlinux-dirs): prepare scripts 747$(vmlinux-dirs): prepare scripts
783 $(Q)$(MAKE) $(build)=$@ 748 $(Q)$(MAKE) $(build)=$@
784 749
750# Build the kernel release string
751# The KERNELRELEASE is stored in a file named .kernelrelease
752# to be used when executing for example make install or make modules_install
753#
754# Take the contents of any files called localversion* and the config
755# variable CONFIG_LOCALVERSION and append them to KERNELRELEASE.
756# LOCALVERSION from the command line override all of this
757
758nullstring :=
759space := $(nullstring) # end of line
760
761___localver = $(objtree)/localversion* $(srctree)/localversion*
762__localver = $(sort $(wildcard $(___localver)))
763# skip backup files (containing '~')
764_localver = $(foreach f, $(__localver), $(if $(findstring ~, $(f)),,$(f)))
765
766localver = $(subst $(space),, \
767 $(shell cat /dev/null $(_localver)) \
768 $(patsubst "%",%,$(CONFIG_LOCALVERSION)))
769
770# If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called
771# and if the SCM is know a tag from the SCM is appended.
772# The appended tag is determinded by the SCM used.
773#
774# Currently, only git is supported.
775# Other SCMs can edit scripts/setlocalversion and add the appropriate
776# checks as needed.
777ifdef CONFIG_LOCALVERSION_AUTO
778 _localver-auto = $(shell $(CONFIG_SHELL) \
779 $(srctree)/scripts/setlocalversion $(srctree))
780 localver-auto = $(LOCALVERSION)$(_localver-auto)
781endif
782
783localver-full = $(localver)$(localver-auto)
784
785# Store (new) KERNELRELASE string in .kernelrelease
786kernelrelease = \
787 $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(localver-full)
788.kernelrelease: FORCE
789 $(Q)rm -f .kernelrelease
790 $(Q)echo $(kernelrelease) > .kernelrelease
791 $(Q)echo " Building kernel $(kernelrelease)"
792
793
785# Things we need to do before we recursively start building the kernel 794# Things we need to do before we recursively start building the kernel
786# or the modules are listed in "prepare". 795# or the modules are listed in "prepare".
787# A multi level approach is used. prepareN is processed before prepareN-1. 796# A multi level approach is used. prepareN is processed before prepareN-1.
@@ -798,8 +807,7 @@ $(vmlinux-dirs): prepare scripts
798# and if so do: 807# and if so do:
799# 1) Check that make has not been executed in the kernel src $(srctree) 808# 1) Check that make has not been executed in the kernel src $(srctree)
800# 2) Create the include2 directory, used for the second asm symlink 809# 2) Create the include2 directory, used for the second asm symlink
801 810prepare3: .kernelrelease
802prepare3:
803ifneq ($(KBUILD_SRC),) 811ifneq ($(KBUILD_SRC),)
804 @echo ' Using $(srctree) as source for kernel' 812 @echo ' Using $(srctree) as source for kernel'
805 $(Q)if [ -f $(srctree)/.config ]; then \ 813 $(Q)if [ -f $(srctree)/.config ]; then \
@@ -986,7 +994,7 @@ CLEAN_FILES += vmlinux System.map \
986MRPROPER_DIRS += include/config include2 994MRPROPER_DIRS += include/config include2
987MRPROPER_FILES += .config .config.old include/asm .version .old_version \ 995MRPROPER_FILES += .config .config.old include/asm .version .old_version \
988 include/linux/autoconf.h include/linux/version.h \ 996 include/linux/autoconf.h include/linux/version.h \
989 Module.symvers tags TAGS cscope* 997 .kernelrelease Module.symvers tags TAGS cscope*
990 998
991# clean - Delete most, but leave enough to build external modules 999# clean - Delete most, but leave enough to build external modules
992# 1000#
@@ -1072,6 +1080,7 @@ help:
1072 @echo ' tags/TAGS - Generate tags file for editors' 1080 @echo ' tags/TAGS - Generate tags file for editors'
1073 @echo ' cscope - Generate cscope index' 1081 @echo ' cscope - Generate cscope index'
1074 @echo ' kernelrelease - Output the release version string' 1082 @echo ' kernelrelease - Output the release version string'
1083 @echo ' kernelversion - Output the version stored in Makefile'
1075 @echo '' 1084 @echo ''
1076 @echo 'Static analysers' 1085 @echo 'Static analysers'
1077 @echo ' buildcheck - List dangling references to vmlinux discarded sections' 1086 @echo ' buildcheck - List dangling references to vmlinux discarded sections'
@@ -1293,6 +1302,8 @@ checkstack:
1293 1302
1294kernelrelease: 1303kernelrelease:
1295 @echo $(KERNELRELEASE) 1304 @echo $(KERNELRELEASE)
1305kernelversion:
1306 @echo $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
1296 1307
1297# FIXME Should go into a make.lib or something 1308# FIXME Should go into a make.lib or something
1298# =========================================================================== 1309# ===========================================================================