1 2# Variable naming conventions: 3# TARGET_*: A build system variable specifying a property for building for 4# the target platform (usually Haiku). E.g. TARGET_CC specifies the 5# compiler when building a target for the target platform. 6# HOST_*: A build system variable specifying a property of the platform 7# hosting the build. E.g. HOST_CC specifies the compiler when 8# building a target for the host platform (a build tool for 9# instance). 10# HAIKU_*: A build system variable specifying a build system property. Usually 11# directory paths and the like. 12 13 14# Include BuildConfig/Timezones/libgccObjects 15{ 16 local buildConfig = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : BuildConfig ] ; 17 local timezones = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : Timezones ] ; 18 local libgccObjects = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : libgccObjects ] ; 19 20 if ! $(buildConfig) { 21 ECHO "No `BuildConfig' found in $(HAIKU_BUILD_OUTPUT_DIR)!" ; 22 EXIT "Run ./configure in the source tree's root directory first!" ; 23 } 24 if ! ( $(timezones) && $(libgccObjects) ) { 25 ECHO "No `Timezones' or `libgccObjects' found in $(HAIKU_BUILD_OUTPUT_DIR)!" ; 26 EXIT "Please run ./configure in the source tree's root directory again!" ; 27 } 28 29 LOCATE on BuildConfig = $(HAIKU_BUILD_OUTPUT_DIR) ; 30 LOCATE on Timezones = $(HAIKU_BUILD_OUTPUT_DIR) ; 31 LOCATE on libgccObjects = $(HAIKU_BUILD_OUTPUT_DIR) ; 32 33 include BuildConfig ; 34 include Timezones ; 35 include libgccObjects ; 36} 37 38 39# supported debug levels 40HAIKU_DEBUG_LEVELS = 0 1 2 3 4 5 ; 41 42# BeOS, BONE, Dan0 compatible platforms 43HAIKU_BEOS_COMPATIBLE_PLATFORMS = haiku r5 bone dano ; 44HAIKU_BONE_COMPATIBLE_PLATFORMS = haiku bone dano ; 45HAIKU_DANO_COMPATIBLE_PLATFORMS = haiku dano ; 46 47 48#pragma mark - 49 50# haiku target platform settings 51 52# initial state for flags etc. 53HAIKU_C++ ?= $(HAIKU_CC) ; 54HAIKU_LINK = $(HAIKU_CC) ; 55HAIKU_LINKFLAGS = ; 56 57HAIKU_HDRS = [ FStandardHeaders ] ; 58HAIKU_CCFLAGS = -nostdinc ; 59HAIKU_C++FLAGS = -nostdinc ; 60HAIKU_DEFINES = __HAIKU__ ; 61 62# analyze the gcc machine spec to determine HAIKU_CPU 63switch $(HAIKU_GCC_MACHINE) { 64 case i386-* : HAIKU_CPU = x86 ; 65 case i486-* : HAIKU_CPU = x86 ; 66 case i586-* : HAIKU_CPU = x86 ; 67 case i686-* : HAIKU_CPU = x86 ; 68 case powerpc-* : HAIKU_CPU = ppc ; 69 case * : Exit "Unsupported gcc target machine:" $(HAIKU_GCC_MACHINE) ; 70} 71 72switch $(HAIKU_CPU) { 73 case ppc : 74 { 75 HAIKU_DEFINES += __POWERPC__ ; 76 HAIKU_BOOT_PLATFORM = openfirmware ; 77 } 78 case x86 : 79 { 80 HAIKU_DEFINES += __INTEL__ ; 81 HAIKU_BOOT_PLATFORM = bios_ia32 ; 82 } 83 case * : 84 Exit "Currently unsupported target CPU:" $(HAIKU_CPU) ; 85} 86HAIKU_ARCH ?= $(HAIKU_CPU) ; 87HAIKU_ARCH_MACRO_DEFINE = ARCH_$(HAIKU_ARCH) ; 88HAIKU_DEFINES += $(HAIKU_ARCH_MACRO_DEFINE) ; 89 90# directories 91HAIKU_OBJECT_BASE_DIR = [ FDirName $(HAIKU_OBJECT_DIR) haiku ] ; 92HAIKU_COMMON_ARCH_OBJECT_DIR = [ FDirName $(HAIKU_OBJECT_BASE_DIR) common ] ; 93HAIKU_ARCH_OBJECT_DIR = [ FDirName $(HAIKU_OBJECT_BASE_DIR) $(HAIKU_ARCH) ] ; 94HAIKU_COMMON_DEBUG_OBJECT_DIR = [ FDirName $(HAIKU_ARCH_OBJECT_DIR) common ] ; 95HAIKU_DEBUG_0_OBJECT_DIR = [ FDirName $(HAIKU_ARCH_OBJECT_DIR) release ] ; 96 97local level ; 98for level in $(HAIKU_DEBUG_LEVELS[2-]) { 99 HAIKU_DEBUG_$(level)_OBJECT_DIR 100 = [ FDirName $(HAIKU_ARCH_OBJECT_DIR) debug_$(level) ] ; 101} 102 103# analyze GCC version 104HAIKU_GCC_VERSION = [ FAnalyzeGCCVersion HAIKU_GCC_RAW_VERSION ] ; 105 106# set variables for gcc header options 107SetIncludePropertiesVariables HAIKU ; 108 109# assembler flags 110HAIKU_ASFLAGS = ; 111 112# C/C++ flags 113HAIKU_CCFLAGS += -Wno-multichar ; 114HAIKU_C++FLAGS += -Wno-multichar ; 115 116HAIKU_KERNEL_CCFLAGS += -finline -fno-builtin 117 -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; 118HAIKU_KERNEL_C++FLAGS += -finline -fno-builtin -fno-exceptions 119 -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; 120 121if $(HAIKU_GCC_VERSION[1]) >= 3 { 122 HAIKU_KERNEL_C++FLAGS += -fno-use-cxa-atexit ; 123} 124 125HAIKU_KERNEL_PIC_CCFLAGS = -fno-pic ; 126HAIKU_KERNEL_PIC_LINKFLAGS = ; 127if $(HAIKU_ARCH) = ppc { 128 # Build a position independent PPC kernel. We need to be able to relocate 129 # the kernel, since the virtual address space layout at boot time is not 130 # fixed. 131 HAIKU_KERNEL_PIC_CCFLAGS = -fPIE ; 132 HAIKU_KERNEL_PIC_LINKFLAGS = -shared -fPIE ; 133} 134 135# If the environment variable DEBUG_PRINTF is defined we define an equally 136# named macro to the variable value. Some components use the macro to allow 137# another function than printf() to print the debug output. The variable should 138# be set to the name of the alternative function. 139# 140if $(DEBUG_PRINTF) { 141 HAIKU_CCFLAGS += [ FDefines DEBUG_PRINTF=$(DEBUG_PRINTF) ] ; 142 HAIKU_C++FLAGS += [ FDefines DEBUG_PRINTF=$(DEBUG_PRINTF) ] ; 143} 144 145# warning flags 146HAIKU_WARNING_CCFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wcast-align 147 -Wsign-compare ; 148HAIKU_WARNING_C++FLAGS = -Wall -Wno-ctor-dtor-privacy 149 -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare ; 150 151HAIKU_KERNEL_WARNING_CCFLAGS = -Wall -Wmissing-prototypes ; 152HAIKU_KERNEL_WARNING_C++FLAGS = -Wall ; 153 154# debug flags 155HAIKU_DEBUG_FLAGS ?= -ggdb ; 156 157# debug 0: suppress asserts 158HAIKU_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 159HAIKU_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 160 161HAIKU_KERNEL_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 162HAIKU_KERNEL_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 163 164local level ; 165for level in $(HAIKU_DEBUG_LEVELS[2-]) { 166 local flags = $(HAIKU_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ; 167 HAIKU_DEBUG_$(level)_CCFLAGS = $(flags) ; 168 HAIKU_DEBUG_$(level)_C++FLAGS = $(flags) ; 169 HAIKU_KERNEL_DEBUG_$(level)_CCFLAGS = $(flags) ; 170 HAIKU_KERNEL_DEBUG_$(level)_C++FLAGS = $(flags) ; 171} 172 173if $(HAIKU_GCC_VERSION[1]) >= 3 { 174 # TODO: Temporary work-around. Should be defined in the compiler specs 175 HAIKU_LINKFLAGS += -Xlinker --no-undefined ; 176} else { 177 HAIKU_DEFINES += _BEOS_R5_COMPATIBLE_ ; 178} 179 180# private kernel headers do be used when compiling kernel code 181HAIKU_PRIVATE_KERNEL_HEADERS = 182 [ PrivateHeaders $(DOT) kernel libroot 183 kernel/boot/platform/$(HAIKU_BOOT_PLATFORM) ] 184 [ ArchHeaders $(HAIKU_ARCH) ] 185; 186 187# Add some grist to the libgcc objects 188HAIKU_GCC_LIBGCC_OBJECTS = $(HAIKU_GCC_LIBGCC_OBJECTS:G=libgcc) ; 189 190# the C++ library 191if $(HAIKU_SHARED_LIBSTDC++) { 192 HAIKU_LIBSTDC++ = $(HAIKU_SHARED_LIBSTDC++) ; 193} else if $(HAIKU_STATIC_LIBSTDC++) { 194 HAIKU_LIBSTDC++ = $(HAIKU_STATIC_LIBSTDC++) ; 195} else { 196 HAIKU_LIBSTDC++ = libstdc++.r4.so ; 197} 198 199# the C++ support library 200if $(HAIKU_SHARED_LIBSUPC++) { 201 HAIKU_LIBSUPC++ = $(HAIKU_SHARED_LIBSUPC++) ; 202} else if $(HAIKU_STATIC_LIBSUPC++) { 203 HAIKU_LIBSUPC++ = $(HAIKU_STATIC_LIBSUPC++) ; 204} else { 205 HAIKU_LIBSUPC++ = ; 206} 207 208# library and executable glue code 209local commonGlueCode = 210 <src!system!glue>init_term_dyn.o 211 <src!system!glue!arch!$(HAIKU_ARCH)>crti.o 212 <src!system!glue!arch!$(HAIKU_ARCH)>crtn.o 213; 214HAIKU_LIBRARY_BEGIN_GLUE_CODE = 215 <src!system!glue!arch!$(HAIKU_ARCH)>crti.o 216 crtbegin.o 217 <src!system!glue>init_term_dyn.o 218; 219HAIKU_LIBRARY_END_GLUE_CODE = 220 # TODO: For the time being always link against libsupc++.a. 221 $(HAIKU_STATIC_LIBSUPC++) 222 crtend.o 223 <src!system!glue!arch!$(HAIKU_ARCH)>crtn.o 224; 225HAIKU_EXECUTABLE_BEGIN_GLUE_CODE = 226 <src!system!glue!arch!$(HAIKU_ARCH)>crti.o 227 crtbegin.o 228 <src!system!glue>start_dyn.o 229 <src!system!glue>init_term_dyn.o 230; 231HAIKU_EXECUTABLE_END_GLUE_CODE = $(HAIKU_LIBRARY_END_GLUE_CODE) ; 232HAIKU_KERNEL_ADDON_BEGIN_GLUE_CODE = crtbegin.o ; 233HAIKU_KERNEL_ADDON_END_GLUE_CODE = crtend.o ; 234 235SEARCH on crtbegin.o crtend.o = $(HAIKU_GCC_LIB_DIR) ; 236 237HAIKU_EXECUTABLE_MIME_TYPE = "application/x-vnd.Be-elfexecutable" ; 238 239# TODO: The version stuff should probably go into a separate file and be made 240# available as macro, too. 241# Set our version number if not already set and mark it as a developer build 242if ! $(HAIKU_BUILD_VERSION) { 243 HAIKU_BUILD_VERSION ?= "1 0 0 a 1" ; 244 HAIKU_BUILD_DESCRIPTION ?= "Developer Build" ; 245} 246 247# If HAIKU_BUILD_VERSION is set, but HAIKU_BUILD_DESCRIPTION isn't, mark it as 248# an unknown build. 249HAIKU_BUILD_DESCRIPTION ?= "Unknown Build" ; 250 251# init library name map 252{ 253 local i ; 254 for i in be game GL mail media midi midi2 network netapi opengl screensaver root z 255 textencoding tracker translation { 256 HAIKU_LIBRARY_NAME_MAP_$(i) = lib$(i).so ; 257 } 258 HAIKU_LIBRARY_NAME_MAP_libstdc++ = $(HAIKU_LIBSTDC++) ; 259} 260 261 262#pragma mark - 263 264# host platform settings 265 266# save jam's variables for the build platform 267HOST_AR ?= $(AR) ; 268HOST_CC ?= $(CC) ; 269HOST_C++ ?= $(C++) ; 270HOST_LINK ?= $(LINK) ; 271HOST_LD ?= ld ; # TODO: Fix this! 272HOST_OBJCOPY ?= objcopy ; # 273HOST_RANLIB ?= $(RANLIB) ; 274HOST_CPPFLAGS ?= $(CPPFLAGS) ; 275HOST_CCFLAGS ?= $(CCFLAGS) ; 276HOST_C++FLAGS ?= $(C++FLAGS) ; 277HOST_LDFLAGS ?= $(LDFLAGS) ; 278HOST_LINKFLAGS ?= $(LINKFLAGS) ; 279HOST_DEFINES ?= $(DEFINES) ; 280HOST_HDRS ?= $(HDRS) ; 281 282# split up HOST_AR into the command name and flags 283HOST_AR = [ Match "([^ ]*) *(.*)" : $(HOST_AR[1]) ] 284 $(HOST_AR[2-]) ; 285HOST_ARFLAGS = $(HOST_AR[2-]) ; 286HOST_AR = $(HOST_AR[1]) ; 287HOST_UNARFLAGS ?= x ; 288 289# check the host platform compatibility 290SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host : linux freebsd ; 291 292if $(HOST_PLATFORM) = linux { 293 # don't use lex: otherwise rc will not work correctly 294 if $(LEX) = lex { 295 LEX = flex ; 296 } 297} 298 299HOST_CPU ?= $(OSPLAT:L) ; 300 301HOST_ARCH ?= $(HOST_CPU) ; 302HOST_ARCH_MACRO_DEFINE = ARCH_$(HOST_CPU) ; 303 304# directories 305HOST_OBJECT_BASE_DIR = [ FDirName $(HAIKU_OBJECT_DIR) $(HOST_PLATFORM) ] ; 306HOST_COMMON_ARCH_OBJECT_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) common ] ; 307HOST_ARCH_OBJECT_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) $(HOST_ARCH) ] ; 308HOST_COMMON_DEBUG_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) common ] ; 309HOST_DEBUG_0_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) release ] ; 310 311local level ; 312for level in $(HAIKU_DEBUG_LEVELS[2-]) { 313 HOST_DEBUG_$(level)_OBJECT_DIR 314 = [ FDirName $(HOST_ARCH_OBJECT_DIR) debug_$(level) ] ; 315} 316 317# analyze GCC version 318HOST_GCC_VERSION = [ FAnalyzeGCCVersion HOST_GCC_RAW_VERSION ] ; 319 320# set variables for gcc header options 321SetIncludePropertiesVariables HOST ; 322 323# assembler flags 324HOST_ASFLAGS = ; 325 326# C/C++ flags 327HOST_CCFLAGS += -Wno-multichar ; 328HOST_C++FLAGS += -Wno-multichar ; 329 330HOST_KERNEL_CCFLAGS += -finline -fno-builtin 331 -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; 332HOST_KERNEL_C++FLAGS += -finline -fno-builtin -fno-exceptions 333 -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; 334 335HOST_KERNEL_PIC_CCFLAGS = -fno-pic ; 336HOST_KERNEL_PIC_LINKFLAGS = ; 337if $(HOST_ARCH) = ppc { 338 # Build a position independent PPC kernel. We need to be able to relocate 339 # the kernel, since the virtual address space layout at boot time is not 340 # fixed. 341 HOST_KERNEL_PIC_CCFLAGS = -fPIE ; 342 HOST_KERNEL_PIC_LINKFLAGS = -shared -fPIE ; 343} 344 345# warning flags 346HOST_WARNING_CCFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wcast-align 347 -Wsign-compare ; 348HOST_WARNING_C++FLAGS = -Wall -Wno-ctor-dtor-privacy 349 -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare ; 350 351HOST_KERNEL_WARNING_CCFLAGS = -Wall -Wmissing-prototypes ; 352HOST_KERNEL_WARNING_C++FLAGS = -Wall ; 353 354# debug flags 355switch $(HOST_PLATFORM) { 356 case haiku : HOST_DEBUG_FLAGS ?= -ggdb ; 357 case linux : HOST_DEBUG_FLAGS ?= -ggdb ; 358 case freebsd : HOST_DEBUG_FLAGS ?= -ggdb ; 359 case * : HOST_DEBUG_FLAGS ?= -g ; 360} 361 362# debug 0: suppress asserts 363HOST_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 364HOST_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 365 366HOST_KERNEL_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 367HOST_KERNEL_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 368 369local level ; 370for level in $(HAIKU_DEBUG_LEVELS[2-]) { 371 local flags = $(HOST_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ; 372 HOST_DEBUG_$(level)_CCFLAGS = $(flags) ; 373 HOST_DEBUG_$(level)_C++FLAGS = $(flags) ; 374 HOST_KERNEL_DEBUG_$(level)_CCFLAGS = $(flags) ; 375 HOST_KERNEL_DEBUG_$(level)_C++FLAGS = $(flags) ; 376} 377 378# private kernel headers do be used when compiling kernel code 379HOST_PRIVATE_KERNEL_HEADERS = ; 380 381# under BeOS use copyattr instead of cp 382if $(HOST_PLATFORM_BEOS_COMPATIBLE) 383{ 384 CP = copyattr --data ; 385} 386 387HOST_DEFINES += $(HOST_ARCH_MACRO_DEFINE) ; 388HOST_DEFINES += _NO_INLINE_ASM ; 389 390if $(HOST_PLATFORM_BEOS_COMPATIBLE) { 391 # TODO: That's obviously not correct, but in the way the COMPILE_FOR_R5 392 # macro is used, it actually seems to mean r5/bone/dano. 393 # TODO: Deprecated. Remove! 394 HOST_DEFINES += COMPILE_FOR_R5 ; 395} 396 397# for builds of tools in the current environment 398HOST_BUILD_COMPATIBILITY_LIB_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) lib ] ; 399 400if $(HOST_PLATFORM_BEOS_COMPATIBLE) { 401 HOST_LIBSTDC++ = stdc++.r4 ; 402 HOST_LIBROOT = root ; 403 HOST_LIBBE = be ; 404 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR = ; 405} else { 406 HOST_LIBSTDC++ = stdc++ ; 407 HOST_LIBROOT = libroot_build.so ; 408 HOST_LIBBE = libbe_build.so ; 409 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR 410 = "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ; 411 412 # the C++ support library 413 if $(HOST_GCC_VERSION[1]) < 3 { 414 HOST_LIBSUPC++ = ; 415 } else { 416 HOST_LIBSUPC++ = supc++ ; 417 } 418 419 # The BeOS compilers define __INTEL__ respectively __POWERPC__. On the 420 # build platform we need to make sure, this is also defined. 421 if $(HOST_CPU) = x86 { 422 HOST_DEFINES += __INTEL__ ; 423 } else if $(HOST_CPU) = ppc { 424 HOST_DEFINES += __POWERPC__ ; 425 } 426 427 # Supposing this is a glibc platform, let's try to get large file support 428 HOST_DEFINES += 429 _LARGEFILE_SOURCE _LARGEFILE64_SOURCE _FILE_OFFSET_BITS=64 430 ; 431} 432 433# define the executable MIME type 434HOST_EXECUTABLE_MIME_TYPE = "application/x-vnd.Be-elfexecutable" ; 435 436if $(METROWERKS) { 437 # at least parts of Haiku still can be compiled with 438 # the Metrowerks compiler on BeOS/PPC 439 HOST_EXECUTABLE_MIME_TYPE = "application/x-be-executable" ; 440} 441 442# Be API compatibility 443HOST_BE_API_HEADERS = ; 444HOST_BE_API_CCFLAGS = ; 445HOST_BE_API_C++FLAGS = ; 446 447if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) { 448 HOST_BE_API_HEADERS = 449 [ FDirName $(HAIKU_TOP) headers build ] 450 [ FDirName $(HAIKU_TOP) headers build os ] 451 [ FDirName $(HAIKU_TOP) headers build os app ] 452 [ FDirName $(HAIKU_TOP) headers build os drivers ] 453 [ FDirName $(HAIKU_TOP) headers build os kernel ] 454 [ FDirName $(HAIKU_TOP) headers build os interface ] 455 [ FDirName $(HAIKU_TOP) headers build os storage ] 456 [ FDirName $(HAIKU_TOP) headers build os support ] 457 ; 458 HOST_BE_API_CCFLAGS = -include BeOSBuildCompatibility.h ; 459 HOST_BE_API_C++FLAGS = $(HOST_BE_API_CCFLAGS) ; 460} 461 462 463#pragma mark - 464 465# target platform settings 466 467# check the target platform compatibility 468SetPlatformCompatibilityFlagVariables TARGET_PLATFORM : TARGET : target ; 469 470# check the compatibility between host and target platform 471if $(TARGET_PLATFORM) != haiku { 472 if ! $(HOST_PLATFORM_($(TARGET_PLATFORM))_COMPATIBLE) { 473 Exit ERROR: The host platform is not compatible with target platform 474 $(TARGET_PLATFORM). ; 475 } 476} 477 478# TODO: Fix the naming! 479if $(TARGET_PLATFORM) = haiku { 480 NETWORK_LIBS = network ; 481 SELECT_UNAME_ETC_LIB = root ; 482 NETAPI_LIB = netapi ; 483} else if $(TARGET_PLATFORM_BONE_COMPATIBLE) { 484 NETWORK_LIBS = socket bind ; 485 NETAPI_LIB = bnetapi ; 486 SELECT_UNAME_ETC_LIB = root ; 487} else { 488 NETWORK_LIBS = net ; 489 NETAPI_LIB = netapi ; 490 SELECT_UNAME_ETC_LIB = net ; 491} 492 493# TODO: For compatibility only. Remove when no longer used. 494R5_COMPATIBLE = $(TARGET_PLATFORM_BEOS_COMPATIBLE) ; 495BONE_COMPATIBLE = $(TARGET_PLATFORM_BONE_COMPATIBLE) ; 496DANO_COMPATIBLE = $(TARGET_PLATFORM_DANO_COMPATIBLE) ; 497HAIKU_COMPATIBLE = $(TARGET_PLATFORM_HAIKU_COMPATIBLE) ; 498 499# Set TARGET_* variables either from HAIKU_* or HOST_* depending on the 500# specified TARGET_PLATFORM. 501 502local buildVars = 503 ARCH CPU GCC_VERSION 504 505 AR CC C++ LD OBJCOPY RANLIB 506 507 INCLUDES_SEPARATOR LOCAL_INCLUDES_OPTION SYSTEM_INCLUDES_OPTION 508 509 HDRS CPPFLAGS CCFLAGS C++FLAGS LDFLAGS LINK LINKFLAGS DEFINES 510 ARFLAGS UNARFLAGS 511 512 KERNEL_CCFLAGS KERNEL_C++FLAGS 513 KERNEL_PIC_CCFLAGS KERNEL_PIC_LINKFLAGS 514 WARNING_CCFLAGS WARNING_C++FLAGS 515 516 KERNEL_WARNING_CCFLAGS KERNEL_WARNING_C++FLAGS 517 518 DEBUG_FLAGS 519 520 DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS 521 522 KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS 523 KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS 524 525 PRIVATE_KERNEL_HEADERS 526 527 LIBSTDC++ LIBSUPC++ 528 529 ARCH_MACRO_DEFINE EXECUTABLE_MIME_TYPE 530 531 OBJECT_BASE_DIR COMMON_ARCH_OBJECT_DIR COMMON_DEBUG_OBJECT_DIR 532 DEBUG_$(HAIKU_DEBUG_LEVELS)_OBJECT_DIR 533; 534 535if $(TARGET_PLATFORM) = haiku { 536 local var ; 537 for var in $(buildVars) { 538 TARGET_$(var) = $(HAIKU_$(var)) ; 539 } 540 541 TARGET_GCC_LIB_DIR = $(HAIKU_GCC_LIB_DIR) ; 542 TARGET_GCC_HEADERS_DIR = $(HAIKU_GCC_HEADERS_DIR) ; 543 TARGET_GCC_LIBGCC = $(HAIKU_GCC_LIBGCC) ; 544 TARGET_GCC_LIBGCC_OBJECTS = $(HAIKU_GCC_LIBGCC_OBJECTS) ; 545 546 TARGET_BOOT_PLATFORM = $(HAIKU_BOOT_PLATFORM) ; 547 548 TARGET_LIBRARY_NAME_MAP = HAIKU_LIBRARY_NAME_MAP ; 549 550} else { 551 local var ; 552 for var in $(buildVars) { 553 TARGET_$(var) = $(HOST_$(var)) ; 554 } 555 556 TARGET_GCC_LIB_DIR = ; 557 TARGET_GCC_HEADERS_DIR = ; 558 TARGET_GCC_LIBGCC = ; 559 TARGET_GCC_LIBGCC_OBJECTS = ; 560 561 TARGET_BOOT_PLATFORM = ; 562 563 TARGET_LIBRARY_NAME_MAP = ; 564} 565 566# define macro, for identifying the platform 567switch $(TARGET_PLATFORM) { 568 case r5 : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_BEOS ; 569 case bone : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_BONE ; 570 case dano : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_DANO ; 571 case haiku : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_HAIKU ; 572 case linux : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_LINUX ; 573 case freebsd : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_FREEBSD ; 574 case libbe_test : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_LIBBE_TEST ; 575} 576 577# define macro, for identifying the host platform 578switch $(HOST_PLATFORM) { 579 case r5 : HOST_DEFINES += HAIKU_HOST_PLATFORM_BEOS ; 580 case bone : HOST_DEFINES += HAIKU_HOST_PLATFORM_BONE ; 581 case dano : HOST_DEFINES += HAIKU_HOST_PLATFORM_DANO ; 582 case haiku : HOST_DEFINES += HAIKU_HOST_PLATFORM_HAIKU ; 583 case linux : HOST_DEFINES += HAIKU_HOST_PLATFORM_LINUX ; 584 case freebsd : HOST_DEFINES += HAIKU_HOST_PLATFORM_FREEBSD ; 585} 586 587 588#pragma mark - 589 590# In case we build for a BeOS compatible platform, but not for Haiku, we 591# include the HaikuBuildCompatibility.h header and link against 592# libhaikucompat.a. 593 594if $(TARGET_PLATFORM) != haiku && $(TARGET_PLATFORM_BEOS_COMPATIBLE) { 595 # headers and flags 596 local compatibilityHeader = -include [ FDirName $(HAIKU_TOP) headers build 597 HaikuBuildCompatibility.h ] ; 598 TARGET_CCFLAGS += $(compatibilityHeader) ; 599 TARGET_C++FLAGS += $(compatibilityHeader) ; 600 601 # compatibility library 602 TARGET_HAIKU_COMPATIBILITY_LIBS = libhaikucompat.a ; 603} 604 605# special target libbe_test 606 607if $(TARGET_PLATFORM) = libbe_test { 608 # headers and flags 609 TARGET_HDRS += [ PublicHeaders app game interface storage support ] 610 [ PrivateHeaders $(DOT) ] ; 611 TARGET_DEFINES += __HAIKU__ ; 612 613 # directories 614 TARGET_OBJECT_BASE_DIR 615 = [ FDirName $(HAIKU_OBJECT_DIR) $(TARGET_PLATFORM) ] ; 616 TARGET_COMMON_ARCH_OBJECT_DIR 617 = [ FDirName $(TARGET_OBJECT_BASE_DIR) common ] ; 618 TARGET_ARCH_OBJECT_DIR 619 = [ FDirName $(TARGET_OBJECT_BASE_DIR) $(TARGET_ARCH) ] ; 620 TARGET_COMMON_DEBUG_OBJECT_DIR 621 = [ FDirName $(TARGET_ARCH_OBJECT_DIR) common ] ; 622 TARGET_DEBUG_0_OBJECT_DIR 623 = [ FDirName $(TARGET_ARCH_OBJECT_DIR) release ] ; 624 625 local level ; 626 for level in $(HAIKU_DEBUG_LEVELS[2-]) { 627 TARGET_DEBUG_$(level)_OBJECT_DIR 628 = [ FDirName $(TARGET_ARCH_OBJECT_DIR) debug_$(level) ] ; 629 } 630 631 # library name map 632 TARGET_LIBRARY_NAME_MAP = LIBBE_LIBRARY_NAME_MAP ; 633 LIBBE_LIBRARY_NAME_MAP_be = libbe_haiku.so ; 634} 635 636 637#pragma mark - 638 639# common stuff 640 641# start with a clean slate 642CCFLAGS = ; 643C++FLAGS = ; 644DEFINES = ; 645 646# Set CC, C++, LINK to invalid values, so that we realize early, that we use 647# the wrong compiler. 648CC = bad-cc ; 649C++ = bad-c++ ; 650LINK = bad-link ; 651 652# Allow compiling unit tests on Zeta. Instead of fixing the PostMessage() 653# issues, they deprecated that nice function. This will enable it again: 654C++FLAGS += -D_ZETA_USING_DEPRECATED_API_=1 ; 655# Same for buggy find_directory threadsafety fixes 656C++FLAGS += -D_ZETA_TS_FIND_DIR_=1 ; 657 # TODO: Doesn't really belong here. 658 659 660# Defaults for warnings, optimization, and debugging. 661# 662WARNINGS ?= 1 ; 663OPTIM ?= -O2 ; 664DEBUG ?= 0 ; 665 666 667# Set the defaults for PLATFORM and SUPPORTED_PLATFORMS. PLATFORM is only 668# overridden for targets to be built for the host platform. SUPPORTED_PLATFORMS 669# can be overridden by the author of a component. 670PLATFORM = $(TARGET_PLATFORM) ; 671SUPPORTED_PLATFORMS = haiku ; 672 673 674# Instructs the Library rule to not make its object files temporary. 675# This is needed as some objects are used in a static library and for an 676# executable. 677KEEPOBJS = true ; 678 679 680# output directories 681# TODO: Review this. 682HAIKU_DOCUMENTATION_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) documentation ] ; 683HAIKU_DOCUMENTATION_OBJECT_DIR ?= [ FDirName $(HAIKU_COMMON_PLATFORM_DIR) 684 documentation ] ; 685 686# TODO: Rethink test stuff. 687HAIKU_TEST_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) tests $(TARGET_PLATFORM) $(HAIKU_ARCH) ] ; 688HAIKU_APP_TEST_DIR ?= [ FDirName $(HAIKU_TEST_DIR) apps ] ; 689HAIKU_APP_TEST_LIB_DIR ?= [ FDirName $(HAIKU_APP_TEST_DIR) lib ] ; 690HAIKU_TMP_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) tmp ] ; 691 692HAIKU_PACKAGE_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) packages ] ; 693HAIKU_PACKAGE_OBJECT_DIR ?= [ FDirName $(HAIKU_OBJECT_DIR) packages ] ; 694 695TARGET_TEST_DIR ?= [ FDirName $(HAIKU_TEST_DIR) 696 $(TARGET_PLATFORM) ] ; 697TARGET_UNIT_TEST_DIR ?= [ FDirName $(TARGET_TEST_DIR) unittests ] ; 698TARGET_UNIT_TEST_LIB_DIR ?= [ FDirName $(TARGET_UNIT_TEST_DIR) lib ] ; 699 700# automatically setup the objects directory per subdirectory 701SUBDIRRULES += SetupObjectsDir ; 702 703# Add the standard (userland) warning flags variables to the ones restored in 704# every subdirectory. Thus we can easily meddle with them in subdirectories 705# with imported sources. 706AUTO_SET_UP_CONFIG_VARIABLES += 707 HOST_WARNING_CCFLAGS HOST_WARNING_C++FLAGS 708 TARGET_WARNING_CCFLAGS TARGET_WARNING_C++FLAGS 709 710 # also add PLATFORM and SUPPORTED_PLATFORMS 711 PLATFORM SUPPORTED_PLATFORMS 712; 713