diff options
author | Sam Ravnborg <sam@mars.ravnborg.org> | 2006-01-09 15:20:34 -0500 |
---|---|---|
committer | Sam Ravnborg <sam@mars.ravnborg.org> | 2006-01-09 15:20:34 -0500 |
commit | cb58455c48dc43536e5548bdba4e916b2f0cf13d (patch) | |
tree | cc54d3ba40c77bf2c949f3f689452e3492b7907b /Makefile | |
parent | a9aa1ffaac7c8d6f093bb8f7cdeea761a5e25f53 (diff) |
kbuild: KERNELRELEASE is only re-defined when buiding the kernel
To avoid running setlocalversion as root no longer (re-)define
KERNELRELEASE for each run. With this patch KERNELRELEASE is
only re-read when we do an actual kernel build.
Rationale behind this is "do as little as possible" when executing
make install - as root!
A new file named .kernelrelease is strored in the root of the kernel
tree containing the actual version string.
So when we use do a kernel build the .kernelrelease file will be updated.
But in all other situations it is left as-is.
To make it more visible the kernel now prints out the version being build.
Sample:
Building kernel 2.6.15-g63b794bf-dirty
...
...
The patch also un-exports VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION LOCALVERSION
since all users of these are anyway broken - and none is left in the
tree.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 95 |
1 files changed, 53 insertions, 42 deletions
@@ -141,24 +141,6 @@ VPATH := $(srctree) | |||
141 | 141 | ||
142 | export srctree objtree VPATH TOPDIR | 142 | export srctree objtree VPATH TOPDIR |
143 | 143 | ||
144 | nullstring := | ||
145 | space := $(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 | |||
152 | localver := $(objtree)/localversion* $(srctree)/localversion* | ||
153 | localver := $(sort $(wildcard $(localver))) | ||
154 | # skip backup files (containing '~') | ||
155 | localver := $(foreach f, $(localver), $(if $(findstring ~, $(f)),,$(f))) | ||
156 | |||
157 | LOCALVERSION = $(subst $(space),, \ | ||
158 | $(shell cat /dev/null $(localver)) \ | ||
159 | $(patsubst "%",%,$(CONFIG_LOCALVERSION))) | ||
160 | |||
161 | KERNELRELEASE=$(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 |
354 | AFLAGS := -D__ASSEMBLY__ | 336 | AFLAGS := -D__ASSEMBLY__ |
355 | 337 | ||
356 | export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION LOCALVERSION KERNELRELEASE \ | 338 | # Read KERNELRELEASE from .kernelrelease (if it exists) |
339 | KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null) | ||
340 | |||
341 | export 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 |
552 | export INSTALL_PATH ?= /boot | 537 | export 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 | |||
569 | ifdef CONFIG_LOCALVERSION_AUTO | ||
570 | localversion-auto := $(shell $(PERL) $(srctree)/scripts/setlocalversion $(srctree)) | ||
571 | LOCALVERSION := $(LOCALVERSION)$(localversion-auto) | ||
572 | endif | ||
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 | |||
758 | nullstring := | ||
759 | space := $(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 | |||
766 | localver = $(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. | ||
777 | ifdef CONFIG_LOCALVERSION_AUTO | ||
778 | _localver-auto = $(shell $(CONFIG_SHELL) \ | ||
779 | $(srctree)/scripts/setlocalversion $(srctree)) | ||
780 | localver-auto = $(LOCALVERSION)$(_localver-auto) | ||
781 | endif | ||
782 | |||
783 | localver-full = $(localver)$(localver-auto) | ||
784 | |||
785 | # Store (new) KERNELRELASE string in .kernelrelease | ||
786 | kernelrelease = \ | ||
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 | 810 | prepare3: .kernelrelease | |
802 | prepare3: | ||
803 | ifneq ($(KBUILD_SRC),) | 811 | ifneq ($(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 \ | |||
986 | MRPROPER_DIRS += include/config include2 | 994 | MRPROPER_DIRS += include/config include2 |
987 | MRPROPER_FILES += .config .config.old include/asm .version .old_version \ | 995 | MRPROPER_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 | ||
1294 | kernelrelease: | 1303 | kernelrelease: |
1295 | @echo $(KERNELRELEASE) | 1304 | @echo $(KERNELRELEASE) |
1305 | kernelversion: | ||
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 | # =========================================================================== |