[PATCH] kbuild: Support LOCALVERSION

From: Ian Wienand
Date: Thu Sep 02 2004 - 05:46:49 EST


On Wed, Sep 01, 2004 at 04:56:47PM +0200, Sam Ravnborg wrote:
> Ian addedconfig CONFIG_LOCALVERSION to a Kconfig file. I will
> try to add it and see how it turns out. If Ian does not beat me..

Ok, here is my attempt. I think it does everything everyone wants

* localversion* files are read first
* config variable is appended last
* LOCALVERSION from the command line overrides all of this
* check is forced on build, since we can't really know when
the config or environment options change.

Thanks,

-i

Add LOCALVERSION so we can append strings that show up in uname
without having to fiddle with the Makefile and EXTRAVERSION, etc.

Signed-off-by: Ian Wienand <ianw@xxxxxxxxxxxxxxxxxx>

===== Makefile 1.523 vs edited =====
--- 1.523/Makefile 2004-08-25 06:34:30 +10:00
+++ edited/Makefile 2004-09-02 20:32:57 +10:00
@@ -141,7 +141,26 @@

export srctree objtree VPATH TOPDIR

-KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+nullstring :=
+space := $(nullstring) # end of line
+
+# Take the contents of any files called localversion and the config
+# variable CONFIG_LOCALVERSION and append them to KERNELRELEASE. Be
+# careful not to include files twice if building in the source
+# directory. LOCALVERSION from the command line should override all
+# of this
+
+ifeq ($(objtree),$(srctree))
+localversion-files := $(wildcard $(srctree)/localversion*)
+else
+localversion-files := $(wildcard $(objtree)/localversion* $(srctree)/localversion*)
+endif
+
+LOCALVERSION = $(subst $(space),, \
+ $(shell cat /dev/null $(localversion-files)) \
+ $(subst ",,$(CONFIG_LOCALVERSION)))
+
+KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(LOCALVERSION)

# SUBARCH tells the usermode build what the underlying arch is. That is set
# first, and if a usermode build is happening, the "ARCH=um" on the command
@@ -329,8 +348,8 @@
-fno-strict-aliasing -fno-common
AFLAGS := -D__ASSEMBLY__

-export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \
- CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
+export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION LOCALVERSION KERNELRELEASE \
+ ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \
HOSTCXX HOSTCXXFLAGS LDFLAGS_BLOB LDFLAGS_MODULE CHECK CHECKFLAGS

@@ -747,8 +766,8 @@
# Generate some files
# ---------------------------------------------------------------------------

-# version.h changes when $(KERNELRELEASE) etc change, as defined in
-# this Makefile
+# KERNELRELEASE can change from a few different places, meaning version.h
+# needs to be updated, so this check is forced on all builds

uts_len := 64

@@ -763,7 +782,7 @@
)
endef

-include/linux/version.h: Makefile
+include/linux/version.h: $(srctree)/Makefile $(localversion-files) FORCE
$(call filechk,version.h)

# ---------------------------------------------------------------------------
===== init/Kconfig 1.48 vs edited =====
--- 1.48/init/Kconfig 2004-08-31 18:00:08 +10:00
+++ edited/init/Kconfig 2004-09-02 20:13:01 +10:00
@@ -293,6 +293,16 @@
option replaces shmem and tmpfs with the much simpler ramfs code,
which may be appropriate on small systems without swap.

+config LOCALVERSION
+ string "Local Version"
+ help
+ Append an extra string to the end of your kernel version.
+ This will show up when you type uname, for example.
+ The string you set here will be appended after the contents of
+ any files with a filename matching localversion* in your
+ object and source tree, in that order. Your total string can
+ be a maximum of 64 characters.
+
endmenu # General setup

config TINY_SHMEM

Attachment: signature.asc
Description: Digital signature