xref: /haiku/build/jam/BuildSetup (revision 746cac055adc6ac3308c7bc2d29040fb95689cc9)
1
2# Variable naming conventions:
3# TARGET_*:	A build system variable specifying a property for building for
4#			the target platform (usually Haiku). E.g. TARGET_CC specifies the
5#			compiler when building a target for the target platform.
6# HOST_*:	A build system variable specifying a property of the platform
7#			hosting the build. E.g. HOST_CC specifies the compiler when
8#			building a target for the host platform (a build tool for
9#			instance).
10# HAIKU_*:	A build system variable specifying a build system property. Usually
11#			directory paths and the like.
12
13
14#pragma mark - container settings
15
16# Haiku image
17HAIKU_IMAGE_CONTAINER_NAME = haiku-image-container ;
18HAIKU_CONTAINER_GRIST on $(HAIKU_IMAGE_CONTAINER_NAME) = HaikuImage ;
19HAIKU_INCLUDE_IN_CONTAINER_VAR on $(HAIKU_IMAGE_CONTAINER_NAME)
20	= HAIKU_INCLUDE_IN_IMAGE ;
21HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_IMAGE_CONTAINER_NAME)
22	= HAIKU_IMAGE_INSTALL_TARGETS ;
23
24# network boot archive
25HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME = haiku-netboot-archive-container ;
26HAIKU_CONTAINER_GRIST on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
27	= NetBootArchive ;
28# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported
29HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
30	= HAIKU_NET_BOOT_ARCHIVE_INSTALL_TARGETS ;
31
32# boot floppy
33HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME = haiku-boot-floppy-container ;
34HAIKU_CONTAINER_GRIST on $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME) = FloppyBootImage ;
35# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported
36HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
37	= HAIKU_FLOPPY_BOOT_IMAGE_INSTALL_TARGETS ;
38
39# boot CD image
40HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME = haiku-boot-cd-container ;
41HAIKU_CONTAINER_GRIST on $(HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME) = CDBootImage ;
42# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported
43HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME)
44	= HAIKU_CD_BOOT_IMAGE_INSTALL_TARGETS ;
45
46# Haiku image/install defaults
47HAIKU_DEFAULT_IMAGE_NAME = haiku.image ;
48HAIKU_DEFAULT_IMAGE_DIR = $(HAIKU_OUTPUT_DIR) ;
49HAIKU_DEFAULT_VMWARE_IMAGE_NAME = haiku.vmdk ;
50HAIKU_DEFAULT_INSTALL_DIR = /Haiku ;
51HAIKU_DEFAULT_IMAGE_SIZE ?= 128 ; # 128 MB
52
53
54# analyze an optionally replace jam's target parameters
55HAIKU_ORIGINAL_JAM_TARGETS = $(JAM_TARGETS) ;
56HAIKU_BUILD_PROFILE = ;
57if $(JAM_TARGETS) {
58	switch $(JAM_TARGETS[1]) {
59		# If the target to be built is "all" (i.e. the default) and we're in
60		# the output directory, the root directory of the build system, or
61		# in "src/", we change the target to be built to "haiku-image".
62		case all : {
63			if ! $(INVOCATION_SUBDIR) || $(INVOCATION_SUBDIR) = src {
64				JAM_TARGETS = haiku-image ;
65			}
66		}
67
68		# The "run" target allows for running arbitrary command lines containing
69		# build system targets, which are built and replaced accordingly.
70		case run : {
71			if $(JAM_TARGETS[2]) {
72				JAM_TARGETS = [ RunCommandLine $(JAM_TARGETS[2-]) ] ;
73			} else {
74				Exit "\"jam run\" requires parameters!" ;
75			}
76		}
77
78		# A target starting with "@" is a build profile.
79		case @* : {
80			HAIKU_BUILD_PROFILE = [ Match "@(.*)" : $(JAM_TARGETS[1]) ] ;
81			HAIKU_BUILD_PROFILE_ACTION = $(JAM_TARGETS[2]:E=build) ;
82			HAIKU_BUILD_PROFILE_PARAMETERS = $(JAM_TARGETS[3-]) ;
83			HAIKU_BUILD_PROFILE_DEFINED = ;
84		}
85
86		case * : {
87			# "update-image", "update-vmware-image", and "update-install"
88			# targets allow for updating only specific targets in the
89			# image/installation dir.
90			if $(JAM_TARGETS[1]) in update-image update-vmware-image
91					update-install {
92				SetUpdateHaikuImageOnly 1 ;
93				HAIKU_INCLUDE_IN_IMAGE on $(JAM_TARGETS[2-]) = 1 ;
94
95				if $(JAM_TARGETS[1]) = update-image {
96					JAM_TARGETS = haiku-image ;
97				} else if $(JAM_TARGETS[1]) = update-vmware-image {
98					JAM_TARGETS = haiku-vmware-image ;
99				} else {
100					JAM_TARGETS = install-haiku ;
101				}
102			}
103		}
104	}
105}
106
107
108# Include BuildConfig/Timezones/libgccObjects
109{
110	local buildConfig = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : BuildConfig ] ;
111	local timezones = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : Timezones ] ;
112	local libgccObjects = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : libgccObjects ] ;
113
114	if ! $(buildConfig) {
115		ECHO "No `BuildConfig' found in $(HAIKU_BUILD_OUTPUT_DIR)!" ;
116		EXIT "Run ./configure in the source tree's root directory first!" ;
117	}
118	if ! ( $(timezones) && $(libgccObjects) ) {
119		ECHO "No `Timezones' or `libgccObjects' found in $(HAIKU_BUILD_OUTPUT_DIR)!" ;
120		EXIT "Please run ./configure in the source tree's root directory again!" ;
121	}
122
123	LOCATE on BuildConfig = $(HAIKU_BUILD_OUTPUT_DIR) ;
124	LOCATE on Timezones = $(HAIKU_BUILD_OUTPUT_DIR) ;
125	LOCATE on libgccObjects = $(HAIKU_BUILD_OUTPUT_DIR) ;
126
127	include BuildConfig ;
128	include Timezones ;
129	include libgccObjects ;
130}
131
132
133# supported debug levels
134HAIKU_DEBUG_LEVELS = 0 1 2 3 4 5 ;
135
136# BeOS, BONE, Dan0 compatible platforms
137HAIKU_BEOS_COMPATIBLE_PLATFORMS = haiku r5 bone dano haiku_host ;
138HAIKU_BONE_COMPATIBLE_PLATFORMS = haiku bone dano haiku_host ;
139HAIKU_DANO_COMPATIBLE_PLATFORMS = haiku dano haiku_host ;
140HAIKU_HAIKU_COMPATIBLE_PLATFORMS = haiku haiku_host ;
141
142# configuration header directories
143HAIKU_CONFIG_HEADERS = [ FDirName $(HAIKU_TOP) build user_config_headers ]
144	[ FDirName $(HAIKU_TOP) build config_headers ] ;
145
146
147#pragma mark -
148
149# haiku target platform settings
150
151# analyze GCC version
152HAIKU_GCC_VERSION = [ FAnalyzeGCCVersion HAIKU_GCC_RAW_VERSION ] ;
153
154# enable GCC -pipe option, if requested
155if $(HAIKU_USE_GCC_PIPE) = 1 {
156	HAIKU_GCC_BASE_FLAGS = -pipe ;
157}
158
159# disable strict aliasing on anything newer than gcc 2 as it may lead to
160# unexpected results. also disable the tree-vrp (value range propagation)
161# optimization for now as with the current gcc4 version we are using this
162# results in some broken code.
163# TODO: remove the -fno-strict-aliasing option when all code has been
164#		analyzed/fixed with regard to aliasing.
165# TODO: retest/remove the -fno-tree-vrp option as soon as we have updated our
166#		gcc4 compiler.
167if $(HAIKU_GCC_VERSION[1]) >= 3 {
168	HAIKU_GCC_BASE_FLAGS += -fno-strict-aliasing -fno-tree-vrp ;
169}
170
171# override gcc 2.95.3's header directory -- strictly necessary only when using
172# the BeOS native compiler (since its headers are incompatible), but it doesn't
173# harm for the cross-compiler either.
174if $(HAIKU_GCC_VERSION[1]) = 2 {
175	HAIKU_GCC_HEADERS_DIR = [ FDirName $(HAIKU_TOP) headers build gcc-2.95.3 ] ;
176}
177
178# initial state for flags etc.
179HAIKU_C++ ?= $(HAIKU_CC) ;
180HAIKU_LINK = $(HAIKU_CC) ;
181HAIKU_LINKFLAGS = $(HAIKU_GCC_BASE_FLAGS) ;
182
183HAIKU_HDRS = [ FStandardHeaders ] ;
184HAIKU_CCFLAGS = $(HAIKU_GCC_BASE_FLAGS) -nostdinc ;
185HAIKU_C++FLAGS = $(HAIKU_GCC_BASE_FLAGS) -nostdinc ;
186HAIKU_KERNEL_CCFLAGS = $(HAIKU_GCC_BASE_FLAGS) ;
187HAIKU_KERNEL_C++FLAGS = $(HAIKU_GCC_BASE_FLAGS) ;
188HAIKU_DEFINES = __HAIKU__ ;
189
190# distro compatibility level defines
191HAIKU_DISTRO_COMPATIBILITY ?= "default" ;
192switch $(HAIKU_DISTRO_COMPATIBILITY) {
193	case official	: HAIKU_DEFINES += HAIKU_DISTRO_COMPATIBILITY_OFFICIAL ;
194	case compatible	: HAIKU_DEFINES += HAIKU_DISTRO_COMPATIBILITY_COMPATIBLE ;
195	case "default"	: HAIKU_DEFINES += HAIKU_DISTRO_COMPATIBILITY_DEFAULT ;
196	case *			: Exit "Invalid value for HAIKU_DISTRO_COMPATIBILITY:"
197						$(HAIKU_DISTRO_COMPATIBILITY) ;
198}
199
200# analyze the gcc machine spec to determine HAIKU_CPU
201switch $(HAIKU_GCC_MACHINE) {
202	case i386-*		: HAIKU_CPU = x86 ;
203	case i486-*		: HAIKU_CPU = x86 ;
204	case i586-*		: HAIKU_CPU = x86 ;
205	case i686-*		: HAIKU_CPU = x86 ;
206	case powerpc-*	: HAIKU_CPU = ppc ;
207	case m68k-*	: HAIKU_CPU = m68k ;
208	case * : Exit "Unsupported gcc target machine:" $(HAIKU_GCC_MACHINE) ;
209}
210
211switch $(HAIKU_CPU) {
212	case ppc :
213	{
214		HAIKU_DEFINES += __POWERPC__ ;
215		HAIKU_BOOT_PLATFORM = openfirmware ;
216	}
217	case x86 :
218	{
219		HAIKU_DEFINES += __INTEL__ ;
220		HAIKU_BOOT_PLATFORM = bios_ia32 ;
221	}
222	case m68k :
223	{
224		HAIKU_DEFINES += __M68K__ ;
225		HAIKU_BOOT_PLATFORM = atari_m68k ;
226	}
227	case * :
228		Exit "Currently unsupported target CPU:" $(HAIKU_CPU) ;
229}
230HAIKU_ARCH ?= $(HAIKU_CPU) ;
231HAIKU_ARCH_MACRO_DEFINE = ARCH_$(HAIKU_ARCH) ;
232HAIKU_DEFINES += $(HAIKU_ARCH_MACRO_DEFINE) ;
233
234# directories
235HAIKU_OBJECT_BASE_DIR = [ FDirName $(HAIKU_OBJECT_DIR) haiku ] ;
236HAIKU_COMMON_ARCH_OBJECT_DIR = [ FDirName $(HAIKU_OBJECT_BASE_DIR) common ] ;
237HAIKU_ARCH_OBJECT_DIR = [ FDirName $(HAIKU_OBJECT_BASE_DIR) $(HAIKU_ARCH) ] ;
238HAIKU_COMMON_DEBUG_OBJECT_DIR = [ FDirName $(HAIKU_ARCH_OBJECT_DIR) common ] ;
239HAIKU_DEBUG_0_OBJECT_DIR = [ FDirName $(HAIKU_ARCH_OBJECT_DIR) release ] ;
240
241local level ;
242for level in $(HAIKU_DEBUG_LEVELS[2-]) {
243	HAIKU_DEBUG_$(level)_OBJECT_DIR
244		= [ FDirName $(HAIKU_ARCH_OBJECT_DIR) debug_$(level) ] ;
245}
246
247# set variables for gcc header options
248SetIncludePropertiesVariables HAIKU ;
249
250# assembler flags
251HAIKU_ASFLAGS = ;
252
253# C/C++ flags
254HAIKU_CCFLAGS += -Wno-multichar ;
255HAIKU_C++FLAGS += -Wno-multichar ;
256
257HAIKU_KERNEL_CCFLAGS += -finline -fno-builtin -Wno-multichar
258	-DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) ;
259HAIKU_KERNEL_C++FLAGS += -finline -fno-builtin -fno-exceptions -Wno-multichar
260	-DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) ;
261HAIKU_KERNEL_DEFINES += _KERNEL_MODE ;
262
263if $(HAIKU_GCC_VERSION[1]) >= 3 {
264	HAIKU_KERNEL_C++FLAGS += -fno-use-cxa-atexit ;
265}
266
267if $(HAIKU_GCC_VERSION[1]) >= 4 {
268	HAIKU_C++FLAGS += -Wno-deprecated ;
269}
270
271HAIKU_KERNEL_PIC_CCFLAGS = -fno-pic ;
272HAIKU_KERNEL_PIC_LINKFLAGS = ;
273if $(HAIKU_ARCH) = ppc {
274	# Build a position independent PPC kernel. We need to be able to relocate
275	# the kernel, since the virtual address space layout at boot time is not
276	# fixed.
277	HAIKU_KERNEL_PIC_CCFLAGS = -fPIE ;
278	HAIKU_KERNEL_PIC_LINKFLAGS = -shared -fPIE ;
279}
280if $(HAIKU_ARCH) = m68k {
281	# We don't need a PIC kernel as it's always at the same place.
282	# it's actually needed to not use pic, else linking fails due to too large pc refs.
283	HAIKU_KERNEL_PIC_CCFLAGS = -fno-pic ;
284	HAIKU_KERNEL_PIC_LINKFLAGS = ;
285	# we don't want to have to handle emulating missing FPU opcodes for 040 and 060 in the kernel
286	HAIKU_KERNEL_CCFLAGS += -m68020-60 ;
287	HAIKU_KERNEL_C++FLAGS += -m68020-60 ;
288}
289
290# If the environment variable DEBUG_PRINTF is defined we define an equally
291# named macro to the variable value. Some components use the macro to allow
292# another function than printf() to print the debug output. The variable should
293# be set to the name of the alternative function.
294#
295if $(DEBUG_PRINTF) {
296	HAIKU_CCFLAGS += [ FDefines DEBUG_PRINTF=$(DEBUG_PRINTF) ] ;
297	HAIKU_C++FLAGS += [ FDefines DEBUG_PRINTF=$(DEBUG_PRINTF) ] ;
298}
299
300# warning flags
301HAIKU_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes -Wpointer-arith -Wcast-align
302	-Wsign-compare ;
303HAIKU_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-ctor-dtor-privacy
304	-Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare ;
305
306HAIKU_KERNEL_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes
307	-Wno-multichar ;
308HAIKU_KERNEL_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-multichar ;
309
310# debug flags
311HAIKU_DEBUG_FLAGS ?= -ggdb ;
312
313# debug 0: suppress asserts
314HAIKU_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ;
315HAIKU_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ;
316
317HAIKU_KERNEL_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ;
318HAIKU_KERNEL_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ;
319
320local level ;
321for level in $(HAIKU_DEBUG_LEVELS[2-]) {
322	local flags = $(HAIKU_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ;
323	HAIKU_DEBUG_$(level)_CCFLAGS			= $(flags) ;
324	HAIKU_DEBUG_$(level)_C++FLAGS			= $(flags) ;
325	HAIKU_KERNEL_DEBUG_$(level)_CCFLAGS		= $(flags) ;
326	HAIKU_KERNEL_DEBUG_$(level)_C++FLAGS	= $(flags) ;
327}
328
329if $(HAIKU_GCC_VERSION[1]) >= 3 {
330	# TODO: Temporary work-around. Should be defined in the compiler specs
331	HAIKU_LINKFLAGS += -Xlinker --no-undefined ;
332} else {
333	HAIKU_DEFINES += _BEOS_R5_COMPATIBLE_ ;
334}
335
336# private shared kernel/libroot headers
337HAIKU_PRIVATE_SYSTEM_HEADERS =
338	[ PrivateHeaders $(DOT) system system/arch/$(HAIKU_ARCH) ]
339;
340
341# private kernel headers to be used when compiling kernel code
342HAIKU_PRIVATE_KERNEL_HEADERS =
343	[ PrivateHeaders $(DOT) kernel libroot
344		kernel/boot/platform/$(HAIKU_BOOT_PLATFORM) ]
345	[ ArchHeaders $(HAIKU_ARCH) ]
346	$(HAIKU_PRIVATE_SYSTEM_HEADERS)
347;
348
349# Add some grist to the libgcc objects
350HAIKU_GCC_LIBGCC_OBJECTS = $(HAIKU_GCC_LIBGCC_OBJECTS:G=libgcc) ;
351
352# the C++ library
353if $(HAIKU_SHARED_LIBSTDC++) {
354	HAIKU_LIBSTDC++ = $(HAIKU_SHARED_LIBSTDC++) ;
355} else if $(HAIKU_STATIC_LIBSTDC++) {
356	HAIKU_LIBSTDC++ = $(HAIKU_STATIC_LIBSTDC++) ;
357} else {
358	HAIKU_LIBSTDC++ = libstdc++.r4.so ;
359}
360
361# the C++ support library
362if $(HAIKU_SHARED_LIBSUPC++) {
363	HAIKU_LIBSUPC++ = $(HAIKU_SHARED_LIBSUPC++) ;
364} else if $(HAIKU_STATIC_LIBSUPC++) {
365	HAIKU_LIBSUPC++ = $(HAIKU_STATIC_LIBSUPC++) ;
366} else {
367	HAIKU_LIBSUPC++ = ;
368}
369
370# network libraries
371HAIKU_NETWORK_LIBS = network ;
372HAIKU_NETAPI_LIB = bnetapi ;
373HAIKU_SELECT_UNAME_ETC_LIB = ;	# libroot, against which we link anyway
374
375# library and executable glue code
376local commonGlueCode =
377	<src!system!glue>init_term_dyn.o
378	<src!system!glue!arch!$(HAIKU_ARCH)>crti.o
379	<src!system!glue!arch!$(HAIKU_ARCH)>crtn.o
380;
381HAIKU_LIBRARY_BEGIN_GLUE_CODE =
382	<src!system!glue!arch!$(HAIKU_ARCH)>crti.o
383	crtbegin.o
384	<src!system!glue>init_term_dyn.o
385;
386HAIKU_LIBRARY_END_GLUE_CODE =
387	# TODO: For the time being always link against libsupc++.a.
388	$(HAIKU_STATIC_LIBSUPC++)
389	crtend.o
390	<src!system!glue!arch!$(HAIKU_ARCH)>crtn.o
391;
392HAIKU_EXECUTABLE_BEGIN_GLUE_CODE =
393	<src!system!glue!arch!$(HAIKU_ARCH)>crti.o
394	crtbegin.o
395	<src!system!glue>start_dyn.o
396	<src!system!glue>init_term_dyn.o
397;
398HAIKU_EXECUTABLE_END_GLUE_CODE = $(HAIKU_LIBRARY_END_GLUE_CODE) ;
399HAIKU_KERNEL_ADDON_BEGIN_GLUE_CODE = crtbegin.o ;
400HAIKU_KERNEL_ADDON_END_GLUE_CODE = $(HAIKU_GCC_LIBGCC) crtend.o ;
401
402SEARCH on crtbegin.o crtend.o = $(HAIKU_GCC_LIB_DIR) ;
403
404HAIKU_EXECUTABLE_MIME_TYPE = "application/x-vnd.Be-elfexecutable" ;
405
406# TODO: The version stuff should probably go into a separate file and be made
407# available as macro, too.
408# Set our version number if not already set and mark it as a developer build
409if ! $(HAIKU_BUILD_VERSION) {
410	HAIKU_BUILD_VERSION ?= "1 0 0 a 1" ;
411	HAIKU_BUILD_DESCRIPTION ?= "Developer Build" ;
412}
413
414# If HAIKU_BUILD_VERSION is set, but HAIKU_BUILD_DESCRIPTION isn't, mark it as
415# an unknown build.
416HAIKU_BUILD_DESCRIPTION ?= "Unknown Build" ;
417
418# init library name map
419{
420	local i ;
421	for i in be game GL mail media midi midi2 network bnetapi opengl
422			screensaver root z textencoding tracker translation {
423		HAIKU_LIBRARY_NAME_MAP_$(i) = lib$(i).so ;
424	}
425	HAIKU_LIBRARY_NAME_MAP_libstdc++ = $(HAIKU_LIBSTDC++) ;
426	HAIKU_LIBRARY_NAME_MAP_input_server = <nogrist>input_server ;
427}
428
429
430#pragma mark -
431
432# host platform settings
433
434# enable GCC -m32 option, if requested
435if $(HAIKU_HOST_USE_32BIT) = 1 {
436	HOST_GCC_BASE_FLAGS = -m32 ;
437}
438
439
440# save jam's variables for the build platform
441HOST_AR				?= $(AR) ;
442HOST_CC				?= $(CC) ;
443HOST_C++			?= $(C++) ;
444HOST_LINK			?= $(LINK) ;
445HOST_LD				?= ld ;			# TODO: Fix this!
446HOST_OBJCOPY		?= objcopy ;	#
447HOST_RANLIB			?= $(RANLIB) ;
448HOST_CPPFLAGS		?= $(CPPFLAGS) ;
449HOST_CCFLAGS		?= $(HOST_GCC_BASE_FLAGS) $(CCFLAGS) ;
450HOST_C++FLAGS		?= $(HOST_GCC_BASE_FLAGS) $(C++FLAGS) ;
451HOST_LDFLAGS		?= $(HOST_GCC_BASE_FLAGS) $(LDFLAGS) ;
452HOST_LINKFLAGS		?= $(HOST_GCC_BASE_FLAGS) $(LINKFLAGS) ;
453HOST_DEFINES		?= $(DEFINES) ;
454HOST_HDRS			?= $(HDRS) ;
455
456
457# split up HOST_AR into the command name and flags
458HOST_AR				= [ Match "([^ ]*) *(.*)" : $(HOST_AR[1]) ]
459					  $(HOST_AR[2-]) ;
460HOST_ARFLAGS		= $(HOST_AR[2-]) ;
461HOST_AR				= $(HOST_AR[1]) ;
462HOST_UNARFLAGS		?= x ;
463
464# check the host platform compatibility
465SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host
466	: linux freebsd darwin sunos cygwin ;
467
468if $(HOST_PLATFORM) = linux || $(HOST_PLATFORM) = freebsd
469	|| $(HOST_PLATFORM) = darwin || $(HOST_PLATFORM) = cygwin
470	|| $(HOST_PLATFORM) = sunos {
471	# don't use lex: otherwise rc will not work correctly
472	if $(LEX) = lex {
473		LEX = flex ;
474	}
475}
476
477if $(HOST_PLATFORM) = cygwin {
478	HOST_LINKFLAGS += -Xlinker --allow-multiple-definition -Xlinker --enable-auto-import ;
479}
480
481HOST_CPU	?= $(OSPLAT:L) ;
482
483HOST_ARCH				?= $(HOST_CPU) ;
484HOST_ARCH_MACRO_DEFINE	= ARCH_$(HOST_CPU) ;
485
486# directories
487HOST_OBJECT_BASE_DIR = [ FDirName $(HAIKU_OBJECT_DIR) $(HOST_PLATFORM) ] ;
488HOST_COMMON_ARCH_OBJECT_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) common ] ;
489HOST_ARCH_OBJECT_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) $(HOST_ARCH) ] ;
490HOST_COMMON_DEBUG_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) common ] ;
491HOST_DEBUG_0_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) release ] ;
492
493local level ;
494for level in $(HAIKU_DEBUG_LEVELS[2-]) {
495	HOST_DEBUG_$(level)_OBJECT_DIR
496		= [ FDirName $(HOST_ARCH_OBJECT_DIR) debug_$(level) ] ;
497}
498
499# analyze GCC version
500HOST_GCC_VERSION = [ FAnalyzeGCCVersion HOST_GCC_RAW_VERSION ] ;
501
502# set variables for gcc header options
503SetIncludePropertiesVariables HOST ;
504
505# assembler flags
506HOST_ASFLAGS = ;
507
508# C/C++ flags
509HOST_CCFLAGS += -Wno-multichar ;
510HOST_C++FLAGS += -Wno-multichar ;
511
512if $(HOST_PLATFORM) != cygwin {
513	HOST_PIC_CCFLAGS += -fPIC ;
514	HOST_PIC_C++FLAGS += -fPIC ;
515}
516
517HOST_KERNEL_CCFLAGS += $(HOST_GCC_BASE_FLAGS) -finline -fno-builtin
518	-DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ;
519HOST_KERNEL_C++FLAGS += $(HOST_GCC_BASE_FLAGS) -finline -fno-builtin
520	-fno-exceptions -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ;
521HOST_KERNEL_DEFINES += _KERNEL_MODE ;
522
523HOST_KERNEL_PIC_CCFLAGS = -fno-pic ;
524HOST_KERNEL_PIC_LINKFLAGS = ;
525if $(HOST_ARCH) = ppc {
526	# Build a position independent PPC kernel. We need to be able to relocate
527	# the kernel, since the virtual address space layout at boot time is not
528	# fixed.
529	HOST_KERNEL_PIC_CCFLAGS = -fPIE ;
530	HOST_KERNEL_PIC_LINKFLAGS = -shared -fPIE ;
531}
532if $(HOST_ARCH) = m68k {
533	# Build a position independent M68K kernel. We need to be able to relocate
534	# the kernel, since the virtual address space layout at boot time is not
535	# fixed.
536	HOST_KERNEL_PIC_CCFLAGS = $(HAIKU_KERNEL_PIC_CCFLAGS) ;
537	HOST_KERNEL_PIC_LINKFLAGS = $(HAIKU_KERNEL_PIC_LINKFLAGS) ;
538}
539
540# warning flags
541HOST_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes -Wpointer-arith -Wcast-align
542	-Wsign-compare ;
543HOST_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-ctor-dtor-privacy
544	-Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare ;
545
546HOST_KERNEL_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes ;
547HOST_KERNEL_WARNING_C++FLAGS = -Wall -Wno-trigraphs ;
548
549# debug flags
550switch $(HOST_PLATFORM) {
551	case haiku	: HOST_DEBUG_FLAGS ?= -ggdb ;
552	case haiku_host	: HOST_DEBUG_FLAGS ?= -ggdb ;
553	case linux	: HOST_DEBUG_FLAGS ?= -ggdb ;
554	case freebsd	: HOST_DEBUG_FLAGS ?= -ggdb ;
555	case darwin	: HOST_DEBUG_FLAGS ?= -ggdb ;
556	case *		: HOST_DEBUG_FLAGS ?= -g ;
557}
558
559# debug 0: suppress asserts
560HOST_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ;
561HOST_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ;
562
563HOST_KERNEL_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ;
564HOST_KERNEL_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ;
565
566local level ;
567for level in $(HAIKU_DEBUG_LEVELS[2-]) {
568	local flags = $(HOST_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ;
569	HOST_DEBUG_$(level)_CCFLAGS			= $(flags) ;
570	HOST_DEBUG_$(level)_C++FLAGS		= $(flags) ;
571	HOST_KERNEL_DEBUG_$(level)_CCFLAGS	= $(flags) ;
572	HOST_KERNEL_DEBUG_$(level)_C++FLAGS	= $(flags) ;
573}
574
575# ld flags
576if $(HOST_ARCH) = x86 && $(HAIKU_HOST_USE_32BIT) = 1 {
577	HOST_LDFLAGS += -melf_i386 ;
578}
579
580# private kernel headers do be used when compiling kernel code
581HOST_PRIVATE_KERNEL_HEADERS = ;
582
583# private shared kernel/libroot headers
584HOST_PRIVATE_SYSTEM_HEADERS = ;
585
586# under BeOS use copyattr instead of cp
587if $(HOST_PLATFORM_BEOS_COMPATIBLE)
588{
589	CP = copyattr --data ;
590}
591
592HOST_DEFINES += $(HOST_ARCH_MACRO_DEFINE) ;
593HOST_DEFINES += _NO_INLINE_ASM ;
594
595if $(HOST_PLATFORM_BEOS_COMPATIBLE) {
596	# TODO: That's obviously not correct, but in the way the COMPILE_FOR_R5
597	# macro is used, it actually seems to mean r5/bone/dano.
598	# TODO: Deprecated. Remove!
599	HOST_DEFINES += COMPILE_FOR_R5 ;
600}
601
602# for builds of tools in the current environment
603HOST_BUILD_COMPATIBILITY_LIB_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) lib ] ;
604
605# For the generic attributes emulation: Target rm_attrs -- rm replacement that
606# also removes the attributes.
607HOST_RM_ATTRS_TARGET = ;
608
609if $(HOST_PLATFORM_BEOS_COMPATIBLE) {
610	HOST_LIBSTDC++ = stdc++.r4 ;
611	HOST_LIBROOT = root ;
612	HOST_STATIC_LIBROOT = $(HOST_LIBROOT) ;
613	HOST_LIBBE = be ;
614	HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR = ;
615	HOST_LIBRARY_NAME_MAP_input_server = /system/servers/input_server ;
616} else {
617	HOST_LIBSTDC++ = stdc++ ;
618	HOST_LIBROOT = libroot_build.so ;
619	HOST_STATIC_LIBROOT = libroot_build.a ;
620	HOST_LIBBE = libbe_build.so ;
621	if $(HOST_PLATFORM) = cygwin {
622		HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR
623			= "export PATH=$PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ;
624	} else {
625		HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR
626			= "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ;
627	}
628
629	# the C++ support library
630	if $(HOST_GCC_VERSION[1]) < 3 {
631		HOST_LIBSUPC++ = ;
632	} else {
633		HOST_LIBSUPC++ = supc++ ;
634	}
635
636	if $(HOST_PLATFORM) = darwin {
637		# part of the C++ runtime lives in libstdc++ on Darwin
638		HOST_LIBSUPC++ = gcc_s.1 stdc++ ;
639		HOST_LIBSTDC++ = ;
640	}
641
642	# Unlike glibc FreeBSD's libc doesn't have built-in regex support.
643	if $(HOST_PLATFORM) = freebsd {
644		HOST_LIBROOT += /usr/lib/libgnuregex.so ;
645		HOST_STATIC_LIBROOT += /usr/lib/libgnuregex.so ;
646	} else if $(HOST_PLATFORM) = darwin {
647		HOST_LIBROOT += /opt/local/lib/libgnuregex.dylib ;
648		HOST_STATIC_LIBROOT += /opt/local/lib/libgnuregex.dylib ;
649	}
650
651
652	# The BeOS compilers define __INTEL__ respectively __POWERPC__. On the
653	# build platform we need to make sure, this is also defined.
654	if $(HOST_CPU) = x86 {
655		HOST_DEFINES += __INTEL__ ;
656	} else if $(HOST_CPU) = ppc {
657		HOST_DEFINES += __POWERPC__ ;
658	} else if $(HOST_CPU) = m68k {
659		HOST_DEFINES += __M68K__ ;
660	}
661
662	# Supposing this is a glibc platform, let's try to get features like large
663	# file support, ISO C 99 definitions, etc. On some platforms we need to
664	# request 64 bit off_t support explicitely.
665	HOST_DEFINES += _GNU_SOURCE _FILE_OFFSET_BITS=64 ;
666
667	# On Linux with xattr support we can use it for our attribute emulation,
668	# which is somewhat more robust.
669	if $(HAIKU_HOST_USE_XATTR) = 1 {
670		HOST_DEFINES += HAIKU_HOST_USE_XATTR ;
671	} else {
672		# Otherwise the generic attribute emulation is used, which uses a
673		# directory per file to store its attribute. We need to redefine RM so
674		# that the attributes are removed as well. We use a wrapper script, which
675		# invokes a build tool. If the build tool hasn't been built yet, the
676		# normal "rm" is used and the attributes are leaked (likely there aren't
677		# any yet).
678		RM = $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) ";"
679			[ FDirName $(HAIKU_TOP) build scripts rm_attrs ]
680			[ FDirName $(HAIKU_OBJECT_DIR) $(HOST_PLATFORM) $(HOST_ARCH) release
681				tools rm_attrs ] -f ;
682			# assumes that rm_attrs is built with debugging disabled
683		HOST_RM_ATTRS_TARGET = <build>rm_attrs ;
684	}
685}
686
687# network libraries
688if $(HOST_PLATFORM_HAIKU_COMPATIBLE) {
689	HOST_NETWORK_LIBS = network ;
690	HOST_NETAPI_LIB = bnetapi ;
691	HOST_SELECT_UNAME_ETC_LIB = ;	# libroot
692} else if $(HOST_PLATFORM_BONE_COMPATIBLE) {
693	HOST_NETWORK_LIBS = socket bind ;
694	HOST_NETAPI_LIB = bnetapi ;
695	HOST_SELECT_UNAME_ETC_LIB = ;	# libroot
696} else if $(HOST_PLATFORM_BEOS_COMPATIBLE) {
697	HOST_NETWORK_LIBS = net ;
698	HOST_NETAPI_LIB = netapi ;
699	HOST_SELECT_UNAME_ETC_LIB = net ;
700} else if $(HOST_PLATFORM) = "sunos" {
701	HOST_NETWORK_LIBS = xnet ;
702	HOST_NETAPI_LIB = ;
703	HOST_SELECT_UNAME_ETC_LIB = ;
704} else {
705	# Linux,...
706	HOST_NETWORK_LIBS = ;
707	HOST_NETAPI_LIB = ;
708	HOST_SELECT_UNAME_ETC_LIB = ;
709}
710
711# define the executable MIME type
712HOST_EXECUTABLE_MIME_TYPE = "application/x-vnd.Be-elfexecutable" ;
713
714if $(METROWERKS) {
715	# at least parts of Haiku still can be compiled with
716	# the Metrowerks compiler on BeOS/PPC
717	HOST_EXECUTABLE_MIME_TYPE = "application/x-be-executable" ;
718}
719
720# Be API compatibility
721HOST_BE_API_HEADERS = ;
722HOST_BE_API_CCFLAGS = ;
723HOST_BE_API_C++FLAGS = ;
724
725if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) {
726	HOST_BE_API_HEADERS =
727		[ FDirName $(HAIKU_TOP) headers build ]
728		[ FDirName $(HAIKU_TOP) headers build os ]
729		[ FDirName $(HAIKU_TOP) headers build os app ]
730		[ FDirName $(HAIKU_TOP) headers build os drivers ]
731		[ FDirName $(HAIKU_TOP) headers build os kernel ]
732		[ FDirName $(HAIKU_TOP) headers build os interface ]
733		[ FDirName $(HAIKU_TOP) headers build os storage ]
734		[ FDirName $(HAIKU_TOP) headers build os support ]
735	;
736	HOST_BE_API_CCFLAGS = -include BeOSBuildCompatibility.h ;
737	HOST_BE_API_C++FLAGS = $(HOST_BE_API_CCFLAGS) ;
738}
739
740# Add directory with system headers we need when building something for the host
741# platform, e.g. containing missing POSIX/GNU headers.
742HOST_HDRS += [ FDirName $(HAIKU_TOP) headers build host $(HOST_PLATFORM) ] ;
743
744# For all versions of BeOS also add the common beos directory.
745if $(HOST_PLATFORM) in r5 bone dano {
746	HOST_HDRS += [ FDirName $(HAIKU_TOP) headers build host beos_common ] ;
747}
748
749
750#pragma mark -
751
752# target platform settings
753
754# check the target platform compatibility
755SetPlatformCompatibilityFlagVariables TARGET_PLATFORM : TARGET : target ;
756
757# check the compatibility between host and target platform
758if $(TARGET_PLATFORM) != haiku {
759	if ! $(HOST_PLATFORM_($(TARGET_PLATFORM))_COMPATIBLE) {
760		Exit ERROR: The host platform is not compatible with target platform
761			$(TARGET_PLATFORM). ;
762	}
763}
764
765# Set TARGET_* variables either from HAIKU_* or HOST_* depending on the
766# specified TARGET_PLATFORM.
767
768local buildVars =
769	ARCH CPU GCC_VERSION
770
771	AR CC C++ LD OBJCOPY RANLIB
772
773	INCLUDES_SEPARATOR LOCAL_INCLUDES_OPTION SYSTEM_INCLUDES_OPTION
774
775	HDRS CPPFLAGS CCFLAGS C++FLAGS LDFLAGS LINK LINKFLAGS DEFINES
776	ARFLAGS UNARFLAGS
777	KERNEL_DEFINES
778
779	KERNEL_CCFLAGS KERNEL_C++FLAGS
780	KERNEL_PIC_CCFLAGS KERNEL_PIC_LINKFLAGS
781	WARNING_CCFLAGS WARNING_C++FLAGS
782
783	KERNEL_WARNING_CCFLAGS KERNEL_WARNING_C++FLAGS
784
785	DEBUG_FLAGS
786
787	DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS
788
789	KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS
790	KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS
791
792	PRIVATE_KERNEL_HEADERS
793	PRIVATE_SYSTEM_HEADERS
794
795	LIBSTDC++ LIBSUPC++
796
797	NETWORK_LIBS NETAPI_LIB SELECT_UNAME_ETC_LIB
798
799	ARCH_MACRO_DEFINE EXECUTABLE_MIME_TYPE
800
801	OBJECT_BASE_DIR COMMON_ARCH_OBJECT_DIR COMMON_DEBUG_OBJECT_DIR
802	DEBUG_$(HAIKU_DEBUG_LEVELS)_OBJECT_DIR
803;
804
805if $(TARGET_PLATFORM) = haiku {
806	local var ;
807	for var in $(buildVars) {
808		TARGET_$(var) = $(HAIKU_$(var)) ;
809	}
810
811	TARGET_GCC_LIB_DIR			= $(HAIKU_GCC_LIB_DIR) ;
812	TARGET_GCC_HEADERS_DIR		= $(HAIKU_GCC_HEADERS_DIR) ;
813	TARGET_GCC_LIBGCC			= $(HAIKU_GCC_LIBGCC) ;
814	TARGET_GCC_LIBGCC_OBJECTS	= $(HAIKU_GCC_LIBGCC_OBJECTS) ;
815
816	TARGET_BOOT_PLATFORM		?= $(HAIKU_BOOT_PLATFORM) ;
817
818	TARGET_LIBRARY_NAME_MAP		= HAIKU_LIBRARY_NAME_MAP ;
819
820} else {
821	local var ;
822	for var in $(buildVars) {
823		TARGET_$(var) = $(HOST_$(var)) ;
824	}
825
826	TARGET_GCC_LIB_DIR			= ;
827	TARGET_GCC_HEADERS_DIR		= ;
828	TARGET_GCC_LIBGCC			= ;
829	TARGET_GCC_LIBGCC_OBJECTS	= ;
830
831	TARGET_BOOT_PLATFORM		= ;
832
833	TARGET_LIBRARY_NAME_MAP		= HOST_LIBRARY_NAME_MAP ;
834}
835
836# define macro, for identifying the platform
837switch $(TARGET_PLATFORM) {
838	case r5			: TARGET_DEFINES	+= HAIKU_TARGET_PLATFORM_BEOS ;
839	case bone		: TARGET_DEFINES	+= HAIKU_TARGET_PLATFORM_BONE ;
840	case dano		: TARGET_DEFINES	+= HAIKU_TARGET_PLATFORM_DANO ;
841	case haiku_host	: TARGET_DEFINES	+= HAIKU_TARGET_PLATFORM_HAIKU ;
842	case haiku		: TARGET_DEFINES	+= HAIKU_TARGET_PLATFORM_HAIKU ;
843	case linux		: TARGET_DEFINES	+= HAIKU_TARGET_PLATFORM_LINUX ;
844	case freebsd	: TARGET_DEFINES	+= HAIKU_TARGET_PLATFORM_FREEBSD ;
845	case darwin		: TARGET_DEFINES	+= HAIKU_TARGET_PLATFORM_DARWIN ;
846	case cygwin		: TARGET_DEFINES += HAIKU_TARGET_PLATFORM_CYGWIN ;
847	case sunos		: TARGET_DEFINES += HAIKU_TARGET_PLATFORM_SUNOS ;
848	case libbe_test	: TARGET_DEFINES	+= HAIKU_TARGET_PLATFORM_LIBBE_TEST ;
849}
850
851# define macro, for identifying the host platform
852switch $(HOST_PLATFORM) {
853	case r5			: HOST_DEFINES	+= HAIKU_HOST_PLATFORM_BEOS ;
854	case bone		: HOST_DEFINES	+= HAIKU_HOST_PLATFORM_BONE ;
855	case dano		: HOST_DEFINES	+= HAIKU_HOST_PLATFORM_DANO ;
856	case haiku_host	: HOST_DEFINES	+= HAIKU_HOST_PLATFORM_HAIKU ;
857	case linux		: HOST_DEFINES	+= HAIKU_HOST_PLATFORM_LINUX ;
858	case freebsd	: HOST_DEFINES	+= HAIKU_HOST_PLATFORM_FREEBSD ;
859	case darwin		: HOST_DEFINES	+= HAIKU_HOST_PLATFORM_DARWIN ;
860	case cygwin		: HOST_DEFINES += HAIKU_HOST_PLATFORM_CYGWIN ;
861	case sunos		: HOST_DEFINES += HAIKU_HOST_PLATFORM_SUNOS ;
862}
863
864
865#pragma mark -
866
867# In case we build for a BeOS compatible platform, but not for Haiku, we
868# include the HaikuBuildCompatibility.h header and link against
869# libhaikucompat.a.
870
871if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) && $(TARGET_PLATFORM_BEOS_COMPATIBLE) {
872	# headers and flags
873	local compatibilityHeader = -include [ FDirName $(HAIKU_TOP) headers build
874		HaikuBuildCompatibility.h ] ;
875	TARGET_CCFLAGS += $(compatibilityHeader) ;
876	TARGET_C++FLAGS += $(compatibilityHeader) ;
877
878	# compatibility library
879	TARGET_HAIKU_COMPATIBILITY_LIBS = libhaikucompat.a ;
880}
881
882# special target libbe_test
883
884if $(TARGET_PLATFORM) = libbe_test {
885	# headers and flags
886	TARGET_HDRS +=
887		[ PublicHeaders $(DOT) app drivers game interface kernel storage
888			support ]
889		[ PrivateHeaders $(DOT) ] ;
890	TARGET_DEFINES += __HAIKU__ ;
891
892	TARGET_PRIVATE_SYSTEM_HEADERS =
893		[ PrivateHeaders $(DOT) system system/arch/$(TARGET_ARCH) ] ;
894
895	# directories
896	TARGET_OBJECT_BASE_DIR
897		= [ FDirName $(HAIKU_OBJECT_DIR) $(TARGET_PLATFORM) ] ;
898	TARGET_COMMON_ARCH_OBJECT_DIR
899		= [ FDirName $(TARGET_OBJECT_BASE_DIR) common ] ;
900	TARGET_ARCH_OBJECT_DIR
901		= [ FDirName $(TARGET_OBJECT_BASE_DIR) $(TARGET_ARCH) ] ;
902	TARGET_COMMON_DEBUG_OBJECT_DIR
903		= [ FDirName $(TARGET_ARCH_OBJECT_DIR) common ] ;
904	TARGET_DEBUG_0_OBJECT_DIR
905		= [ FDirName $(TARGET_ARCH_OBJECT_DIR) release ] ;
906
907	local level ;
908	for level in $(HAIKU_DEBUG_LEVELS[2-]) {
909		TARGET_DEBUG_$(level)_OBJECT_DIR
910			= [ FDirName $(TARGET_ARCH_OBJECT_DIR) debug_$(level) ] ;
911	}
912
913	# library name map
914	TARGET_LIBRARY_NAME_MAP = LIBBE_LIBRARY_NAME_MAP ;
915	LIBBE_LIBRARY_NAME_MAP_be = libbe_haiku.so ;
916}
917
918
919#pragma mark -
920
921# common stuff
922
923# start with a clean state
924CCFLAGS = ;
925C++FLAGS = ;
926DEFINES = ;
927
928# Set CC, C++, LINK to invalid values, so that we realize early, that we use
929# the wrong compiler.
930CC = bad-cc ;
931C++ = bad-c++ ;
932LINK = bad-link ;
933
934# Allow compiling unit tests on Zeta. Instead of fixing the PostMessage()
935# issues, they deprecated that nice function. This will enable it again:
936C++FLAGS += -D_ZETA_USING_DEPRECATED_API_=1 ;
937# Same for buggy find_directory threadsafety fixes
938C++FLAGS += -D_ZETA_TS_FIND_DIR_=1 ;
939	# TODO: Doesn't really belong here.
940
941
942# Defaults for warnings, optimization, and debugging.
943#
944WARNINGS ?= 1 ;
945OPTIM ?= -O2 ;
946DEBUG ?= 0 ;
947
948
949# Set the defaults for PLATFORM and SUPPORTED_PLATFORMS. PLATFORM is only
950# overridden for targets to be built for the host platform. SUPPORTED_PLATFORMS
951# can be overridden by the author of a component.
952PLATFORM = $(TARGET_PLATFORM) ;
953SUPPORTED_PLATFORMS = haiku ;
954
955
956# Instructs the Library rule to not make its object files temporary.
957# This is needed as some objects are used in a static library and for an
958# executable.
959KEEPOBJS = true ;
960
961
962# Set permissions to how they should be on the image.
963EXEMODE		= 755 ;
964FILEMODE	= 644 ;
965SHELLMODE	= 755 ;
966
967
968# output directories
969# TODO: Review this.
970HAIKU_DOCUMENTATION_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) documentation ] ;
971HAIKU_DOCUMENTATION_OBJECT_DIR ?= [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR)
972	documentation ] ;
973
974# TODO: Rethink test stuff.
975HAIKU_TEST_DIR			?= [ FDirName $(HAIKU_OUTPUT_DIR) tests $(TARGET_PLATFORM) $(HAIKU_ARCH) ] ;
976HAIKU_APP_TEST_DIR		?= [ FDirName $(HAIKU_TEST_DIR) apps ] ;
977HAIKU_APP_TEST_LIB_DIR 	?= [ FDirName $(HAIKU_APP_TEST_DIR) lib ] ;
978HAIKU_TMP_DIR			?= [ FDirName $(HAIKU_OUTPUT_DIR) tmp ] ;
979
980HAIKU_PACKAGE_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) packages ] ;
981HAIKU_PACKAGE_OBJECT_DIR ?= [ FDirName $(HAIKU_OBJECT_DIR) packages ] ;
982
983TARGET_TEST_DIR				?= [ FDirName $(HAIKU_TEST_DIR)
984									$(TARGET_PLATFORM) ] ;
985TARGET_UNIT_TEST_DIR		?= [ FDirName $(TARGET_TEST_DIR) unittests ] ;
986TARGET_UNIT_TEST_LIB_DIR	?= [ FDirName $(TARGET_UNIT_TEST_DIR) lib ] ;
987
988# automatically setup the objects directory per subdirectory
989SUBDIRRULES += SetupObjectsDir ;
990
991# Add the standard (userland) warning flags variables to the ones restored in
992# every subdirectory. Thus we can easily meddle with them in subdirectories
993# with imported sources.
994AUTO_SET_UP_CONFIG_VARIABLES +=
995	HOST_WARNING_CCFLAGS HOST_WARNING_C++FLAGS
996	TARGET_WARNING_CCFLAGS TARGET_WARNING_C++FLAGS
997
998	# also add PLATFORM and SUPPORTED_PLATFORMS
999	PLATFORM SUPPORTED_PLATFORMS
1000;
1001