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