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 8# instance). 9# HAIKU_*: A build system variable specifying a build system property. Usually 10# directory paths and the like. 11 12 13# The Haiku (base) version. For development builds the revision will be 14# attached. 15HAIKU_VERSION = r1~alpha4_pm ; 16 17 18#pragma mark - container settings 19 20# Haiku image 21HAIKU_IMAGE_CONTAINER_NAME = haiku-image-container ; 22HAIKU_CONTAINER_GRIST on $(HAIKU_IMAGE_CONTAINER_NAME) = HaikuImage ; 23HAIKU_INCLUDE_IN_CONTAINER_VAR on $(HAIKU_IMAGE_CONTAINER_NAME) 24 = HAIKU_INCLUDE_IN_IMAGE ; 25HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_IMAGE_CONTAINER_NAME) 26 = HAIKU_IMAGE_INSTALL_TARGETS ; 27HAIKU_CONTAINER_SYSTEM_DIR_TOKENS on $(HAIKU_IMAGE_CONTAINER_NAME) 28 = system non-packaged ; 29 30# network boot archive 31HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME = haiku-netboot-archive-container ; 32HAIKU_CONTAINER_GRIST on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) 33 = NetBootArchive ; 34# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported 35HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) 36 = HAIKU_NET_BOOT_ARCHIVE_INSTALL_TARGETS ; 37HAIKU_CONTAINER_SYSTEM_DIR_TOKENS on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) 38 = system ; 39 40# boot floppy 41HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME = haiku-boot-floppy-container ; 42HAIKU_CONTAINER_GRIST on $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME) 43 = FloppyBootImage ; 44# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported 45HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME) 46 = HAIKU_FLOPPY_BOOT_IMAGE_INSTALL_TARGETS ; 47HAIKU_CONTAINER_SYSTEM_DIR_TOKENS on $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME) 48 = system ; 49 50# boot CD image 51HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME = haiku-boot-cd-container ; 52HAIKU_CONTAINER_GRIST on $(HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME) = CDBootImage ; 53# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported 54HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME) 55 = HAIKU_CD_BOOT_IMAGE_INSTALL_TARGETS ; 56HAIKU_CONTAINER_SYSTEM_DIR_TOKENS on $(HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME) 57 = system ; 58 59# boot CD for PPC image 60HAIKU_CD_BOOT_PPC_IMAGE_CONTAINER_NAME = haiku-boot-cd-ppc-container ; 61HAIKU_CONTAINER_GRIST on $(HAIKU_CD_BOOT_PPC_IMAGE_CONTAINER_NAME) 62 = CDBootPPCImage ; 63# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported 64HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_CD_BOOT_PPC_IMAGE_CONTAINER_NAME) 65 = HAIKU_CD_BOOT_PPC_IMAGE_INSTALL_TARGETS ; 66HAIKU_CONTAINER_SYSTEM_DIR_TOKENS on $(HAIKU_CD_BOOT_PPC_IMAGE_CONTAINER_NAME) 67 = system ; 68 69# Haiku image/install defaults 70HAIKU_DEFAULT_IMAGE_NAME = haiku.image ; 71HAIKU_DEFAULT_IMAGE_DIR = $(HAIKU_OUTPUT_DIR) ; 72HAIKU_DEFAULT_VMWARE_IMAGE_NAME = haiku.vmdk ; 73HAIKU_DEFAULT_INSTALL_DIR = /Haiku ; 74HAIKU_DEFAULT_IMAGE_SIZE ?= 300 ; # 300 MB 75HAIKU_DEFAULT_IMAGE_LABEL ?= Haiku ; 76 77# Haiku CD defaults 78HAIKU_DEFAULT_CD_NAME = haiku-cd.iso ; 79HAIKU_DEFAULT_CD_DIR = $(HAIKU_OUTPUT_DIR) ; 80HAIKU_DEFAULT_CD_LABEL = Haiku ; 81 82# Haiku Anyboot defaults 83HAIKU_DEFAULT_ANYBOOT_NAME = haiku-anyboot.iso ; 84HAIKU_DEFAULT_ANYBOOT_DIR = $(HAIKU_OUTPUT_DIR) ; 85HAIKU_DEFAULT_ANYBOOT_LABEL ?= Haiku ; 86 87# Haiku MMC defaults 88HAIKU_DEFAULT_MMC_IMAGE_NAME = haiku-mmc.image ; 89HAIKU_DEFAULT_MMC_DIR = $(HAIKU_OUTPUT_DIR) ; 90HAIKU_DEFAULT_MMC_LABEL ?= Haiku ; 91 92# analyze and optionally replace jam's target parameters 93ProcessCommandLineArguments ; 94 95 96# supported debug levels 97HAIKU_DEBUG_LEVELS = 0 1 2 3 4 5 ; 98 99# BeOS, BONE, Dan0 compatible platforms 100HAIKU_BEOS_COMPATIBLE_PLATFORMS = haiku r5 bone dano haiku_host ; 101HAIKU_BONE_COMPATIBLE_PLATFORMS = haiku bone dano haiku_host ; 102HAIKU_DANO_COMPATIBLE_PLATFORMS = haiku dano haiku_host ; 103HAIKU_HAIKU_COMPATIBLE_PLATFORMS = haiku haiku_host ; 104 105# configuration header directories 106HAIKU_CONFIG_HEADERS = [ FDirName $(HAIKU_TOP) build user_config_headers ] 107 [ FDirName $(HAIKU_TOP) build config_headers ] ; 108 109 110# object directories common to all architectures 111HAIKU_OBJECT_BASE_DIR = [ FDirName $(HAIKU_OBJECT_DIR) haiku ] ; 112HAIKU_COMMON_ARCH_OBJECT_DIR = [ FDirName $(HAIKU_OBJECT_BASE_DIR) common ] ; 113 114 115#pragma mark - haiku target platform settings 116 117 118local architecture ; 119for architecture in $(HAIKU_PACKAGING_ARCHS) { 120 ArchitectureSetup $(architecture) ; 121} 122 123# TODO: Might not be needed anymore. 124if $(HAIKU_HOST_BUILD_ONLY) = 1 { 125 HAIKU_GCC_VERSION = 0 0 0 ; 126} 127 128if $(HAIKU_PACKAGING_ARCH) { 129 KernelArchitectureSetup $(HAIKU_PACKAGING_ARCH) ; 130} 131 132# define primary packaging architecture macro 133HAIKU_DEFINES = __HAIKU_PRIMARY_PACKAGING_ARCH=\\\"$(HAIKU_PACKAGING_ARCH)\\\" ; 134 135 136# distro compatibility level defines 137HAIKU_DISTRO_COMPATIBILITY ?= "default" ; 138switch $(HAIKU_DISTRO_COMPATIBILITY) { 139 case official : 140 HAIKU_DEFINES += HAIKU_DISTRO_COMPATIBILITY_OFFICIAL ; 141 HAIKU_INCLUDE_TRADEMARKS = "" ; 142 case compatible : 143 HAIKU_DEFINES += HAIKU_DISTRO_COMPATIBILITY_COMPATIBLE ; 144 HAIKU_INCLUDE_TRADEMARKS = "" ; 145 case "default" : 146 HAIKU_DEFINES += HAIKU_DISTRO_COMPATIBILITY_DEFAULT ; 147 HAIKU_INCLUDE_TRADEMARKS = ; 148 case * : 149 Exit "Invalid value for HAIKU_DISTRO_COMPATIBILITY:" 150 $(HAIKU_DISTRO_COMPATIBILITY) ; 151} 152 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. 158if $(HAIKU_INCLUDE_PATENTED_CODE) { 159 HAIKU_DEFINES 160 += HAIKU_INCLUDE_PATENTED_CODE=$(HAIKU_INCLUDE_PATENTED_CODE) ; 161} 162 163# network libraries 164HAIKU_NETWORK_LIBS = network ; 165HAIKU_NETAPI_LIB = bnetapi ; 166HAIKU_SELECT_UNAME_ETC_LIB = ; # libroot, against which we link anyway 167 168HAIKU_EXECUTABLE_MIME_TYPE = "application/x-vnd.Be-elfexecutable" ; 169 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 173if ! $(HAIKU_BUILD_VERSION) { 174 HAIKU_BUILD_VERSION ?= "1 0 0 a 1" ; 175 HAIKU_BUILD_DESCRIPTION ?= "Developer Build" ; 176} 177 178# If HAIKU_BUILD_VERSION is set, but HAIKU_BUILD_DESCRIPTION isn't, mark it as 179# an unknown build. 180HAIKU_BUILD_DESCRIPTION ?= "Unknown Build" ; 181 182 183#pragma mark - host platform settings 184 185 186# determine the endianness of the host 187switch $(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 ; 192 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) ; 201} 202 203# analyze the host gcc machine spec to find out about 64-bitness 204HOST_PLATFORM_IS_64_BIT = ; 205switch $(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 ; 211} 212 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. 220if $(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 = ; 225 } else { 226 HAIKU_HOST_USE_32BIT = 0 ; 227 } 228} 229 230 231# save jam's variables for the build platform 232HOST_AR ?= $(AR) ; 233HOST_CC ?= $(CC) ; 234HOST_C++ ?= $(C++) ; 235HOST_LINK ?= $(LINK) ; 236HOST_RANLIB ?= $(RANLIB) ; 237HOST_CPPFLAGS ?= $(CPPFLAGS) ; 238HOST_CCFLAGS ?= $(HOST_GCC_BASE_FLAGS) $(CCFLAGS) ; 239HOST_C++FLAGS ?= $(HOST_GCC_BASE_FLAGS) $(C++FLAGS) ; 240HOST_LDFLAGS ?= $(LDFLAGS) ; 241HOST_LINKFLAGS ?= $(HOST_GCC_BASE_FLAGS) $(LINKFLAGS) ; 242HOST_DEFINES ?= $(DEFINES) ; 243HOST_HDRS ?= $(HDRS) ; 244 245 246# split up HOST_AR into the command name and flags 247HOST_AR = [ Match "([^ ]*) *(.*)" : $(HOST_AR[1]) ] 248 $(HOST_AR[2-]) ; 249HOST_ARFLAGS = $(HOST_AR[2-]) ; 250HOST_AR = $(HOST_AR[1]) ; 251HOST_UNARFLAGS ?= x ; 252 253# check the host platform compatibility 254SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host 255 : linux openbsd freebsd darwin sunos cygwin ; 256HOST_PLATFORM_(host)_COMPATIBLE = 1 ; 257 258if $(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 262 if $(LEX) = lex { 263 LEX = flex ; 264 } 265} 266 267if $(HOST_PLATFORM) = cygwin { 268 HOST_LINKFLAGS += -Xlinker --allow-multiple-definition -Xlinker 269 --enable-auto-import ; 270} 271 272HOST_CPU ?= $(OSPLAT:L) ; 273 274# Jam doesn't know x86_64, so override HOST_CPU, if 64 bit. 275if $(HOST_CPU) = x86 && $(HOST_PLATFORM_IS_64_BIT) { 276 HOST_CPU = x86_64 ; 277} 278 279HOST_ARCH ?= $(HOST_CPU) ; 280HOST_ARCHS = $(HOST_ARCH) ; 281HOST_KERNEL_ARCH = host ; 282 283# analyze GCC version 284HOST_GCC_VERSION = [ FAnalyzeGCCVersion HOST_GCC_RAW_VERSION ] ; 285 286# set packaging architecture 287HOST_PACKAGING_ARCH ?= $(HOST_CPU) ; 288if $(HOST_PACKAGING_ARCH) = x86 && $(HOST_GCC_VERSION[1]) = 2 { 289 HOST_PACKAGING_ARCH = x86_gcc2 ; 290} 291HOST_PACKAGING_ARCHS = $(HOST_PACKAGING_ARCH) ; 292 293# directories 294HOST_OBJECT_BASE_DIR = [ FDirName $(HAIKU_OBJECT_DIR) $(HOST_PLATFORM) ] ; 295HOST_COMMON_ARCH_OBJECT_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) common ] ; 296HOST_ARCH_OBJECT_DIR 297 = [ FDirName $(HOST_OBJECT_BASE_DIR) $(HOST_PACKAGING_ARCH) ] ; 298HOST_COMMON_DEBUG_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) common ] ; 299HOST_DEBUG_0_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) release ] ; 300 301local level ; 302for level in $(HAIKU_DEBUG_LEVELS[2-]) { 303 HOST_DEBUG_$(level)_OBJECT_DIR 304 = [ FDirName $(HOST_ARCH_OBJECT_DIR) debug_$(level) ] ; 305} 306 307# set variables for gcc header options 308SetIncludePropertiesVariables HOST ; 309 310# assembler flags 311HOST_ASFLAGS = ; 312 313# C/C++ flags 314HOST_CCFLAGS += -Wno-multichar ; 315HOST_C++FLAGS += -Wno-multichar ; 316 317if $(HOST_PLATFORM) != cygwin { 318 HOST_PIC_CCFLAGS += -fPIC ; 319 HOST_PIC_C++FLAGS += -fPIC ; 320} 321 322if $(HOST_GCC_VERSION[1]) >= 3 { 323 HOST_GCC_BASE_FLAGS += -fno-strict-aliasing -fno-tree-vrp ; 324} 325 326HOST_KERNEL_CCFLAGS += $(HOST_GCC_BASE_FLAGS) -finline -fno-builtin 327 -D_KERNEL_MODE ; 328HOST_KERNEL_C++FLAGS += $(HOST_GCC_BASE_FLAGS) -finline -fno-builtin 329 -fno-exceptions -D_KERNEL_MODE ; 330HOST_KERNEL_DEFINES += _KERNEL_MODE ; 331 332HOST_KERNEL_PIC_CCFLAGS = -fno-pic ; 333HOST_KERNEL_PIC_LINKFLAGS = ; 334if $(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 337 # fixed. 338 HOST_KERNEL_PIC_CCFLAGS = -fPIE ; 339 HOST_KERNEL_PIC_LINKFLAGS = -shared -fPIE ; 340} 341if $(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 344 # fixed. 345 HOST_KERNEL_PIC_CCFLAGS = $(HAIKU_KERNEL_PIC_CCFLAGS) ; 346 HOST_KERNEL_PIC_LINKFLAGS = $(HAIKU_KERNEL_PIC_LINKFLAGS) ; 347} 348 349if $(HOST_PLATFORM) != darwin { 350 # fix for new changes to DSO linking policies 351 HOST_LINKFLAGS += -Xlinker --no-as-needed ; 352} 353 354 355# warning flags 356HOST_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes -Wpointer-arith 357 -Wcast-align -Wsign-compare ; 358HOST_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-ctor-dtor-privacy 359 -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare ; 360 361HOST_KERNEL_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes ; 362HOST_KERNEL_WARNING_C++FLAGS = -Wall -Wno-trigraphs ; 363 364HOST_WERROR_FLAGS = ; 365 366# debug flags 367local hostDebugFlags ; 368switch $(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 ; 375} 376 377# debug 0: suppress asserts 378HOST_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 379HOST_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 380 381HOST_KERNEL_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 382HOST_KERNEL_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 383 384local level ; 385for 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) ; 391} 392 393# ld flags 394if $(HAIKU_HOST_USE_32BIT) = 1 { 395 HOST_LDFLAGS += -melf_i386 ; 396} 397 398# private kernel headers do be used when compiling kernel code 399HOST_PRIVATE_KERNEL_HEADERS = ; 400 401# private shared kernel/libroot headers 402HOST_PRIVATE_SYSTEM_HEADERS = ; 403 404# under BeOS use copyattr instead of cp 405if $(HOST_PLATFORM_BEOS_COMPATIBLE) { 406 CP = copyattr --data ; 407} 408 409HOST_DEFINES += ARCH_$(HOST_CPU) ; 410HOST_DEFINES += _NO_INLINE_ASM ; 411 412# for builds of tools in the current environment 413HOST_BUILD_COMPATIBILITY_LIB_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) lib ] ; 414 415# For the generic attributes emulation: Target rm_attrs -- rm replacement that 416# also removes the attributes. 417HOST_RM_ATTRS_TARGET = ; 418 419HOST_LIBROOT = libroot_build_function_remapper.a libroot_build.so ; 420HOST_STATIC_LIBROOT = libroot_build_function_remapper.a libroot_build.a ; 421HOST_LIBBE = libbe_build.so ; 422 423if $(HOST_PLATFORM_BEOS_COMPATIBLE) { 424 # the C++ standard and support libraries 425 if $(HOST_GCC_VERSION[1]) < 3 { 426 HOST_LIBSTDC++ = stdc++.r4 ; 427 HOST_LIBSUPC++ = ; 428 } else { 429 HOST_LIBSTDC++ = stdc++ ; 430 HOST_LIBSUPC++ = supc++ ; 431 } 432 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 ; 438 439 local compatibilityHeader = -include [ FDirName $(HAIKU_TOP) headers build 440 HaikuBuildCompatibility.h ] ; 441 HOST_CCFLAGS += $(compatibilityHeader) ; 442 HOST_C++FLAGS += $(compatibilityHeader) ; 443} else { 444 HOST_LINKFLAGS += -lm ; 445 HOST_LIBSTDC++ = stdc++ ; 446 if $(HOST_PLATFORM) = cygwin { 447 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR 448 = "export PATH=$PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ; 449 } else if $(HOST_PLATFORM) = darwin { 450 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR 451 = "export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ; 452 } else { 453 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR 454 = "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ; 455 } 456 457 if $(HOST_PLATFORM) = cygwin { 458 # not needed 459 HOST_PTHREAD_LINKFLAGS = ; 460 } else if $(HOST_PLATFORM) = freebsd { 461 HOST_PTHREAD_LINKFLAGS = -pthread ; 462 } else { 463 HOST_PTHREAD_LINKFLAGS = -pthread ; 464 } 465 466 # the C++ support library 467 if $(HOST_GCC_VERSION[1]) < 3 { 468 HOST_LIBSUPC++ = ; 469 } else { 470 HOST_LIBSUPC++ = supc++ ; 471 } 472 473 if $(HOST_PLATFORM) = darwin { 474 # part of the C++ runtime lives in libstdc++ on Darwin 475 HOST_LIBSUPC++ = gcc_s.1 stdc++ ; 476 HOST_LIBSTDC++ = ; 477 } else if $(HOST_PLATFORM) = freebsd { 478 if $(HOST_CPU) = x86_64 { 479 # amd64 FreeBSD 8 doesn't come without a shared libsupc++, and the 480 # static one prevents us from building shared libraries. So we have 481 # to work around by using the shared libstdc++. 482 HOST_LIBSUPC++ = stdc++ ; 483 HOST_LIBSTDC++ = ; 484 } 485 } 486 487 # Unlike glibc FreeBSD's libc doesn't have built-in regex support. 488 if $(HOST_PLATFORM) = freebsd { 489 HOST_LIBROOT += /usr/lib/libgnuregex.so ; 490 HOST_STATIC_LIBROOT += /usr/lib/libgnuregex.so ; 491 } else if $(HOST_PLATFORM) = darwin { 492 HOST_LIBROOT += libgnuregex_build.so ; 493 HOST_STATIC_LIBROOT += libgnuregex_build.so ; 494 } 495 496 # The BeOS compilers define __INTEL__ respectively __POWERPC__. On the 497 # build platform we need to make sure, this is also defined. 498 if $(HOST_CPU) = x86 { 499 HOST_DEFINES += __INTEL__ ; 500 } else if $(HOST_CPU) = x86_64 { 501 HOST_DEFINES += __x86_64__ ; 502 } else if $(HOST_CPU) = ppc { 503 HOST_DEFINES += __POWERPC__ ; 504 } else if $(HOST_CPU) = m68k { 505 HOST_DEFINES += __M68K__ ; 506 } 507 508 # Supposing this is a glibc platform, let's try to get features like large 509 # file support, ISO C 99 definitions, etc. On some platforms we need to 510 # request 64 bit off_t support explicitely. 511 HOST_DEFINES += _GNU_SOURCE _FILE_OFFSET_BITS=64 __STDC_FORMAT_MACROS 512 __STDC_LIMIT_MACROS ; 513} 514 515if $(HAIKU_HOST_USE_XATTR) = 1 { 516 HOST_DEFINES += HAIKU_HOST_USE_XATTR ; 517} else { 518 # Otherwise the generic attribute emulation is used, which uses a 519 # directory per file to store its attribute. We need to redefine RM so 520 # that the attributes are removed as well. We use a wrapper script, 521 # which invokes a build tool. If the build tool hasn't been built yet, 522 # the normal "rm" is used and the attributes are leaked (likely there 523 # aren't any yet). 524 RM = $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) ";" 525 [ FDirName $(HAIKU_TOP) build scripts rm_attrs ] 526 [ FDirName $(HAIKU_OBJECT_DIR) $(HOST_PLATFORM) $(HOST_ARCH) release 527 tools rm_attrs ] -f ; 528 # assumes that rm_attrs is built with debugging disabled 529 HOST_RM_ATTRS_TARGET = <build>rm_attrs ; 530 531 # If specified, use xattr support to tag files with unique IDs. 532 if $(HAIKU_HOST_USE_XATTR_REF) = 1 { 533 HOST_DEFINES += HAIKU_HOST_USE_XATTR_REF ; 534 } 535} 536 537# network libraries 538if $(HOST_PLATFORM_HAIKU_COMPATIBLE) { 539 HOST_NETWORK_LIBS = network ; 540 HOST_NETAPI_LIB = bnetapi ; 541 HOST_SELECT_UNAME_ETC_LIB = ; # libroot 542} else if $(HOST_PLATFORM) = "sunos" { 543 HOST_NETWORK_LIBS = xnet ; 544 HOST_NETAPI_LIB = ; 545 HOST_SELECT_UNAME_ETC_LIB = ; 546} else { 547 # Linux,... 548 HOST_NETWORK_LIBS = ; 549 HOST_NETAPI_LIB = ; 550 HOST_SELECT_UNAME_ETC_LIB = ; 551} 552 553# define the executable MIME type 554HOST_EXECUTABLE_MIME_TYPE = "application/x-vnd.Be-elfexecutable" ; 555 556if $(METROWERKS) { 557 # at least parts of Haiku still can be compiled with 558 # the Metrowerks compiler on BeOS/PPC 559 HOST_EXECUTABLE_MIME_TYPE = "application/x-be-executable" ; 560} 561 562# Be API compatibility 563HOST_BE_API_HEADERS = ; 564HOST_BE_API_CCFLAGS = ; 565HOST_BE_API_C++FLAGS = ; 566 567# Add directory with system headers we need when building something for the host 568# platform, e.g. containing missing POSIX/GNU headers. 569HOST_HDRS += [ FDirName $(HAIKU_TOP) headers build host $(HOST_PLATFORM) ] ; 570 571if $(HOST_PLATFORM) = freebsd { 572 # FreeBSD's gcc doesn't include /usr/local/* in its search paths, 573 # though that's where most things from ports wind up being installed. 574 HOST_HDRS += /usr/local/include /usr/include/gnu ; 575 HOST_LINKFLAGS += -L/usr/local/lib ; 576} 577 578if $(HOST_PLATFORM) = darwin { 579 HOST_HDRS += [ FDirName $(HAIKU_TOP) src build libgnuregex ] ; 580 581 # Mac OS X users may be using macports libraries, in which case the headers 582 # and the libs are located in /opt/local/. 583 HOST_HDRS += /opt/local/include ; 584 HOST_LINKFLAGS += -L/opt/local/lib ; 585 586 # Mac OS X users may be using homebrew libraries, in which case the headers 587 # and the libs are locted in the /usr/local/. 588 HOST_HDRS += /usr/local/include ; 589 HOST_LINKFLAGS += -L/usr/local/lib ; 590} 591 592HOST_BE_API_HEADERS = 593 [ FDirName $(HAIKU_TOP) headers build ] 594 [ FDirName $(HAIKU_TOP) headers build os ] 595 [ FDirName $(HAIKU_TOP) headers build os add-ons registrar ] 596 [ FDirName $(HAIKU_TOP) headers build os app ] 597 [ FDirName $(HAIKU_TOP) headers build os bluetooth ] 598 [ FDirName $(HAIKU_TOP) headers build os drivers ] 599 [ FDirName $(HAIKU_TOP) headers build os kernel ] 600 [ FDirName $(HAIKU_TOP) headers build os interface ] 601 [ FDirName $(HAIKU_TOP) headers build os locale ] 602 [ FDirName $(HAIKU_TOP) headers build os storage ] 603 [ FDirName $(HAIKU_TOP) headers build os support ] 604 [ FDirName $(HAIKU_TOP) headers build private ] 605; 606if ! $(HOST_PLATFORM_HAIKU_COMPATIBLE) { 607 HOST_BE_API_CCFLAGS = -include BeOSBuildCompatibility.h ; 608 HOST_BE_API_C++FLAGS = $(HOST_BE_API_CCFLAGS) ; 609} 610 611 612#pragma mark - target platform settings 613 614 615# check the target platform compatibility 616SetPlatformCompatibilityFlagVariables TARGET_PLATFORM : TARGET : target ; 617 618# Haiku architecture is undefined on host-only builds 619# set here to host arch to prevent recusive loops. 620if $(HAIKU_HOST_BUILD_ONLY) = 1 { 621 HAIKU_ARCH = $(HOST_ARCH) ; 622 HAIKU_KERNEL_ARCH = $(HOST_ARCH) ; 623} 624 625# Set TARGET_* variables either from HAIKU_* or HOST_* depending on the 626# specified TARGET_PLATFORM. Some variables are package architecture dependent 627# and their name gets a respective suffix. A few variables exist both with and 628# without suffix. The latter is either equivalent to the variable with the 629# primary architecture suffix (e.g. TARGET_ARCH) or is (additionally) applicable 630# for all architectures (e.g. TARGET_DEFINES). 631 632local buildVars = 633 ARCH ARCHS KERNEL_ARCH PACKAGING_ARCH PACKAGING_ARCHS 634 635 DEFINES 636 KERNEL_DEFINES 637 638 KERNEL_CCFLAGS KERNEL_C++FLAGS 639 KERNEL_PIC_CCFLAGS KERNEL_PIC_LINKFLAGS KERNEL_ADDON_LINKFLAGS 640 BOOT_CCFLAGS BOOT_C++FLAGS BOOT_LINKFLAGS BOOT_LDFLAGS 641 642 KERNEL_WARNING_CCFLAGS KERNEL_WARNING_C++FLAGS 643 644 KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS 645 KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS 646 647 PRIVATE_KERNEL_HEADERS 648 649 NETWORK_LIBS NETAPI_LIB SELECT_UNAME_ETC_LIB 650 651 EXECUTABLE_MIME_TYPE 652 653 OBJECT_BASE_DIR COMMON_ARCH_OBJECT_DIR 654 ; 655 656local archDependentBuildVars = 657 ARCH CPU GCC_VERSION 658 659 AR CC C++ ELFEDIT LD OBJCOPY RANLIB STRIP 660 661 ARFLAGS ASFLAGS UNARFLAGS CPPFLAGS CCFLAGS C++FLAGS HDRS LDFLAGS 662 LINK LINKFLAGS 663 664 WARNING_CCFLAGS WARNING_C++FLAGS WERROR_FLAGS 665 666 DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS 667 668 INCLUDES_SEPARATOR LOCAL_INCLUDES_OPTION SYSTEM_INCLUDES_OPTION 669 670 PRIVATE_SYSTEM_HEADERS 671 672 ARCH_OBJECT_DIR COMMON_DEBUG_OBJECT_DIR 673 DEBUG_$(HAIKU_DEBUG_LEVELS)_OBJECT_DIR 674 ; 675 676# target platform setup 677local var ; 678for var in $(buildVars) { 679 TARGET_$(var) = $(HAIKU_$(var)) ; 680} 681 682for var in $(archDependentBuildVars)_$(TARGET_PACKAGING_ARCHS) { 683 TARGET_$(var) = $(HAIKU_$(var)) ; 684} 685 686TARGET_BOOT_LIBGCC = $(HAIKU_BOOT_LIBGCC_$(TARGET_PACKAGING_ARCH)) ; 687TARGET_BOOT_LIBSUPC++ = $(HAIKU_BOOT_LIBSUPC++_$(TARGET_PACKAGING_ARCH)) ; 688 689TARGET_BOOT_PLATFORM ?= $(HAIKU_BOOT_PLATFORM) ; 690 691local architecture ; 692for architecture in $(TARGET_PACKAGING_ARCHS) { 693 TARGET_DEFINES_$(architecture) = $(HAIKU_DEFINES_$(architecture)) ; 694 TARGET_LIBRARY_NAME_MAP_$(architecture) 695 = HAIKU_LIBRARY_NAME_MAP_$(architecture) ; 696} 697 698# define macro, for identifying the platform 699switch $(TARGET_PLATFORM) { 700 case haiku : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_HAIKU ; 701 case libbe_test : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_LIBBE_TEST ; 702} 703 704# define macro, for identifying the host platform 705switch $(HOST_PLATFORM) { 706 case haiku_host : HOST_DEFINES += HAIKU_HOST_PLATFORM_HAIKU ; 707 case linux : HOST_DEFINES += HAIKU_HOST_PLATFORM_LINUX ; 708 case freebsd : HOST_DEFINES += HAIKU_HOST_PLATFORM_FREEBSD ; 709 case darwin : HOST_DEFINES += HAIKU_HOST_PLATFORM_DARWIN ; 710 case cygwin : HOST_DEFINES += HAIKU_HOST_PLATFORM_CYGWIN ; 711 case sunos : HOST_DEFINES += HAIKU_HOST_PLATFORM_SUNOS ; 712} 713 714# define host platform 64 bit macro 715if $(HOST_PLATFORM_IS_64_BIT) { 716 HOST_DEFINES += HAIKU_HOST_PLATFORM_64_BIT ; 717} 718 719# define Haiku packaging architecture macro for host build 720HOST_DEFINES += HAIKU_PACKAGING_ARCH=\\\"$(HAIKU_PACKAGING_ARCH)\\\" ; 721 722 723#pragma mark - 724 725# special target libbe_test 726 727if $(TARGET_PLATFORM) = libbe_test { 728 # headers and flags 729 TARGET_HDRS_$(TARGET_PACKAGING_ARCH) += 730 [ PublicHeaders $(DOT) app drivers game interface kernel locale storage 731 support ] 732 [ PrivateHeaders $(DOT) ] ; 733 TARGET_DEFINES += __HAIKU__ ; 734 735 TARGET_PRIVATE_SYSTEM_HEADERS_$(TARGET_PACKAGING_ARCH) = 736 [ PrivateHeaders $(DOT) system system/arch/$(TARGET_ARCH) ] ; 737 738 # directories 739 TARGET_OBJECT_BASE_DIR 740 = [ FDirName $(HAIKU_OBJECT_DIR) $(TARGET_PLATFORM) ] ; 741 TARGET_COMMON_ARCH_OBJECT_DIR 742 = [ FDirName $(TARGET_OBJECT_BASE_DIR) common ] ; 743 TARGET_ARCH_OBJECT_DIR_$(TARGET_PACKAGING_ARCH) 744 = [ FDirName $(TARGET_OBJECT_BASE_DIR) $(TARGET_ARCH) ] ; 745 TARGET_COMMON_DEBUG_OBJECT_DIR_$(TARGET_PACKAGING_ARCH) 746 = [ FDirName $(TARGET_ARCH_OBJECT_DIR_$(TARGET_PACKAGING_ARCH)) 747 common ] ; 748 TARGET_DEBUG_0_OBJECT_DIR_$(TARGET_PACKAGING_ARCH) 749 = [ FDirName $(TARGET_ARCH_OBJECT_DIR_$(TARGET_PACKAGING_ARCH)) 750 release ] ; 751 752 local level ; 753 for level in $(HAIKU_DEBUG_LEVELS[2-]) { 754 TARGET_DEBUG_$(level)_OBJECT_DIR_$(TARGET_PACKAGING_ARCH) 755 = [ FDirName $(TARGET_ARCH_OBJECT_DIR_$(TARGET_PACKAGING_ARCH)) 756 debug_$(level) ] ; 757 } 758 759 # library name map 760 TARGET_LIBRARY_NAME_MAP_$(TARGET_PACKAGING_ARCH) = LIBBE_LIBRARY_NAME_MAP ; 761 LIBBE_LIBRARY_NAME_MAP_be = libbe_test.so ; 762} 763 764 765#pragma mark - common stuff 766 767 768# start with a clean state 769CCFLAGS = ; 770C++FLAGS = ; 771DEFINES = ; 772 773# Set CC, C++, LINK to invalid values, so that we realize early, that we use 774# the wrong compiler. 775CC = bad-cc ; 776C++ = bad-c++ ; 777LINK = bad-link ; 778 779 780# Defaults for warnings, optimization, and debugging. 781# 782WARNINGS ?= 1 ; 783OPTIM ?= -O2 ; 784DEBUG ?= 0 ; 785 786 787# Set a sane default for whether this is a CI build. 788HAIKU_CONTINUOUS_INTEGRATION_BUILD ?= 0 ; 789 790 791# Set the defaults for PLATFORM and SUPPORTED_PLATFORMS. PLATFORM is only 792# overridden for targets to be built for the host platform. SUPPORTED_PLATFORMS 793# can be overridden by the author of a component. 794PLATFORM = $(TARGET_PLATFORM) ; 795SUPPORTED_PLATFORMS = haiku ; 796 797 798# Define two pseudo targets for the target and buildhost platform. The main 799# build rules (Cc, C++, As, ...) depend on these pseude targets such that global 800# initializations that are required before anything is built for a specific 801# platform can be forced by depending the pseudo target for the platform on the 802# initializations. 803# This is currently used to unpack the external headers from the 804# gcc_syslibs_devel build feature before anything is built for the target 805# platform. 806NotFile $(TARGET_PLATFORM) ; 807NotFile host ; 808 809 810# Instructs the Library rule to not make its object files temporary. 811# This is needed as some objects are used in a static library and for an 812# executable. 813KEEPOBJS = true ; 814 815 816# Set permissions to how they should be on the image. 817EXEMODE = 755 ; 818FILEMODE = 644 ; 819SHELLMODE = 755 ; 820 821 822# output directories 823# TODO: Review this. 824HAIKU_DOCUMENTATION_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) documentation ] ; 825HAIKU_DOCUMENTATION_OBJECT_DIR ?= [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) 826 documentation ] ; 827 828# TODO: Rethink test stuff. 829HAIKU_TEST_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) tests 830 $(TARGET_PLATFORM) $(HAIKU_ARCH) ] ; 831HAIKU_APP_TEST_DIR ?= [ FDirName $(HAIKU_TEST_DIR) apps ] ; 832HAIKU_APP_TEST_LIB_DIR ?= [ FDirName $(HAIKU_APP_TEST_DIR) lib ] ; 833HAIKU_TMP_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) tmp ] ; 834 835local architecture ; 836for architecture in $(HAIKU_PACKAGING_ARCHS) { 837 local baseDir 838 = [ FDirName $(TARGET_OBJECT_BASE_DIR) $(architecture) packaging ] ; 839 HAIKU_PACKAGES_DIR_$(architecture) = [ FDirName $(baseDir) packages ] ; 840 HAIKU_PACKAGES_BUILD_DIR_$(architecture) 841 = [ FDirName $(baseDir) packages_build ] ; 842 HAIKU_PACKAGE_REPOSITORIES_DIR_$(architecture) 843 = [ FDirName $(baseDir) repositories ] ; 844} 845 846 847HAIKU_PACKAGE_INFOS_DIR = [ FDirName $(HAIKU_TOP) src data 848 package_infos ] ; 849 850TARGET_TEST_DIR ?= [ FDirName $(HAIKU_TEST_DIR) 851 $(TARGET_PLATFORM) ] ; 852TARGET_UNIT_TEST_DIR ?= [ FDirName $(TARGET_TEST_DIR) unittests ] ; 853TARGET_UNIT_TEST_LIB_DIR ?= [ FDirName $(TARGET_UNIT_TEST_DIR) lib ] ; 854 855# automatically setup the objects directory per subdirectory 856SUBDIRRULES += SetupObjectsDir ; 857 858# Add the standard (userland) warning flags variables to the ones restored in 859# every subdirectory. Thus we can easily meddle with them in subdirectories 860# with imported sources. 861AUTO_SET_UP_CONFIG_VARIABLES += 862 HOST_WARNING_CCFLAGS HOST_WARNING_C++FLAGS 863 TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCHS) 864 TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCHS) 865 ; 866 867# also add PLATFORM and SUPPORTED_PLATFORMS 868AUTO_SET_UP_CONFIG_VARIABLES += PLATFORM SUPPORTED_PLATFORMS ; 869 870 871# set up warnings 872local architecture ; 873for architecture in $(TARGET_PACKAGING_ARCHS) { 874 ArchitectureSetupWarnings $(architecture) ; 875} 876 877 878# set up architecture build features 879local architecture ; 880for architecture in $(TARGET_PACKAGING_ARCHS) { 881 InitArchitectureBuildFeatures $(architecture) ; 882} 883 884 885# The following directories cannot currently be compiled with DEBUG=1 886SetConfigVar DEBUG : HAIKU_TOP src add-ons disk_systems bfs : 0 : local ; 887SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel drivers audio hda : 0 : local ; 888SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel drivers audio ac97 auich : 0 : local ; # fails with gcc4 only 889SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel drivers audio ac97 auvia : 0 : local ; # fails with gcc4 only 890SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel drivers audio ac97 sis7018 : 0 : local ; 891SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel file_systems btrfs : 0 : local ; 892SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel file_systems ntfs libntfs : 0 : local ; 893SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel file_systems udf : 0 : local ; 894SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel file_systems userlandfs server : 0 : local ; # fails with gcc2 only 895SetConfigVar DEBUG : HAIKU_TOP src add-ons kernel file_systems userlandfs server haiku : 0 : local ; # fails with gcc2 only 896SetConfigVar DEBUG : HAIKU_TOP src add-ons media media-add-ons dvb : 0 : local ; 897SetConfigVar DEBUG : HAIKU_TOP src add-ons print drivers gutenprint : 0 : local ; 898SetConfigVar DEBUG : HAIKU_TOP src servers input : 0 : local ; 899SetConfigVar DEBUG : HAIKU_TOP src servers media_addon : 0 : local ; 900SetConfigVar DEBUG : HAIKU_TOP src system boot loader file_systems bfs : 0 : local ; 901