public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Makefile: version.h macros KERNEL_EXTRAVERSION, LINUX_EXTRAVERSION_CODE
@ 2014-06-19 14:44 Kamal Mostafa
  2014-06-20  9:39 ` Michal Marek
  0 siblings, 1 reply; 5+ messages in thread
From: Kamal Mostafa @ 2014-06-19 14:44 UTC (permalink / raw)
  To: Michal Marek, linux-kbuild, linux-kernel

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@vger.kernel.org
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-20 20:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-19 14:44 [PATCH] Makefile: version.h macros KERNEL_EXTRAVERSION, LINUX_EXTRAVERSION_CODE Kamal Mostafa
2014-06-20  9:39 ` Michal Marek
2014-06-20 15:47   ` Kamal Mostafa
2014-06-20 20:34     ` Michal Marek
2014-06-20 20:56       ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox