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