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