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