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