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