kbuild: Support LOCALVERSION

From: Sam Ravnborg
Date: Tue Aug 31 2004 - 20:11:27 EST


The following patch combines the request from several people.
If you place a file named localversion* in the root of your
soruce tree or the root of your output tree the text included in this
file will be appended to KERNELRELEASE.

LOCALVERSION was originally introduced by Ian Wienand <ianw@xxxxxxxxxxxxxxxxxx>

This allows one to put a short string in localversion identifying this
particular configuration "-smpacpi", or to identify applied patches
to the source "-llat-np".

More specifically:
$(srctree)/localversion-lowlatency contains "-llat"
$(srctree)/localversion-scheduler-nick constins "-np"

$(objtree)/localversion contains "-smpacpi"

Resulting KERNELRELEASE would be:
2.6.8.rc1-smpacpi-llat-np


Note that you no longer need to modify your Makefile to identify
your kernel so no rejects when applying new patches.
If you add a new localversion* file, or change a existing one kbuild
will pick up this and do the proper rebuild next time you run make.

Only issue is that KERNELRELEASE needs to be <= 64 chars - so keep the names short.

kbuild errors out if you are above limit.
$ cat localviersion-long
very-long-version-in-localversion-file-exceeding-64-chars-for-sure
Example:
CHK include/linux/version.h
"2.6.9-rc1-very-long-version-in-localversion-file-exceeding-64-chars-for-sure" exceeds 64 characters
make: *** [include/linux/version.h] Error 1


Where do we document this?

[This is deliberately not pushed to my bk tree - want some comments first].

Sam

===== Makefile 1.526 vs edited =====
--- 1.526/Makefile 2004-08-30 21:23:05 +02:00
+++ edited/Makefile 2004-08-31 21:05:38 +02:00
@@ -141,7 +141,14 @@ VPATH := $(srctree)

export srctree objtree VPATH TOPDIR

-KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+nullstring :=
+space := $(nullstring) # end of line
+
+LOCALVERSION := $(subst $(space),, \
+ $(shell cat /dev/null $(objtree)/localversion* \
+ $(if $(KBUILD_SRC),$(srctree)/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 +336,8 @@ CFLAGS := -Wall -Wstrict-prototypes -W
-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

@@ -763,7 +770,8 @@ define filechk_version.h
)
endef

-include/linux/version.h: Makefile
+include/linux/version.h: $(srctree)/Makefile \
+ $(objtree)/localversion* $(srctree)/localversion*
$(call filechk,version.h)

# ---------------------------------------------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/