]> git.saurik.com Git - apple/xnu.git/blob - makedefs/MakeInc.def
xnu-792.10.96.tar.gz
[apple/xnu.git] / makedefs / MakeInc.def
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
19 #
20 # Component List
21 #
22 ifndef COMPONENT_LIST
23 export COMPONENT_LIST = osfmk bsd iokit pexpert libkern libsa
24 export COMPONENT_LIST_UC := $(shell printf "%s" "$(COMPONENT_LIST)" | $(TR) a-z A-Z)
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
35
36 # Architecture options
37 #
38 # supported configurations : PPC I386
39 #
40 ifndef ARCH_CONFIGS
41 ifdef RC_ARCHS
42 export ARCH_CONFIGS := $(shell printf "%s" "$(RC_ARCHS)" | $(TR) a-z A-Z)
43 else
44 export ARCH_CONFIGS := $(shell arch | $(TR) a-z A-Z)
45 endif
46 endif
47 ifdef ARCH_CONFIG
48 ifndef ARCH_CONFIG_LC
49 export ARCH_CONFIG_LC := $(shell printf "%s" "$(ARCH_CONFIG)" | $(TR) A-Z a-z)
50 endif
51 endif
52
53
54 # Kernel Configuration options
55 #
56 # supported configurations : RELEASE DEBUG PROFILE
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
62 ifndef KERNEL_CONFIGS
63 ifndef KERNEL_CONFIG
64 export KERNEL_CONFIGS = RELEASE
65 else
66 export KERNEL_CONFIGS = $(KERNEL_CONFIG)
67 endif
68 endif
69
70 ifndef KERNEL_CONFIG
71 export KERNEL_CONFIG = $(firstword $(KERNEL_CONFIGS))
72 endif
73
74 #
75 # Kernel Configuration to install
76 #
77 # supported install architecture : PPC I386
78 #
79 export INSTALL_TYPE = RELEASE
80 ifndef INSTALL_ARCHS
81 ifdef RC_ARCHS
82 export INSTALL_ARCHS = $(ARCH_CONFIGS)
83 else
84 export INSTALL_ARCHS = $(ARCH_CONFIGS)
85 endif
86 export INSTALL_ARCHS_LC := $(shell printf "%s" "$(ARCH_CONFIGS)" | $(TR) A-Z a-z)
87 endif
88
89 export INSTALL_ARCH_DEFAULT = PPC
90
91 #
92 # Standard defines list
93 #
94 export DEFINES = -DAPPLE -DNeXT -DKERNEL -DKERNEL_PRIVATE -DXNU_KERNEL_PRIVATE -DPRIVATE -D__MACHO__=1 -Dvolatile=__volatile $(IDENT)
95
96 #
97 # Compiler command
98 #
99 KCC := $(CC)
100 KC++ := $(CXX)
101
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 = \
123 -Wall -Wno-format-y2k -W \
124 -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch \
125 -Wshadow -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls
126
127 export CXXWARNFLAGS ?= $(CXXWARNFLAGS_STD)
128
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
138
139 #
140 # Default CFLAGS
141 #
142 ifdef RC_CFLAGS
143 export OTHER_CFLAGS = $(subst $(addprefix -arch ,$(RC_ARCHS)),,$(RC_CFLAGS))
144 endif
145
146 export CFLAGS_GEN = -static -g -nostdinc -nostdlib -no-cpp-precomp \
147 -fno-builtin -finline -fno-keep-inline-functions -msoft-float \
148 -fsigned-bitfields $(OTHER_CFLAGS) -force_cpusubtype_ALL
149
150 export CFLAGS_RELEASE =
151 export CFLAGS_DEBUG =
152 export CFLAGS_PROFILE = -pg
153
154 export CFLAGS_PPC = -arch ppc -Dppc -DPPC -D__PPC__ -DPAGE_SIZE_FIXED
155 export CFLAGS_I386 = -arch i386 -Di386 -DI386 -D__I386__ -DPAGE_SIZE_FIXED
156
157 export CFLAGS_RELEASEPPC = -O2 -mcpu=750 -mmultiple -fschedule-insns
158 export CFLAGS_RELEASE_TRACEPPC = -O2 -mcpu=750 -mmultiple -fschedule-insns
159 export CFLAGS_DEBUGPPC = -O2 -mcpu=750 -mmultiple -fschedule-insns
160 export CFLAGS_PROFILEPPC = -O2 -mcpu=750 -mmultiple -fschedule-insns
161 export CFLAGS_RELEASEI386 = -Os
162 export CFLAGS_DEBUGI386 = -Os
163 export CFLAGS_PROFILEI386 = -Os
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
171 export MIGCC = $(CC)
172
173 # Default C++ flags
174 #
175 CXXFLAGS_GEN = -fno-rtti -fno-exceptions -fcheck-new -fapple-kext
176
177 CXXFLAGS = $(CXXFLAGS_GEN) \
178 $($(addsuffix $(ARCH_CONFIG),CXXFLAGS_)) \
179 $($(addsuffix $(KERNEL_CONFIG),CXXFLAGS_))
180
181 #
182 # Assembler command
183 #
184 AS = $(CC)
185 S_KCC = $(CC)
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 #
207 LD = $(KC++) -nostdlib
208
209 #
210 # Default LDFLAGS
211 #
212 export LDFLAGS_COMPONENT_GEN = -static -r $(COMP_LDFLAGS_COMPONENT_GEN)
213
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)
217
218 export LDFLAGS_COMPONENT_PPC = -arch ppc $(COMP_LDFLAGS_COMPONENT_PPC)
219 export LDFLAGS_COMPONENT_I386 = -arch i386 $(COMP_LDFLAGS_COMPONENT_i386)
220
221 export LDFLAGS_COMPONENT = $(LDFLAGS_COMPONENT_GEN) \
222 $($(addsuffix $(ARCH_CONFIG),LDFLAGS_COMPONENT_)) \
223 $($(addsuffix $(KERNEL_CONFIG),LDFLAGS_COMPONENT_))
224
225 export LDFLAGS_KERNEL_GEN = \
226 -static \
227 -fapple-kext \
228 -force_cpusubtype_ALL \
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
237
238 export LDFLAGS_KERNEL_RELEASE =
239 # -noseglinkedit
240 export LDFLAGS_KERNEL_DEBUG =
241 export LDFLAGS_KERNEL_PROFILE =
242
243 export LDFLAGS_KERNEL_PPC = \
244 -arch ppc \
245 -Wl,-segaddr,__VECTORS,0x0 \
246 -Wl,-segaddr,__HIB,0x7000 \
247 -Wl,-segaddr,__TEXT,0xe000
248
249 export LDFLAGS_KERNEL_I386 = \
250 -arch i386 \
251 -Wl,-segaddr,__HIB,0x100000 \
252 -Wl,-segaddr,__TEXT,0x111000
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
269 export INCFLAGS_GEN = -I$(SRCROOT)/$(COMPONENT) -I$(OBJROOT)/EXPORT_HDRS/$(COMPONENT)
270 export INCFLAGS_POSIX = -I$(OBJROOT)/EXPORT_HDRS/bsd
271 export INCFLAGS_LOCAL = -I.
272
273 export INCFLAGS = $(INCFLAGS_LOCAL) $(INCFLAGS_GEN) $(INCFLAGS_IMPORT) $(INCFLAGS_EXTERN) $(INCFLAGS_MAKEFILE)
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
297 FILE_INSTALL_FLAGS = -c -m 0644
298 DATA_INSTALL_FLAGS = -c -m 0644
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
314 KPINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/PrivateHeaders
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
323
324 #
325 # Compononent Header file destinations
326 #
327 EXPDIR = EXPORT_HDRS/$(COMPONENT)
328
329 #
330 # Strip Flags
331 #
332 export STRIP_FLAGS_RELEASE = -S -x
333 export STRIP_FLAGS_RELEASE_TRACE = -S -x
334 export STRIP_FLAGS_DEBUG = -S
335 export STRIP_FLAGS_DEBUG_TRACE = -S
336 export STRIP_FLAGS_PROFILE = -S -x
337
338 export STRIP_FLAGS = $($(addsuffix $(KERNEL_CONFIG),STRIP_FLAGS_))
339
340 #
341 # Man Page destination
342 #
343 MANDIR = usr/share/man
344
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