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