xref: /haiku/build/jam/ArchitectureRules (revision 16c83730262f1e4f0fc69d80744bb36dcfbbe3af)
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
322		case mipsel :
323			# RouterBOARD firmware (ELF image over TFTP)
324			HAIKU_BOOT_PLATFORM = routerboard_mipsel ;
325			# offset in floppy image (>= sizeof(haiku_loader))
326			HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB
327
328		case * :
329			Exit "Currently unsupported target CPU:" $(cpu) ;
330	}
331
332	# Include embedded board-specific file.
333	if $(HAIKU_BOOT_BOARD) {
334		include [ FDirName $(HAIKU_BUILD_RULES_DIR) board $(HAIKU_BOOT_BOARD)
335			BoardSetup ] ;
336	}
337
338	# private kernel headers to be used when compiling kernel code
339	HAIKU_PRIVATE_KERNEL_HEADERS =
340		[ PrivateHeaders $(DOT) kernel libroot shared
341			kernel/boot/platform/$(HAIKU_BOOT_PLATFORM) ]
342		[ ArchHeaders $(HAIKU_KERNEL_ARCH) ]
343		[ FDirName $(HAIKU_COMMON_DEBUG_OBJECT_DIR_$(architecture)) system
344			kernel ]
345		$(HAIKU_PRIVATE_SYSTEM_HEADERS_$(architecture))
346		;
347
348	# C/C++ flags
349	local gccBaseFlags = $(HAIKU_GCC_BASE_FLAGS_$(architecture))
350		-finline -fno-builtin ;
351
352	if $(gccVersion[1]) >= 4 {
353		gccBaseFlags += -ffreestanding ;
354	}
355
356	local g++BaseFlags = $(gccBaseFlags) -fno-exceptions ;
357
358	if $(gccVersion[1]) >= 3 {
359		g++BaseFlags += -fno-use-cxa-atexit ;
360	}
361
362	HAIKU_KERNEL_CCFLAGS = $(HAIKU_CCFLAGS_$(architecture)) $(gccBaseFlags) ;
363	HAIKU_KERNEL_C++FLAGS = $(HAIKU_C++FLAGS_$(architecture)) $(g++BaseFlags) ;
364	HAIKU_BOOT_CCFLAGS = $(HAIKU_CCFLAGS_$(architecture)) $(gccBaseFlags) ;
365	HAIKU_BOOT_C++FLAGS = $(HAIKU_C++FLAGS_$(architecture)) $(g++BaseFlags) ;
366	HAIKU_BOOT_LINKFLAGS = ;
367
368	HAIKU_KERNEL_PIC_CCFLAGS = -fno-pic ;
369	HAIKU_KERNEL_PIC_LINKFLAGS = ;
370	HAIKU_KERNEL_ADDON_LINKFLAGS = ;
371
372	switch $(cpu) {
373		case ppc :
374			# Build a position independent PPC kernel. We need to be able to
375			# relocate the kernel, since the virtual address space layout at
376			# boot time is not fixed.
377			HAIKU_KERNEL_PIC_CCFLAGS = -fPIE ;
378			HAIKU_KERNEL_PIC_LINKFLAGS = -shared -fPIE ;
379
380		case m68k :
381			# We don't want to have to handle emulating missing FPU opcodes for
382			# 040 and 060 in the kernel.
383			HAIKU_KERNEL_CCFLAGS += -mtune=68020-60 ;
384			HAIKU_KERNEL_C++FLAGS += -mtune=68020-60 ;
385
386		case x86 :
387			HAIKU_KERNEL_CCFLAGS += -march=pentium ;
388			HAIKU_KERNEL_C++FLAGS += -march=pentium ;
389
390		case x86_64 :
391			# Kernel lives in the top 2GB of the address space, use kernel code
392			# model.
393			HAIKU_KERNEL_PIC_CCFLAGS += -mcmodel=kernel ;
394
395			# Disable the red zone, which cannot be used in kernel code due to
396			# interrupts, and always enable the frame pointer so stack traces
397			# are correct.
398			HAIKU_KERNEL_CCFLAGS += -mno-red-zone -fno-omit-frame-pointer ;
399			HAIKU_KERNEL_C++FLAGS += -mno-red-zone -fno-omit-frame-pointer ;
400			HAIKU_KERNEL_PIC_LINKFLAGS += -z max-page-size=0x1000 ;
401			HAIKU_KERNEL_ADDON_LINKFLAGS += -z max-page-size=0x1000 ;
402
403			# Bootloader is 32-bit.
404			HAIKU_BOOT_LINKFLAGS += -m elf_i386_haiku ;
405			HAIKU_BOOT_CCFLAGS += -m32 -march=pentium ;
406			HAIKU_BOOT_C++FLAGS += -m32 -march=pentium ;
407	}
408
409	# warning flags
410	HAIKU_KERNEL_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes
411		-Wno-multichar ;
412	HAIKU_KERNEL_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-multichar ;
413
414	# debug flags
415	local level ;
416	for level in $(HAIKU_DEBUG_LEVELS) {
417		local flags = $(HAIKU_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ;
418		HAIKU_KERNEL_DEBUG_$(level)_CCFLAGS
419			= $(HAIKU_DEBUG_$(level)_CCFLAGS_$(architecture)) ;
420		HAIKU_KERNEL_DEBUG_$(level)_C++FLAGS
421			= $(HAIKU_DEBUG_$(level)_C++FLAGS_$(architecture)) ;
422	}
423
424	# defines
425	HAIKU_KERNEL_DEFINES += _KERNEL_MODE ;
426
427	HAIKU_DEFINES_$(architecture)
428		+= BOOT_ARCHIVE_IMAGE_OFFSET=$(HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET) ;
429		# TODO: That doesn't need to be a general define. It's just needed for
430		# compiling (part of) the boot loader.
431
432	# kernel add-on glue code
433	HAIKU_KERNEL_ADDON_BEGIN_GLUE_CODE = <$(architecture)>crtbegin.o
434		<src!system!glue!$(architecture)>haiku_version_glue.o ;
435	HAIKU_KERNEL_ADDON_END_GLUE_CODE
436		= $(HAIKU_GCC_LIBGCC_$(architecture)) <$(architecture)>crtend.o ;
437}
438
439
440rule ArchitectureSetupWarnings architecture
441{
442	# ArchitectureSetupWarnings <architecture> ;
443	#
444	# Sets up compiler warnings and error flags for various subdirectories for
445	# the given packaging architecture.
446
447	local cpu = $(HAIKU_CPU_$(architecture)) ;
448	switch $(cpu) {
449		case arm :
450			return ;
451				# we use #warning as placeholders for things to write...
452		case m68k :
453			return ;
454				# we use #warning as placeholders for things to write...
455		case mipsel :
456			return ;
457				# we use #warning as placeholders for things to write...
458	}
459
460
461	# enable -Werror for certain parts of the source tree
462	HAIKU_WERRORFLAGS = ;
463	local gccVersion = $(HAIKU_GCC_VERSION_$(architecture)) ;
464	if $(gccVersion[1]) >= 4 {
465		# -Wuninitialized gives too many false positives.
466		HAIKU_WERRORFLAGS = -Wno-error=uninitialized ;
467
468		# TODO: remove the -Wno-unused-but-set-variable option
469		HAIKU_WERRORFLAGS += -Wno-unused-but-set-variable ;
470	}
471
472	HAIKU_WERROR_ARCH = $(architecture) ;
473
474	rule EnableWerror dirTokens : scope {
475		AppendToConfigVar TARGET_WARNING_CCFLAGS_$(HAIKU_WERROR_ARCH)
476			: HAIKU_TOP $(dirTokens)
477			: -Werror $(HAIKU_WERRORFLAGS) : $(scope) ;
478		AppendToConfigVar TARGET_WARNING_C++FLAGS_$(HAIKU_WERROR_ARCH)
479			: HAIKU_TOP $(dirTokens)
480			: -Werror $(HAIKU_WERRORFLAGS) : $(scope) ;
481	}
482
483	# Work-around for GCC 2 problem -- despite -Wno-multichar it reports
484	# multichar warnings in headers/private/kernel/debugger_keymaps.h included
485	# by src/system/kernel/arch/x86/arch_debug_console.cpp.
486	if $(gccVersion[1]) = 2 {
487		local file = <src!system!kernel!arch!x86>arch_debug_console.o ;
488		TARGET_WARNING_C++FLAGS_$(architecture) on $(file)
489			= [ on $(file) return $(TARGET_WARNING_C++FLAGS_$(architecture)) ] ;
490	}
491
492	EnableWerror src add-ons accelerants 3dfx ;
493	EnableWerror src add-ons accelerants ati ;
494	EnableWerror src add-ons accelerants common ;
495	EnableWerror src add-ons accelerants et6x00 ;
496#	EnableWerror src add-ons accelerants intel_extreme ;
497#	EnableWerror src add-ons accelerants matrox ;
498	EnableWerror src add-ons accelerants neomagic ;
499#	EnableWerror src add-ons accelerants nvidia ;
500	EnableWerror src add-ons accelerants nvidia_gpgpu ;
501#	EnableWerror src add-ons accelerants radeon ;
502#	EnableWerror src add-ons accelerants radeon_hd ;
503	EnableWerror src add-ons accelerants s3 ;
504	EnableWerror src add-ons accelerants skeleton ;
505	EnableWerror src add-ons accelerants vesa ;
506	EnableWerror src add-ons accelerants via ;
507	EnableWerror src add-ons accelerants vmware ;
508	EnableWerror src add-ons bluetooth ;
509	EnableWerror src add-ons decorators ;
510	EnableWerror src add-ons disk_systems ;
511	EnableWerror src add-ons input_server devices ;
512#	EnableWerror src add-ons input_server filters ;
513#	EnableWerror src add-ons input_server methods ;
514	EnableWerror src add-ons kernel bluetooth ;
515#	EnableWerror src add-ons kernel bus_managers acpi ;
516	EnableWerror src add-ons kernel bus_managers agp_gart ;
517	EnableWerror src add-ons kernel bus_managers ata ;
518	EnableWerror src add-ons kernel bus_managers config_manager ;
519#	EnableWerror src add-ons kernel bus_managers firewire ;
520	EnableWerror src add-ons kernel bus_managers isa ;
521	EnableWerror src add-ons kernel bus_managers pci ;
522#	EnableWerror src add-ons kernel bus_managers ps2 ; # gcc2
523	EnableWerror src add-ons kernel bus_managers scsi ;
524	EnableWerror src add-ons kernel bus_managers usb ;
525	EnableWerror src add-ons kernel busses agp_gart ;
526	EnableWerror src add-ons kernel busses ata ;
527	EnableWerror src add-ons kernel busses scsi ;
528	EnableWerror src add-ons kernel busses usb ;
529	EnableWerror src add-ons kernel console ;
530	EnableWerror src add-ons kernel cpu ;
531#	EnableWerror src add-ons kernel debugger ; # gcc2
532#	EnableWerror src add-ons kernel drivers audio ;
533	EnableWerror src add-ons kernel drivers bluetooth ;
534	EnableWerror src add-ons kernel drivers bus ;
535	EnableWerror src add-ons kernel drivers common ;
536	EnableWerror src add-ons kernel drivers disk ;
537	EnableWerror src add-ons kernel drivers dvb ;
538#	EnableWerror src add-ons kernel drivers graphics ;
539#	EnableWerror src add-ons kernel drivers input ;
540	EnableWerror src add-ons kernel drivers joystick ;
541	EnableWerror src add-ons kernel drivers midi ;
542	EnableWerror src add-ons kernel drivers misc ;
543#	EnableWerror src add-ons kernel drivers network ;
544	EnableWerror src add-ons kernel drivers ports ;
545#	EnableWerror src add-ons kernel drivers power ;
546	EnableWerror src add-ons kernel drivers printer ;
547	EnableWerror src add-ons kernel drivers random ;
548	EnableWerror src add-ons kernel drivers tty ;
549	EnableWerror src add-ons kernel drivers video ;
550	EnableWerror src add-ons kernel file_systems bfs ;
551	EnableWerror src add-ons kernel file_systems cdda ;
552#	EnableWerror src add-ons kernel file_systems ext2 ;
553#	EnableWerror src add-ons kernel file_systems fat ;
554#	EnableWerror src add-ons kernel file_systems googlefs ;
555	EnableWerror src add-ons kernel file_systems iso9660 ;
556	EnableWerror src add-ons kernel file_systems layers ;
557	EnableWerror src add-ons kernel file_systems netfs ;
558	EnableWerror src add-ons kernel file_systems nfs ;
559	EnableWerror src add-ons kernel file_systems nfs4 ;
560#	EnableWerror src add-ons kernel file_systems ntfs ;
561	EnableWerror src add-ons kernel file_systems packagefs ;
562	EnableWerror src add-ons kernel file_systems ramfs ;
563#	EnableWerror src add-ons kernel file_systems reiserfs ;
564	EnableWerror src add-ons kernel file_systems udf ;
565	EnableWerror src add-ons kernel file_systems userlandfs ;
566	EnableWerror src add-ons kernel generic ;
567#	EnableWerror src add-ons kernel network datalink_protocols ;
568	EnableWerror src add-ons kernel network devices ;
569	EnableWerror src add-ons kernel network dns_resolver ;
570	EnableWerror src add-ons kernel network notifications ;
571	EnableWerror src add-ons kernel network ppp ;
572	EnableWerror src add-ons kernel network protocols ;
573#	EnableWerror src add-ons kernel network stack ;
574	EnableWerror src add-ons kernel partitioning_systems ;
575	EnableWerror src add-ons locale ;
576	EnableWerror src add-ons mail_daemon ;
577	EnableWerror src add-ons media media-add-ons demultiplexer ;
578	EnableWerror src add-ons media media-add-ons dvb ;
579	EnableWerror src add-ons media media-add-ons esound_sink ;
580	EnableWerror src add-ons media media-add-ons finepix_webcam ;
581	EnableWerror src add-ons media media-add-ons firewire_dv ;
582	EnableWerror src add-ons media media-add-ons legacy ;
583	EnableWerror src add-ons media media-add-ons mixer ;
584	EnableWerror src add-ons media media-add-ons multi_audio ;
585	EnableWerror src add-ons media media-add-ons opensound ;
586	EnableWerror src add-ons media media-add-ons radeon ;
587	EnableWerror src add-ons media media-add-ons reader ;
588	EnableWerror src add-ons media media-add-ons tone_producer_demo ;
589	EnableWerror src add-ons media media-add-ons usb_vision ;
590#	EnableWerror src add-ons media media-add-ons usb_webcam ;
591	EnableWerror src add-ons media media-add-ons video_mixer ;
592#	EnableWerror src add-ons media media-add-ons video_producer_demo ;
593	EnableWerror src add-ons media media-add-ons videowindow ;
594	EnableWerror src add-ons media media-add-ons writer ;
595	EnableWerror src add-ons media plugins ac3_decoder ;
596	EnableWerror src add-ons media plugins aiff_reader ;
597	EnableWerror src add-ons media plugins ape_reader ;
598#	EnableWerror src add-ons media plugins asf_reader ;
599	EnableWerror src add-ons media plugins au_reader ;
600#	EnableWerror src add-ons media plugins avi_reader ;
601#	EnableWerror src add-ons media plugins ffmpeg ;
602#	EnableWerror src add-ons media plugins matroska ;
603#	EnableWerror src add-ons media plugins mov_reader ;
604	EnableWerror src add-ons media plugins mp3_decoder ;
605#	EnableWerror src add-ons media plugins mp3_reader ;
606	EnableWerror src add-ons media plugins mp4_reader ;
607	EnableWerror src add-ons media plugins musepack ;
608#	EnableWerror src add-ons media plugins ogg ;
609#	EnableWerror src add-ons media plugins raw_decoder ;
610#	EnableWerror src add-ons media plugins speex ;
611	EnableWerror src add-ons media plugins theora ;
612	EnableWerror src add-ons media plugins vorbis ;
613#	EnableWerror src add-ons media plugins wav_reader ;
614	EnableWerror src add-ons media plugins xvid_decoder ;
615	EnableWerror src add-ons opengl ;
616	EnableWerror src add-ons print ;
617	EnableWerror src add-ons screen_savers ;
618	EnableWerror src add-ons tracker ;
619	EnableWerror src add-ons translators bmp ;
620#	EnableWerror src add-ons translators exr ;
621	EnableWerror src add-ons translators gif ;
622#	EnableWerror src add-ons translators hpgs ;
623	EnableWerror src add-ons translators hvif ;
624	EnableWerror src add-ons translators ico ;
625#	EnableWerror src add-ons translators jpeg ; # gcc2
626	EnableWerror src add-ons translators jpeg2000 ;
627	EnableWerror src add-ons translators pcx ;
628#	EnableWerror src add-ons translators png ; # gcc2
629	EnableWerror src add-ons translators ppm ;
630	EnableWerror src add-ons translators raw ;
631	EnableWerror src add-ons translators rtf ;
632	EnableWerror src add-ons translators sgi ;
633	EnableWerror src add-ons translators shared ;
634#	EnableWerror src add-ons translators stxt ;
635	EnableWerror src add-ons translators tga ;
636	EnableWerror src add-ons translators tiff ;
637#	EnableWerror src add-ons translators wonderbrush ;
638	EnableWerror src add-ons print ;
639	EnableWerror src bin multiuser ;
640	EnableWerror src bin package ;
641	EnableWerror src bin package_repo ;
642	EnableWerror src bin pkgman ;
643	EnableWerror src apps ;
644	EnableWerror src kits ;
645	EnableWerror src preferences ;
646	EnableWerror src servers ;
647	EnableWerror src system kernel ;
648	EnableWerror src system libroot add-ons ;
649	EnableWerror src system libroot posix locale ;
650	EnableWerror src system libroot posix wchar ;
651	EnableWerror src system runtime_loader ;
652}
653
654
655rule MultiArchIfPrimary ifValue : elseValue : architecture
656{
657	# MultiArchIfPrimary <ifValue> : <elseValue>
658	#	[ : <architecture> = $(TARGET_PACKAGING_ARCH) ] ;
659	#
660	# Returns one of the two given values depending on whether
661	# <architecture> is the primary packaging architecture.
662
663	architecture ?= $(TARGET_PACKAGING_ARCH) ;
664
665	if $(architecture) = $(TARGET_PACKAGING_ARCHS[1]) {
666		return $(ifValue) ;
667	}
668	return $(elseValue) ;
669}
670
671
672rule MultiArchConditionalGristFiles files : primaryGrist : secondaryGrist
673	: architecture
674{
675	# MultiArchConditionalGristFiles <files> : <primaryGrist>
676	#	: <secondaryGrist> [ : <architecture> = $(TARGET_PACKAGING_ARCH) ] ;
677	#
678	# Returns <files> with their grist set to either <primaryGrist> or
679	# <secondaryGrist> depending on whether <architecture> is the primary
680	# packaging architecture.
681
682	architecture ?= $(TARGET_PACKAGING_ARCH) ;
683
684	local grist = [ MultiArchIfPrimary $(primaryGrist) : $(secondaryGrist)
685		: $(architecture) ] ;
686	return $(files:G=$(grist:E=)) ;
687}
688
689
690rule MultiArchDefaultGristFiles files : gristPrefix : architecture
691{
692	# MultiArchDefaultGristFiles <files> : <gristPrefix>
693	#	[ : <architecture> = $(TARGET_PACKAGING_ARCH) ] ;
694	#
695	# Convenient shorthand for MultiArchConditionalGristFiles for the common
696	# case that for a secondary packaging architecture the packaging
697	# architecture name shall be appended to the grist while it shall be omitted
698	# for the primary packaging architecture. IOW, if architecture is the
699	# primary packaging architecture, <files> are returned with their grist set
700	# to <gristPrefix>, otherwise <files> are returned with their grist set to
701	# <gristPrefix>!<architecture> respectively <architecture> (if <gristPrefix>
702	# is empty).
703
704	architecture ?= $(TARGET_PACKAGING_ARCH) ;
705
706	local secondaryGrist = $(gristPrefix)!$(architecture) ;
707	secondaryGrist ?= $(architecture) ;
708
709	return [ MultiArchConditionalGristFiles $(files) : $(gristPrefix) :
710		$(secondaryGrist) : $(architecture) ] ;
711}
712
713
714rule MultiArchSubDirSetup architectures
715{
716	# MultiArchSubDirSetup <architectures> ;
717	#
718	# For each of the given packaging architectures <architectures> that are
719	# in the packaging architectures configured for the build (or all configured
720	# packaging architectures, if <architectures> is empty) an object is
721	# prepared that can be used for an "on ... { ... }" block to set up subdir
722	# variables for the respective packaging architecture. Most notably
723	# TARGET_PACKAGING_ARCH, TARGET_ARCH, TARGET_LIBSUPC++, and TARGET_LIBSTDC++
724	# are set to the values for the respective packaging architecture. The
725	# per-subdir variables SOURCE_GRIST, LOCATE_TARGET, LOCATE_SOURCE,
726	# SEARCH_SOURCE, *_LOCATE_TARGET, are reset. All SUBDIR* and config
727	# variables are set to the values they had when this rule was invoked.
728
729	local result ;
730	architectures ?= $(TARGET_PACKAGING_ARCHS) ;
731	local architecture ;
732	for architecture in $(architectures) {
733		if ! $(architecture) in $(TARGET_PACKAGING_ARCHS) {
734			continue ;
735		}
736
737		local architectureObject = $(architecture:G=<arch-object>) ;
738		result += $(architectureObject) ;
739
740		# Set the variables that default to the values of the respective
741		# variables for the primary architecture.
742		TARGET_PACKAGING_ARCH on $(architectureObject) = $(architecture) ;
743
744		local var ;
745		for var in TARGET_ARCH TARGET_LIBSUPC++ TARGET_LIBSTDC++ {
746			$(var) on $(architectureObject) = $($(var)_$(architecture)) ;
747		}
748
749		# Clone the current config variable values and the variables SubDir
750		# resets.
751		for var in $(AUTO_SET_UP_CONFIG_VARIABLES) SUBDIR$(SUBDIRRESET) {
752			$(var) on $(architectureObject) = $($(var)) ;
753		}
754
755		# adjust SOURCE_GRIST
756		SOURCE_GRIST on $(architectureObject)
757			= $(SOURCE_GRIST:E=)!$(architecture) ;
758
759		# Adjust the subdir's object dirs that are architecture dependent. To
760		# avoid duplicating the code from SetupObjectsDir, we call it. Since it
761		# sets global variables, we set these variables on our object, call
762		# SetupObjectsDir in an "on" block, and grab the new variable values.
763		local hostTarget = HOST TARGET ;
764		local objectDirVars =
765			COMMON_ARCH COMMON_DEBUG DEBUG_$(HAIKU_DEBUG_LEVELS)
766			;
767		objectDirVars =
768			COMMON_PLATFORM_LOCATE_TARGET
769			$(hostTarget)_$(objectDirVars)_LOCATE_TARGET
770			LOCATE_TARGET
771			LOCATE_SOURCE
772			SEARCH_SOURCE
773			;
774
775		for var in $(objectDirVars) {
776			$(var) on $(architectureObject) = ;
777		}
778
779		on $(architectureObject) {
780			SetupObjectsDir ;
781
782			for var in $(objectDirVars) {
783				$(var) on $(architectureObject) = $($(var)) ;
784			}
785		}
786	}
787
788	return $(result) ;
789}
790