xref: /haiku/build/jam/ArchitectureRules (revision faf38d0fc0b16b984be6a34c4c60615d10948452)
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		# We need -integrated-as, as otherwise Clang uses GCC as assembler and
478		# passes -fheinous-gnu-extensions to GCC, which GCC does not understand
479		# then errors out.
480		AppendToConfigVar CCFLAGS :
481			HAIKU_TOP src system libroot posix glibc :
482			-integrated-as -fgnu89-inline -fheinous-gnu-extensions : global ;
483	}
484
485	EnableWerror src add-ons accelerants ;
486	EnableWerror src add-ons bluetooth ;
487	EnableWerror src add-ons decorators ;
488	EnableWerror src add-ons disk_systems ;
489	EnableWerror src add-ons input_server devices ;
490	EnableWerror src add-ons input_server filters ;
491#	EnableWerror src add-ons input_server methods pen ;
492	EnableWerror src add-ons input_server methods t9 ;
493	EnableWerror src add-ons kernel bluetooth ;
494	EnableWerror src add-ons kernel bus_managers acpi ;
495	EnableWerror src add-ons kernel bus_managers agp_gart ;
496	EnableWerror src add-ons kernel bus_managers ata ;
497	EnableWerror src add-ons kernel bus_managers config_manager ;
498#	EnableWerror src add-ons kernel bus_managers firewire ;
499	EnableWerror src add-ons kernel bus_managers ide ;
500	EnableWerror src add-ons kernel bus_managers isa ;
501	EnableWerror src add-ons kernel bus_managers pci ;
502	EnableWerror src add-ons kernel bus_managers ps2 ;
503	EnableWerror src add-ons kernel bus_managers random ;
504	EnableWerror src add-ons kernel bus_managers scsi ;
505	EnableWerror src add-ons kernel bus_managers tty ;
506	EnableWerror src add-ons kernel bus_managers usb ;
507	EnableWerror src add-ons kernel bus_managers virtio ;
508	EnableWerror src add-ons kernel busses agp_gart ;
509	EnableWerror src add-ons kernel busses ata ;
510	EnableWerror src add-ons kernel busses scsi ;
511	EnableWerror src add-ons kernel busses usb ;
512	EnableWerror src add-ons kernel console ;
513	EnableWerror src add-ons kernel cpu ;
514#	EnableWerror src add-ons kernel debugger ; # gcc2
515#	EnableWerror src add-ons kernel drivers audio ;
516	EnableWerror src add-ons kernel drivers bluetooth ;
517	EnableWerror src add-ons kernel drivers bus ;
518	EnableWerror src add-ons kernel drivers common ;
519	EnableWerror src add-ons kernel drivers disk ;
520	EnableWerror src add-ons kernel drivers dvb ;
521#	EnableWerror src add-ons kernel drivers graphics ;
522	EnableWerror src add-ons kernel drivers graphics intel_extreme ;
523#	EnableWerror src add-ons kernel drivers input ;
524	EnableWerror src add-ons kernel drivers joystick ;
525	EnableWerror src add-ons kernel drivers midi ;
526	EnableWerror src add-ons kernel drivers misc ;
527#	EnableWerror src add-ons kernel drivers network ;
528	EnableWerror src add-ons kernel drivers ports ;
529#	EnableWerror src add-ons kernel drivers power ;
530	EnableWerror src add-ons kernel drivers printer ;
531	EnableWerror src add-ons kernel drivers random ;
532	EnableWerror src add-ons kernel drivers tty ;
533	EnableWerror src add-ons kernel drivers video ;
534	EnableWerror src add-ons kernel file_systems bfs ;
535	EnableWerror src add-ons kernel file_systems cdda ;
536#	EnableWerror src add-ons kernel file_systems ext2 ;
537#	EnableWerror src add-ons kernel file_systems fat ;
538#	EnableWerror src add-ons kernel file_systems googlefs ;
539	EnableWerror src add-ons kernel file_systems iso9660 ;
540	EnableWerror src add-ons kernel file_systems layers ;
541	EnableWerror src add-ons kernel file_systems netfs ;
542	EnableWerror src add-ons kernel file_systems nfs ;
543	EnableWerror src add-ons kernel file_systems nfs4 ;
544#	EnableWerror src add-ons kernel file_systems ntfs ;
545	EnableWerror src add-ons kernel file_systems packagefs ;
546	EnableWerror src add-ons kernel file_systems ramfs ;
547#	EnableWerror src add-ons kernel file_systems reiserfs ;
548	EnableWerror src add-ons kernel file_systems udf ;
549	EnableWerror src add-ons kernel file_systems userlandfs ;
550	EnableWerror src add-ons kernel generic ;
551#	EnableWerror src add-ons kernel network datalink_protocols ;
552	EnableWerror src add-ons kernel network devices ;
553	EnableWerror src add-ons kernel network dns_resolver ;
554	EnableWerror src add-ons kernel network notifications ;
555	EnableWerror src add-ons kernel network ppp ;
556	EnableWerror src add-ons kernel network protocols ;
557#	EnableWerror src add-ons kernel network stack ;
558	EnableWerror src add-ons kernel partitioning_systems ;
559	EnableWerror src add-ons kernel power ;
560	EnableWerror src add-ons locale ;
561	EnableWerror src add-ons mail_daemon ;
562	EnableWerror src add-ons media media-add-ons demultiplexer ;
563	EnableWerror src add-ons media media-add-ons dvb ;
564	EnableWerror src add-ons media media-add-ons esound_sink ;
565	EnableWerror src add-ons media media-add-ons finepix_webcam ;
566	EnableWerror src add-ons media media-add-ons firewire_dv ;
567	EnableWerror src add-ons media media-add-ons legacy ;
568	EnableWerror src add-ons media media-add-ons mixer ;
569	EnableWerror src add-ons media media-add-ons multi_audio ;
570	EnableWerror src add-ons media media-add-ons opensound ;
571	EnableWerror src add-ons media media-add-ons radeon ;
572	EnableWerror src add-ons media media-add-ons reader ;
573	EnableWerror src add-ons media media-add-ons tone_producer_demo ;
574	EnableWerror src add-ons media media-add-ons usb_vision ;
575#	EnableWerror src add-ons media media-add-ons usb_webcam ;
576	EnableWerror src add-ons media media-add-ons video_mixer ;
577#	EnableWerror src add-ons media media-add-ons video_producer_demo ;
578	EnableWerror src add-ons media media-add-ons videowindow ;
579	EnableWerror src add-ons media media-add-ons writer ;
580	EnableWerror src add-ons media plugins aiff_reader ;
581	EnableWerror src add-ons media plugins ape_reader ;
582#	EnableWerror src add-ons media plugins asf_reader ;
583	EnableWerror src add-ons media plugins au_reader ;
584#	EnableWerror src add-ons media plugins avi_reader ;
585#	EnableWerror src add-ons media plugins ffmpeg ;
586#	EnableWerror src add-ons media plugins matroska ;
587#	EnableWerror src add-ons media plugins mov_reader ;
588	EnableWerror src add-ons media plugins mp3_decoder ;
589#	EnableWerror src add-ons media plugins mp3_reader ;
590	EnableWerror src add-ons media plugins mp4_reader ;
591	EnableWerror src add-ons media plugins musepack ;
592#	EnableWerror src add-ons media plugins ogg ;
593#	EnableWerror src add-ons media plugins raw_decoder ;
594#	EnableWerror src add-ons media plugins speex ;
595	EnableWerror src add-ons media plugins theora ;
596	EnableWerror src add-ons media plugins vorbis ;
597#	EnableWerror src add-ons media plugins wav_reader ;
598	EnableWerror src add-ons print ;
599	EnableWerror src add-ons screen_savers ;
600	EnableWerror src add-ons tracker ;
601	EnableWerror src add-ons translators bmp ;
602	EnableWerror src add-ons translators exr ;
603	EnableWerror src add-ons translators gif ;
604	EnableWerror src add-ons translators hvif ;
605	EnableWerror src add-ons translators ico ;
606	EnableWerror src add-ons translators jpeg ;
607#	EnableWerror src add-ons translators jpeg2000 ;
608	EnableWerror src add-ons translators pcx ;
609	EnableWerror src add-ons translators png ;
610	EnableWerror src add-ons translators ppm ;
611	EnableWerror src add-ons translators raw ;
612	EnableWerror src add-ons translators rtf ;
613	EnableWerror src add-ons translators sgi ;
614	EnableWerror src add-ons translators shared ;
615	EnableWerror src add-ons translators stxt ;
616	EnableWerror src add-ons translators tga ;
617	EnableWerror src add-ons translators tiff ;
618	EnableWerror src add-ons translators wonderbrush ;
619	EnableWerror src add-ons print ;
620	EnableWerror src bin desklink ;
621	EnableWerror src bin multiuser ;
622	EnableWerror src bin package ;
623	EnableWerror src bin package_repo ;
624	EnableWerror src bin pkgman ;
625	EnableWerror src libs bsd ;
626	EnableWerror src apps ;
627	EnableWerror src kits ;
628	EnableWerror src preferences ;
629	EnableWerror src servers ;
630	EnableWerror src system boot ;
631#	EnableWerror src system kernel ;
632	EnableWerror src system libroot add-ons ;
633	EnableWerror src system libroot os ;
634	EnableWerror src system libroot posix locale ;
635	EnableWerror src system libroot posix wchar ;
636	EnableWerror src system runtime_loader ;
637}
638
639
640rule MultiArchIfPrimary ifValue : elseValue : architecture
641{
642	# MultiArchIfPrimary <ifValue> : <elseValue>
643	#	[ : <architecture> = $(TARGET_PACKAGING_ARCH) ] ;
644	#
645	# Returns one of the two given values depending on whether
646	# <architecture> is the primary packaging architecture.
647
648	architecture ?= $(TARGET_PACKAGING_ARCH) ;
649
650	if $(architecture) = $(TARGET_PACKAGING_ARCHS[1]) {
651		return $(ifValue) ;
652	}
653	return $(elseValue) ;
654}
655
656
657rule MultiArchConditionalGristFiles files : primaryGrist : secondaryGrist
658	: architecture
659{
660	# MultiArchConditionalGristFiles <files> : <primaryGrist>
661	#	: <secondaryGrist> [ : <architecture> = $(TARGET_PACKAGING_ARCH) ] ;
662	#
663	# Returns <files> with their grist set to either <primaryGrist> or
664	# <secondaryGrist> depending on whether <architecture> is the primary
665	# packaging architecture.
666
667	architecture ?= $(TARGET_PACKAGING_ARCH) ;
668
669	local grist = [ MultiArchIfPrimary $(primaryGrist) : $(secondaryGrist)
670		: $(architecture) ] ;
671	return $(files:G=$(grist:E=)) ;
672}
673
674
675rule MultiArchDefaultGristFiles files : gristPrefix : architecture
676{
677	# MultiArchDefaultGristFiles <files> : <gristPrefix>
678	#	[ : <architecture> = $(TARGET_PACKAGING_ARCH) ] ;
679	#
680	# Convenient shorthand for MultiArchConditionalGristFiles for the common
681	# case that for a secondary packaging architecture the packaging
682	# architecture name shall be appended to the grist while it shall be omitted
683	# for the primary packaging architecture. IOW, if architecture is the
684	# primary packaging architecture, <files> are returned with their grist set
685	# to <gristPrefix>, otherwise <files> are returned with their grist set to
686	# <gristPrefix>!<architecture> respectively <architecture> (if <gristPrefix>
687	# is empty).
688
689	architecture ?= $(TARGET_PACKAGING_ARCH) ;
690
691	local secondaryGrist = $(gristPrefix)!$(architecture) ;
692	secondaryGrist ?= $(architecture) ;
693
694	return [ MultiArchConditionalGristFiles $(files) : $(gristPrefix) :
695		$(secondaryGrist) : $(architecture) ] ;
696}
697
698
699rule MultiArchSubDirSetup architectures
700{
701	# MultiArchSubDirSetup <architectures> ;
702	#
703	# For each of the given packaging architectures <architectures> that are
704	# in the packaging architectures configured for the build (or all configured
705	# packaging architectures, if <architectures> is empty) an object is
706	# prepared that can be used for an "on ... { ... }" block to set up subdir
707	# variables for the respective packaging architecture. Most notably
708	# TARGET_PACKAGING_ARCH, TARGET_ARCH are set to the values for the
709	# respective packaging architecture. The per-subdir variables SOURCE_GRIST,
710	# LOCATE_TARGET, LOCATE_SOURCE, SEARCH_SOURCE, *_LOCATE_TARGET, are reset.
711	# All SUBDIR* and config variables are set to the values they had when this
712	# rule was invoked.
713
714	local result ;
715	architectures ?= $(TARGET_PACKAGING_ARCHS) ;
716	local architecture ;
717	for architecture in $(architectures) {
718		if ! $(architecture) in $(TARGET_PACKAGING_ARCHS) {
719			continue ;
720		}
721
722		local architectureObject = $(architecture:G=<arch-object>) ;
723		result += $(architectureObject) ;
724
725		# Set the variables that default to the values of the respective
726		# variables for the primary architecture.
727		TARGET_PACKAGING_ARCH on $(architectureObject) = $(architecture) ;
728
729		local var ;
730		for var in TARGET_ARCH {
731			$(var) on $(architectureObject) = $($(var)_$(architecture)) ;
732		}
733
734		# Clone the current config variable values and the variables SubDir
735		# resets.
736		for var in $(AUTO_SET_UP_CONFIG_VARIABLES) SUBDIR$(SUBDIRRESET) {
737			$(var) on $(architectureObject) = $($(var)) ;
738		}
739
740		# adjust SOURCE_GRIST and HDRGRIST
741		SOURCE_GRIST on $(architectureObject)
742			= $(SOURCE_GRIST:E=)!$(architecture) ;
743
744		HDRGRIST on $(architectureObject)
745			= $(HDRGRIST:E=)!$(architecture) ;
746
747		# Adjust the subdir's object dirs that are architecture dependent. To
748		# avoid duplicating the code from SetupObjectsDir, we call it. Since it
749		# sets global variables, we set these variables on our object, call
750		# SetupObjectsDir in an "on" block, and grab the new variable values.
751		local hostTarget = HOST TARGET ;
752		local objectDirVars =
753			COMMON_ARCH COMMON_DEBUG DEBUG_$(HAIKU_DEBUG_LEVELS)
754			;
755		objectDirVars =
756			COMMON_PLATFORM_LOCATE_TARGET
757			$(hostTarget)_$(objectDirVars)_LOCATE_TARGET
758			LOCATE_TARGET
759			LOCATE_SOURCE
760			SEARCH_SOURCE
761			;
762
763		for var in $(objectDirVars) {
764			$(var) on $(architectureObject) = ;
765		}
766
767		on $(architectureObject) {
768			SetupObjectsDir ;
769
770			for var in $(objectDirVars) {
771				$(var) on $(architectureObject) = $($(var)) ;
772			}
773		}
774	}
775
776	return $(result) ;
777}
778