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