xref: /xnu-10002.81.5/doc/xnu_version.md (revision 5e3eaea39dcf651e66cb99ba7d70e32cc4a99587)
1*5e3eaea3SApple OSS Distributions# XNU Version Number #
2*5e3eaea3SApple OSS Distributions
3*5e3eaea3SApple OSS DistributionsThe first line of the generated file `$(OBJROOT)/xnuVersion` contains the
4*5e3eaea3SApple OSS Distributionsversion number for the kernel being built. All other instances of the kernel
5*5e3eaea3SApple OSS Distributionsversion in xnu are derived from that file.
6*5e3eaea3SApple OSS Distributions
7*5e3eaea3SApple OSS Distributions## Generating the XNU version number ##
8*5e3eaea3SApple OSS Distributions
9*5e3eaea3SApple OSS DistributionsThe buildsystem (`makedefs/MakeInc.kernel`) generates the `xnuVersion` file by
10*5e3eaea3SApple OSS Distributionsderiving the xnu version from the SDK or KDK that xnu is being built against.
11*5e3eaea3SApple OSS DistributionsThe xnu version number is read from the `CFBundleVersion` property of
12*5e3eaea3SApple OSS Distributionsthe `System/Library/Extensions/System.kext/Info.plist` file in the SDK or KDK.
13*5e3eaea3SApple OSS Distributions
14*5e3eaea3SApple OSS Distributions### Customizing the XNU version number ###
15*5e3eaea3SApple OSS Distributions
16*5e3eaea3SApple OSS DistributionsThe derivation above can be bypassed and the xnu version customized by setting
17*5e3eaea3SApple OSS Distributionsthe `RC_DARWIN_KERNEL_VERSION` variable in the environment or overriding it on
18*5e3eaea3SApple OSS Distributionsthe `make` command line.
19*5e3eaea3SApple OSS Distributions
20*5e3eaea3SApple OSS Distributions
21*5e3eaea3SApple OSS Distributions## Format of the XNU version number ##
22*5e3eaea3SApple OSS Distributions
23*5e3eaea3SApple OSS DistributionsThe format of the version number must conform to the version resource format
24*5e3eaea3SApple OSS Distributionsas described in [TN1132]
25*5e3eaea3SApple OSS Distributions(https://web.archive.org/web/20090330032438/http://developer.apple.com/technotes/tn/tn1132.html).
26*5e3eaea3SApple OSS Distributions
27*5e3eaea3SApple OSS DistributionsIn particular, the string is formatted as: `J[.N[.R[S[L]]]]`, where:
28*5e3eaea3SApple OSS Distributions
29*5e3eaea3SApple OSS Distributions* `J` represents the kernel major version number (integer)
30*5e3eaea3SApple OSS Distributions* `N` represents the kernel minor version number (integer)
31*5e3eaea3SApple OSS Distributions* `R` represents the kernel revision number (integer)
32*5e3eaea3SApple OSS Distributions* `S` represents the kernel build stage (one of `d`, `a`, `b`, or `r`)
33*5e3eaea3SApple OSS Distributions* `L` represents the kernel pre-release level (integer)
34*5e3eaea3SApple OSS Distributions
35*5e3eaea3SApple OSS Distributions## Using the XNU version number ##
36*5e3eaea3SApple OSS Distributions
37*5e3eaea3SApple OSS DistributionsThe correct way to make use of the kernel version within kernel code or a
38*5e3eaea3SApple OSS Distributionskext is to include `<libkern/version.h>`.  This header contains defines that
39*5e3eaea3SApple OSS Distributionscan be used for build-time version logic and prototypes for variables that can
40*5e3eaea3SApple OSS Distributionsbe used for run-time version logic.
41*5e3eaea3SApple OSS Distributions
42