[PATCH] Makefile: version.h macros KERNEL_EXTRAVERSION, LINUX_EXTRAVERSION_CODE

From: Kamal Mostafa
Date: Thu Jun 19 2014 - 10:44:27 EST


Adds new macro KERNEL_EXTRAVERSION(a,b,c,d) and value
LINUX_EXTRAVERSION_CODE to version.h, allowing ranged version checks of
extended-stable versions that use a numeric EXTRAVERSION value.

The new KERNEL_EXTRAVERSION(a,b,c,d) works like KERNEL_VERSION(a,b,c)...
If EXTRAVERSION is set to ".{integer}" (the common extended-stable kernel
version number scheme) then {integer} corresponds to KERNEL_EXTRAVERSION's
fourth arg. If EXTRAVERSION is blank or a non-".{integer}" string like
"-rc5", that corresponds to a fourth parameter of 0.

Example usage:

#if ( LINUX_EXTRAVERSION_CODE >= KERNEL_EXTRAVERSION(3,13,11,5) )
// compiles for (3.13.11 with "EXTRAVERSION = .5") or greater value
#endif

Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Kamal Mostafa <kamal@xxxxxxxxxxxxx>
---
Makefile | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 97b2861..e579628 100644
--- a/Makefile
+++ b/Makefile
@@ -953,10 +953,15 @@ define filechk_utsrelease.h
(echo \#define UTS_RELEASE \"$(KERNELRELEASE)\";)
endef

+extraversionnum := $(shell \
+ echo "$(EXTRAVERSION)" | sed -n '/\.\([0-9]*\).*/s//\1/p')
define filechk_version.h
(echo \#define LINUX_VERSION_CODE $(shell \
expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 0$(SUBLEVEL)); \
- echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
+ echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \
+ echo \#define LINUX_EXTRAVERSION_CODE $(shell \
+ expr $(VERSION) \* 268435456 + 0$(PATCHLEVEL) \* 1048576 + 0$(SUBLEVEL) \* 4096 + 0$(extraversionnum)); \
+ echo '#define KERNEL_EXTRAVERSION(a,b,c,d) (((a)<<28) + ((b)<<20) + ((c)<<12) + (d))';)
endef

$(version_h): $(srctree)/Makefile FORCE
--
1.9.1

--
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/