ArchitectureRules revision b3e749b0
1rule ArchitectureSetup architecture
2{
3	# ArchitectureSetup <architecture> ;
4	#
5	# Initializes all global packaging architecture dependent variables for the
6	# given packaging architecture. Also sets HAIKU_ARCH (to the primary
7	# architecture), if this is the first invocation of the rule, and adds
8	# the architecture to HAIKU_ARCHS, if not yet contained.
9
10	# analyze GCC version
11	local gccVersion
12		= [ FAnalyzeGCCVersion HAIKU_GCC_RAW_VERSION_$(architecture) ] ;
13	HAIKU_GCC_VERSION_$(architecture) = $(gccVersion) ;
14
15	# enable GCC -pipe option, if requested
16	local gccBaseFlags ;
17	if $(HAIKU_USE_GCC_PIPE) = 1 {
18		gccBaseFlags = -pipe ;
19	}
20
21	# disable strict aliasing on anything newer than gcc 2 as it may lead to
22	# unexpected results. also disable the tree-vrp (value range propagation)
23	# optimization for now as with the current gcc4 version we are using this
24	# results in some broken code.
25	# TODO: remove the -fno-strict-aliasing option when all code has been
26	#		analyzed/fixed with regard to aliasing.
27	# TODO: retest/remove the -fno-tree-vrp option as soon as we have updated
28	#		our gcc4 compiler. See this discussion on some issues:
29	# http://www.freelists.org/post/haiku-development/hrev45320-Yet-another-nonobvious-effect-of-ftreevrp-optimization
30	if $(gccVersion[1]) >= 3 {
31		gccBaseFlags += -fno-strict-aliasing -fno-builtin-fork ;
32		if $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 {
33			gccBaseFlags += -fno-tree-vrp ;
34		}
35	}
36
37	if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 {
38		gccBaseFlags += -fno-builtin-vfork ;
39	}
40
41	# disable array bounds warnings on gcc 4.6 or newer since they trigger
42	# too many false positives. Coverity does a better job of this kind of
43	# analysis anyways.
44	if $(gccVersion[1]) >= 4 {
45		gccBaseFlags += -Wno-array-bounds ;
46	}
47
48	local cpu = $(HAIKU_CPU_$(architecture)) ;
49	if $(cpu) = arm {
50		if $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 {
51			# For stackcrawls - not supported by Clang
52			gccBaseFlags += -mapcs-frame ;
53		}
54	}
55
56	# activating graphite optimizations
57	if $(HAIKU_USE_GCC_GRAPHITE_$(architecture)) = 1 {
58		gccBaseFlags += -floop-interchange -ftree-loop-distribution
59			-floop-strip-mine -floop-block ;
60	}
61	HAIKU_GCC_BASE_FLAGS_$(architecture) = $(gccBaseFlags) ;
62
63	# initial state for flags etc.
64	HAIKU_C++_$(architecture) ?= $(HAIKU_CC_$(architecture)) ;
65	HAIKU_LINK_$(architecture) = $(HAIKU_CC_$(architecture)) ;
66	HAIKU_LINKFLAGS_$(architecture) = $(gccBaseFlags) ;
67
68	HAIKU_CCFLAGS_$(architecture) += $(gccBaseFlags) -nostdinc ;
69	HAIKU_C++FLAGS_$(architecture) += $(gccBaseFlags) -nostdinc ;
70
71	# strip is required
72	if ! $(HAIKU_STRIP_$(architecture)) {
73		Exit "HAIKU_STRIP_$(architecture) not set. Please re-run configure." ;
74	}
75
76	HAIKU_ARCH_$(architecture) = $(cpu) ;
77	HAIKU_ARCH ?= $(cpu) ;
78		# Set only, if not set yet. This way HAIKU_ARCH is set to the primary
79		# architecture.
80	if ! $(cpu) in $(HAIKU_ARCHS) {
81		HAIKU_ARCHS += $(cpu) ;
82	}
83	HAIKU_DEFINES_$(architecture) += ARCH_$(cpu) ;
84
85	# directories
86	HAIKU_ARCH_OBJECT_DIR_$(architecture)
87		= [ FDirName $(HAIKU_OBJECT_BASE_DIR) $(architecture) ] ;
88	HAIKU_COMMON_DEBUG_OBJECT_DIR_$(architecture)
89		= [ FDirName $(HAIKU_ARCH_OBJECT_DIR_$(architecture)) common ] ;
90	HAIKU_DEBUG_0_OBJECT_DIR_$(architecture)
91		= [ FDirName $(HAIKU_ARCH_OBJECT_DIR_$(architecture)) release ] ;
92
93	local level ;
94	for level in $(HAIKU_DEBUG_LEVELS[2-]) {
95		HAIKU_DEBUG_$(level)_OBJECT_DIR_$(architecture)
96			= [ FDirName $(HAIKU_ARCH_OBJECT_DIR_$(architecture))
97				debug_$(level) ] ;
98	}
99
100	# set variables for gcc header options
101	SetIncludePropertiesVariables HAIKU : _$(architecture) ;
102
103	# assembler flags
104	HAIKU_ASFLAGS_$(architecture) = ;
105
106	# C/C++ flags
107	if $(gccVersion[1]) >= 4 {
108		HAIKU_C++FLAGS_$(architecture) += -Wno-deprecated ;
109	}
110
111	switch $(cpu) {
112		case x86* :
113			# Enable use of the gcc built-in atomic functions instead of
114			# atomic_*(). The former are inlined and have thus less overhead.
115			# They are not available with gcc 2, but the header will take care
116			# of that.
117			HAIKU_DEFINES_$(architecture) += B_USE_BUILTIN_ATOMIC_FUNCTIONS ;
118	}
119
120	# warning flags
121	HAIKU_WARNING_CCFLAGS_$(architecture)
122		= -Wall -Wno-trigraphs -Wmissing-prototypes
123		-Wpointer-arith -Wcast-align -Wsign-compare -Wno-multichar ;
124	HAIKU_WARNING_C++FLAGS_$(architecture) = -Wall -Wno-trigraphs
125		-Wno-ctor-dtor-privacy -Woverloaded-virtual -Wpointer-arith -Wcast-align
126		-Wsign-compare -Wno-multichar ;
127
128	HAIKU_WERROR_FLAGS_$(architecture) = ;
129
130	if $(gccVersion[1]) >= 4 {
131		# -Wuninitialized gives too many false positives.
132		HAIKU_WERROR_FLAGS_$(architecture) += -Wno-error=uninitialized
133			-Wno-error=maybe-uninitialized ;
134
135		# TODO: remove the -Wno-unused-but-set-variable option
136		HAIKU_WERROR_FLAGS_$(architecture) += -Wno-unused-but-set-variable ;
137	}
138
139	if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 {
140		gccBaseFlags += -Wno-address-of-packed-member -Wno-unused-private-field ;
141	}
142
143	# debug flags
144	local debugFlags = -ggdb ;
145
146	# debug 0: suppress asserts
147	HAIKU_DEBUG_0_CCFLAGS_$(architecture) = [ FDefines NDEBUG=$(NDEBUG) ] ;
148	HAIKU_DEBUG_0_C++FLAGS_$(architecture) = [ FDefines NDEBUG=$(NDEBUG) ] ;
149
150	local level ;
151	for level in $(HAIKU_DEBUG_LEVELS[2-]) {
152		local flags = $(debugFlags) [ FDefines DEBUG=$(level) ] ;
153		HAIKU_DEBUG_$(level)_CCFLAGS_$(architecture) = $(flags) ;
154		HAIKU_DEBUG_$(level)_C++FLAGS_$(architecture) = $(flags) ;
155	}
156
157	if $(gccVersion[1]) >= 3 {
158		# TODO: Temporary work-around. Should be defined in the compiler specs
159		HAIKU_LINKFLAGS_$(architecture) += -Xlinker --no-undefined ;
160	} else {
161		HAIKU_DEFINES_$(architecture) += _BEOS_R5_COMPATIBLE_ ;
162	}
163
164	# private shared kernel/libroot headers
165	HAIKU_PRIVATE_SYSTEM_HEADERS_$(architecture)
166		= [ PrivateHeaders $(DOT) system system/arch/$(cpu) ] ;
167
168	# library and executable glue code
169	local commonGlueCode =
170		<src!system!glue!$(architecture)>init_term_dyn.o
171		<src!system!glue!arch!$(cpu)!$(architecture)>crti.o
172		<src!system!glue!arch!$(cpu)!$(architecture)>crtn.o
173		;
174	HAIKU_LIBRARY_BEGIN_GLUE_CODE_$(architecture) =
175		<src!system!glue!arch!$(cpu)!$(architecture)>crti.o
176		<$(architecture)>crtbeginS.o
177		<src!system!glue!$(architecture)>init_term_dyn.o
178		;
179	HAIKU_LIBRARY_END_GLUE_CODE_$(architecture) =
180		<$(architecture)>crtendS.o
181		<src!system!glue!arch!$(cpu)!$(architecture)>crtn.o
182		;
183	HAIKU_EXECUTABLE_BEGIN_GLUE_CODE_$(architecture) =
184		<src!system!glue!arch!$(cpu)!$(architecture)>crti.o
185		<$(architecture)>crtbeginS.o
186		<src!system!glue!$(architecture)>start_dyn.o
187		<src!system!glue!$(architecture)>init_term_dyn.o
188		;
189	HAIKU_EXECUTABLE_END_GLUE_CODE_$(architecture)
190		= $(HAIKU_LIBRARY_END_GLUE_CODE_$(architecture)) ;
191
192	SEARCH on <$(architecture)>crtbeginS.o <$(architecture)>crtendS.o
193		= $(HAIKU_GCC_LIB_DIR_$(architecture)) ;
194
195	# init library name map
196	local libraryGrist = "" ;
197	if $(architecture) != $(HAIKU_PACKAGING_ARCHS[1]) {
198		libraryGrist = $(architecture) ;
199	}
200	local i ;
201	for i in be bnetapi debug device game locale mail media midi midi2
202			network package root screensaver textencoding tracker
203			translation z {
204		local library = lib$(i).so ;
205		HAIKU_LIBRARY_NAME_MAP_$(architecture)_$(i)
206			= $(library:G=$(libraryGrist)) ;
207	}
208	HAIKU_LIBRARY_NAME_MAP_$(architecture)_localestub
209		= <$(architecture)>liblocalestub.a ;
210	HAIKU_LIBRARY_NAME_MAP_$(architecture)_shared
211		= <$(architecture)>libshared.a ;
212	if $(architecture) = $(HAIKU_PACKAGING_ARCHS[1]) {
213		HAIKU_LIBRARY_NAME_MAP_$(architecture)_input_server
214			= <nogrist>input_server ;
215	} else {
216		HAIKU_LIBRARY_NAME_MAP_$(architecture)_input_server
217			= <$(architecture)>input_server ;
218	}
219}
220
221
222rule KernelArchitectureSetup architecture
223{
224	# KernelArchitectureSetup <architecture> ;
225	#
226	# Initializes the global kernel and boot loader related variables. Those
227	# don't have a packaging architecture suffix, since they are only set for
228	# the primary packaging architecture. <architecture> is the primary
229	# packaging architecture (supplied for convenience).
230
231	HAIKU_KERNEL_ARCH = $(HAIKU_ARCH) ;
232
233	local gccVersion = $(HAIKU_GCC_VERSION_$(architecture)) ;
234	local cpu = $(HAIKU_CPU_$(architecture)) ;
235
236	switch $(cpu) {
237		case ppc :
238			HAIKU_BOOT_PLATFORM ?= openfirmware ;
239			HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; # in kB
240			# offset in floppy image (>= sizeof(haiku_loader))
241			HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet
242
243		case arm :
244			HAIKU_BOOT_PLATFORM ?= u-boot ;
245
246			HAIKU_BOOT_SDIMAGE_SIZE ?= 128 ;
247			# SOC's like allwinner need an offset to skip the hardcoded initial loader
248			HAIKU_BOOT_SDIMAGE_BEGIN = 40950 ; # 512-byte sectors (divisible by 63)
249
250			HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ;
251			# offset in floppy image (>= sizeof(haiku_loader))
252			HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet
253			HAIKU_BOOT_LOADER_BASE ?= 0x1000000 ;
254
255		case x86 :
256			HAIKU_BOOT_PLATFORM ?= bios_ia32 ;
257			HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 2880 ; # in kB
258			# offset in floppy image (>= sizeof(haiku_loader))
259			HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 320 ; # in kB
260
261			# nasm is required for target arch x86
262			if ! $(HAIKU_NASM) {
263				Exit "HAIKU_NASM not set. Please re-run configure." ;
264			}
265
266		case x86_64 :
267			# x86_64 completely shares the x86 bootloader.
268			HAIKU_BOOT_PLATFORM ?= bios_ia32 ;
269			HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 2880 ; # in kB
270			# offset in floppy image (>= sizeof(haiku_loader))
271			HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 320 ; # in kB
272
273			# x86_64 kernel source is under arch/x86.
274			HAIKU_KERNEL_ARCH = x86 ;
275
276			# nasm is required for target arch x86_64
277			if ! $(HAIKU_NASM) {
278				Exit "HAIKU_NASM not set. Please re-run configure." ;
279			}
280
281		case m68k :
282			HAIKU_BOOT_PLATFORM ?= atari_m68k ;
283			switch $(HAIKU_BOOT_PLATFORM) {
284				case atari_m68k :
285				{
286					HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; # in kB
287				}
288				case amiga_m68k :
289				{
290					# for now we have trouble reading from double-sided images
291					HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 880 ; # in kB
292				}
293			}
294			# offset in floppy image (>= sizeof(haiku_loader))
295			HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 260 ; # in kB
296			HAIKU_CONTAINER_STRIP_EXECUTABLES on
297				$(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME) = 1 ;
298
299		case * :
300			Exit "Currently unsupported target CPU:" $(cpu) ;
301	}
302
303	# private kernel headers to be used when compiling kernel code
304	HAIKU_PRIVATE_KERNEL_HEADERS =
305		[ PrivateHeaders $(DOT) kernel libroot shared
306			kernel/boot/platform/$(HAIKU_BOOT_PLATFORM) ]
307		[ ArchHeaders $(HAIKU_KERNEL_ARCH) ]
308		[ FDirName $(HAIKU_COMMON_DEBUG_OBJECT_DIR_$(architecture)) system
309			kernel ]
310		$(HAIKU_PRIVATE_SYSTEM_HEADERS_$(architecture))
311		;
312
313	# C/C++ flags
314	local gccBaseFlags = $(HAIKU_GCC_BASE_FLAGS_$(architecture))
315		-finline -fno-builtin ;
316
317	if $(gccVersion[1]) >= 4 {
318		gccBaseFlags += -ffreestanding ;
319	}
320
321	local g++BaseFlags = $(gccBaseFlags) -fno-exceptions ;
322
323	if $(gccVersion[1]) >= 3 && $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 {
324		g++BaseFlags += -fno-use-cxa-atexit ;
325	}
326
327	HAIKU_KERNEL_CCFLAGS = $(HAIKU_CCFLAGS_$(architecture)) $(gccBaseFlags) ;
328	HAIKU_KERNEL_C++FLAGS = $(HAIKU_C++FLAGS_$(architecture)) $(g++BaseFlags) ;
329	HAIKU_BOOT_CCFLAGS = $(HAIKU_CCFLAGS_$(architecture)) $(gccBaseFlags) ;
330	HAIKU_BOOT_C++FLAGS = $(HAIKU_C++FLAGS_$(architecture)) $(g++BaseFlags) ;
331	HAIKU_BOOT_LINKFLAGS = ;
332	HAIKU_BOOT_LDFLAGS = -Bstatic ;
333
334	if $(gccVersion[1]) >= 6 {
335		HAIKU_KERNEL_C++FLAGS += -fno-delete-null-pointer-checks ;
336		HAIKU_KERNEL_CCFLAGS += -fno-delete-null-pointer-checks ;
337	}
338
339	HAIKU_KERNEL_PIC_CCFLAGS = -fno-pic ;
340	HAIKU_KERNEL_PIC_LINKFLAGS = ;
341	HAIKU_KERNEL_ADDON_LINKFLAGS = ;
342
343	# Any special kernel base addresses
344	if $(HAIKU_BOOT_LOADER_BASE) {
345		HAIKU_BOOT_LDFLAGS +=
346			--defsym BOOT_LOADER_BASE=$(HAIKU_BOOT_LOADER_BASE) ;
347	}
348
349	switch $(cpu) {
350		case arm :
351			# Workaround for ld using 32k for alignment despite forcing it in the config...
352			# should definitely not be needed!
353			HAIKU_KERNEL_LINKFLAGS +=
354				-Wl,-z -Wl,max-page-size=0x1000
355				-Wl,-z -Wl,common-page-size=0x1000 ;
356
357		case ppc :
358			# Build a position independent PPC kernel. We need to be able to
359			# relocate the kernel, since the virtual address space layout at
360			# boot time is not fixed.
361			HAIKU_KERNEL_PIC_CCFLAGS = -fPIE ;
362			HAIKU_KERNEL_PIC_LINKFLAGS = -shared -fPIE ;
363
364		case m68k :
365			# We don't want to have to handle emulating missing FPU opcodes for
366			# 040 and 060 in the kernel.
367			HAIKU_KERNEL_CCFLAGS += -mtune=68020-60 ;
368			HAIKU_KERNEL_C++FLAGS += -mtune=68020-60 ;
369
370		case x86 :
371			HAIKU_KERNEL_CCFLAGS += -march=pentium ;
372			HAIKU_KERNEL_C++FLAGS += -march=pentium ;
373
374		case x86_64 :
375			# Kernel lives in the top 2GB of the address space, use kernel code
376			# model.
377			HAIKU_KERNEL_PIC_CCFLAGS += -mcmodel=kernel ;
378
379			# Disable the red zone, which cannot be used in kernel code due to
380			# interrupts, and always enable the frame pointer so stack traces
381			# are correct.
382			HAIKU_KERNEL_CCFLAGS += -mno-red-zone -fno-omit-frame-pointer ;
383			HAIKU_KERNEL_C++FLAGS += -mno-red-zone -fno-omit-frame-pointer ;
384			HAIKU_KERNEL_PIC_LINKFLAGS += -z max-page-size=0x1000 ;
385			HAIKU_KERNEL_ADDON_LINKFLAGS += -z max-page-size=0x1000 ;
386
387			# BIOS Bootloader is 32-bit.
388			if $(HAIKU_BOOT_PLATFORM) = bios_ia32 {
389				HAIKU_BOOT_LINKFLAGS += -m elf_i386_haiku ;
390				HAIKU_BOOT_CCFLAGS += -m32 -march=pentium ;
391				HAIKU_BOOT_C++FLAGS += -m32 -march=pentium ;
392			}
393
394			if x86 in $(HAIKU_ARCHS[2-]) || x86_gcc2 in $(HAIKU_ARCHS[2-]) {
395				Echo "Enable kernel ia32 compatibility" ;
396				HAIKU_KERNEL_DEFINES += _COMPAT_MODE ;
397				HAIKU_KERNEL_COMPAT_MODE = 1 ;
398			}
399	}
400
401	if $(HAIKU_BOOT_PLATFORM) = efi {
402		HAIKU_BOOT_CCFLAGS += -fpic -fno-stack-protector -fPIC -fshort-wchar -mno-red-zone
403			-maccumulate-outgoing-args -Wno-error=unused-variable ;
404		HAIKU_BOOT_C++FLAGS += -fpic -fno-stack-protector -fPIC -fshort-wchar -mno-red-zone
405			-maccumulate-outgoing-args -Wno-error=unused-variable ;
406		HAIKU_BOOT_LDFLAGS = -Bstatic -Bsymbolic -shared -nostdlib -znocombreloc -nostartfiles -no-undefined ;
407	} else {
408		HAIKU_BOOT_CCFLAGS += -fno-pic ;
409		HAIKU_BOOT_C++FLAGS += -fno-pic ;
410	}
411
412	# warning flags
413	HAIKU_KERNEL_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes
414		-Wno-multichar ;
415	HAIKU_KERNEL_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-multichar ;
416
417	# debug flags
418	local level ;
419	for level in $(HAIKU_DEBUG_LEVELS) {
420		local flags = $(HAIKU_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ;
421		HAIKU_KERNEL_DEBUG_$(level)_CCFLAGS
422			= $(HAIKU_DEBUG_$(level)_CCFLAGS_$(architecture)) ;
423		HAIKU_KERNEL_DEBUG_$(level)_C++FLAGS
424			= $(HAIKU_DEBUG_$(level)_C++FLAGS_$(architecture)) ;
425	}
426
427	# defines
428	HAIKU_KERNEL_DEFINES += _KERNEL_MODE ;
429
430	HAIKU_DEFINES_$(architecture)
431		+= BOOT_ARCHIVE_IMAGE_OFFSET=$(HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET) ;
432		# TODO: That doesn't need to be a general define. It's just needed for
433		# compiling (part of) the boot loader.
434
435	# kernel add-on glue code
436	HAIKU_KERNEL_ADDON_BEGIN_GLUE_CODE = <$(architecture)>crtbeginS.o
437		<src!system!glue!$(architecture)>haiku_version_glue.o ;
438	HAIKU_KERNEL_ADDON_END_GLUE_CODE = <$(architecture)>crtendS.o ;
439}
440
441
442rule ArchitectureSetupWarnings architecture
443{
444	# ArchitectureSetupWarnings <architecture> ;
445	#
446	# Sets up compiler warnings and error flags for various subdirectories for
447	# the given packaging architecture.
448
449	local cpu = $(HAIKU_CPU_$(architecture)) ;
450	switch $(cpu) {
451		case arm :
452			return ;
453				# we use #warning as placeholders for things to write...
454		case m68k :
455			return ;
456				# we use #warning as placeholders for things to write...
457		case ppc :
458			return ;
459				# we use #warning as placeholders for things to write...
460	}
461
462	# enable -Werror for certain parts of the source tree
463	HAIKU_WERROR_ARCH = $(architecture) ;
464
465	rule EnableWerror dirTokens : scope {
466		# Clang gives way more warnings than GCC, so that code won't compile
467		# with -Werror when using Clang.
468		if $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 {
469			SetConfigVar WARNINGS : HAIKU_TOP $(dirTokens) : treatAsErrors
470				: $(scope) ;
471		}
472	}
473
474	# Work-around for GCC 2 problem -- despite -Wno-multichar it reports
475	# multichar warnings in headers/private/kernel/debugger_keymaps.h included
476	# by src/system/kernel/arch/x86/arch_debug_console.cpp.
477	local gccVersion = $(HAIKU_GCC_VERSION_$(architecture)) ;
478	if $(gccVersion[1]) = 2 {
479		local file = <src!system!kernel!arch!x86>arch_debug_console.o ;
480		WARNINGS on $(file) = $(WARNINGS) ;
481	}
482
483	if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 {
484		# We need -integrated-as, as otherwise Clang uses GCC as assembler and
485		# passes -fheinous-gnu-extensions to GCC, which GCC does not understand
486		# then errors out.
487		AppendToConfigVar CCFLAGS :
488			HAIKU_TOP src system libroot posix glibc :
489			-integrated-as -fgnu89-inline -fheinous-gnu-extensions : global ;
490	}
491
492	EnableWerror src add-ons accelerants ;
493	EnableWerror src add-ons bluetooth ;
494	EnableWerror src add-ons decorators ;
495	EnableWerror src add-ons disk_systems ;
496	EnableWerror src add-ons input_server devices ;
497	EnableWerror src add-ons input_server filters ;
498#	EnableWerror src add-ons input_server methods pen ;
499	EnableWerror src add-ons input_server methods t9 ;
500	EnableWerror src add-ons kernel bluetooth ;
501	EnableWerror src add-ons kernel bus_managers acpi ;
502	EnableWerror src add-ons kernel bus_managers agp_gart ;
503	EnableWerror src add-ons kernel bus_managers ata ;
504	EnableWerror src add-ons kernel bus_managers config_manager ;
505#	EnableWerror src add-ons kernel bus_managers firewire ;
506	EnableWerror src add-ons kernel bus_managers ide ;
507	EnableWerror src add-ons kernel bus_managers isa ;
508	EnableWerror src add-ons kernel bus_managers pci ;
509	EnableWerror src add-ons kernel bus_managers ps2 ;
510	EnableWerror src add-ons kernel bus_managers random ;
511	EnableWerror src add-ons kernel bus_managers scsi ;
512	EnableWerror src add-ons kernel bus_managers tty ;
513	EnableWerror src add-ons kernel bus_managers usb ;
514	EnableWerror src add-ons kernel bus_managers virtio ;
515	EnableWerror src add-ons kernel busses agp_gart ;
516	EnableWerror src add-ons kernel busses ata ;
517	EnableWerror src add-ons kernel busses scsi ;
518	EnableWerror src add-ons kernel busses usb ;
519	EnableWerror src add-ons kernel console ;
520	EnableWerror src add-ons kernel cpu ;
521#	EnableWerror src add-ons kernel debugger ; # gcc2
522#	EnableWerror src add-ons kernel drivers audio ;
523	EnableWerror src add-ons kernel drivers bluetooth ;
524	EnableWerror src add-ons kernel drivers bus ;
525	EnableWerror src add-ons kernel drivers common ;
526	EnableWerror src add-ons kernel drivers disk ;
527	EnableWerror src add-ons kernel drivers dvb ;
528#	EnableWerror src add-ons kernel drivers graphics ;
529	EnableWerror src add-ons kernel drivers graphics intel_extreme ;
530#	EnableWerror src add-ons kernel drivers input ;
531	EnableWerror src add-ons kernel drivers joystick ;
532	EnableWerror src add-ons kernel drivers midi ;
533	EnableWerror src add-ons kernel drivers misc ;
534#	EnableWerror src add-ons kernel drivers network ;
535	EnableWerror src add-ons kernel drivers ports ;
536#	EnableWerror src add-ons kernel drivers power ;
537	EnableWerror src add-ons kernel drivers printer ;
538	EnableWerror src add-ons kernel drivers random ;
539	EnableWerror src add-ons kernel drivers tty ;
540	EnableWerror src add-ons kernel drivers video ;
541	EnableWerror src add-ons kernel file_systems bfs ;
542	EnableWerror src add-ons kernel file_systems cdda ;
543#	EnableWerror src add-ons kernel file_systems ext2 ;
544#	EnableWerror src add-ons kernel file_systems fat ;
545#	EnableWerror src add-ons kernel file_systems googlefs ;
546	EnableWerror src add-ons kernel file_systems iso9660 ;
547	EnableWerror src add-ons kernel file_systems layers ;
548	EnableWerror src add-ons kernel file_systems netfs ;
549	EnableWerror src add-ons kernel file_systems nfs ;
550	EnableWerror src add-ons kernel file_systems nfs4 ;
551#	EnableWerror src add-ons kernel file_systems ntfs ;
552	EnableWerror src add-ons kernel file_systems packagefs ;
553	EnableWerror src add-ons kernel file_systems ramfs ;
554#	EnableWerror src add-ons kernel file_systems reiserfs ;
555	EnableWerror src add-ons kernel file_systems udf ;
556	EnableWerror src add-ons kernel file_systems userlandfs ;
557	EnableWerror src add-ons kernel generic ;
558#	EnableWerror src add-ons kernel network datalink_protocols ;
559	EnableWerror src add-ons kernel network devices ;
560	EnableWerror src add-ons kernel network dns_resolver ;
561	EnableWerror src add-ons kernel network notifications ;
562	EnableWerror src add-ons kernel network ppp ;
563	EnableWerror src add-ons kernel network protocols ;
564#	EnableWerror src add-ons kernel network stack ;
565	EnableWerror src add-ons kernel partitioning_systems ;
566	EnableWerror src add-ons kernel power ;
567	EnableWerror src add-ons locale ;
568	EnableWerror src add-ons mail_daemon ;
569	EnableWerror src add-ons media media-add-ons demultiplexer ;
570	EnableWerror src add-ons media media-add-ons dvb ;
571	EnableWerror src add-ons media media-add-ons esound_sink ;
572	EnableWerror src add-ons media media-add-ons finepix_webcam ;
573	EnableWerror src add-ons media media-add-ons firewire_dv ;
574	EnableWerror src add-ons media media-add-ons legacy ;
575	EnableWerror src add-ons media media-add-ons mixer ;
576	EnableWerror src add-ons media media-add-ons multi_audio ;
577	EnableWerror src add-ons media media-add-ons opensound ;
578	EnableWerror src add-ons media media-add-ons radeon ;
579	EnableWerror src add-ons media media-add-ons reader ;
580	EnableWerror src add-ons media media-add-ons tone_producer_demo ;
581	EnableWerror src add-ons media media-add-ons usb_vision ;
582#	EnableWerror src add-ons media media-add-ons usb_webcam ;
583	EnableWerror src add-ons media media-add-ons video_mixer ;
584#	EnableWerror src add-ons media media-add-ons video_producer_demo ;
585	EnableWerror src add-ons media media-add-ons videowindow ;
586	EnableWerror src add-ons media media-add-ons writer ;
587	EnableWerror src add-ons media plugins aiff_reader ;
588	EnableWerror src add-ons media plugins ape_reader ;
589#	EnableWerror src add-ons media plugins asf_reader ;
590	EnableWerror src add-ons media plugins au_reader ;
591#	EnableWerror src add-ons media plugins avi_reader ;
592#	EnableWerror src add-ons media plugins ffmpeg ;
593#	EnableWerror src add-ons media plugins matroska ;
594#	EnableWerror src add-ons media plugins mov_reader ;
595	EnableWerror src add-ons media plugins mp3_decoder ;
596#	EnableWerror src add-ons media plugins mp3_reader ;
597	EnableWerror src add-ons media plugins mp4_reader ;
598	EnableWerror src add-ons media plugins musepack ;
599#	EnableWerror src add-ons media plugins ogg ;
600#	EnableWerror src add-ons media plugins raw_decoder ;
601#	EnableWerror src add-ons media plugins speex ;
602	EnableWerror src add-ons media plugins theora ;
603	EnableWerror src add-ons media plugins vorbis ;
604#	EnableWerror src add-ons media plugins wav_reader ;
605	EnableWerror src add-ons print ;
606	EnableWerror src add-ons screen_savers ;
607	EnableWerror src add-ons tracker ;
608	EnableWerror src add-ons translators bmp ;
609	EnableWerror src add-ons translators exr ;
610	EnableWerror src add-ons translators gif ;
611#	EnableWerror src add-ons translators hpgs ;
612	EnableWerror src add-ons translators hvif ;
613	EnableWerror src add-ons translators ico ;
614	EnableWerror src add-ons translators jpeg ;
615#	EnableWerror src add-ons translators jpeg2000 ;
616	EnableWerror src add-ons translators pcx ;
617	EnableWerror src add-ons translators png ;
618	EnableWerror src add-ons translators ppm ;
619	EnableWerror src add-ons translators raw ;
620	EnableWerror src add-ons translators rtf ;
621	EnableWerror src add-ons translators sgi ;
622	EnableWerror src add-ons translators shared ;
623	EnableWerror src add-ons translators stxt ;
624	EnableWerror src add-ons translators tga ;
625	EnableWerror src add-ons translators tiff ;
626	EnableWerror src add-ons translators wonderbrush ;
627	EnableWerror src add-ons print ;
628	EnableWerror src bin desklink ;
629	EnableWerror src bin multiuser ;
630	EnableWerror src bin package ;
631	EnableWerror src bin package_repo ;
632	EnableWerror src bin pkgman ;
633	EnableWerror src libs bsd ;
634	EnableWerror src apps ;
635	EnableWerror src kits ;
636	EnableWerror src preferences ;
637	EnableWerror src servers ;
638	EnableWerror src system boot ;
639#	EnableWerror src system kernel ;
640	EnableWerror src system libroot add-ons ;
641	EnableWerror src system libroot os ;
642	EnableWerror src system libroot posix locale ;
643	EnableWerror src system libroot posix wchar ;
644	EnableWerror src system runtime_loader ;
645}
646
647
648rule MultiArchIfPrimary ifValue : elseValue : architecture
649{
650	# MultiArchIfPrimary <ifValue> : <elseValue>
651	#	[ : <architecture> = $(TARGET_PACKAGING_ARCH) ] ;
652	#
653	# Returns one of the two given values depending on whether
654	# <architecture> is the primary packaging architecture.
655
656	architecture ?= $(TARGET_PACKAGING_ARCH) ;
657
658	if $(architecture) = $(TARGET_PACKAGING_ARCHS[1]) {
659		return $(ifValue) ;
660	}
661	return $(elseValue) ;
662}
663
664
665rule MultiArchConditionalGristFiles files : primaryGrist : secondaryGrist
666	: architecture
667{
668	# MultiArchConditionalGristFiles <files> : <primaryGrist>
669	#	: <secondaryGrist> [ : <architecture> = $(TARGET_PACKAGING_ARCH) ] ;
670	#
671	# Returns <files> with their grist set to either <primaryGrist> or
672	# <secondaryGrist> depending on whether <architecture> is the primary
673	# packaging architecture.
674
675	architecture ?= $(TARGET_PACKAGING_ARCH) ;
676
677	local grist = [ MultiArchIfPrimary $(primaryGrist) : $(secondaryGrist)
678		: $(architecture) ] ;
679	return $(files:G=$(grist:E=)) ;
680}
681
682
683rule MultiArchDefaultGristFiles files : gristPrefix : architecture
684{
685	# MultiArchDefaultGristFiles <files> : <gristPrefix>
686	#	[ : <architecture> = $(TARGET_PACKAGING_ARCH) ] ;
687	#
688	# Convenient shorthand for MultiArchConditionalGristFiles for the common
689	# case that for a secondary packaging architecture the packaging
690	# architecture name shall be appended to the grist while it shall be omitted
691	# for the primary packaging architecture. IOW, if architecture is the
692	# primary packaging architecture, <files> are returned with their grist set
693	# to <gristPrefix>, otherwise <files> are returned with their grist set to
694	# <gristPrefix>!<architecture> respectively <architecture> (if <gristPrefix>
695	# is empty).
696
697	architecture ?= $(TARGET_PACKAGING_ARCH) ;
698
699	local secondaryGrist = $(gristPrefix)!$(architecture) ;
700	secondaryGrist ?= $(architecture) ;
701
702	return [ MultiArchConditionalGristFiles $(files) : $(gristPrefix) :
703		$(secondaryGrist) : $(architecture) ] ;
704}
705
706
707rule MultiArchSubDirSetup architectures
708{
709	# MultiArchSubDirSetup <architectures> ;
710	#
711	# For each of the given packaging architectures <architectures> that are
712	# in the packaging architectures configured for the build (or all configured
713	# packaging architectures, if <architectures> is empty) an object is
714	# prepared that can be used for an "on ... { ... }" block to set up subdir
715	# variables for the respective packaging architecture. Most notably
716	# TARGET_PACKAGING_ARCH, TARGET_ARCH are set to the values for the
717	# respective packaging architecture. The per-subdir variables SOURCE_GRIST,
718	# LOCATE_TARGET, LOCATE_SOURCE, SEARCH_SOURCE, *_LOCATE_TARGET, are reset.
719	# All SUBDIR* and config variables are set to the values they had when this
720	# rule was invoked.
721
722	local result ;
723	architectures ?= $(TARGET_PACKAGING_ARCHS) ;
724	local architecture ;
725	for architecture in $(architectures) {
726		if ! $(architecture) in $(TARGET_PACKAGING_ARCHS) {
727			continue ;
728		}
729
730		local architectureObject = $(architecture:G=<arch-object>) ;
731		result += $(architectureObject) ;
732
733		# Set the variables that default to the values of the respective
734		# variables for the primary architecture.
735		TARGET_PACKAGING_ARCH on $(architectureObject) = $(architecture) ;
736
737		local var ;
738		for var in TARGET_ARCH {
739			$(var) on $(architectureObject) = $($(var)_$(architecture)) ;
740		}
741
742		# Clone the current config variable values and the variables SubDir
743		# resets.
744		for var in $(AUTO_SET_UP_CONFIG_VARIABLES) SUBDIR$(SUBDIRRESET) {
745			$(var) on $(architectureObject) = $($(var)) ;
746		}
747
748		# adjust SOURCE_GRIST and HDRGRIST
749		SOURCE_GRIST on $(architectureObject)
750			= $(SOURCE_GRIST:E=)!$(architecture) ;
751
752		HDRGRIST on $(architectureObject)
753			= $(HDRGRIST:E=)!$(architecture) ;
754
755		# Adjust the subdir's object dirs that are architecture dependent. To
756		# avoid duplicating the code from SetupObjectsDir, we call it. Since it
757		# sets global variables, we set these variables on our object, call
758		# SetupObjectsDir in an "on" block, and grab the new variable values.
759		local hostTarget = HOST TARGET ;
760		local objectDirVars =
761			COMMON_ARCH COMMON_DEBUG DEBUG_$(HAIKU_DEBUG_LEVELS)
762			;
763		objectDirVars =
764			COMMON_PLATFORM_LOCATE_TARGET
765			$(hostTarget)_$(objectDirVars)_LOCATE_TARGET
766			LOCATE_TARGET
767			LOCATE_SOURCE
768			SEARCH_SOURCE
769			;
770
771		for var in $(objectDirVars) {
772			$(var) on $(architectureObject) = ;
773		}
774
775		on $(architectureObject) {
776			SetupObjectsDir ;
777
778			for var in $(objectDirVars) {
779				$(var) on $(architectureObject) = $($(var)) ;
780			}
781		}
782	}
783
784	return $(result) ;
785}
786