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