1 # Variable naming conventions:
2 # TARGET_*: A build system variable specifying a property for building for
3 # the target platform (usually Haiku). E.g. TARGET_CC specifies the
4 # compiler when building a target for the target platform.
5 # HOST_*: A build system variable specifying a property of the platform
6 # hosting the build. E.g. HOST_CC specifies the compiler when
7 # building a target for the host platform (a build tool for
9 # HAIKU_*: A build system variable specifying a build system property. Usually
10 # directory paths and the like.
13 # The Haiku (base) version. For development builds the revision will be
15 HAIKU_VERSION = r1~alpha4_pm ;
18 #pragma mark - container settings
21 HAIKU_IMAGE_CONTAINER_NAME = haiku-image-container ;
22 HAIKU_CONTAINER_GRIST on $(HAIKU_IMAGE_CONTAINER_NAME) = HaikuImage ;
23 HAIKU_INCLUDE_IN_CONTAINER_VAR on $(HAIKU_IMAGE_CONTAINER_NAME)
24 = HAIKU_INCLUDE_IN_IMAGE ;
25 HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_IMAGE_CONTAINER_NAME)
26 = HAIKU_IMAGE_INSTALL_TARGETS ;
27 HAIKU_CONTAINER_SYSTEM_DIR_TOKENS on $(HAIKU_IMAGE_CONTAINER_NAME)
28 = system non-packaged ;
30 # network boot archive
31 HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME = haiku-netboot-archive-container ;
32 HAIKU_CONTAINER_GRIST on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
34 # HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported
35 HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
36 = HAIKU_NET_BOOT_ARCHIVE_INSTALL_TARGETS ;
37 HAIKU_CONTAINER_SYSTEM_DIR_TOKENS on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
41 HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME = haiku-boot-floppy-container ;
42 HAIKU_CONTAINER_GRIST on $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
44 # HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported
45 HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
46 = HAIKU_FLOPPY_BOOT_IMAGE_INSTALL_TARGETS ;
47 HAIKU_CONTAINER_SYSTEM_DIR_TOKENS on $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
51 HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME = haiku-boot-cd-container ;
52 HAIKU_CONTAINER_GRIST on $(HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME) = CDBootImage ;
53 # HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported
54 HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME)
55 = HAIKU_CD_BOOT_IMAGE_INSTALL_TARGETS ;
56 HAIKU_CONTAINER_SYSTEM_DIR_TOKENS on $(HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME)
59 # boot CD for PPC image
60 HAIKU_CD_BOOT_PPC_IMAGE_CONTAINER_NAME = haiku-boot-cd-ppc-container ;
61 HAIKU_CONTAINER_GRIST on $(HAIKU_CD_BOOT_PPC_IMAGE_CONTAINER_NAME)
63 # HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported
64 HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_CD_BOOT_PPC_IMAGE_CONTAINER_NAME)
65 = HAIKU_CD_BOOT_PPC_IMAGE_INSTALL_TARGETS ;
66 HAIKU_CONTAINER_SYSTEM_DIR_TOKENS on $(HAIKU_CD_BOOT_PPC_IMAGE_CONTAINER_NAME)
69 # Haiku image/install defaults
70 HAIKU_DEFAULT_IMAGE_NAME = haiku.image ;
71 HAIKU_DEFAULT_IMAGE_DIR = $(HAIKU_OUTPUT_DIR) ;
72 HAIKU_DEFAULT_VMWARE_IMAGE_NAME = haiku.vmdk ;
73 HAIKU_DEFAULT_INSTALL_DIR = /Haiku ;
74 HAIKU_DEFAULT_IMAGE_SIZE ?= 300 ; # 300 MB
75 HAIKU_DEFAULT_IMAGE_LABEL ?= Haiku ;
78 HAIKU_DEFAULT_CD_NAME = haiku-cd.iso ;
79 HAIKU_DEFAULT_CD_DIR = $(HAIKU_OUTPUT_DIR) ;
80 HAIKU_DEFAULT_CD_LABEL = Haiku ;
82 # Haiku Anyboot defaults
83 HAIKU_DEFAULT_ANYBOOT_NAME = haiku-anyboot.iso ;
84 HAIKU_DEFAULT_ANYBOOT_DIR = $(HAIKU_OUTPUT_DIR) ;
85 HAIKU_DEFAULT_ANYBOOT_LABEL ?= Haiku ;
88 HAIKU_DEFAULT_MMC_IMAGE_NAME = haiku-mmc.image ;
89 HAIKU_DEFAULT_MMC_DIR = $(HAIKU_OUTPUT_DIR) ;
90 HAIKU_DEFAULT_MMC_LABEL ?= Haiku ;
92 # analyze and optionally replace jam's target parameters
93 ProcessCommandLineArguments ;
96 # supported debug levels
97 HAIKU_DEBUG_LEVELS = 0 1 2 3 4 5 ;
99 # BeOS, BONE, Dan0 compatible platforms
100 HAIKU_BEOS_COMPATIBLE_PLATFORMS = haiku r5 bone dano haiku_host ;
101 HAIKU_BONE_COMPATIBLE_PLATFORMS = haiku bone dano haiku_host ;
102 HAIKU_DANO_COMPATIBLE_PLATFORMS = haiku dano haiku_host ;
103 HAIKU_HAIKU_COMPATIBLE_PLATFORMS = haiku haiku_host ;
105 # configuration header directories
106 HAIKU_CONFIG_HEADERS = [ FDirName $(HAIKU_TOP) build user_config_headers ]
107 [ FDirName $(HAIKU_TOP) build config_headers ] ;
110 # object directories common to all architectures
111 HAIKU_OBJECT_BASE_DIR = [ FDirName $(HAIKU_OBJECT_DIR) haiku ] ;
112 HAIKU_COMMON_ARCH_OBJECT_DIR = [ FDirName $(HAIKU_OBJECT_BASE_DIR) common ] ;
115 #pragma mark - haiku target platform settings
119 for architecture in $(HAIKU_PACKAGING_ARCHS) {
120 ArchitectureSetup $(architecture) ;
123 # TODO: Might not be needed anymore.
124 if $(HAIKU_HOST_BUILD_ONLY) = 1 {
125 HAIKU_GCC_VERSION = 0 0 0 ;
128 if $(HAIKU_PACKAGING_ARCH) {
129 KernelArchitectureSetup $(HAIKU_PACKAGING_ARCH) ;
132 # define primary packaging architecture macro
133 HAIKU_DEFINES = __HAIKU_PRIMARY_PACKAGING_ARCH=\\\"$(HAIKU_PACKAGING_ARCH)\\\" ;
136 # distro compatibility level defines
137 HAIKU_DISTRO_COMPATIBILITY ?= "default" ;
138 switch $(HAIKU_DISTRO_COMPATIBILITY) {
140 HAIKU_DEFINES += HAIKU_DISTRO_COMPATIBILITY_OFFICIAL ;
141 HAIKU_INCLUDE_TRADEMARKS = "" ;
143 HAIKU_DEFINES += HAIKU_DISTRO_COMPATIBILITY_COMPATIBLE ;
144 HAIKU_INCLUDE_TRADEMARKS = "" ;
146 HAIKU_DEFINES += HAIKU_DISTRO_COMPATIBILITY_DEFAULT ;
147 HAIKU_INCLUDE_TRADEMARKS = ;
149 Exit "Invalid value for HAIKU_DISTRO_COMPATIBILITY:"
150 $(HAIKU_DISTRO_COMPATIBILITY) ;
153 # If the environment variable HAIKU_INCLUDE_PATENTED_CODE is defined, we define
154 # an equally named macro to the variable value. Some components use the macro
155 # to allow compilation of code known to implemented patented ideas and/or
156 # techniques, for example the Freetype bytecode hinter or sub-pixel rendering as
157 # well as some problematic media codecs.
158 if $(HAIKU_INCLUDE_PATENTED_CODE) {
160 += HAIKU_INCLUDE_PATENTED_CODE=$(HAIKU_INCLUDE_PATENTED_CODE) ;
164 HAIKU_NETWORK_LIBS = network ;
165 HAIKU_NETAPI_LIB = bnetapi ;
166 HAIKU_SELECT_UNAME_ETC_LIB = ; # libroot, against which we link anyway
168 HAIKU_EXECUTABLE_MIME_TYPE = "application/x-vnd.Be-elfexecutable" ;
170 # TODO: The version stuff should probably go into a separate file and be made
171 # available as macro, too.
172 # Set our version number if not already set and mark it as a developer build
173 if ! $(HAIKU_BUILD_VERSION) {
174 HAIKU_BUILD_VERSION ?= "1 0 0 a 1" ;
175 HAIKU_BUILD_DESCRIPTION ?= "Developer Build" ;
178 # If HAIKU_BUILD_VERSION is set, but HAIKU_BUILD_DESCRIPTION isn't, mark it as
180 HAIKU_BUILD_DESCRIPTION ?= "Unknown Build" ;
183 #pragma mark - host platform settings
186 # determine the endianness of the host
187 switch $(HOST_GCC_MACHINE) {
188 case amd64-* : HAIKU_HOST_IS_BIG_ENDIAN = 0 ;
189 case i?86-* : HAIKU_HOST_IS_BIG_ENDIAN = 0 ;
190 case powerpc-* : HAIKU_HOST_IS_BIG_ENDIAN = 1 ;
191 case x86_64-* : HAIKU_HOST_IS_BIG_ENDIAN = 0 ;
193 # the following are rather unlikely as hosts ...
194 case arm-* : HAIKU_HOST_IS_BIG_ENDIAN = 0 ;
195 case armv7l-* : HAIKU_HOST_IS_BIG_ENDIAN = 0 ;
196 case armv7hl-* : HAIKU_HOST_IS_BIG_ENDIAN = 0 ;
197 case armv7b-* : HAIKU_HOST_IS_BIG_ENDIAN = 1 ;
198 case aarch64-* : HAIKU_HOST_IS_BIG_ENDIAN = 0 ;
199 case m68k-* : HAIKU_HOST_IS_BIG_ENDIAN = 1 ;
200 case * : Exit "Unsupported gcc host machine:" $(HOST_GCC_MACHINE) ;
203 # analyze the host gcc machine spec to find out about 64-bitness
204 HOST_PLATFORM_IS_64_BIT = ;
205 switch $(HOST_GCC_MACHINE) {
206 case amd64-* : HOST_PLATFORM_IS_64_BIT = 1 ;
207 case i686-apple-darwin10 : HOST_PLATFORM_IS_64_BIT = 1 ;
208 case i686-apple-darwin11 : HOST_PLATFORM_IS_64_BIT = 1 ;
209 case x86_64-* : HOST_PLATFORM_IS_64_BIT = 1 ;
210 case aarch64-* : HOST_PLATFORM_IS_64_BIT = 1 ;
213 # If HAIKU_HOST_USE_32BIT is set, add the required gcc base flag (the LD flag
214 # is set later), or, if the architecture isn't actually 64 bit, clear
215 # HAIKU_HOST_USE_32BIT.
216 # Afterwards HOST_PLATFORM_IS_64_BIT will indicate whether the architecture is
217 # effectively (i.e. when using the compiler/linker flags) 64 bit and
218 # HAIKU_HOST_USE_32BIT will be set, iff the architecture is really 64 bit and
219 # 32 bit mode was requested.
220 if $(HAIKU_HOST_USE_32BIT) = 1 {
221 if $(HOST_PLATFORM_IS_64_BIT) {
222 # enable GCC -m32 option
223 HOST_GCC_BASE_FLAGS = -m32 ;
224 HOST_PLATFORM_IS_64_BIT = ;
226 HAIKU_HOST_USE_32BIT = 0 ;
231 # save jam's variables for the build platform
235 HOST_LINK ?= $(LINK) ;
236 HOST_RANLIB ?= $(RANLIB) ;
237 HOST_CPPFLAGS ?= $(CPPFLAGS) ;
238 HOST_CCFLAGS ?= $(HOST_GCC_BASE_FLAGS) $(CCFLAGS) ;
239 HOST_C++FLAGS ?= $(HOST_GCC_BASE_FLAGS) $(C++FLAGS) ;
240 HOST_LDFLAGS ?= $(LDFLAGS) ;
241 HOST_LINKFLAGS ?= $(HOST_GCC_BASE_FLAGS) $(LINKFLAGS) ;
242 HOST_DEFINES ?= $(DEFINES) ;
243 HOST_HDRS ?= $(HDRS) ;
246 # split up HOST_AR into the command name and flags
247 HOST_AR = [ Match "([^ ]*) *(.*)" : $(HOST_AR[1]) ]
249 HOST_ARFLAGS = $(HOST_AR[2-]) ;
250 HOST_AR = $(HOST_AR[1]) ;
251 HOST_UNARFLAGS ?= x ;
253 # check the host platform compatibility
254 SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host
255 : linux openbsd freebsd darwin sunos cygwin ;
256 HOST_PLATFORM_(host)_COMPATIBLE = 1 ;
258 if $(HOST_PLATFORM) = linux || $(HOST_PLATFORM) = freebsd
259 || $(HOST_PLATFORM) = darwin || $(HOST_PLATFORM) = cygwin
260 || $(HOST_PLATFORM) = sunos || $(HOST_PLATFORM) = openbsd {
261 # don't use lex: otherwise rc will not work correctly
267 if $(HOST_PLATFORM) = cygwin {
268 HOST_LINKFLAGS += -Xlinker --allow-multiple-definition -Xlinker
269 --enable-auto-import ;
272 HOST_CPU ?= $(OSPLAT:L) ;
274 # Jam doesn't know x86_64, so override HOST_CPU, if 64 bit.
275 if $(HOST_CPU) = x86 && $(HOST_PLATFORM_IS_64_BIT) {
279 HOST_ARCH ?= $(HOST_CPU) ;
280 HOST_ARCHS = $(HOST_ARCH) ;
281 HOST_KERNEL_ARCH = host ;
283 # analyze GCC version
284 HOST_GCC_VERSION = [ FAnalyzeGCCVersion HOST_GCC_RAW_VERSION ] ;
286 # set packaging architecture
287 HOST_PACKAGING_ARCH ?= $(HOST_CPU) ;
288 if $(HOST_PACKAGING_ARCH) = x86 && $(HOST_GCC_VERSION[1]) = 2 {
289 HOST_PACKAGING_ARCH = x86_gcc2 ;
291 HOST_PACKAGING_ARCHS = $(HOST_PACKAGING_ARCH) ;
294 HOST_OBJECT_BASE_DIR = [ FDirName $(HAIKU_OBJECT_DIR) $(HOST_PLATFORM) ] ;
295 HOST_COMMON_ARCH_OBJECT_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) common ] ;
297 = [ FDirName $(HOST_OBJECT_BASE_DIR) $(HOST_PACKAGING_ARCH) ] ;
298 HOST_COMMON_DEBUG_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) common ] ;
299 HOST_DEBUG_0_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) release ] ;
302 for level in $(HAIKU_DEBUG_LEVELS[2-]) {
303 HOST_DEBUG_$(level)_OBJECT_DIR
304 = [ FDirName $(HOST_ARCH_OBJECT_DIR) debug_$(level) ] ;
307 # set variables for gcc header options
308 SetIncludePropertiesVariables HOST ;
314 HOST_CCFLAGS += -Wno-multichar ;
315 HOST_C++FLAGS += -Wno-multichar ;
317 if $(HOST_PLATFORM) != cygwin {
318 HOST_PIC_CCFLAGS += -fPIC ;
319 HOST_PIC_C++FLAGS += -fPIC ;
322 if $(HOST_GCC_VERSION[1]) >= 3 {
323 HOST_GCC_BASE_FLAGS += -fno-strict-aliasing -fno-tree-vrp ;
326 HOST_KERNEL_CCFLAGS += $(HOST_GCC_BASE_FLAGS) -finline -fno-builtin
328 HOST_KERNEL_C++FLAGS += $(HOST_GCC_BASE_FLAGS) -finline -fno-builtin
329 -fno-exceptions -D_KERNEL_MODE ;
330 HOST_KERNEL_DEFINES += _KERNEL_MODE ;
332 HOST_KERNEL_PIC_CCFLAGS = -fno-pic ;
333 HOST_KERNEL_PIC_LINKFLAGS = ;
334 if $(HOST_ARCH) = ppc {
335 # Build a position independent PPC kernel. We need to be able to relocate
336 # the kernel, since the virtual address space layout at boot time is not
338 HOST_KERNEL_PIC_CCFLAGS = -fPIE ;
339 HOST_KERNEL_PIC_LINKFLAGS = -shared -fPIE ;
341 if $(HOST_ARCH) = m68k {
342 # Build a position independent M68K kernel. We need to be able to relocate
343 # the kernel, since the virtual address space layout at boot time is not
345 HOST_KERNEL_PIC_CCFLAGS = $(HAIKU_KERNEL_PIC_CCFLAGS) ;
346 HOST_KERNEL_PIC_LINKFLAGS = $(HAIKU_KERNEL_PIC_LINKFLAGS) ;
349 if $(HOST_PLATFORM) != darwin {
350 # fix for new changes to DSO linking policies
351 HOST_LINKFLAGS += -Xlinker --no-as-needed ;
356 HOST_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes -Wpointer-arith
357 -Wcast-align -Wsign-compare ;
358 HOST_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-ctor-dtor-privacy
359 -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare ;
361 HOST_KERNEL_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes ;
362 HOST_KERNEL_WARNING_C++FLAGS = -Wall -Wno-trigraphs ;
364 HOST_WERROR_FLAGS = ;
367 local hostDebugFlags ;
368 switch $(HOST_PLATFORM) {
369 case haiku : hostDebugFlags ?= -ggdb ;
370 case haiku_host : hostDebugFlags ?= -ggdb ;
371 case linux : hostDebugFlags ?= -ggdb ;
372 case freebsd : hostDebugFlags ?= -ggdb ;
373 case darwin : hostDebugFlags ?= -ggdb ;
374 case * : hostDebugFlags ?= -g ;
377 # debug 0: suppress asserts
378 HOST_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ;
379 HOST_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ;
381 HOST_KERNEL_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ;
382 HOST_KERNEL_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ;
385 for level in $(HAIKU_DEBUG_LEVELS[2-]) {
386 local flags = $(hostDebugFlags) [ FDefines DEBUG=$(level) ] ;
387 HOST_DEBUG_$(level)_CCFLAGS = $(flags) ;
388 HOST_DEBUG_$(level)_C++FLAGS = $(flags) ;
389 HOST_KERNEL_DEBUG_$(level)_CCFLAGS = $(flags) ;
390 HOST_KERNEL_DEBUG_$(level)_C++FLAGS = $(flags) ;
394 if $(HAIKU_HOST_USE_32BIT) = 1 {
395 HOST_LDFLAGS += -melf_i386 ;
398 # private kernel headers do be used when compiling kernel code
399 HOST_PRIVATE_KERNEL_HEADERS = ;
401 # private shared kernel/libroot headers
402 HOST_PRIVATE_SYSTEM_HEADERS = ;
404 # under BeOS use copyattr instead of cp
405 if $(HOST_PLATFORM_BEOS_COMPATIBLE)
407 CP = copyattr --data ;
410 HOST_DEFINES += ARCH_$(HOST_CPU) ;
411 HOST_DEFINES += _NO_INLINE_ASM ;
413 # for builds of tools in the current environment
414 HOST_BUILD_COMPATIBILITY_LIB_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) lib ] ;
416 # For the generic attributes emulation: Target rm_attrs -- rm replacement that
417 # also removes the attributes.
418 HOST_RM_ATTRS_TARGET = ;
420 if $(HOST_PLATFORM_BEOS_COMPATIBLE) {
421 # the C++ standard and support libraries
422 if $(HOST_GCC_VERSION[1]) < 3 {
423 HOST_LIBSTDC++ = stdc++.r4 ;
426 HOST_LIBSTDC++ = stdc++ ;
427 HOST_LIBSUPC++ = supc++ ;
430 HOST_LIBROOT = root ;
431 HOST_STATIC_LIBROOT = $(HOST_LIBROOT) ;
432 HOST_LIBBE = libbe_build.so ;
433 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR
434 = "export LIBRARY_PATH=$LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ;
435 HOST_PTHREAD_LINKFLAGS = ;
436 HOST_LIBRARY_NAME_MAP_input_server = /system/servers/input_server ;
437 HOST_DEFINES += __STDC_FORMAT_MACROS __STDC_LIMIT_MACROS ;
439 local compatibilityHeader = -include [ FDirName $(HAIKU_TOP) headers build
440 HaikuBuildCompatibility.h ] ;
441 HOST_CCFLAGS += $(compatibilityHeader) ;
442 HOST_C++FLAGS += $(compatibilityHeader) ;
444 # compatibility library
445 HOST_HAIKU_COMPATIBILITY_LIBS = libhaikucompat.a ;
447 HOST_LINKFLAGS += -lm ;
448 HOST_LIBSTDC++ = stdc++ ;
449 HOST_LIBROOT = libroot_build_function_remapper.a libroot_build.so ;
450 HOST_STATIC_LIBROOT = libroot_build_function_remapper.a libroot_build.a ;
451 HOST_LIBBE = libbe_build.so ;
452 if $(HOST_PLATFORM) = cygwin {
453 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR
454 = "export PATH=$PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ;
455 } else if $(HOST_PLATFORM) = darwin {
456 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR
457 = "export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ;
459 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR
460 = "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ;
463 if $(HOST_PLATFORM) = cygwin {
465 HOST_PTHREAD_LINKFLAGS = ;
466 } else if $(HOST_PLATFORM) = freebsd {
467 HOST_PTHREAD_LINKFLAGS = -pthread ;
469 HOST_PTHREAD_LINKFLAGS = -pthread ;
472 # the C++ support library
473 if $(HOST_GCC_VERSION[1]) < 3 {
476 HOST_LIBSUPC++ = supc++ ;
479 if $(HOST_PLATFORM) = darwin {
480 # part of the C++ runtime lives in libstdc++ on Darwin
481 HOST_LIBSUPC++ = gcc_s.1 stdc++ ;
483 } else if $(HOST_PLATFORM) = freebsd {
484 if $(HOST_CPU) = x86_64 {
485 # amd64 FreeBSD 8 doesn't come without a shared libsupc++, and the
486 # static one prevents us from building shared libraries. So we have
487 # to work around by using the shared libstdc++.
488 HOST_LIBSUPC++ = stdc++ ;
493 # Unlike glibc FreeBSD's libc doesn't have built-in regex support.
494 if $(HOST_PLATFORM) = freebsd {
495 HOST_LIBROOT += /usr/lib/libgnuregex.so ;
496 HOST_STATIC_LIBROOT += /usr/lib/libgnuregex.so ;
497 } else if $(HOST_PLATFORM) = darwin {
498 HOST_LIBROOT += libgnuregex_build.so ;
499 HOST_STATIC_LIBROOT += libgnuregex_build.so ;
502 # The BeOS compilers define __INTEL__ respectively __POWERPC__. On the
503 # build platform we need to make sure, this is also defined.
504 if $(HOST_CPU) = x86 {
505 HOST_DEFINES += __INTEL__ ;
506 } else if $(HOST_CPU) = x86_64 {
507 HOST_DEFINES += __x86_64__ ;
508 } else if $(HOST_CPU) = ppc {
509 HOST_DEFINES += __POWERPC__ ;
510 } else if $(HOST_CPU) = m68k {
511 HOST_DEFINES += __M68K__ ;
514 # Supposing this is a glibc platform, let's try to get features like large
515 # file support, ISO C 99 definitions, etc. On some platforms we need to
516 # request 64 bit off_t support explicitely.
517 HOST_DEFINES += _GNU_SOURCE _FILE_OFFSET_BITS=64 __STDC_FORMAT_MACROS
518 __STDC_LIMIT_MACROS ;
520 # On Linux with xattr support we can use it for our attribute emulation,
521 # which is somewhat more robust.
522 if $(HAIKU_HOST_USE_XATTR) = 1 {
523 HOST_DEFINES += HAIKU_HOST_USE_XATTR ;
525 # Otherwise the generic attribute emulation is used, which uses a
526 # directory per file to store its attribute. We need to redefine RM so
527 # that the attributes are removed as well. We use a wrapper script,
528 # which invokes a build tool. If the build tool hasn't been built yet,
529 # the normal "rm" is used and the attributes are leaked (likely there
531 RM = $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) ";"
532 [ FDirName $(HAIKU_TOP) build scripts rm_attrs ]
533 [ FDirName $(HAIKU_OBJECT_DIR) $(HOST_PLATFORM) $(HOST_ARCH) release
534 tools rm_attrs ] -f ;
535 # assumes that rm_attrs is built with debugging disabled
536 HOST_RM_ATTRS_TARGET = <build>rm_attrs ;
538 # If specified, use xattr support to tag files with unique IDs.
539 if $(HAIKU_HOST_USE_XATTR_REF) = 1 {
540 HOST_DEFINES += HAIKU_HOST_USE_XATTR_REF ;
546 if $(HOST_PLATFORM_HAIKU_COMPATIBLE) {
547 HOST_NETWORK_LIBS = network ;
548 HOST_NETAPI_LIB = bnetapi ;
549 HOST_SELECT_UNAME_ETC_LIB = ; # libroot
550 } else if $(HOST_PLATFORM_BONE_COMPATIBLE) {
551 HOST_NETWORK_LIBS = socket bind ;
552 HOST_NETAPI_LIB = bnetapi ;
553 HOST_SELECT_UNAME_ETC_LIB = ; # libroot
554 } else if $(HOST_PLATFORM_BEOS_COMPATIBLE) {
555 HOST_NETWORK_LIBS = net ;
556 HOST_NETAPI_LIB = netapi ;
557 HOST_SELECT_UNAME_ETC_LIB = net ;
558 } else if $(HOST_PLATFORM) = "sunos" {
559 HOST_NETWORK_LIBS = xnet ;
561 HOST_SELECT_UNAME_ETC_LIB = ;
564 HOST_NETWORK_LIBS = ;
566 HOST_SELECT_UNAME_ETC_LIB = ;
569 # define the executable MIME type
570 HOST_EXECUTABLE_MIME_TYPE = "application/x-vnd.Be-elfexecutable" ;
573 # at least parts of Haiku still can be compiled with
574 # the Metrowerks compiler on BeOS/PPC
575 HOST_EXECUTABLE_MIME_TYPE = "application/x-be-executable" ;
578 # Be API compatibility
579 HOST_BE_API_HEADERS = ;
580 HOST_BE_API_CCFLAGS = ;
581 HOST_BE_API_C++FLAGS = ;
583 # Add directory with system headers we need when building something for the host
584 # platform, e.g. containing missing POSIX/GNU headers.
585 HOST_HDRS += [ FDirName $(HAIKU_TOP) headers build host $(HOST_PLATFORM) ] ;
587 if $(HOST_PLATFORM) = freebsd {
588 # FreeBSD's gcc doesn't include /usr/local/* in its search paths,
589 # though that's where most things from ports wind up being installed.
590 HOST_HDRS += /usr/local/include ;
591 HOST_LINKFLAGS += -L/usr/local/lib ;
594 if $(HOST_PLATFORM) = darwin {
595 HOST_HDRS += [ FDirName $(HAIKU_TOP) src build libgnuregex ] ;
597 # Mac OS X users may be using macports libraries, in which case the headers
598 # and the libs are located in /opt/local/.
599 HOST_HDRS += /opt/local/include ;
600 HOST_LINKFLAGS += -L/opt/local/lib ;
602 # Mac OS X users may be using homebrew libraries, in which case the headers
603 # and the libs are locted in the /usr/local/.
604 HOST_HDRS += /usr/local/include ;
605 HOST_LINKFLAGS += -L/usr/local/lib ;
608 HOST_BE_API_HEADERS =
609 [ FDirName $(HAIKU_TOP) headers build ]
610 [ FDirName $(HAIKU_TOP) headers build os ]
611 [ FDirName $(HAIKU_TOP) headers build os add-ons registrar ]
612 [ FDirName $(HAIKU_TOP) headers build os app ]
613 [ FDirName $(HAIKU_TOP) headers build os bluetooth ]
614 [ FDirName $(HAIKU_TOP) headers build os drivers ]
615 [ FDirName $(HAIKU_TOP) headers build os kernel ]
616 [ FDirName $(HAIKU_TOP) headers build os interface ]
617 [ FDirName $(HAIKU_TOP) headers build os locale ]
618 [ FDirName $(HAIKU_TOP) headers build os storage ]
619 [ FDirName $(HAIKU_TOP) headers build os support ]
620 [ FDirName $(HAIKU_TOP) headers build private ]
622 if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) {
623 HOST_BE_API_CCFLAGS = -include BeOSBuildCompatibility.h ;
624 HOST_BE_API_C++FLAGS = $(HOST_BE_API_CCFLAGS) ;
628 #pragma mark - target platform settings
631 # check the target platform compatibility
632 SetPlatformCompatibilityFlagVariables TARGET_PLATFORM : TARGET : target ;
634 # check the compatibility between host and target platform
635 if $(TARGET_PLATFORM) != haiku {
636 if ! $(HOST_PLATFORM_($(TARGET_PLATFORM))_COMPATIBLE) {
637 Exit ERROR: The host platform is not compatible with target platform
638 $(TARGET_PLATFORM). ;
643 # Haiku architecture is undefined on host-only builds
644 # set here to host arch to prevent recusive loops.
645 if $(HAIKU_HOST_BUILD_ONLY) = 1 {
646 HAIKU_ARCH = $(HOST_ARCH) ;
647 HAIKU_KERNEL_ARCH = $(HOST_ARCH) ;
650 # Set TARGET_* variables either from HAIKU_* or HOST_* depending on the
651 # specified TARGET_PLATFORM. Some variables are package architecture dependent
652 # and their name gets a respective suffix. A few variables exist both with and
653 # without suffix. The latter is either equivalent to the variable with the
654 # primary architecture suffix (e.g. TARGET_ARCH) or is (additionally) applicable
655 # for all architectures (e.g. TARGET_DEFINES).
658 ARCH ARCHS KERNEL_ARCH PACKAGING_ARCH PACKAGING_ARCHS
663 KERNEL_CCFLAGS KERNEL_C++FLAGS
664 KERNEL_PIC_CCFLAGS KERNEL_PIC_LINKFLAGS KERNEL_ADDON_LINKFLAGS
665 BOOT_CCFLAGS BOOT_C++FLAGS BOOT_LINKFLAGS BOOT_LDFLAGS
667 KERNEL_WARNING_CCFLAGS KERNEL_WARNING_C++FLAGS
669 KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS
670 KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS
672 PRIVATE_KERNEL_HEADERS
674 NETWORK_LIBS NETAPI_LIB SELECT_UNAME_ETC_LIB
678 OBJECT_BASE_DIR COMMON_ARCH_OBJECT_DIR
681 local archDependentBuildVars =
684 AR CC C++ ELFEDIT LD OBJCOPY RANLIB STRIP
686 ARFLAGS ASFLAGS UNARFLAGS CPPFLAGS CCFLAGS C++FLAGS HDRS LDFLAGS
689 WARNING_CCFLAGS WARNING_C++FLAGS WERROR_FLAGS
691 DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS
693 INCLUDES_SEPARATOR LOCAL_INCLUDES_OPTION SYSTEM_INCLUDES_OPTION
695 PRIVATE_SYSTEM_HEADERS
697 ARCH_OBJECT_DIR COMMON_DEBUG_OBJECT_DIR
698 DEBUG_$(HAIKU_DEBUG_LEVELS)_OBJECT_DIR
701 if $(TARGET_PLATFORM) = haiku {
703 for var in $(buildVars) {
704 TARGET_$(var) = $(HAIKU_$(var)) ;
707 for var in $(archDependentBuildVars)_$(TARGET_PACKAGING_ARCHS) {
708 TARGET_$(var) = $(HAIKU_$(var)) ;
711 TARGET_BOOT_LIBGCC = $(HAIKU_BOOT_LIBGCC_$(TARGET_PACKAGING_ARCH)) ;
712 TARGET_BOOT_LIBSUPC++ = $(HAIKU_BOOT_LIBSUPC++_$(TARGET_PACKAGING_ARCH)) ;
714 TARGET_BOOT_PLATFORM ?= $(HAIKU_BOOT_PLATFORM) ;
717 for architecture in $(TARGET_PACKAGING_ARCHS) {
718 TARGET_DEFINES_$(architecture) = $(HAIKU_DEFINES_$(architecture)) ;
719 TARGET_LIBRARY_NAME_MAP_$(architecture)
720 = HAIKU_LIBRARY_NAME_MAP_$(architecture) ;
724 for var in $(buildVars) {
725 TARGET_$(var) = $(HOST_$(var)) ;
728 for var in $(archDependentBuildVars) {
729 TARGET_$(var)_$(TARGET_PACKAGING_ARCH) = $(HOST_$(var)) ;
732 TARGET_BOOT_LIBGCC = ;
733 TARGET_BOOT_LIBSUPC++ = ;
735 TARGET_BOOT_PLATFORM = ;
737 TARGET_DEFINES_$(TARGET_PACKAGING_ARCH) = ;
738 # all flags are in TARGET_DEFINES
740 TARGET_LIBRARY_NAME_MAP_$(TARGET_PACKAGING_ARCH) = HOST_LIBRARY_NAME_MAP ;
743 # define macro, for identifying the platform
744 switch $(TARGET_PLATFORM) {
745 case r5 : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_BEOS ;
746 case bone : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_BONE ;
747 case dano : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_DANO ;
748 case haiku_host : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_HAIKU ;
749 case haiku : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_HAIKU ;
750 case linux : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_LINUX ;
751 case freebsd : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_FREEBSD ;
752 case darwin : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_DARWIN ;
753 case cygwin : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_CYGWIN ;
754 case sunos : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_SUNOS ;
755 case libbe_test : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_LIBBE_TEST ;
758 # define macro, for identifying the host platform
759 switch $(HOST_PLATFORM) {
760 case r5 : HOST_DEFINES += HAIKU_HOST_PLATFORM_BEOS ;
761 case bone : HOST_DEFINES += HAIKU_HOST_PLATFORM_BONE ;
762 case dano : HOST_DEFINES += HAIKU_HOST_PLATFORM_DANO ;
763 case haiku_host : HOST_DEFINES += HAIKU_HOST_PLATFORM_HAIKU ;
764 case linux : HOST_DEFINES += HAIKU_HOST_PLATFORM_LINUX ;
765 case freebsd : HOST_DEFINES += HAIKU_HOST_PLATFORM_FREEBSD ;
766 case darwin : HOST_DEFINES += HAIKU_HOST_PLATFORM_DARWIN ;
767 case cygwin : HOST_DEFINES += HAIKU_HOST_PLATFORM_CYGWIN ;
768 case sunos : HOST_DEFINES += HAIKU_HOST_PLATFORM_SUNOS ;
771 # define host platform 64 bit macro
772 if $(HOST_PLATFORM_IS_64_BIT) {
773 HOST_DEFINES += HAIKU_HOST_PLATFORM_64_BIT ;
776 # define Haiku packaging architecture macro for host build
777 HOST_DEFINES += HAIKU_PACKAGING_ARCH=\\\"$(HAIKU_PACKAGING_ARCH)\\\" ;
782 # In case we build for a BeOS compatible platform, but not for Haiku, we
783 # include the HaikuBuildCompatibility.h header and link against
786 if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) && $(TARGET_PLATFORM_BEOS_COMPATIBLE) {
788 local compatibilityHeader = -include [ FDirName $(HAIKU_TOP) headers build
789 HaikuBuildCompatibility.h ] ;
790 TARGET_CCFLAGS_$(TARGET_PACKAGING_ARCH) += $(compatibilityHeader) ;
791 TARGET_C++FLAGS_$(TARGET_PACKAGING_ARCH) += $(compatibilityHeader) ;
793 # compatibility library
794 TARGET_HAIKU_COMPATIBILITY_LIBS = libhaikucompat.a ;
797 # special target libbe_test
799 if $(TARGET_PLATFORM) = libbe_test {
801 TARGET_HDRS_$(TARGET_PACKAGING_ARCH) +=
802 [ PublicHeaders $(DOT) app drivers game interface kernel locale storage
804 [ PrivateHeaders $(DOT) ] ;
805 TARGET_DEFINES += __HAIKU__ ;
807 TARGET_PRIVATE_SYSTEM_HEADERS_$(TARGET_PACKAGING_ARCH) =
808 [ PrivateHeaders $(DOT) system system/arch/$(TARGET_ARCH) ] ;
811 TARGET_OBJECT_BASE_DIR
812 = [ FDirName $(HAIKU_OBJECT_DIR) $(TARGET_PLATFORM) ] ;
813 TARGET_COMMON_ARCH_OBJECT_DIR
814 = [ FDirName $(TARGET_OBJECT_BASE_DIR) common ] ;
815 TARGET_ARCH_OBJECT_DIR_$(TARGET_PACKAGING_ARCH)
816 = [ FDirName $(TARGET_OBJECT_BASE_DIR) $(TARGET_ARCH) ] ;
817 TARGET_COMMON_DEBUG_OBJECT_DIR_$(TARGET_PACKAGING_ARCH)
818 = [ FDirName $(TARGET_ARCH_OBJECT_DIR_$(TARGET_PACKAGING_ARCH))
820 TARGET_DEBUG_0_OBJECT_DIR_$(TARGET_PACKAGING_ARCH)
821 = [ FDirName $(TARGET_ARCH_OBJECT_DIR_$(TARGET_PACKAGING_ARCH))
825 for level in $(HAIKU_DEBUG_LEVELS[2-]) {
826 TARGET_DEBUG_$(level)_OBJECT_DIR_$(TARGET_PACKAGING_ARCH)
827 = [ FDirName $(TARGET_ARCH_OBJECT_DIR_$(TARGET_PACKAGING_ARCH))
832 TARGET_LIBRARY_NAME_MAP_$(TARGET_PACKAGING_ARCH) = LIBBE_LIBRARY_NAME_MAP ;
833 LIBBE_LIBRARY_NAME_MAP_be = libbe_test.so ;
837 #pragma mark - common stuff
840 # start with a clean state
845 # Set CC, C++, LINK to invalid values, so that we realize early, that we use
846 # the wrong compiler.
852 # Defaults for warnings, optimization, and debugging.
859 # Set a sane default for whether this is a CI build.
860 HAIKU_CONTINUOUS_INTEGRATION_BUILD ?= 0 ;
863 # Set the defaults for PLATFORM and SUPPORTED_PLATFORMS. PLATFORM is only
864 # overridden for targets to be built for the host platform. SUPPORTED_PLATFORMS
865 # can be overridden by the author of a component.
866 PLATFORM = $(TARGET_PLATFORM) ;
867 SUPPORTED_PLATFORMS = haiku ;
870 # Define two pseudo targets for the target and buildhost platform. The main
871 # build rules (Cc, C++, As, ...) depend on these pseude targets such that global
872 # initializations that are required before anything is built for a specific
873 # platform can be forced by depending the pseudo target for the platform on the
875 # This is currently used to unpack the external headers from the
876 # gcc_syslibs_devel build feature before anything is built for the target
878 NotFile $(TARGET_PLATFORM) ;
882 # Instructs the Library rule to not make its object files temporary.
883 # This is needed as some objects are used in a static library and for an
888 # Set permissions to how they should be on the image.
896 HAIKU_DOCUMENTATION_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) documentation ] ;
897 HAIKU_DOCUMENTATION_OBJECT_DIR ?= [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR)
900 # TODO: Rethink test stuff.
901 HAIKU_TEST_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) tests
902 $(TARGET_PLATFORM) $(HAIKU_ARCH) ] ;
903 HAIKU_APP_TEST_DIR ?= [ FDirName $(HAIKU_TEST_DIR) apps ] ;
904 HAIKU_APP_TEST_LIB_DIR ?= [ FDirName $(HAIKU_APP_TEST_DIR) lib ] ;
905 HAIKU_TMP_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) tmp ] ;
908 for architecture in $(HAIKU_PACKAGING_ARCHS) {
910 = [ FDirName $(TARGET_OBJECT_BASE_DIR) $(architecture) packaging ] ;
911 HAIKU_PACKAGES_DIR_$(architecture) = [ FDirName $(baseDir) packages ] ;
912 HAIKU_PACKAGES_BUILD_DIR_$(architecture)
913 = [ FDirName $(baseDir) packages_build ] ;
914 HAIKU_PACKAGE_REPOSITORIES_DIR_$(architecture)
915 = [ FDirName $(baseDir) repositories ] ;
919 HAIKU_PACKAGE_INFOS_DIR = [ FDirName $(HAIKU_TOP) src data
922 TARGET_TEST_DIR ?= [ FDirName $(HAIKU_TEST_DIR)
923 $(TARGET_PLATFORM) ] ;
924 TARGET_UNIT_TEST_DIR ?= [ FDirName $(TARGET_TEST_DIR) unittests ] ;
925 TARGET_UNIT_TEST_LIB_DIR ?= [ FDirName $(TARGET_UNIT_TEST_DIR) lib ] ;
927 # automatically setup the objects directory per subdirectory
928 SUBDIRRULES += SetupObjectsDir ;
930 # Add the standard (userland) warning flags variables to the ones restored in
931 # every subdirectory. Thus we can easily meddle with them in subdirectories
932 # with imported sources.
933 AUTO_SET_UP_CONFIG_VARIABLES +=
934 HOST_WARNING_CCFLAGS HOST_WARNING_C++FLAGS
935 TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCHS)
936 TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCHS)
939 # also add PLATFORM and SUPPORTED_PLATFORMS
940 AUTO_SET_UP_CONFIG_VARIABLES += PLATFORM SUPPORTED_PLATFORMS ;
945 for architecture in $(TARGET_PACKAGING_ARCHS) {
946 ArchitectureSetupWarnings $(architecture) ;
950 # set up architecture build features
952 for architecture in $(TARGET_PACKAGING_ARCHS) {
953 InitArchitectureBuildFeatures $(architecture) ;
957 # The following directories cannot currently be compiled with DEBUG=1
958 SetConfigVar DEBUG : HAIKU_TOP src add-ons disk_systems bfs : 0 : local ;
959 SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel drivers audio hda : 0 : local ;
960 SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel drivers audio ac97 auich : 0 : local ; # fails with gcc4 only
961 SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel drivers audio ac97 auvia : 0 : local ; # fails with gcc4 only
962 SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel drivers audio ac97 sis7018 : 0 : local ;
963 SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel file_systems btrfs : 0 : local ;
964 SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel file_systems ntfs libntfs : 0 : local ;
965 SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel file_systems udf : 0 : local ;
966 SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel file_systems userlandfs server : 0 : local ; # fails with gcc2 only
967 SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel file_systems userlandfs server haiku : 0 : local ; # fails with gcc2 only
968 SetConfigVar DEBUG : HAIKU_TOP src add-ons media media-add-ons dvb : 0 : local ;
969 SetConfigVar DEBUG : HAIKU_TOP src add-ons print drivers gutenprint : 0 : local ;
970 SetConfigVar DEBUG : HAIKU_TOP src servers input : 0 : local ;
971 SetConfigVar DEBUG : HAIKU_TOP src servers media_addon : 0 : local ;
972 SetConfigVar DEBUG : HAIKU_TOP src system boot loader file_systems bfs : 0 : local ;