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