]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | export SOURCE=$(shell /bin/pwd) |
2 | ||
3 | # | |
4 | # gnumake 3.77 support | |
5 | # | |
6 | export USE_APPLE_PB_SUPPORT = all | |
7 | ||
8 | # | |
9 | # Incremental Build option | |
10 | # | |
11 | ifndef INCR_EXPORTHDRS | |
12 | ifeq ($(shell test -d $$OBJROOT/EXPORT_HDRS;echo $$?),0) | |
13 | export INCR_EXPORTHDRS = TRUE | |
14 | else | |
15 | export INCR_EXPORTHDRS = FALSE | |
16 | endif | |
17 | endif | |
18 | ||
1c79356b A |
19 | # |
20 | # Component List | |
21 | # | |
0b4e3aa0 | 22 | ifndef COMPONENT_LIST |
1c79356b | 23 | export COMPONENT_LIST = osfmk bsd iokit pexpert libkern libsa |
0c530ab8 | 24 | export COMPONENT_LIST_UC := $(shell printf "%s" "$(COMPONENT_LIST)" | $(TR) a-z A-Z) |
0b4e3aa0 A |
25 | endif |
26 | ifndef COMPONENT | |
27 | export COMPONENT := $(firstword $(subst /, ,$(shell $(RELPATH) $(SRCROOT) $(SOURCE)))) | |
28 | export COMPONENT_IMPORT_LIST := $(filter-out $(COMPONENT),$(COMPONENT_LIST)) | |
29 | else | |
30 | ifeq ($(COMPONENT), .) | |
31 | export COMPONENT := $(firstword $(subst /, ,$(shell $(RELPATH) $(SRCROOT) $(SOURCE)))) | |
32 | export COMPONENT_IMPORT_LIST := $(filter-out $(COMPONENT),$(COMPONENT_LIST)) | |
33 | endif | |
34 | endif | |
1c79356b A |
35 | |
36 | # Architecture options | |
37 | # | |
38 | # supported configurations : PPC I386 | |
39 | # | |
0b4e3aa0 | 40 | ifndef ARCH_CONFIGS |
1c79356b | 41 | ifdef RC_ARCHS |
0c530ab8 | 42 | export ARCH_CONFIGS := $(shell printf "%s" "$(RC_ARCHS)" | $(TR) a-z A-Z) |
1c79356b | 43 | else |
0b4e3aa0 A |
44 | export ARCH_CONFIGS := $(shell arch | $(TR) a-z A-Z) |
45 | endif | |
46 | endif | |
47 | ifdef ARCH_CONFIG | |
48 | ifndef ARCH_CONFIG_LC | |
0c530ab8 | 49 | export ARCH_CONFIG_LC := $(shell printf "%s" "$(ARCH_CONFIG)" | $(TR) A-Z a-z) |
1c79356b A |
50 | endif |
51 | endif | |
1c79356b A |
52 | |
53 | ||
54 | # Kernel Configuration options | |
55 | # | |
56 | # supported configurations : RELEASE DEBUG PROFILE | |
0c530ab8 A |
57 | # By default, make wll build RELEASE, otherwise the value of KERNEL_CONFIG |
58 | # will be used as kernel configuration. If KERNEL_CONFIGS (plural) is set | |
59 | # it will override KERNEL_CONFIG. Make sure to set KERNEL_CONFIGS because | |
60 | # build_all rule loops over it when building. | |
61 | ||
1c79356b | 62 | ifndef KERNEL_CONFIGS |
0c530ab8 | 63 | ifndef KERNEL_CONFIG |
1c79356b | 64 | export KERNEL_CONFIGS = RELEASE |
0c530ab8 A |
65 | else |
66 | export KERNEL_CONFIGS = $(KERNEL_CONFIG) | |
1c79356b | 67 | endif |
0c530ab8 A |
68 | endif |
69 | ||
0b4e3aa0 | 70 | ifndef KERNEL_CONFIG |
1c79356b | 71 | export KERNEL_CONFIG = $(firstword $(KERNEL_CONFIGS)) |
0b4e3aa0 | 72 | endif |
1c79356b A |
73 | |
74 | # | |
75 | # Kernel Configuration to install | |
76 | # | |
77 | # supported install architecture : PPC I386 | |
78 | # | |
79 | export INSTALL_TYPE = RELEASE | |
0b4e3aa0 | 80 | ifndef INSTALL_ARCHS |
1c79356b A |
81 | ifdef RC_ARCHS |
82 | export INSTALL_ARCHS = $(ARCH_CONFIGS) | |
83 | else | |
84 | export INSTALL_ARCHS = $(ARCH_CONFIGS) | |
85 | endif | |
0c530ab8 | 86 | export INSTALL_ARCHS_LC := $(shell printf "%s" "$(ARCH_CONFIGS)" | $(TR) A-Z a-z) |
0b4e3aa0 | 87 | endif |
1c79356b A |
88 | |
89 | export INSTALL_ARCH_DEFAULT = PPC | |
90 | ||
91 | # | |
92 | # Standard defines list | |
93 | # | |
91447636 | 94 | export DEFINES = -DAPPLE -DNeXT -DKERNEL -DKERNEL_PRIVATE -DXNU_KERNEL_PRIVATE -DPRIVATE -D__MACHO__=1 -Dvolatile=__volatile $(IDENT) |
1c79356b A |
95 | |
96 | # | |
97 | # Compiler command | |
98 | # | |
0c530ab8 A |
99 | KCC := $(CC) |
100 | KC++ := $(CXX) | |
9bccf70c | 101 | |
91447636 A |
102 | # |
103 | # Compiler warning flags | |
104 | # | |
105 | ||
106 | CWARNFLAGS_STD = \ | |
107 | -Wall -Wno-format-y2k -W -Wstrict-prototypes -Wmissing-prototypes \ | |
108 | -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch \ | |
109 | -Wshadow -Wcast-align -Wbad-function-cast -Wchar-subscripts -Winline \ | |
110 | -Wnested-externs -Wredundant-decls | |
111 | ||
112 | export CWARNFLAGS ?= $(CWARNFLAGS_STD) | |
113 | ||
114 | MWARNFLAGS_STD = \ | |
115 | -Wall -Wno-format-y2k -W -Wstrict-prototypes -Wmissing-prototypes \ | |
116 | -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch \ | |
117 | -Wshadow -Wcast-align -Wbad-function-cast -Wchar-subscripts -Winline \ | |
118 | -Wnested-externs -Wredundant-decls | |
119 | ||
120 | export MWARNFLAGS ?= $(MWARNFLAGS_STD) | |
121 | ||
122 | CXXWARNFLAGS_STD = \ | |
0c530ab8 | 123 | -Wall -Wno-format-y2k -W \ |
91447636 | 124 | -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch \ |
0c530ab8 | 125 | -Wshadow -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls |
91447636 A |
126 | |
127 | export CXXWARNFLAGS ?= $(CXXWARNFLAGS_STD) | |
128 | ||
9bccf70c A |
129 | |
130 | # | |
131 | # Setup for parallel sub-makes when doing an RC build | |
132 | # | |
133 | ifndef MAKEJOBS | |
134 | ifeq "YES" "$(RC_XBS)" | |
135 | export MAKEJOBS = --jobs=3 | |
136 | endif | |
137 | endif | |
1c79356b A |
138 | |
139 | # | |
140 | # Default CFLAGS | |
141 | # | |
142 | ifdef RC_CFLAGS | |
143 | export OTHER_CFLAGS = $(subst $(addprefix -arch ,$(RC_ARCHS)),,$(RC_CFLAGS)) | |
144 | endif | |
145 | ||
9bccf70c A |
146 | export CFLAGS_GEN = -static -g -nostdinc -nostdlib -no-cpp-precomp \ |
147 | -fno-builtin -finline -fno-keep-inline-functions -msoft-float \ | |
0c530ab8 | 148 | -fsigned-bitfields $(OTHER_CFLAGS) -force_cpusubtype_ALL |
1c79356b A |
149 | |
150 | export CFLAGS_RELEASE = | |
55e303ae A |
151 | export CFLAGS_DEBUG = |
152 | export CFLAGS_PROFILE = -pg | |
1c79356b | 153 | |
55e303ae | 154 | export CFLAGS_PPC = -arch ppc -Dppc -DPPC -D__PPC__ -DPAGE_SIZE_FIXED |
0c530ab8 | 155 | export CFLAGS_I386 = -arch i386 -Di386 -DI386 -D__I386__ -DPAGE_SIZE_FIXED |
1c79356b | 156 | |
0b4e3aa0 A |
157 | export CFLAGS_RELEASEPPC = -O2 -mcpu=750 -mmultiple -fschedule-insns |
158 | export CFLAGS_RELEASE_TRACEPPC = -O2 -mcpu=750 -mmultiple -fschedule-insns | |
55e303ae A |
159 | export CFLAGS_DEBUGPPC = -O2 -mcpu=750 -mmultiple -fschedule-insns |
160 | export CFLAGS_PROFILEPPC = -O2 -mcpu=750 -mmultiple -fschedule-insns | |
91447636 A |
161 | export CFLAGS_RELEASEI386 = -Os |
162 | export CFLAGS_DEBUGI386 = -Os | |
163 | export CFLAGS_PROFILEI386 = -Os | |
1c79356b A |
164 | |
165 | export CFLAGS = $(CFLAGS_GEN) \ | |
166 | $($(addsuffix $(ARCH_CONFIG),CFLAGS_)) \ | |
167 | $($(addsuffix $(KERNEL_CONFIG),CFLAGS_)) \ | |
168 | $($(addsuffix $(ARCH_CONFIG), $(addsuffix $(KERNEL_CONFIG),CFLAGS_))) \ | |
169 | $(DEFINES) | |
170 | ||
0c530ab8 A |
171 | export MIGCC = $(CC) |
172 | ||
55e303ae | 173 | # Default C++ flags |
1c79356b | 174 | # |
0c530ab8 | 175 | CXXFLAGS_GEN = -fno-rtti -fno-exceptions -fcheck-new -fapple-kext |
1c79356b | 176 | |
55e303ae A |
177 | CXXFLAGS = $(CXXFLAGS_GEN) \ |
178 | $($(addsuffix $(ARCH_CONFIG),CXXFLAGS_)) \ | |
179 | $($(addsuffix $(KERNEL_CONFIG),CXXFLAGS_)) | |
1c79356b A |
180 | |
181 | # | |
182 | # Assembler command | |
183 | # | |
0c530ab8 A |
184 | AS = $(CC) |
185 | S_KCC = $(CC) | |
1c79356b A |
186 | |
187 | # | |
188 | # Default SFLAGS | |
189 | # | |
190 | export SFLAGS_GEN = -static -D__ASSEMBLER__ -force_cpusubtype_ALL $(OTHER_CFLAGS) | |
191 | ||
192 | export SFLAGS_RELEASE = | |
193 | export SFLAGS_DEBUG = | |
194 | export SFLAGS_PROFILE = | |
195 | ||
196 | export SFLAGS_PPC = $(CFLAGS_PPC) | |
197 | export SFLAGS_I386 = $(CFLAGS_I386) | |
198 | ||
199 | export SFLAGS = $(SFLAGS_GEN) \ | |
200 | $($(addsuffix $(ARCH_CONFIG),SFLAGS_)) \ | |
201 | $($(addsuffix $(KERNEL_CONFIG),SFLAGS_)) \ | |
202 | $(DEFINES) | |
203 | ||
204 | # | |
205 | # Linker command | |
206 | # | |
0c530ab8 | 207 | LD = $(KC++) -nostdlib |
1c79356b A |
208 | |
209 | # | |
210 | # Default LDFLAGS | |
211 | # | |
55e303ae | 212 | export LDFLAGS_COMPONENT_GEN = -static -r $(COMP_LDFLAGS_COMPONENT_GEN) |
1c79356b | 213 | |
55e303ae A |
214 | export LDFLAGS_COMPONENT_RELEASE = $(COMP_LDFLAGS_COMPONENT_RELEASE) |
215 | export LDFLAGS_COMPONENT_DEBUG = $(COMP_LDFLAGS_COMPONENT_DEBUG) | |
216 | export LDFLAGS_COMPONENT_PROFILE = $(COMP_LDFLAGS_COMPONENT_PROFILE) | |
1c79356b | 217 | |
55e303ae A |
218 | export LDFLAGS_COMPONENT_PPC = -arch ppc $(COMP_LDFLAGS_COMPONENT_PPC) |
219 | export LDFLAGS_COMPONENT_I386 = -arch i386 $(COMP_LDFLAGS_COMPONENT_i386) | |
1c79356b A |
220 | |
221 | export LDFLAGS_COMPONENT = $(LDFLAGS_COMPONENT_GEN) \ | |
222 | $($(addsuffix $(ARCH_CONFIG),LDFLAGS_COMPONENT_)) \ | |
223 | $($(addsuffix $(KERNEL_CONFIG),LDFLAGS_COMPONENT_)) | |
224 | ||
91447636 A |
225 | export LDFLAGS_KERNEL_GEN = \ |
226 | -static \ | |
0c530ab8 | 227 | -fapple-kext \ |
91447636 | 228 | -force_cpusubtype_ALL \ |
0c530ab8 A |
229 | -Wl,-e,__start \ |
230 | -Wl,-segalign,0x1000 \ | |
231 | -Wl,-sectalign,__TEXT,__text,0x1000 \ | |
232 | -Wl,-sectalign,__DATA,__common,0x1000 \ | |
233 | -Wl,-sectalign,__DATA,__bss,0x1000 \ | |
234 | -Wl,-sectcreate,__PRELINK,__text,/dev/null \ | |
235 | -Wl,-sectcreate,__PRELINK,__symtab,/dev/null \ | |
236 | -Wl,-sectcreate,__PRELINK,__info,/dev/null | |
1c79356b A |
237 | |
238 | export LDFLAGS_KERNEL_RELEASE = | |
239 | # -noseglinkedit | |
240 | export LDFLAGS_KERNEL_DEBUG = | |
241 | export LDFLAGS_KERNEL_PROFILE = | |
242 | ||
91447636 A |
243 | export LDFLAGS_KERNEL_PPC = \ |
244 | -arch ppc \ | |
0c530ab8 A |
245 | -Wl,-segaddr,__VECTORS,0x0 \ |
246 | -Wl,-segaddr,__HIB,0x7000 \ | |
247 | -Wl,-segaddr,__TEXT,0xe000 | |
91447636 A |
248 | |
249 | export LDFLAGS_KERNEL_I386 = \ | |
250 | -arch i386 \ | |
0c530ab8 A |
251 | -Wl,-segaddr,__HIB,0x100000 \ |
252 | -Wl,-segaddr,__TEXT,0x111000 | |
1c79356b A |
253 | |
254 | export LDFLAGS_KERNEL = $(LDFLAGS_KERNEL_GEN) \ | |
255 | $($(addsuffix $(ARCH_CONFIG),LDFLAGS_KERNEL_)) \ | |
256 | $($(addsuffix $(KERNEL_CONFIG),LDFLAGS_KERNEL_)) | |
257 | ||
258 | ||
259 | # | |
260 | # Default runtime libraries to be linked with the kernel | |
261 | # | |
262 | export LD_KERNEL_LIBS = -lcc_kext | |
263 | ||
264 | # | |
265 | # Default INCFLAGS | |
266 | # | |
267 | export INCFLAGS_IMPORT = $(patsubst %, -I$(OBJROOT)/EXPORT_HDRS/%, $(COMPONENT_IMPORT_LIST)) | |
268 | export INCFLAGS_EXTERN = -I$(OBJROOT)/EXTERN_HDRS -I$(SRCROOT)/EXTERNAL_HEADERS -I$(SRCROOT)/EXTERNAL_HEADERS/bsd | |
91447636 | 269 | export INCFLAGS_GEN = -I$(SRCROOT)/$(COMPONENT) -I$(OBJROOT)/EXPORT_HDRS/$(COMPONENT) |
1c79356b A |
270 | export INCFLAGS_POSIX = -I$(OBJROOT)/EXPORT_HDRS/bsd |
271 | export INCFLAGS_LOCAL = -I. | |
272 | ||
9bccf70c | 273 | export INCFLAGS = $(INCFLAGS_LOCAL) $(INCFLAGS_GEN) $(INCFLAGS_IMPORT) $(INCFLAGS_EXTERN) $(INCFLAGS_MAKEFILE) |
1c79356b A |
274 | |
275 | # | |
276 | # Default MIGFLAGS | |
277 | # | |
278 | export MIGFLAGS = $(DEFINES) $(INCFLAGS) $($(addsuffix $(ARCH_CONFIG),CFLAGS_)) | |
279 | ||
280 | # | |
281 | # Default VPATH | |
282 | # | |
283 | empty:= | |
284 | space:= $(empty) $(empty) | |
285 | export VPATH_IMPORT = $(subst $(space),:,$(patsubst %,$(OBJROOT)/EXPORT_HDRS/%,$(strip $(COMPONENT_IMPORT_LIST)))): | |
286 | export VPATH_EXTERN = $(OBJROOT)/EXTERN_HDRS: | |
287 | export VPATH_GEN = .:$(SOURCE): | |
288 | ||
289 | export VPATH = $(VPATH_GEN)$(VPATH_IMPORT)$(VPATH_EXTERN)$(VPATH_MAKEFILE) | |
290 | ||
291 | # | |
292 | # Macros that control installation of kernel and it's header files | |
293 | # | |
294 | # install flags for header files | |
295 | # | |
296 | INSTALL_FLAGS = -c -m 0444 | |
d7e50217 A |
297 | FILE_INSTALL_FLAGS = -c -m 0644 |
298 | DATA_INSTALL_FLAGS = -c -m 0644 | |
1c79356b A |
299 | |
300 | # | |
301 | # Header file destinations | |
302 | # | |
303 | FRAMEDIR = System/Library/Frameworks | |
304 | ifndef INCDIR | |
305 | INCDIR = /usr/include | |
306 | endif | |
307 | ifndef LCLDIR | |
308 | LCLDIR = $(FRAMEDIR)/System.framework/Versions/B/PrivateHeaders | |
309 | endif | |
310 | ||
311 | KINCVERS = A | |
312 | KINCFRAME = $(FRAMEDIR)/Kernel.framework | |
313 | KINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Headers | |
0b4e3aa0 | 314 | KPINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/PrivateHeaders |
91447636 A |
315 | KRESDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Resources |
316 | ||
317 | XNU_PRIVATE_UNIFDEF = -UMACH_KERNEL_PRIVATE -UBSD_KERNEL_PRIVATE -UIOKIT_KERNEL_PRIVATE -ULIBKERN_KERNEL_PRIVATE -ULIBSA_KERNEL_PRIVATE -UPEXPERT_KERNEL_PRIVATE -UXNU_KERNEL_PRIVATE | |
318 | ||
319 | SPINCFRAME_UNIFDEF = $(XNU_PRIVATE_UNIFDEF) -UKERNEL_PRIVATE -UKERNEL -DPRIVATE | |
320 | SINCFRAME_UNIFDEF = $(XNU_PRIVATE_UNIFDEF) -UKERNEL_PRIVATE -UKERNEL -UPRIVATE | |
321 | KPINCFRAME_UNIFDEF = $(XNU_PRIVATE_UNIFDEF) -DKERNEL_PRIVATE -DPRIVATE -DKERNEL | |
322 | KINCFRAME_UNIFDEF = $(XNU_PRIVATE_UNIFDEF) -UKERNEL_PRIVATE -UPRIVATE -DKERNEL | |
1c79356b A |
323 | |
324 | # | |
325 | # Compononent Header file destinations | |
326 | # | |
327 | EXPDIR = EXPORT_HDRS/$(COMPONENT) | |
328 | ||
329 | # | |
330 | # Strip Flags | |
331 | # | |
55e303ae A |
332 | export STRIP_FLAGS_RELEASE = -S -x |
333 | export STRIP_FLAGS_RELEASE_TRACE = -S -x | |
1c79356b | 334 | export STRIP_FLAGS_DEBUG = -S |
55e303ae A |
335 | export STRIP_FLAGS_DEBUG_TRACE = -S |
336 | export STRIP_FLAGS_PROFILE = -S -x | |
1c79356b A |
337 | |
338 | export STRIP_FLAGS = $($(addsuffix $(KERNEL_CONFIG),STRIP_FLAGS_)) | |
339 | ||
9bccf70c A |
340 | # |
341 | # Man Page destination | |
342 | # | |
343 | MANDIR = usr/share/man | |
344 | ||
1c79356b A |
345 | # |
346 | # This must be here before any rules are possibly defined by the | |
347 | # machine dependent makefile fragment so that a plain "make" command | |
348 | # always works. The config program will emit an appropriate rule to | |
349 | # cause "all" to depend on every kernel configuration it generates. | |
350 | # | |
351 | ||
352 | default: all | |
353 |