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