Re: kbuild: Support LOCALVERSION

From: Ian Wienand
Date: Tue Aug 31 2004 - 20:26:42 EST


On Wed, Sep 01, 2004 at 11:08:40AM +1000, Ian Wienand wrote:
> With this patch *without* a localversion file I get
>
> ianw@baci:/tmp/kbuild-test$ make
> cat: /tmp/kbuild-test/localversion*: No such file or directory
> make: *** No rule to make target `/tmp/kbuild-test/localversion*', needed by `include/linux/version.h'. Stop.
>
> However, with the right files there it works as you describe.

Sorry to reply to myself, but I forgot to include a suggested patch
(attached).

-i
===== Makefile 1.523 vs edited =====
--- 1.523/Makefile 2004-08-25 06:34:30 +10:00
+++ edited/Makefile 2004-09-01 11:17:27 +10:00
@@ -141,7 +141,14 @@

export srctree objtree VPATH TOPDIR

-KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+nullstring :=
+space := $(nullstring) # end of line
+localversion-files := $(wildcard $(objtree)/localversion* $(srctree)/localversion*)
+
+LOCALVERSION := $(subst $(space),, \
+ $(shell cat /dev/null $(localversion-files)))
+
+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 @@
-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,7 @@
)
endef

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

# ---------------------------------------------------------------------------

Attachment: signature.asc
Description: Digital signature