]> git.saurik.com Git - apple/xnu.git/blame - README
xnu-1228.tar.gz
[apple/xnu.git] / README
CommitLineData
2d21ac55
A
1Table of contents:
2A. How to build XNU
3B. How to install a new header file from XNU
4
5=============================================
6A. How to build XNU:
1c79356b 7
9bccf70c 81) Type: "make"
1c79356b 9
2d21ac55
A
10 This builds all the components for kernel, architecture, and machine
11 configurations defined in TARGET_CONFIGS. Additionally, we also support
12 architectures defined in ARCH_CONFIGS and kernel configurations defined in
13 KERNEL_CONFIGS. Note that TARGET_CONFIGS overrides any configurations defined
14 in ARCH_CONFIGS and KERNEL_CONFIGS.
15
16 By default, architecture defaults to the build machine
17 architecture, and the kernel configuration is set to build for DEVELOPMENT.
18 The machine configuration defaults to MX31ADS for arm and nothing for i386 and ppc.
19
1c79356b
A
20 This will also create a bootable image, mach_kernel, and a kernel binary
21 with symbols, mach_kernel.sys.
22
2d21ac55
A
23 Here are the valid arm machine configs:
24 LN2410SBC MX31ADS INTEGRATORCP S5I3000SMDK S5L8900XFPGA S5L8900XRB
25 OLOCREEK
26
27 Examples:
28 /* make a debug kernel for MX31 arm board */
29 make TARGET_CONFIGS="debug arm MX31ADS"
30
31 $(OBJROOT)/DEBUG_ARM_MX31ADS/osfmk/DEBUG/osfmk.o: pre-linked object for osfmk component
32 $(OBJROOT)/DEBUG_ARM_MX31ADS/mach_kernel: bootable image
33
34 /* make debug and development kernels for MX31 arm board */
35 make TARGET_CONFIGS="debug arm MX31ADS development arm MX31ADS"
36
37 $(OBJROOT)/DEBUG_ARM_MX31ADS/osfmk/DEBUG/osfmk.o: pre-linked object for osfmk component
38 $(OBJROOT)/DEBUG_ARM_MX31ADS/mach_kernel: bootable image
39 $(OBJROOT)/DEVELOPMENT_ARM/osfmk/DEVELOPMENT/osfmk.o: pre-linked object for osfmk component
40 $(OBJROOT)/DEVELOPMENT_ARM/mach_kernel: bootable image
41
42 /* this is all you need to do to build MX31ADS arm with DEVELOPMENT kernel configuration */
43 make TARGET_CONFIGS="default arm default"
44
45 or the following is equivalent
46
47 make ARCH_CONFIGS=ARM
1c79356b 48
9bccf70c
A
492) Building a Component
50
51 Go to the top directory in your XNU project.
52
53 If you are using a sh-style shell, run the following command:
54 $ . SETUP/setup.sh
55
56 If you are using a csh-style shell, run the following command:
57 % source SETUP/setup.csh
58
59 This will define the following environmental variables:
60 SRCROOT, OBJROOT, DSTROOT, SYMROOT
1c79356b
A
61
62 From a component top directory:
63
64 $ make all
65
2d21ac55
A
66 This builds a component for all architectures, kernel configurations, and
67 machine configurations defined in TARGET_CONFIGS (or alternately ARCH_CONFIGS
68 and KERNEL_CONFIGS).
69
1c79356b
A
70 Example:
71 $(OBJROOT)/RELEASE_PPC/osfmk/RELEASE/osfmk.o: pre-linked object for osfmk component
72
73 From the component top directory:
74
75 $ make mach_kernel
76
77 This includes your component in the bootable image, mach_kernel, and
78 in the kernel binary with symbols, mach_kernel.sys.
79
9bccf70c
A
80 WARNING: If a component header file has been modified, you will have to do
81 the above procedure 1.
82
833) Building DEBUG
1c79356b 84
2d21ac55 85 Define kernel configuration to DEBUG in your environment or when running a
1c79356b
A
86 make command. Then, apply procedures 4, 5
87
2d21ac55
A
88 $ make TARGET_CONFIGS="DEBUG PPC DEFAULT" all
89
90 or
91
1c79356b
A
92 $ make KERNEL_CONFIGS=DEBUG all
93
94 or
95
2d21ac55 96 $ export TARGET_CONFIGS="DEBUG ARM MX31ADS"
1c79356b
A
97 $ make all
98
99 Example:
100 $(OBJROOT)/DEBUG_PPC/osfmk/DEBUG/osfmk.o: pre-linked object for osfmk component
101 $(OBJROOT)/DEBUG_PPC/mach_kernel: bootable image
102
9bccf70c 1034) Building fat
1c79356b 104
2d21ac55 105 Define architectures in your environment or when running a make command.
1c79356b
A
106 Apply procedures 3, 4, 5
107
2d21ac55
A
108 $ make TARGET_CONFIGS="RELEASE PPC default RELEASE I386 default" exporthdrs all
109
110 or
111
1c79356b
A
112 $ make ARCH_CONFIGS="PPC I386" exporthdrs all
113
114 or
115
116 $ export ARCH_CONFIGS="PPC I386"
117 $ make exporthdrs all
118
2d21ac55
A
1195) Verbose make
120 To display complete tool invocations rather than an abbreviated version,
121 $ make VERBOSE=YES
122
1236) Debug information formats
124 By default, a DWARF debug information repository is created during the install phase; this is a "bundle" named mach_kernel.dSYM
125 To select the older STABS debug information format (where debug information is embedded in the mach_kernel.sys image), set the BUILD_STABS environment variable.
126 $ export BUILD_STABS=1
127 $ make
128
1297) Build check before integration
1c79356b
A
130
131 From the top directory, run:
132
133 $ ~rc/bin/buildit . -arch ppc -arch i386 -noinstallsrc -nosum
2d21ac55
A
134
135 or for multiple arm builds
136
137 $ ~rc/bin/buildit . -noinstallsrc -nosum -- TARGET_CONFIGS="release arm MX31ADS release arm LN2410SBC"
138
139 or for default arm build (kernel config DEVELOPMENT and machine config MX31ADS)
140
141 $ ~rc/bin/buildit . -arch arm -noinstallsrc -nosum -- TARGET_CONFIGS="release arm MX31ADS release arm LN2410SBC"
142
143
1448) Creating tags and cscope
1c79356b
A
145
146 Set up your build environment as per instructions in 2a
147
148 From the top directory, run:
149
2d21ac55
A
150 $ make tags # this will build ctags and etags on a case-sensitive
151 # volume, only ctags on case-insensitive
152
153 $ make TAGS # this will build etags
1c79356b
A
154
155 $ make cscope # this will build cscope database
156
2d21ac55
A
157=============================================
158B. How to install a new header file from XNU
159
160[Note: This does not covers installing header file in IOKit framework]
161
1621) XNU installs header files at the following locations -
163 a. $(DSTROOT)/System/Library/Frameworks/Kernel.framework/Headers
164 b. $(DSTROOT)/System/Library/Frameworks/Kernel.framework/PrivateHeaders
165 c. $(DSTROOT)/System/Library/Frameworks/System.framework/Headers
166 d. $(DSTROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
167 e. $(DSTROOT)/usr/include/
168
169 Kernel.framework is used by kernel extensions. System.framework
170 and /usr/include are used by user level applications. The header
171 files in framework's "PrivateHeaders" are only available for Apple
172 Internal development.
173
1742) The directory containing the header file should have a Makefile that
175 creates the list of files that should be installed at different locations.
176 If you are adding first header file in a directory, you will need to
177 create Makefile similar to xnu/bsd/sys/Makefile.
178
179 Add your header file to the correct file list depending on where you want
180 to install it. The default locations where the header files are installed
181 from each file list are -
182
183 a. DATAFILES : To make header file available in user level -
184 $(DSTROOT)/System/Library/Frameworks/System.framework/Headers
185 $(DSTROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
186 $(DSTROOT)/usr/include/
187
188 b. PRIVATE_DATAFILES : To make header file available to Apple internal in
189 user level -
190 $(DSTROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
191
192 c. KERNELFILES : To make header file available in kernel level -
193 $(DSTROOT)/System/Library/Frameworks/Kernel.framework/Headers
194 $(DSTROOT)/System/Library/Frameworks/Kernel.framework/PrivateHeaders
195
196 d. PRIVATE_KERNELFILES : To make header file available to Apple internal
197 for kernel extensions -
198 $(DSTROOT)/System/Library/Frameworks/Kernel.framework/PrivateHeaders
199
2003) The Makefile combines the file lists mentioned above into different
201 install lists which are used by build system to install the header files.
202
203 If the install list that you are interested does not exists, create it
204 by adding the appropriate file lists. The default install lists, its
205 member file lists and their default location are described below -
206
207 a. INSTALL_MI_LIST : Installs header file to location that is available to
208 everyone in user level.
209 Locations -
210 $(DSTROOT)/System/Library/Frameworks/System.framework/Headers
211 $(DSTROOT)/usr/include/
212 Definition -
213 INSTALL_MI_LIST = ${DATAFILES}
214
215 b. INSTALL_MI_LCL_LIST : Installs header file to location that is available
216 for Apple internal in user level.
217 Locations -
218 $(DSTROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
219 Definition -
220 INSTALL_MI_LCL_LIST = ${DATAFILES} ${PRIVATE_DATAFILES}
221
222 c. INSTALL_KF_MI_LIST : Installs header file to location that is available
223 to everyone for kernel extensions.
224 Locations -
225 $(DSTROOT)/System/Library/Frameworks/Kernel.framework/Headers
226 Definition -
227 INSTALL_KF_MI_LIST = ${KERNELFILES}
228
229 d. INSTALL_KF_MI_LCL_LIST : Installs header file to location that is
230 available for Apple internal for kernel extensions.
231 Locations -
232 $(DSTROOT)/System/Library/Frameworks/Kernel.framework/PrivateHeaders
233 Definition -
234 INSTALL_KF_MI_LCL_LIST = ${KERNELFILES} ${PRIVATE_KERNELFILES}
235
2364) If you want to install the header file in a sub-directory of the paths
237 described in (1), specify the directory name using two variable
238 INSTALL_MI_DIR and EXPORT_MI_DIR as follows -
239
240 INSTALL_MI_DIR = dirname
241 EXPORT_MI_DIR = dirname
242
2435) A single header file can exist at different locations using the steps
244 mentioned above. However it might not be desirable to make all the code
245 in the header file available at all the locations. For example, you
246 want to export a function only to kernel level but not user level.
247
248 You can use C language's pre-processor directive (#ifdef, #endif, #ifndef)
249 to control the text generated before a header file is installed. The kernel
250 only includes the code if the conditional macro is TRUE and strips out
251 code for FALSE conditions from the header file.
252
253 Some pre-defined macros and their descriptions are -
254 a. PRIVATE : If true, code is available to all of the xnu kernel and is
255 not available in kernel extensions and user level header files. The
256 header files installed in all the paths described above in (1) will not
257 have code enclosed within this macro.
258
259 b. KERNEL_PRIVATE : Same as PRIVATE
260
261 c. BSD_KERNEL_PRIVATE : If true, code is available to the xnu/bsd part of
262 the kernel and is not available to rest of the kernel, kernel extensions
263 and user level header files. The header files installed in all the
264 paths described above in (1) will not have code enclosed within this
265 macro.
266
267 d. KERNEL : If true, code is available only in kernel and kernel
268 extensions and is not available in user level header files. Only the
269 header files installed in following paths will have the code -
270 $(DSTROOT)/System/Library/Frameworks/Kernel.framework/Headers
271 $(DSTROOT)/System/Library/Frameworks/Kernel.framework/PrivateHeaders