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