How to retrieve version from kernel source (the right way)?

From: Michael Renzmann
Date: Wed Feb 09 2005 - 03:19:09 EST


Hi all.

(Please CC: me, I'm not subscribed - although I'm following the list through gmane.org)

I'm working on Madwifi (a driver for wireless lan cards with Atheros chipset), which isn't part of the kernel (and probably won't ever be due to the binary-only HAL). As every third-party device driver madwifi needs to know which kernel version it is compiled for, at least for determining the proper location to install itself after compilation. But... what is the right way to do this?

We used to get the kernel version via "uname -r", but dropped that behaviour. Chances are good that one wants to build the driver for a kernel version other than the currently running kernel.

Then we started to grep VERSION, PATCHLEVEL, SUBLEVEL and EXTRAVERSION from the kernel's Makefile. This failed, since some distributors seem to use shell commands for at least one of those. Example from SuSE 9.1:
=== cut ===
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 5
EXTRAVERSION = -$(shell echo $(CONFIG_RELEASE)-$(CONFIG_CFGNAME))
=== cut ===

Newer kernels also allow to set CONFIG_LOCALVERSION in .config.

It seems that include/linux/version.h holds the complete version information in UTS_RELEASE. Is it reliable to get the information from version.h? Or is there any other preferred method for this?

Bye, Mike
-
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/