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