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