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 HAIKU_LIBRARY_NAME_MAP_input_server = <nogrist>input_server ; 260} 261 262 263#pragma mark - 264 265# host platform settings 266 267# save jam's variables for the build platform 268HOST_AR ?= $(AR) ; 269HOST_CC ?= $(CC) ; 270HOST_C++ ?= $(C++) ; 271HOST_LINK ?= $(LINK) ; 272HOST_LD ?= ld ; # TODO: Fix this! 273HOST_OBJCOPY ?= objcopy ; # 274HOST_RANLIB ?= $(RANLIB) ; 275HOST_CPPFLAGS ?= $(CPPFLAGS) ; 276HOST_CCFLAGS ?= $(CCFLAGS) ; 277HOST_C++FLAGS ?= $(C++FLAGS) ; 278HOST_LDFLAGS ?= $(LDFLAGS) ; 279HOST_LINKFLAGS ?= $(LINKFLAGS) ; 280HOST_DEFINES ?= $(DEFINES) ; 281HOST_HDRS ?= $(HDRS) ; 282 283# split up HOST_AR into the command name and flags 284HOST_AR = [ Match "([^ ]*) *(.*)" : $(HOST_AR[1]) ] 285 $(HOST_AR[2-]) ; 286HOST_ARFLAGS = $(HOST_AR[2-]) ; 287HOST_AR = $(HOST_AR[1]) ; 288HOST_UNARFLAGS ?= x ; 289 290# check the host platform compatibility 291SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host : linux freebsd ; 292 293if $(HOST_PLATFORM) = linux { 294 # don't use lex: otherwise rc will not work correctly 295 if $(LEX) = lex { 296 LEX = flex ; 297 } 298} 299 300HOST_CPU ?= $(OSPLAT:L) ; 301 302HOST_ARCH ?= $(HOST_CPU) ; 303HOST_ARCH_MACRO_DEFINE = ARCH_$(HOST_CPU) ; 304 305# directories 306HOST_OBJECT_BASE_DIR = [ FDirName $(HAIKU_OBJECT_DIR) $(HOST_PLATFORM) ] ; 307HOST_COMMON_ARCH_OBJECT_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) common ] ; 308HOST_ARCH_OBJECT_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) $(HOST_ARCH) ] ; 309HOST_COMMON_DEBUG_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) common ] ; 310HOST_DEBUG_0_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) release ] ; 311 312local level ; 313for level in $(HAIKU_DEBUG_LEVELS[2-]) { 314 HOST_DEBUG_$(level)_OBJECT_DIR 315 = [ FDirName $(HOST_ARCH_OBJECT_DIR) debug_$(level) ] ; 316} 317 318# analyze GCC version 319HOST_GCC_VERSION = [ FAnalyzeGCCVersion HOST_GCC_RAW_VERSION ] ; 320 321# set variables for gcc header options 322SetIncludePropertiesVariables HOST ; 323 324# assembler flags 325HOST_ASFLAGS = ; 326 327# C/C++ flags 328HOST_CCFLAGS += -Wno-multichar ; 329HOST_C++FLAGS += -Wno-multichar ; 330 331HOST_KERNEL_CCFLAGS += -finline -fno-builtin 332 -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; 333HOST_KERNEL_C++FLAGS += -finline -fno-builtin -fno-exceptions 334 -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; 335 336HOST_KERNEL_PIC_CCFLAGS = -fno-pic ; 337HOST_KERNEL_PIC_LINKFLAGS = ; 338if $(HOST_ARCH) = ppc { 339 # Build a position independent PPC kernel. We need to be able to relocate 340 # the kernel, since the virtual address space layout at boot time is not 341 # fixed. 342 HOST_KERNEL_PIC_CCFLAGS = -fPIE ; 343 HOST_KERNEL_PIC_LINKFLAGS = -shared -fPIE ; 344} 345 346# warning flags 347HOST_WARNING_CCFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wcast-align 348 -Wsign-compare ; 349HOST_WARNING_C++FLAGS = -Wall -Wno-ctor-dtor-privacy 350 -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare ; 351 352HOST_KERNEL_WARNING_CCFLAGS = -Wall -Wmissing-prototypes ; 353HOST_KERNEL_WARNING_C++FLAGS = -Wall ; 354 355# debug flags 356switch $(HOST_PLATFORM) { 357 case haiku : HOST_DEBUG_FLAGS ?= -ggdb ; 358 case linux : HOST_DEBUG_FLAGS ?= -ggdb ; 359 case freebsd : HOST_DEBUG_FLAGS ?= -ggdb ; 360 case * : HOST_DEBUG_FLAGS ?= -g ; 361} 362 363# debug 0: suppress asserts 364HOST_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 365HOST_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 366 367HOST_KERNEL_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 368HOST_KERNEL_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 369 370local level ; 371for level in $(HAIKU_DEBUG_LEVELS[2-]) { 372 local flags = $(HOST_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ; 373 HOST_DEBUG_$(level)_CCFLAGS = $(flags) ; 374 HOST_DEBUG_$(level)_C++FLAGS = $(flags) ; 375 HOST_KERNEL_DEBUG_$(level)_CCFLAGS = $(flags) ; 376 HOST_KERNEL_DEBUG_$(level)_C++FLAGS = $(flags) ; 377} 378 379# private kernel headers do be used when compiling kernel code 380HOST_PRIVATE_KERNEL_HEADERS = ; 381 382# under BeOS use copyattr instead of cp 383if $(HOST_PLATFORM_BEOS_COMPATIBLE) 384{ 385 CP = copyattr --data ; 386} 387 388HOST_DEFINES += $(HOST_ARCH_MACRO_DEFINE) ; 389HOST_DEFINES += _NO_INLINE_ASM ; 390 391if $(HOST_PLATFORM_BEOS_COMPATIBLE) { 392 # TODO: That's obviously not correct, but in the way the COMPILE_FOR_R5 393 # macro is used, it actually seems to mean r5/bone/dano. 394 # TODO: Deprecated. Remove! 395 HOST_DEFINES += COMPILE_FOR_R5 ; 396} 397 398# for builds of tools in the current environment 399HOST_BUILD_COMPATIBILITY_LIB_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) lib ] ; 400 401if $(HOST_PLATFORM_BEOS_COMPATIBLE) { 402 HOST_LIBSTDC++ = stdc++.r4 ; 403 HOST_LIBROOT = root ; 404 HOST_LIBBE = be ; 405 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR = ; 406 HOST_LIBRARY_NAME_MAP_input_server = /system/servers/input_server ; 407} else { 408 HOST_LIBSTDC++ = stdc++ ; 409 HOST_LIBROOT = libroot_build.so ; 410 HOST_LIBBE = libbe_build.so ; 411 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR 412 = "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ; 413 414 # the C++ support library 415 if $(HOST_GCC_VERSION[1]) < 3 { 416 HOST_LIBSUPC++ = ; 417 } else { 418 HOST_LIBSUPC++ = supc++ ; 419 } 420 421 # The BeOS compilers define __INTEL__ respectively __POWERPC__. On the 422 # build platform we need to make sure, this is also defined. 423 if $(HOST_CPU) = x86 { 424 HOST_DEFINES += __INTEL__ ; 425 } else if $(HOST_CPU) = ppc { 426 HOST_DEFINES += __POWERPC__ ; 427 } 428 429 # Supposing this is a glibc platform, let's try to get large file support 430 HOST_DEFINES += 431 _LARGEFILE_SOURCE _LARGEFILE64_SOURCE _FILE_OFFSET_BITS=64 432 ; 433} 434 435# define the executable MIME type 436HOST_EXECUTABLE_MIME_TYPE = "application/x-vnd.Be-elfexecutable" ; 437 438if $(METROWERKS) { 439 # at least parts of Haiku still can be compiled with 440 # the Metrowerks compiler on BeOS/PPC 441 HOST_EXECUTABLE_MIME_TYPE = "application/x-be-executable" ; 442} 443 444# Be API compatibility 445HOST_BE_API_HEADERS = ; 446HOST_BE_API_CCFLAGS = ; 447HOST_BE_API_C++FLAGS = ; 448 449if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) { 450 HOST_BE_API_HEADERS = 451 [ FDirName $(HAIKU_TOP) headers build ] 452 [ FDirName $(HAIKU_TOP) headers build os ] 453 [ FDirName $(HAIKU_TOP) headers build os app ] 454 [ FDirName $(HAIKU_TOP) headers build os drivers ] 455 [ FDirName $(HAIKU_TOP) headers build os kernel ] 456 [ FDirName $(HAIKU_TOP) headers build os interface ] 457 [ FDirName $(HAIKU_TOP) headers build os storage ] 458 [ FDirName $(HAIKU_TOP) headers build os support ] 459 ; 460 HOST_BE_API_CCFLAGS = -include BeOSBuildCompatibility.h ; 461 HOST_BE_API_C++FLAGS = $(HOST_BE_API_CCFLAGS) ; 462} 463 464 465#pragma mark - 466 467# target platform settings 468 469# check the target platform compatibility 470SetPlatformCompatibilityFlagVariables TARGET_PLATFORM : TARGET : target ; 471 472# check the compatibility between host and target platform 473if $(TARGET_PLATFORM) != haiku { 474 if ! $(HOST_PLATFORM_($(TARGET_PLATFORM))_COMPATIBLE) { 475 Exit ERROR: The host platform is not compatible with target platform 476 $(TARGET_PLATFORM). ; 477 } 478} 479 480# TODO: Fix the naming! 481if $(TARGET_PLATFORM) = haiku { 482 NETWORK_LIBS = network ; 483 SELECT_UNAME_ETC_LIB = root ; 484 NETAPI_LIB = network ; 485} else if $(TARGET_PLATFORM_BONE_COMPATIBLE) { 486 NETWORK_LIBS = socket bind ; 487 NETAPI_LIB = bnetapi ; 488 SELECT_UNAME_ETC_LIB = root ; 489} else { 490 NETWORK_LIBS = net ; 491 NETAPI_LIB = netapi ; 492 SELECT_UNAME_ETC_LIB = net ; 493} 494 495# TODO: For compatibility only. Remove when no longer used. 496R5_COMPATIBLE = $(TARGET_PLATFORM_BEOS_COMPATIBLE) ; 497BONE_COMPATIBLE = $(TARGET_PLATFORM_BONE_COMPATIBLE) ; 498DANO_COMPATIBLE = $(TARGET_PLATFORM_DANO_COMPATIBLE) ; 499HAIKU_COMPATIBLE = $(TARGET_PLATFORM_HAIKU_COMPATIBLE) ; 500 501# Set TARGET_* variables either from HAIKU_* or HOST_* depending on the 502# specified TARGET_PLATFORM. 503 504local buildVars = 505 ARCH CPU GCC_VERSION 506 507 AR CC C++ LD OBJCOPY RANLIB 508 509 INCLUDES_SEPARATOR LOCAL_INCLUDES_OPTION SYSTEM_INCLUDES_OPTION 510 511 HDRS CPPFLAGS CCFLAGS C++FLAGS LDFLAGS LINK LINKFLAGS DEFINES 512 ARFLAGS UNARFLAGS 513 514 KERNEL_CCFLAGS KERNEL_C++FLAGS 515 KERNEL_PIC_CCFLAGS KERNEL_PIC_LINKFLAGS 516 WARNING_CCFLAGS WARNING_C++FLAGS 517 518 KERNEL_WARNING_CCFLAGS KERNEL_WARNING_C++FLAGS 519 520 DEBUG_FLAGS 521 522 DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS 523 524 KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS 525 KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS 526 527 PRIVATE_KERNEL_HEADERS 528 529 LIBSTDC++ LIBSUPC++ 530 531 ARCH_MACRO_DEFINE EXECUTABLE_MIME_TYPE 532 533 OBJECT_BASE_DIR COMMON_ARCH_OBJECT_DIR COMMON_DEBUG_OBJECT_DIR 534 DEBUG_$(HAIKU_DEBUG_LEVELS)_OBJECT_DIR 535; 536 537if $(TARGET_PLATFORM) = haiku { 538 local var ; 539 for var in $(buildVars) { 540 TARGET_$(var) = $(HAIKU_$(var)) ; 541 } 542 543 TARGET_GCC_LIB_DIR = $(HAIKU_GCC_LIB_DIR) ; 544 TARGET_GCC_HEADERS_DIR = $(HAIKU_GCC_HEADERS_DIR) ; 545 TARGET_GCC_LIBGCC = $(HAIKU_GCC_LIBGCC) ; 546 TARGET_GCC_LIBGCC_OBJECTS = $(HAIKU_GCC_LIBGCC_OBJECTS) ; 547 548 TARGET_BOOT_PLATFORM ?= $(HAIKU_BOOT_PLATFORM) ; 549 550 TARGET_LIBRARY_NAME_MAP = HAIKU_LIBRARY_NAME_MAP ; 551 552} else { 553 local var ; 554 for var in $(buildVars) { 555 TARGET_$(var) = $(HOST_$(var)) ; 556 } 557 558 TARGET_GCC_LIB_DIR = ; 559 TARGET_GCC_HEADERS_DIR = ; 560 TARGET_GCC_LIBGCC = ; 561 TARGET_GCC_LIBGCC_OBJECTS = ; 562 563 TARGET_BOOT_PLATFORM = ; 564 565 TARGET_LIBRARY_NAME_MAP = HOST_LIBRARY_NAME_MAP ; 566} 567 568# define macro, for identifying the platform 569switch $(TARGET_PLATFORM) { 570 case r5 : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_BEOS ; 571 case bone : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_BONE ; 572 case dano : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_DANO ; 573 case haiku : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_HAIKU ; 574 case linux : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_LINUX ; 575 case freebsd : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_FREEBSD ; 576 case libbe_test : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_LIBBE_TEST ; 577} 578 579# define macro, for identifying the host platform 580switch $(HOST_PLATFORM) { 581 case r5 : HOST_DEFINES += HAIKU_HOST_PLATFORM_BEOS ; 582 case bone : HOST_DEFINES += HAIKU_HOST_PLATFORM_BONE ; 583 case dano : HOST_DEFINES += HAIKU_HOST_PLATFORM_DANO ; 584 case haiku : HOST_DEFINES += HAIKU_HOST_PLATFORM_HAIKU ; 585 case linux : HOST_DEFINES += HAIKU_HOST_PLATFORM_LINUX ; 586 case freebsd : HOST_DEFINES += HAIKU_HOST_PLATFORM_FREEBSD ; 587} 588 589 590#pragma mark - 591 592# In case we build for a BeOS compatible platform, but not for Haiku, we 593# include the HaikuBuildCompatibility.h header and link against 594# libhaikucompat.a. 595 596if $(TARGET_PLATFORM) != haiku && $(TARGET_PLATFORM_BEOS_COMPATIBLE) { 597 # headers and flags 598 local compatibilityHeader = -include [ FDirName $(HAIKU_TOP) headers build 599 HaikuBuildCompatibility.h ] ; 600 TARGET_CCFLAGS += $(compatibilityHeader) ; 601 TARGET_C++FLAGS += $(compatibilityHeader) ; 602 603 # compatibility library 604 TARGET_HAIKU_COMPATIBILITY_LIBS = libhaikucompat.a ; 605} 606 607# special target libbe_test 608 609if $(TARGET_PLATFORM) = libbe_test { 610 # headers and flags 611 TARGET_HDRS += [ PublicHeaders app game interface storage support ] 612 [ PrivateHeaders $(DOT) ] ; 613 TARGET_DEFINES += __HAIKU__ ; 614 615 # directories 616 TARGET_OBJECT_BASE_DIR 617 = [ FDirName $(HAIKU_OBJECT_DIR) $(TARGET_PLATFORM) ] ; 618 TARGET_COMMON_ARCH_OBJECT_DIR 619 = [ FDirName $(TARGET_OBJECT_BASE_DIR) common ] ; 620 TARGET_ARCH_OBJECT_DIR 621 = [ FDirName $(TARGET_OBJECT_BASE_DIR) $(TARGET_ARCH) ] ; 622 TARGET_COMMON_DEBUG_OBJECT_DIR 623 = [ FDirName $(TARGET_ARCH_OBJECT_DIR) common ] ; 624 TARGET_DEBUG_0_OBJECT_DIR 625 = [ FDirName $(TARGET_ARCH_OBJECT_DIR) release ] ; 626 627 local level ; 628 for level in $(HAIKU_DEBUG_LEVELS[2-]) { 629 TARGET_DEBUG_$(level)_OBJECT_DIR 630 = [ FDirName $(TARGET_ARCH_OBJECT_DIR) debug_$(level) ] ; 631 } 632 633 # library name map 634 TARGET_LIBRARY_NAME_MAP = LIBBE_LIBRARY_NAME_MAP ; 635 LIBBE_LIBRARY_NAME_MAP_be = libbe_haiku.so ; 636} 637 638 639#pragma mark - 640 641# common stuff 642 643# start with a clean slate 644CCFLAGS = ; 645C++FLAGS = ; 646DEFINES = ; 647 648# Set CC, C++, LINK to invalid values, so that we realize early, that we use 649# the wrong compiler. 650CC = bad-cc ; 651C++ = bad-c++ ; 652LINK = bad-link ; 653 654# Allow compiling unit tests on Zeta. Instead of fixing the PostMessage() 655# issues, they deprecated that nice function. This will enable it again: 656C++FLAGS += -D_ZETA_USING_DEPRECATED_API_=1 ; 657# Same for buggy find_directory threadsafety fixes 658C++FLAGS += -D_ZETA_TS_FIND_DIR_=1 ; 659 # TODO: Doesn't really belong here. 660 661 662# Defaults for warnings, optimization, and debugging. 663# 664WARNINGS ?= 1 ; 665OPTIM ?= -O2 ; 666DEBUG ?= 0 ; 667 668 669# Set the defaults for PLATFORM and SUPPORTED_PLATFORMS. PLATFORM is only 670# overridden for targets to be built for the host platform. SUPPORTED_PLATFORMS 671# can be overridden by the author of a component. 672PLATFORM = $(TARGET_PLATFORM) ; 673SUPPORTED_PLATFORMS = haiku ; 674 675 676# Instructs the Library rule to not make its object files temporary. 677# This is needed as some objects are used in a static library and for an 678# executable. 679KEEPOBJS = true ; 680 681 682# output directories 683# TODO: Review this. 684HAIKU_DOCUMENTATION_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) documentation ] ; 685HAIKU_DOCUMENTATION_OBJECT_DIR ?= [ FDirName $(HAIKU_COMMON_PLATFORM_DIR) 686 documentation ] ; 687 688# TODO: Rethink test stuff. 689HAIKU_TEST_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) tests $(TARGET_PLATFORM) $(HAIKU_ARCH) ] ; 690HAIKU_APP_TEST_DIR ?= [ FDirName $(HAIKU_TEST_DIR) apps ] ; 691HAIKU_APP_TEST_LIB_DIR ?= [ FDirName $(HAIKU_APP_TEST_DIR) lib ] ; 692HAIKU_TMP_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) tmp ] ; 693 694HAIKU_PACKAGE_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) packages ] ; 695HAIKU_PACKAGE_OBJECT_DIR ?= [ FDirName $(HAIKU_OBJECT_DIR) packages ] ; 696 697TARGET_TEST_DIR ?= [ FDirName $(HAIKU_TEST_DIR) 698 $(TARGET_PLATFORM) ] ; 699TARGET_UNIT_TEST_DIR ?= [ FDirName $(TARGET_TEST_DIR) unittests ] ; 700TARGET_UNIT_TEST_LIB_DIR ?= [ FDirName $(TARGET_UNIT_TEST_DIR) lib ] ; 701 702# automatically setup the objects directory per subdirectory 703SUBDIRRULES += SetupObjectsDir ; 704 705# Add the standard (userland) warning flags variables to the ones restored in 706# every subdirectory. Thus we can easily meddle with them in subdirectories 707# with imported sources. 708AUTO_SET_UP_CONFIG_VARIABLES += 709 HOST_WARNING_CCFLAGS HOST_WARNING_C++FLAGS 710 TARGET_WARNING_CCFLAGS TARGET_WARNING_C++FLAGS 711 712 # also add PLATFORM and SUPPORTED_PLATFORMS 713 PLATFORM SUPPORTED_PLATFORMS 714; 715