xref: /haiku/build/jam/ArchitectureRules (revision 41660cabf4f1cabafed672078cf3ee6d96eee073)
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		# For stackcrawls
47		gccBaseFlags += -mapcs-frame ;
48	}
49
50	# activating graphite optimizations
51	if $(HAIKU_USE_GCC_GRAPHITE_$(architecture)) = 1 {
52		gccBaseFlags += -floop-interchange -ftree-loop-distribution
53			-floop-strip-mine -floop-block ;
54	}
55	HAIKU_GCC_BASE_FLAGS_$(architecture) = $(gccBaseFlags) ;
56
57	# initial state for flags etc.
58	HAIKU_C++_$(architecture) ?= $(HAIKU_CC_$(architecture)) ;
59	HAIKU_LINK_$(architecture) = $(HAIKU_CC_$(architecture)) ;
60	HAIKU_LINKFLAGS_$(architecture) = $(gccBaseFlags) ;
61
62	HAIKU_CCFLAGS_$(architecture) += $(gccBaseFlags) -nostdinc ;
63	HAIKU_C++FLAGS_$(architecture) += $(gccBaseFlags) -nostdinc ;
64
65	# strip is required
66	if ! $(HAIKU_STRIP_$(architecture)) {
67		Exit "HAIKU_STRIP_$(architecture) not set. Please re-run configure." ;
68	}
69
70	HAIKU_ARCH_$(architecture) = $(cpu) ;
71	HAIKU_ARCH ?= $(cpu) ;
72		# Set only, if not set yet. This way HAIKU_ARCH is set to the primary
73		# architecture.
74	if ! $(cpu) in $(HAIKU_ARCHS) {
75		HAIKU_ARCHS += $(cpu) ;
76	}
77	HAIKU_DEFINES_$(architecture) += ARCH_$(cpu) ;
78
79	# directories
80	HAIKU_ARCH_OBJECT_DIR_$(architecture)
81		= [ FDirName $(HAIKU_OBJECT_BASE_DIR) $(architecture) ] ;
82	HAIKU_COMMON_DEBUG_OBJECT_DIR_$(architecture)
83		= [ FDirName $(HAIKU_ARCH_OBJECT_DIR_$(architecture)) common ] ;
84	HAIKU_DEBUG_0_OBJECT_DIR_$(architecture)
85		= [ FDirName $(HAIKU_ARCH_OBJECT_DIR_$(architecture)) release ] ;
86
87	local level ;
88	for level in $(HAIKU_DEBUG_LEVELS[2-]) {
89		HAIKU_DEBUG_$(level)_OBJECT_DIR_$(architecture)
90			= [ FDirName $(HAIKU_ARCH_OBJECT_DIR_$(architecture))
91				debug_$(level) ] ;
92	}
93
94	# set variables for gcc header options
95	SetIncludePropertiesVariables HAIKU : _$(architecture) ;
96
97	# assembler flags
98	HAIKU_ASFLAGS_$(architecture) = ;
99
100	# C/C++ flags
101	if $(gccVersion[1]) >= 4 {
102		HAIKU_C++FLAGS_$(architecture) += -Wno-deprecated ;
103	}
104
105	switch $(cpu) {
106		case x86* :
107			# Enable use of the gcc built-in atomic functions instead of
108			# atomic_*(). The former are inlined and have thus less overhead.
109			# They are not available with gcc 2, but the header will take care
110			# of that.
111			HAIKU_DEFINES_$(architecture) += B_USE_BUILTIN_ATOMIC_FUNCTIONS ;
112	}
113
114	# warning flags
115	HAIKU_WARNING_CCFLAGS_$(architecture)
116		= -Wall -Wno-trigraphs -Wmissing-prototypes
117		-Wpointer-arith -Wcast-align -Wsign-compare -Wno-multichar ;
118	HAIKU_WARNING_C++FLAGS_$(architecture) = -Wall -Wno-trigraphs
119		-Wno-ctor-dtor-privacy -Woverloaded-virtual -Wpointer-arith -Wcast-align
120		-Wsign-compare -Wno-multichar ;
121
122	HAIKU_WERROR_FLAGS_$(architecture) = ;
123
124	if $(gccVersion[1]) >= 4 {
125		# -Wuninitialized gives too many false positives.
126		HAIKU_WERROR_FLAGS_$(architecture) += -Wno-error=uninitialized ;
127
128		# TODO: remove the -Wno-unused-but-set-variable option
129		HAIKU_WERROR_FLAGS_$(architecture) += -Wno-unused-but-set-variable ;
130	}
131
132	# debug flags
133	local debugFlags = -ggdb ;
134
135	# debug 0: suppress asserts
136	HAIKU_DEBUG_0_CCFLAGS_$(architecture) = [ FDefines NDEBUG=$(NDEBUG) ] ;
137	HAIKU_DEBUG_0_C++FLAGS_$(architecture) = [ FDefines NDEBUG=$(NDEBUG) ] ;
138
139	local level ;
140	for level in $(HAIKU_DEBUG_LEVELS[2-]) {
141		local flags = $(debugFlags) [ FDefines DEBUG=$(level) ] ;
142		HAIKU_DEBUG_$(level)_CCFLAGS_$(architecture) = $(flags) ;
143		HAIKU_DEBUG_$(level)_C++FLAGS_$(architecture) = $(flags) ;
144	}
145
146	if $(gccVersion[1]) >= 3 {
147		# TODO: Temporary work-around. Should be defined in the compiler specs
148		HAIKU_LINKFLAGS_$(architecture) += -Xlinker --no-undefined ;
149	} else {
150		HAIKU_DEFINES_$(architecture) += _BEOS_R5_COMPATIBLE_ ;
151	}
152
153	# private shared kernel/libroot headers
154	HAIKU_PRIVATE_SYSTEM_HEADERS_$(architecture)
155		= [ PrivateHeaders $(DOT) system system/arch/$(cpu) ] ;
156
157	# library and executable glue code
158	local commonGlueCode =
159		<src!system!glue!$(architecture)>init_term_dyn.o
160		<src!system!glue!arch!$(HAIKU_ARCH)!$(architecture)>crti.o
161		<src!system!glue!arch!$(HAIKU_ARCH)!$(architecture)>crtn.o
162		;
163	HAIKU_LIBRARY_BEGIN_GLUE_CODE_$(architecture) =
164		<src!system!glue!arch!$(HAIKU_ARCH)!$(architecture)>crti.o
165		<$(architecture)>crtbeginS.o
166		<src!system!glue!$(architecture)>init_term_dyn.o
167		;
168	HAIKU_LIBRARY_END_GLUE_CODE_$(architecture) =
169		<$(architecture)>crtendS.o
170		<src!system!glue!arch!$(HAIKU_ARCH)!$(architecture)>crtn.o
171		;
172	HAIKU_EXECUTABLE_BEGIN_GLUE_CODE_$(architecture) =
173		<src!system!glue!arch!$(HAIKU_ARCH)!$(architecture)>crti.o
174		<$(architecture)>crtbeginS.o
175		<src!system!glue!$(architecture)>start_dyn.o
176		<src!system!glue!$(architecture)>init_term_dyn.o
177		;
178	HAIKU_EXECUTABLE_END_GLUE_CODE_$(architecture)
179		= $(HAIKU_LIBRARY_END_GLUE_CODE_$(architecture)) ;
180
181	SEARCH on <$(architecture)>crtbeginS.o <$(architecture)>crtendS.o
182		= $(HAIKU_GCC_LIB_DIR_$(architecture)) ;
183
184	# init library name map
185	local libraryGrist = "" ;
186	if $(architecture) != $(HAIKU_PACKAGING_ARCHS[1]) {
187		libraryGrist = $(architecture) ;
188	}
189	local i ;
190	for i in be bnetapi debug device game locale mail media midi midi2
191			network package root screensaver textencoding tracker
192			translation z {
193		local library = lib$(i).so ;
194		HAIKU_LIBRARY_NAME_MAP_$(architecture)_$(i)
195			= $(library:G=$(libraryGrist)) ;
196	}
197	HAIKU_LIBRARY_NAME_MAP_$(architecture)_localestub
198		= <$(architecture)>liblocalestub.a ;
199	if $(architecture) = $(HAIKU_PACKAGING_ARCHS[1]) {
200		HAIKU_LIBRARY_NAME_MAP_$(architecture)_input_server
201			= <nogrist>input_server ;
202	} else {
203		HAIKU_LIBRARY_NAME_MAP_$(architecture)_input_server
204			= <$(architecture)>input_server ;
205	}
206}
207
208
209rule KernelArchitectureSetup architecture
210{
211	# KernelArchitectureSetup <architecture> ;
212	#
213	# Initializes the global kernel and boot loader related variables. Those
214	# don't have a packaging architecture suffix, since they are only set for
215	# the primary packaging architecture. <architecture> is the primary
216	# packaging architecture (supplied for convenience).
217
218	HAIKU_KERNEL_ARCH = $(HAIKU_ARCH) ;
219
220	local gccVersion = $(HAIKU_GCC_VERSION_$(architecture)) ;
221	local cpu = $(HAIKU_CPU_$(architecture)) ;
222
223	switch $(cpu) {
224		case ppc :
225			HAIKU_BOOT_PLATFORM ?= openfirmware ;
226			HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; # in kB
227			# offset in floppy image (>= sizeof(haiku_loader))
228			HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet
229
230		case arm :
231			switch $(HAIKU_BOOT_BOARD) {
232				case beagle :
233				{
234					HAIKU_BOOT_PLATFORM ?= u-boot ;
235					HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ;
236				}
237				case neo_freerunner :
238				{
239					HAIKU_BOOT_PLATFORM ?= u-boot ;
240					HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ;
241				}
242				case overo :
243				{
244					HAIKU_BOOT_PLATFORM ?= u-boot ;
245					HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ;
246				}
247				case raspberry_pi :
248				{
249					# For now rpi has a custom non u-boot loader
250					HAIKU_BOOT_PLATFORM ?= raspberrypi_arm ;
251					HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ;
252				}
253				case verdex :
254				{
255					HAIKU_BOOT_PLATFORM ?= u-boot ;
256					HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ;
257				}
258				case * :
259				{
260					Exit "Set HAIKU_BOOT_BOARD for your target ARM device!" ;
261				}
262			}
263
264			# offset in floppy image (>= sizeof(haiku_loader))
265			HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet
266
267		case x86 :
268			HAIKU_BOOT_PLATFORM = bios_ia32 ;
269			HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 2880 ; # in kB
270			# offset in floppy image (>= sizeof(haiku_loader))
271			HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 320 ; # in kB
272
273			# nasm is required for target arch x86
274			if ! $(HAIKU_NASM) {
275				Exit "HAIKU_NASM not set. Please re-run configure." ;
276			}
277
278		case x86_64 :
279			# x86_64 completely shares the x86 bootloader.
280			HAIKU_BOOT_PLATFORM = bios_ia32 ;
281			HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 2880 ; # in kB
282			# offset in floppy image (>= sizeof(haiku_loader))
283			HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 320 ; # in kB
284
285			# x86_64 kernel source is under arch/x86.
286			HAIKU_KERNEL_ARCH = x86 ;
287
288			# nasm is required for target arch x86_64
289			if ! $(HAIKU_NASM) {
290				Exit "HAIKU_NASM not set. Please re-run configure." ;
291			}
292
293		case m68k :
294			HAIKU_BOOT_PLATFORM ?= atari_m68k ;
295			switch $(HAIKU_BOOT_PLATFORM) {
296				case atari_m68k :
297				{
298					HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; # in kB
299				}
300				case amiga_m68k :
301				{
302					# for now we have trouble reading from double-sided images
303					HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 880 ; # in kB
304				}
305			}
306			# offset in floppy image (>= sizeof(haiku_loader))
307			HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 260 ; # in kB
308			HAIKU_CONTAINER_STRIP_EXECUTABLES on
309				$(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME) = 1 ;
310
311		case * :
312			Exit "Currently unsupported target CPU:" $(cpu) ;
313	}
314
315	# Include embedded board-specific file.
316	if $(HAIKU_BOOT_BOARD) {
317		include [ FDirName $(HAIKU_BUILD_RULES_DIR) board $(HAIKU_BOOT_BOARD)
318			BoardSetup ] ;
319	}
320
321	# private kernel headers to be used when compiling kernel code
322	HAIKU_PRIVATE_KERNEL_HEADERS =
323		[ PrivateHeaders $(DOT) kernel libroot shared
324			kernel/boot/platform/$(HAIKU_BOOT_PLATFORM) ]
325		[ ArchHeaders $(HAIKU_KERNEL_ARCH) ]
326		[ FDirName $(HAIKU_COMMON_DEBUG_OBJECT_DIR_$(architecture)) system
327			kernel ]
328		$(HAIKU_PRIVATE_SYSTEM_HEADERS_$(architecture))
329		;
330
331	# C/C++ flags
332	local gccBaseFlags = $(HAIKU_GCC_BASE_FLAGS_$(architecture))
333		-finline -fno-builtin ;
334
335	if $(gccVersion[1]) >= 4 {
336		gccBaseFlags += -ffreestanding ;
337	}
338
339	local g++BaseFlags = $(gccBaseFlags) -fno-exceptions ;
340
341	if $(gccVersion[1]) >= 3 && $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 {
342		g++BaseFlags += -fno-use-cxa-atexit ;
343	}
344
345	HAIKU_KERNEL_CCFLAGS = $(HAIKU_CCFLAGS_$(architecture)) $(gccBaseFlags) ;
346	HAIKU_KERNEL_C++FLAGS = $(HAIKU_C++FLAGS_$(architecture)) $(g++BaseFlags) ;
347	HAIKU_BOOT_CCFLAGS = $(HAIKU_CCFLAGS_$(architecture)) $(gccBaseFlags) ;
348	HAIKU_BOOT_C++FLAGS = $(HAIKU_C++FLAGS_$(architecture)) $(g++BaseFlags) ;
349	HAIKU_BOOT_LINKFLAGS = ;
350
351	if $(gccVersion[1]) >= 4 {
352		HAIKU_KERNEL_C++FLAGS += -std=gnu++11 ;
353	}
354
355	HAIKU_KERNEL_PIC_CCFLAGS = -fno-pic ;
356	HAIKU_KERNEL_PIC_LINKFLAGS = ;
357	HAIKU_KERNEL_ADDON_LINKFLAGS = ;
358
359	switch $(cpu) {
360		case ppc :
361			# Build a position independent PPC kernel. We need to be able to
362			# relocate the kernel, since the virtual address space layout at
363			# boot time is not fixed.
364			HAIKU_KERNEL_PIC_CCFLAGS = -fPIE ;
365			HAIKU_KERNEL_PIC_LINKFLAGS = -shared -fPIE ;
366
367		case m68k :
368			# We don't want to have to handle emulating missing FPU opcodes for
369			# 040 and 060 in the kernel.
370			HAIKU_KERNEL_CCFLAGS += -mtune=68020-60 ;
371			HAIKU_KERNEL_C++FLAGS += -mtune=68020-60 ;
372
373		case x86 :
374			HAIKU_KERNEL_CCFLAGS += -march=pentium ;
375			HAIKU_KERNEL_C++FLAGS += -march=pentium ;
376
377		case x86_64 :
378			# Kernel lives in the top 2GB of the address space, use kernel code
379			# model.
380			HAIKU_KERNEL_PIC_CCFLAGS += -mcmodel=kernel ;
381
382			# Disable the red zone, which cannot be used in kernel code due to
383			# interrupts, and always enable the frame pointer so stack traces
384			# are correct.
385			HAIKU_KERNEL_CCFLAGS += -mno-red-zone -fno-omit-frame-pointer ;
386			HAIKU_KERNEL_C++FLAGS += -mno-red-zone -fno-omit-frame-pointer ;
387			HAIKU_KERNEL_PIC_LINKFLAGS += -z max-page-size=0x1000 ;
388			HAIKU_KERNEL_ADDON_LINKFLAGS += -z max-page-size=0x1000 ;
389
390			# Bootloader is 32-bit.
391			HAIKU_BOOT_LINKFLAGS += -m elf_i386_haiku ;
392			HAIKU_BOOT_CCFLAGS += -m32 -march=pentium ;
393			HAIKU_BOOT_C++FLAGS += -m32 -march=pentium ;
394	}
395
396	# warning flags
397	HAIKU_KERNEL_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes
398		-Wno-multichar ;
399	HAIKU_KERNEL_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-multichar ;
400
401	# debug flags
402	local level ;
403	for level in $(HAIKU_DEBUG_LEVELS) {
404		local flags = $(HAIKU_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ;
405		HAIKU_KERNEL_DEBUG_$(level)_CCFLAGS
406			= $(HAIKU_DEBUG_$(level)_CCFLAGS_$(architecture)) ;
407		HAIKU_KERNEL_DEBUG_$(level)_C++FLAGS
408			= $(HAIKU_DEBUG_$(level)_C++FLAGS_$(architecture)) ;
409	}
410
411	# defines
412	HAIKU_KERNEL_DEFINES += _KERNEL_MODE ;
413
414	HAIKU_DEFINES_$(architecture)
415		+= BOOT_ARCHIVE_IMAGE_OFFSET=$(HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET) ;
416		# TODO: That doesn't need to be a general define. It's just needed for
417		# compiling (part of) the boot loader.
418
419	# kernel add-on glue code
420	HAIKU_KERNEL_ADDON_BEGIN_GLUE_CODE = <$(architecture)>crtbeginS.o
421		<src!system!glue!$(architecture)>haiku_version_glue.o ;
422	HAIKU_KERNEL_ADDON_END_GLUE_CODE = <$(architecture)>crtendS.o ;
423}
424
425
426rule ArchitectureSetupWarnings architecture
427{
428	# ArchitectureSetupWarnings <architecture> ;
429	#
430	# Sets up compiler warnings and error flags for various subdirectories for
431	# the given packaging architecture.
432
433	local cpu = $(HAIKU_CPU_$(architecture)) ;
434	switch $(cpu) {
435		case arm :
436			return ;
437				# we use #warning as placeholders for things to write...
438		case m68k :
439			return ;
440				# we use #warning as placeholders for things to write...
441	}
442
443	# enable -Werror for certain parts of the source tree
444	HAIKU_WERROR_ARCH = $(architecture) ;
445
446	rule EnableWerror dirTokens : scope {
447		# Clang gives way more warnings than GCC, so that code won't compile
448		# with -Werror when using Clang.
449		if $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 {
450			SetConfigVar WARNINGS : HAIKU_TOP $(dirTokens) : treatAsErrors
451				: $(scope) ;
452		}
453	}
454
455	# Work-around for GCC 2 problem -- despite -Wno-multichar it reports
456	# multichar warnings in headers/private/kernel/debugger_keymaps.h included
457	# by src/system/kernel/arch/x86/arch_debug_console.cpp.
458	local gccVersion = $(HAIKU_GCC_VERSION_$(architecture)) ;
459	if $(gccVersion[1]) = 2 {
460		local file = <src!system!kernel!arch!x86>arch_debug_console.o ;
461		WARNINGS on $(file) = $(WARNINGS) ;
462	}
463
464	if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 {
465		# We need -integrated-as, as otherwise Clang uses GCC as assembler and
466		# passes -fheinous-gnu-extensions to GCC, which GCC does not understand
467		# then errors out.
468		AppendToConfigVar CCFLAGS :
469			HAIKU_TOP src system libroot posix glibc :
470			-integrated-as -fgnu89-inline -fheinous-gnu-extensions : global ;
471	}
472
473	EnableWerror src add-ons accelerants 3dfx ;
474	EnableWerror src add-ons accelerants ati ;
475	EnableWerror src add-ons accelerants common ;
476	EnableWerror src add-ons accelerants et6x00 ;
477#	EnableWerror src add-ons accelerants intel_extreme ;
478#	EnableWerror src add-ons accelerants matrox ;
479	EnableWerror src add-ons accelerants neomagic ;
480#	EnableWerror src add-ons accelerants nvidia ;
481	EnableWerror src add-ons accelerants nvidia_gpgpu ;
482#	EnableWerror src add-ons accelerants radeon ;
483#	EnableWerror src add-ons accelerants radeon_hd ;
484	EnableWerror src add-ons accelerants s3 ;
485	EnableWerror src add-ons accelerants skeleton ;
486	EnableWerror src add-ons accelerants vesa ;
487	EnableWerror src add-ons accelerants via ;
488	EnableWerror src add-ons accelerants vmware ;
489	EnableWerror src add-ons bluetooth ;
490	EnableWerror src add-ons decorators ;
491	EnableWerror src add-ons disk_systems ;
492	EnableWerror src add-ons input_server devices ;
493#	EnableWerror src add-ons input_server filters ;
494#	EnableWerror src add-ons input_server methods ;
495	EnableWerror src add-ons kernel bluetooth ;
496#	EnableWerror src add-ons kernel bus_managers acpi ;
497	EnableWerror src add-ons kernel bus_managers agp_gart ;
498	EnableWerror src add-ons kernel bus_managers ata ;
499	EnableWerror src add-ons kernel bus_managers config_manager ;
500#	EnableWerror src add-ons kernel bus_managers firewire ;
501	EnableWerror src add-ons kernel bus_managers isa ;
502	EnableWerror src add-ons kernel bus_managers pci ;
503#	EnableWerror src add-ons kernel bus_managers ps2 ; # gcc2
504	EnableWerror src add-ons kernel bus_managers scsi ;
505	EnableWerror src add-ons kernel bus_managers usb ;
506	EnableWerror src add-ons kernel busses agp_gart ;
507	EnableWerror src add-ons kernel busses ata ;
508	EnableWerror src add-ons kernel busses scsi ;
509	EnableWerror src add-ons kernel busses usb ;
510	EnableWerror src add-ons kernel console ;
511	EnableWerror src add-ons kernel cpu ;
512#	EnableWerror src add-ons kernel debugger ; # gcc2
513#	EnableWerror src add-ons kernel drivers audio ;
514	EnableWerror src add-ons kernel drivers bluetooth ;
515	EnableWerror src add-ons kernel drivers bus ;
516	EnableWerror src add-ons kernel drivers common ;
517	EnableWerror src add-ons kernel drivers disk ;
518	EnableWerror src add-ons kernel drivers dvb ;
519#	EnableWerror src add-ons kernel drivers graphics ;
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 ac3_decoder ;
578	EnableWerror src add-ons media plugins aiff_reader ;
579	EnableWerror src add-ons media plugins ape_reader ;
580#	EnableWerror src add-ons media plugins asf_reader ;
581	EnableWerror src add-ons media plugins au_reader ;
582#	EnableWerror src add-ons media plugins avi_reader ;
583#	EnableWerror src add-ons media plugins ffmpeg ;
584#	EnableWerror src add-ons media plugins matroska ;
585#	EnableWerror src add-ons media plugins mov_reader ;
586	EnableWerror src add-ons media plugins mp3_decoder ;
587#	EnableWerror src add-ons media plugins mp3_reader ;
588	EnableWerror src add-ons media plugins mp4_reader ;
589	EnableWerror src add-ons media plugins musepack ;
590#	EnableWerror src add-ons media plugins ogg ;
591#	EnableWerror src add-ons media plugins raw_decoder ;
592#	EnableWerror src add-ons media plugins speex ;
593	EnableWerror src add-ons media plugins theora ;
594	EnableWerror src add-ons media plugins vorbis ;
595#	EnableWerror src add-ons media plugins wav_reader ;
596	EnableWerror src add-ons media plugins xvid_decoder ;
597	EnableWerror src add-ons print ;
598	EnableWerror src add-ons screen_savers ;
599	EnableWerror src add-ons tracker ;
600	EnableWerror src add-ons translators bmp ;
601#	EnableWerror src add-ons translators exr ;
602	EnableWerror src add-ons translators gif ;
603#	EnableWerror src add-ons translators hpgs ;
604	EnableWerror src add-ons translators hvif ;
605	EnableWerror src add-ons translators ico ;
606#	EnableWerror src add-ons translators jpeg ; # gcc2
607	EnableWerror src add-ons translators jpeg2000 ;
608	EnableWerror src add-ons translators pcx ;
609#	EnableWerror src add-ons translators png ; # gcc2
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
741		SOURCE_GRIST on $(architectureObject)
742			= $(SOURCE_GRIST: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