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