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#pragma mark - container settings 15 16# Haiku image 17HAIKU_IMAGE_CONTAINER_NAME = haiku-image-container ; 18HAIKU_CONTAINER_GRIST on $(HAIKU_IMAGE_CONTAINER_NAME) = HaikuImage ; 19HAIKU_INCLUDE_IN_CONTAINER_VAR on $(HAIKU_IMAGE_CONTAINER_NAME) 20 = HAIKU_INCLUDE_IN_IMAGE ; 21HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_IMAGE_CONTAINER_NAME) 22 = HAIKU_IMAGE_INSTALL_TARGETS ; 23 24# network boot archive 25HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME = haiku-netboot-archive-container ; 26HAIKU_CONTAINER_GRIST on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) 27 = NetBootArchive ; 28# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported 29HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) 30 = HAIKU_NET_BOOT_ARCHIVE_INSTALL_TARGETS ; 31 32# alternative gcc archive 33HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME 34 = haiku-alternative-gcc-archive-container ; 35HAIKU_CONTAINER_GRIST on $(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME) 36 = AlternativeGCCArchive ; 37# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported 38HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME) 39 = HAIKU_ALTERNATIVE_GCC_ARCHIVE_INSTALL_TARGETS ; 40 41# boot floppy 42HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME = haiku-boot-floppy-container ; 43HAIKU_CONTAINER_GRIST on $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME) 44 = FloppyBootImage ; 45# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported 46HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME) 47 = HAIKU_FLOPPY_BOOT_IMAGE_INSTALL_TARGETS ; 48 49# boot CD image 50HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME = haiku-boot-cd-container ; 51HAIKU_CONTAINER_GRIST on $(HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME) = CDBootImage ; 52# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported 53HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_CD_BOOT_IMAGE_CONTAINER_NAME) 54 = HAIKU_CD_BOOT_IMAGE_INSTALL_TARGETS ; 55 56# boot CD for PPC image 57HAIKU_CD_BOOT_PPC_IMAGE_CONTAINER_NAME = haiku-boot-cd-ppc-container ; 58HAIKU_CONTAINER_GRIST on $(HAIKU_CD_BOOT_PPC_IMAGE_CONTAINER_NAME) = CDBootPPCImage ; 59# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported 60HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_CD_BOOT_PPC_IMAGE_CONTAINER_NAME) 61 = HAIKU_CD_BOOT_PPC_IMAGE_INSTALL_TARGETS ; 62 63# Haiku image/install defaults 64HAIKU_DEFAULT_IMAGE_NAME = haiku.image ; 65HAIKU_DEFAULT_IMAGE_DIR = $(HAIKU_OUTPUT_DIR) ; 66HAIKU_DEFAULT_VMWARE_IMAGE_NAME = haiku.vmdk ; 67HAIKU_DEFAULT_INSTALL_DIR = /Haiku ; 68HAIKU_DEFAULT_IMAGE_SIZE ?= 192 ; # 192 MB 69HAIKU_DEFAULT_IMAGE_LABEL ?= Haiku ; 70 71# Haiku CD defaults 72HAIKU_DEFAULT_CD_NAME = haiku-cd.iso ; 73HAIKU_DEFAULT_CD_DIR = $(HAIKU_OUTPUT_DIR) ; 74HAIKU_DEFAULT_CD_LABEL = Haiku ; 75 76# analyze and optionally replace jam's target parameters 77ProcessCommandLineArguments ; 78 79 80# include Timezones/libgccObjects 81{ 82 local timezones = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : Timezones ] ; 83 local libgccObjects = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : libgccObjects ] ; 84 85 if ! ( $(timezones) && $(libgccObjects) ) { 86 ECHO "No `Timezones' or `libgccObjects' found in" 87 "$(HAIKU_BUILD_OUTPUT_DIR)!" ; 88 EXIT "Please run ./configure in the source tree's root directory" 89 "again!" ; 90 } 91 92 LOCATE on Timezones = $(HAIKU_BUILD_OUTPUT_DIR) ; 93 LOCATE on libgccObjects = $(HAIKU_BUILD_OUTPUT_DIR) ; 94 95 include Timezones ; 96 include libgccObjects ; 97} 98 99 100# supported debug levels 101HAIKU_DEBUG_LEVELS = 0 1 2 3 4 5 ; 102 103# BeOS, BONE, Dan0 compatible platforms 104HAIKU_BEOS_COMPATIBLE_PLATFORMS = haiku r5 bone dano haiku_host ; 105HAIKU_BONE_COMPATIBLE_PLATFORMS = haiku bone dano haiku_host ; 106HAIKU_DANO_COMPATIBLE_PLATFORMS = haiku dano haiku_host ; 107HAIKU_HAIKU_COMPATIBLE_PLATFORMS = haiku haiku_host ; 108 109# configuration header directories 110HAIKU_CONFIG_HEADERS = [ FDirName $(HAIKU_TOP) build user_config_headers ] 111 [ FDirName $(HAIKU_TOP) build config_headers ] ; 112 113 114#pragma mark - 115 116# haiku target platform settings 117 118# analyze GCC version 119HAIKU_GCC_VERSION = [ FAnalyzeGCCVersion HAIKU_GCC_RAW_VERSION ] ; 120 121# enable GCC -pipe option, if requested 122if $(HAIKU_USE_GCC_PIPE) = 1 { 123 HAIKU_GCC_BASE_FLAGS = -pipe ; 124} 125 126# disable strict aliasing on anything newer than gcc 2 as it may lead to 127# unexpected results. also disable the tree-vrp (value range propagation) 128# optimization for now as with the current gcc4 version we are using this 129# results in some broken code. 130# TODO: remove the -fno-strict-aliasing option when all code has been 131# analyzed/fixed with regard to aliasing. 132# TODO: retest/remove the -fno-tree-vrp option as soon as we have updated our 133# gcc4 compiler. 134if $(HAIKU_GCC_VERSION[1]) >= 3 { 135 HAIKU_GCC_BASE_FLAGS += -fno-strict-aliasing -fno-tree-vrp ; 136} 137# TODO: With Haiku as the host platform, this does not appear to be set up 138# correctly, at least when compiling the libbe_test target platform. When 139# enabling the lines below, these flags suddenly appear as link flags passed 140# to ld as well. 141#if $(HOST_GCC_VERSION[1]) >= 3 { 142# HOST_GCC_BASE_FLAGS += -fno-strict-aliasing -fno-tree-vrp ; 143#} 144 145# override gcc 2.95.3's header directory -- strictly necessary only when using 146# the BeOS native compiler (since its headers are incompatible), but it doesn't 147# harm for the cross-compiler either. 148if $(HAIKU_GCC_VERSION[1]) = 2 { 149 HAIKU_GCC_HEADERS_DIR = [ FDirName $(HAIKU_TOP) headers build gcc-2.95.3 ] ; 150} 151 152# the subdirectory into which the alternative GCC libraries are to be installed 153if $(HAIKU_GCC_VERSION[1]) = 2 { 154 HAIKU_ALTERNATIVE_GCC_LIB_SUBDIR = gcc2 ; 155} else { 156 HAIKU_ALTERNATIVE_GCC_LIB_SUBDIR = gcc4 ; 157} 158 159# initial state for flags etc. 160HAIKU_C++ ?= $(HAIKU_CC) ; 161HAIKU_LINK = $(HAIKU_CC) ; 162HAIKU_LINKFLAGS = $(HAIKU_GCC_BASE_FLAGS) ; 163 164HAIKU_HDRS = [ FStandardHeaders ] ; 165HAIKU_CCFLAGS = $(HAIKU_GCC_BASE_FLAGS) -nostdinc ; 166HAIKU_C++FLAGS = $(HAIKU_GCC_BASE_FLAGS) -nostdinc ; 167HAIKU_KERNEL_CCFLAGS = $(HAIKU_GCC_BASE_FLAGS) ; 168HAIKU_KERNEL_C++FLAGS = $(HAIKU_GCC_BASE_FLAGS) ; 169HAIKU_DEFINES = __HAIKU__ ; 170HAIKU_NO_WERROR ?= 0 ; 171 172# distro compatibility level defines 173HAIKU_DISTRO_COMPATIBILITY ?= "default" ; 174switch $(HAIKU_DISTRO_COMPATIBILITY) { 175 case official : HAIKU_DEFINES += HAIKU_DISTRO_COMPATIBILITY_OFFICIAL ; 176 case compatible : HAIKU_DEFINES += HAIKU_DISTRO_COMPATIBILITY_COMPATIBLE ; 177 case "default" : HAIKU_DEFINES += HAIKU_DISTRO_COMPATIBILITY_DEFAULT ; 178 case * : Exit "Invalid value for HAIKU_DISTRO_COMPATIBILITY:" 179 $(HAIKU_DISTRO_COMPATIBILITY) ; 180} 181 182# analyze the gcc machine spec to determine HAIKU_CPU 183switch $(HAIKU_GCC_MACHINE) { 184 case i386-* : HAIKU_CPU = x86 ; 185 case i486-* : HAIKU_CPU = x86 ; 186 case i586-* : HAIKU_CPU = x86 ; 187 case i686-* : HAIKU_CPU = x86 ; 188 case powerpc-* : HAIKU_CPU = ppc ; 189 case m68k-* : HAIKU_CPU = m68k ; 190 case mipsel-* : HAIKU_CPU = mipsel ; 191 case arm-* : HAIKU_CPU = arm ; 192 case * : Exit "Unsupported gcc target machine:" $(HAIKU_GCC_MACHINE) ; 193} 194 195switch $(HAIKU_CPU) { 196 case ppc : 197 { 198 HAIKU_DEFINES += __POWERPC__ ; 199 HAIKU_BOOT_PLATFORM = openfirmware ; 200 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; # in kB 201 # offset in floppy image (>= sizeof(haiku_loader)) 202 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet 203 } 204 case arm : 205 { 206 HAIKU_DEFINES += __ARM__ ; 207 HAIKU_BOOT_PLATFORM = u-boot ; 208 HAIKU_BOOT_BOARD ?= verdex ; 209 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; 210 # in kB (there is not really a floppy on the gumstix ;) ) 211 # offset in floppy image (>= sizeof(haiku_loader)) 212 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet 213 HAIKU_NO_WERROR = 1 ; 214 # we use #warning as placeholders for things to write... 215 } 216 case x86 : 217 { 218 HAIKU_DEFINES += __INTEL__ ; 219 HAIKU_BOOT_PLATFORM = bios_ia32 ; 220 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 2880 ; # in kB 221 # offset in floppy image (>= sizeof(haiku_loader)) 222 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 300 ; # in kB 223 224 # yasm is required for target arch x86 225 if ! $(HAIKU_YASM) { 226 Exit "HAIKU_YASM not set. Please re-run configure." ; 227 } 228 } 229 case m68k : 230 { 231 HAIKU_DEFINES += __M68K__ ; 232 HAIKU_BOOT_PLATFORM = atari_m68k ; 233 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; # in kB 234 # offset in floppy image (>= sizeof(haiku_loader)) 235 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 150 ; # in kB 236 HAIKU_NO_WERROR = 1 ; 237 # we use #warning as placeholders for things to write... 238 } 239 case mipsel : 240 { 241 HAIKU_DEFINES += __MIPSEL__ ; 242 # RouterBOARD firmware (ELF image over TFTP) 243 HAIKU_BOOT_PLATFORM = routerboard_mipsel ; 244 # offset in floppy image (>= sizeof(haiku_loader)) 245 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB 246 HAIKU_NO_WERROR = 1 ; 247 # we use #warning as placeholders for things to write... 248 } 249 case * : 250 Exit "Currently unsupported target CPU:" $(HAIKU_CPU) ; 251} 252HAIKU_ARCH ?= $(HAIKU_CPU) ; 253HAIKU_ARCH_MACRO_DEFINE = ARCH_$(HAIKU_ARCH) ; 254HAIKU_DEFINES += $(HAIKU_ARCH_MACRO_DEFINE) ; 255HAIKU_DEFINES += BOOT_ARCHIVE_IMAGE_OFFSET=$(HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET) ; 256HAIKU_ATA_STACK ?= 1 ; 257 258# directories 259HAIKU_OBJECT_BASE_DIR = [ FDirName $(HAIKU_OBJECT_DIR) haiku ] ; 260HAIKU_COMMON_ARCH_OBJECT_DIR = [ FDirName $(HAIKU_OBJECT_BASE_DIR) common ] ; 261HAIKU_ARCH_OBJECT_DIR = [ FDirName $(HAIKU_OBJECT_BASE_DIR) $(HAIKU_ARCH) ] ; 262HAIKU_COMMON_DEBUG_OBJECT_DIR = [ FDirName $(HAIKU_ARCH_OBJECT_DIR) common ] ; 263HAIKU_DEBUG_0_OBJECT_DIR = [ FDirName $(HAIKU_ARCH_OBJECT_DIR) release ] ; 264 265local level ; 266for level in $(HAIKU_DEBUG_LEVELS[2-]) { 267 HAIKU_DEBUG_$(level)_OBJECT_DIR 268 = [ FDirName $(HAIKU_ARCH_OBJECT_DIR) debug_$(level) ] ; 269} 270 271# set variables for gcc header options 272SetIncludePropertiesVariables HAIKU ; 273 274# assembler flags 275HAIKU_ASFLAGS = ; 276 277# C/C++ flags 278HAIKU_KERNEL_CCFLAGS += -finline -fno-builtin 279 -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) ; 280HAIKU_KERNEL_C++FLAGS += -finline -fno-builtin -fno-exceptions 281 -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) ; 282HAIKU_KERNEL_DEFINES += _KERNEL_MODE ; 283 284if $(HAIKU_GCC_VERSION[1]) >= 3 { 285 HAIKU_KERNEL_C++FLAGS += -fno-use-cxa-atexit ; 286} 287 288if $(HAIKU_GCC_VERSION[1]) >= 4 { 289 HAIKU_C++FLAGS += -Wno-deprecated ; 290 291 if $(HAIKU_GCC_VERSION[2]) >= 3 { 292 HAIKU_KERNEL_CCFLAGS += -ffreestanding ; 293 HAIKU_KERNEL_C++FLAGS += -ffreestanding ; 294 } 295} 296 297HAIKU_KERNEL_PIC_CCFLAGS = -fno-pic ; 298HAIKU_KERNEL_PIC_LINKFLAGS = ; 299if $(HAIKU_ARCH) = ppc { 300 # Build a position independent PPC kernel. We need to be able to relocate 301 # the kernel, since the virtual address space layout at boot time is not 302 # fixed. 303 HAIKU_KERNEL_PIC_CCFLAGS = -fPIE ; 304 HAIKU_KERNEL_PIC_LINKFLAGS = -shared -fPIE ; 305} 306if $(HAIKU_ARCH) = m68k { 307 # We don't need a PIC kernel as it's always at the same place. 308 # it's actually needed to not use pic, else linking fails due to too large 309 # pc refs. 310 HAIKU_KERNEL_PIC_CCFLAGS = -fno-pic ; 311 HAIKU_KERNEL_PIC_LINKFLAGS = ; 312 # we don't want to have to handle emulating missing FPU opcodes for 040 and 313 # 060 in the kernel 314 HAIKU_KERNEL_CCFLAGS += -m68020-60 ; 315 HAIKU_KERNEL_C++FLAGS += -m68020-60 ; 316} 317if $(HAIKU_ARCH) = mipsel { 318 # todo: verify correctness of this 319 HAIKU_KERNEL_PIC_CCFLAGS = -fno-pic ; 320 HAIKU_KERNEL_PIC_LINKFLAGS = ; 321} 322 323# If the environment variable DEBUG_PRINTF is defined we define an equally 324# named macro to the variable value. Some components use the macro to allow 325# another function than printf() to print the debug output. The variable should 326# be set to the name of the alternative function. 327# 328if $(DEBUG_PRINTF) { 329 HAIKU_CCFLAGS += [ FDefines DEBUG_PRINTF=$(DEBUG_PRINTF) ] ; 330 HAIKU_C++FLAGS += [ FDefines DEBUG_PRINTF=$(DEBUG_PRINTF) ] ; 331} 332 333# If the environment variable HAIKU_INCLUDE_PATENTED_CODE is defined, we 334# define an equally named macro to the variable value. Some components use the 335# macro to allow compilation of code known to implemented patented ideas and/or 336# techniques, for example the Freetype bytecode hinter or sub-pixel rendering 337# as well as some problematic media codecs. 338if $(HAIKU_INCLUDE_PATENTED_CODE) { 339 HAIKU_CCFLAGS += [ FDefines 340 HAIKU_INCLUDE_PATENTED_CODE=$(HAIKU_INCLUDE_PATENTED_CODE) ] ; 341 HAIKU_C++FLAGS += [ FDefines 342 HAIKU_INCLUDE_PATENTED_CODE=$(HAIKU_INCLUDE_PATENTED_CODE) ] ; 343} 344 345# warning flags 346HAIKU_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes 347 -Wpointer-arith -Wcast-align -Wsign-compare -Wno-multichar ; 348HAIKU_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-ctor-dtor-privacy 349 -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare 350 -Wno-multichar ; 351 352HAIKU_KERNEL_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes 353 -Wno-multichar ; 354HAIKU_KERNEL_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-multichar ; 355 356# debug flags 357HAIKU_DEBUG_FLAGS ?= -ggdb ; 358 359# debug 0: suppress asserts 360HAIKU_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 361HAIKU_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 362 363HAIKU_KERNEL_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 364HAIKU_KERNEL_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 365 366local level ; 367for level in $(HAIKU_DEBUG_LEVELS[2-]) { 368 local flags = $(HAIKU_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ; 369 HAIKU_DEBUG_$(level)_CCFLAGS = $(flags) ; 370 HAIKU_DEBUG_$(level)_C++FLAGS = $(flags) ; 371 HAIKU_KERNEL_DEBUG_$(level)_CCFLAGS = $(flags) ; 372 HAIKU_KERNEL_DEBUG_$(level)_C++FLAGS = $(flags) ; 373} 374 375if $(HAIKU_GCC_VERSION[1]) >= 3 { 376 # TODO: Temporary work-around. Should be defined in the compiler specs 377 HAIKU_LINKFLAGS += -Xlinker --no-undefined ; 378} else { 379 HAIKU_DEFINES += _BEOS_R5_COMPATIBLE_ ; 380} 381 382# private shared kernel/libroot headers 383HAIKU_PRIVATE_SYSTEM_HEADERS = 384 [ PrivateHeaders $(DOT) system system/arch/$(HAIKU_ARCH) ] 385; 386 387# private kernel headers to be used when compiling kernel code 388HAIKU_PRIVATE_KERNEL_HEADERS = 389 [ PrivateHeaders $(DOT) kernel libroot 390 kernel/boot/platform/$(HAIKU_BOOT_PLATFORM) ] 391 [ ArchHeaders $(HAIKU_ARCH) ] 392 $(HAIKU_PRIVATE_SYSTEM_HEADERS) 393; 394 395# Add some grist to the libgcc objects 396HAIKU_GCC_LIBGCC_OBJECTS = $(HAIKU_GCC_LIBGCC_OBJECTS:G=libgcc) ; 397 398# the C++ library 399if $(HAIKU_SHARED_LIBSTDC++) { 400 HAIKU_LIBSTDC++ = $(HAIKU_SHARED_LIBSTDC++) ; 401} else if $(HAIKU_STATIC_LIBSTDC++) { 402 HAIKU_LIBSTDC++ = $(HAIKU_STATIC_LIBSTDC++) ; 403} else { 404 HAIKU_LIBSTDC++ = libstdc++.r4.so ; 405 HAIKU_SHARED_LIBSTDC++ = $(HAIKU_LIBSTDC++) ; 406} 407 408# the C++ support library 409if $(HAIKU_SHARED_LIBSUPC++) { 410 HAIKU_LIBSUPC++ = $(HAIKU_SHARED_LIBSUPC++) ; 411} else if $(HAIKU_STATIC_LIBSUPC++) { 412 HAIKU_LIBSUPC++ = $(HAIKU_STATIC_LIBSUPC++) ; 413} else { 414 HAIKU_LIBSUPC++ = ; 415} 416 417# network libraries 418HAIKU_NETWORK_LIBS = network ; 419HAIKU_NETAPI_LIB = bnetapi ; 420HAIKU_SELECT_UNAME_ETC_LIB = ; # libroot, against which we link anyway 421 422# library and executable glue code 423local commonGlueCode = 424 <src!system!glue>init_term_dyn.o 425 <src!system!glue!arch!$(HAIKU_ARCH)>crti.o 426 <src!system!glue!arch!$(HAIKU_ARCH)>crtn.o 427; 428HAIKU_LIBRARY_BEGIN_GLUE_CODE = 429 <src!system!glue!arch!$(HAIKU_ARCH)>crti.o 430 crtbegin.o 431 <src!system!glue>init_term_dyn.o 432; 433HAIKU_LIBRARY_END_GLUE_CODE = 434 crtend.o 435 <src!system!glue!arch!$(HAIKU_ARCH)>crtn.o 436; 437HAIKU_EXECUTABLE_BEGIN_GLUE_CODE = 438 <src!system!glue!arch!$(HAIKU_ARCH)>crti.o 439 crtbegin.o 440 <src!system!glue>start_dyn.o 441 <src!system!glue>init_term_dyn.o 442; 443HAIKU_EXECUTABLE_END_GLUE_CODE = $(HAIKU_LIBRARY_END_GLUE_CODE) ; 444HAIKU_KERNEL_ADDON_BEGIN_GLUE_CODE = crtbegin.o 445 <src!system!glue>haiku_version_glue.o ; 446HAIKU_KERNEL_ADDON_END_GLUE_CODE = $(HAIKU_GCC_LIBGCC) crtend.o ; 447 448SEARCH on crtbegin.o crtend.o = $(HAIKU_GCC_LIB_DIR) ; 449 450HAIKU_EXECUTABLE_MIME_TYPE = "application/x-vnd.Be-elfexecutable" ; 451 452# TODO: The version stuff should probably go into a separate file and be made 453# available as macro, too. 454# Set our version number if not already set and mark it as a developer build 455if ! $(HAIKU_BUILD_VERSION) { 456 HAIKU_BUILD_VERSION ?= "1 0 0 a 1" ; 457 HAIKU_BUILD_DESCRIPTION ?= "Developer Build" ; 458} 459 460# If HAIKU_BUILD_VERSION is set, but HAIKU_BUILD_DESCRIPTION isn't, mark it as 461# an unknown build. 462HAIKU_BUILD_DESCRIPTION ?= "Unknown Build" ; 463 464# init library name map 465{ 466 local i ; 467 for i in be game GL mail media midi midi2 network bnetapi opengl 468 screensaver root z textencoding tracker translation { 469 HAIKU_LIBRARY_NAME_MAP_$(i) = lib$(i).so ; 470 } 471 HAIKU_LIBRARY_NAME_MAP_libstdc++ = $(HAIKU_LIBSTDC++) ; 472 HAIKU_LIBRARY_NAME_MAP_libsupc++ = $(HAIKU_LIBSUPC++) ; 473 HAIKU_LIBRARY_NAME_MAP_input_server = <nogrist>input_server ; 474} 475 476 477#pragma mark - 478 479# host platform settings 480 481# enable GCC -m32 option, if requested 482if $(HAIKU_HOST_USE_32BIT) = 1 { 483 HOST_GCC_BASE_FLAGS = -m32 ; 484} 485 486 487# save jam's variables for the build platform 488HOST_AR ?= $(AR) ; 489HOST_CC ?= $(CC) ; 490HOST_C++ ?= $(C++) ; 491HOST_LINK ?= $(LINK) ; 492HOST_LD ?= ld ; # TODO: Fix this! 493HOST_OBJCOPY ?= objcopy ; # 494HOST_RANLIB ?= $(RANLIB) ; 495HOST_CPPFLAGS ?= $(CPPFLAGS) ; 496HOST_CCFLAGS ?= $(HOST_GCC_BASE_FLAGS) $(CCFLAGS) ; 497HOST_C++FLAGS ?= $(HOST_GCC_BASE_FLAGS) $(C++FLAGS) ; 498HOST_LDFLAGS ?= $(HOST_GCC_BASE_FLAGS) $(LDFLAGS) ; 499HOST_LINKFLAGS ?= $(HOST_GCC_BASE_FLAGS) $(LINKFLAGS) ; 500HOST_DEFINES ?= $(DEFINES) ; 501HOST_HDRS ?= $(HDRS) ; 502 503 504# split up HOST_AR into the command name and flags 505HOST_AR = [ Match "([^ ]*) *(.*)" : $(HOST_AR[1]) ] 506 $(HOST_AR[2-]) ; 507HOST_ARFLAGS = $(HOST_AR[2-]) ; 508HOST_AR = $(HOST_AR[1]) ; 509HOST_UNARFLAGS ?= x ; 510 511# check the host platform compatibility 512SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host 513 : linux openbsd freebsd darwin sunos cygwin ; 514 515if $(HOST_PLATFORM) = linux || $(HOST_PLATFORM) = freebsd 516 || $(HOST_PLATFORM) = darwin || $(HOST_PLATFORM) = cygwin 517 || $(HOST_PLATFORM) = sunos || $(HOST_PLATFORM) = openbsd { 518 # don't use lex: otherwise rc will not work correctly 519 if $(LEX) = lex { 520 LEX = flex ; 521 } 522} 523 524if $(HOST_PLATFORM) = cygwin { 525 HOST_LINKFLAGS += -Xlinker --allow-multiple-definition -Xlinker 526 --enable-auto-import ; 527} 528 529HOST_CPU ?= $(OSPLAT:L) ; 530 531HOST_ARCH ?= $(HOST_CPU) ; 532HOST_ARCH_MACRO_DEFINE = ARCH_$(HOST_CPU) ; 533 534# directories 535HOST_OBJECT_BASE_DIR = [ FDirName $(HAIKU_OBJECT_DIR) $(HOST_PLATFORM) ] ; 536HOST_COMMON_ARCH_OBJECT_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) common ] ; 537HOST_ARCH_OBJECT_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) $(HOST_ARCH) ] ; 538HOST_COMMON_DEBUG_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) common ] ; 539HOST_DEBUG_0_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) release ] ; 540 541local level ; 542for level in $(HAIKU_DEBUG_LEVELS[2-]) { 543 HOST_DEBUG_$(level)_OBJECT_DIR 544 = [ FDirName $(HOST_ARCH_OBJECT_DIR) debug_$(level) ] ; 545} 546 547# analyze GCC version 548HOST_GCC_VERSION = [ FAnalyzeGCCVersion HOST_GCC_RAW_VERSION ] ; 549 550# set variables for gcc header options 551SetIncludePropertiesVariables HOST ; 552 553# assembler flags 554HOST_ASFLAGS = ; 555 556# C/C++ flags 557HOST_CCFLAGS += -Wno-multichar ; 558HOST_C++FLAGS += -Wno-multichar ; 559 560if $(HOST_PLATFORM) != cygwin { 561 HOST_PIC_CCFLAGS += -fPIC ; 562 HOST_PIC_C++FLAGS += -fPIC ; 563} 564 565HOST_KERNEL_CCFLAGS += $(HOST_GCC_BASE_FLAGS) -finline -fno-builtin 566 -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; 567HOST_KERNEL_C++FLAGS += $(HOST_GCC_BASE_FLAGS) -finline -fno-builtin 568 -fno-exceptions -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; 569HOST_KERNEL_DEFINES += _KERNEL_MODE ; 570 571HOST_KERNEL_PIC_CCFLAGS = -fno-pic ; 572HOST_KERNEL_PIC_LINKFLAGS = ; 573if $(HOST_ARCH) = ppc { 574 # Build a position independent PPC kernel. We need to be able to relocate 575 # the kernel, since the virtual address space layout at boot time is not 576 # fixed. 577 HOST_KERNEL_PIC_CCFLAGS = -fPIE ; 578 HOST_KERNEL_PIC_LINKFLAGS = -shared -fPIE ; 579} 580if $(HOST_ARCH) = m68k { 581 # Build a position independent M68K kernel. We need to be able to relocate 582 # the kernel, since the virtual address space layout at boot time is not 583 # fixed. 584 HOST_KERNEL_PIC_CCFLAGS = $(HAIKU_KERNEL_PIC_CCFLAGS) ; 585 HOST_KERNEL_PIC_LINKFLAGS = $(HAIKU_KERNEL_PIC_LINKFLAGS) ; 586} 587 588# warning flags 589HOST_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes -Wpointer-arith 590 -Wcast-align -Wsign-compare ; 591HOST_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-ctor-dtor-privacy 592 -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare ; 593 594HOST_KERNEL_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes ; 595HOST_KERNEL_WARNING_C++FLAGS = -Wall -Wno-trigraphs ; 596 597# debug flags 598switch $(HOST_PLATFORM) { 599 case haiku : HOST_DEBUG_FLAGS ?= -ggdb ; 600 case haiku_host : HOST_DEBUG_FLAGS ?= -ggdb ; 601 case linux : HOST_DEBUG_FLAGS ?= -ggdb ; 602 case freebsd : HOST_DEBUG_FLAGS ?= -ggdb ; 603 case darwin : HOST_DEBUG_FLAGS ?= -ggdb ; 604 case * : HOST_DEBUG_FLAGS ?= -g ; 605} 606 607# debug 0: suppress asserts 608HOST_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 609HOST_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 610 611HOST_KERNEL_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 612HOST_KERNEL_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 613 614local level ; 615for level in $(HAIKU_DEBUG_LEVELS[2-]) { 616 local flags = $(HOST_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ; 617 HOST_DEBUG_$(level)_CCFLAGS = $(flags) ; 618 HOST_DEBUG_$(level)_C++FLAGS = $(flags) ; 619 HOST_KERNEL_DEBUG_$(level)_CCFLAGS = $(flags) ; 620 HOST_KERNEL_DEBUG_$(level)_C++FLAGS = $(flags) ; 621} 622 623# ld flags 624if $(HOST_ARCH) = x86 && $(HAIKU_HOST_USE_32BIT) = 1 { 625 HOST_LDFLAGS += -melf_i386 ; 626} 627 628# private kernel headers do be used when compiling kernel code 629HOST_PRIVATE_KERNEL_HEADERS = ; 630 631# private shared kernel/libroot headers 632HOST_PRIVATE_SYSTEM_HEADERS = ; 633 634# under BeOS use copyattr instead of cp 635if $(HOST_PLATFORM_BEOS_COMPATIBLE) 636{ 637 CP = copyattr --data ; 638} 639 640HOST_DEFINES += $(HOST_ARCH_MACRO_DEFINE) ; 641HOST_DEFINES += _NO_INLINE_ASM ; 642 643if $(HOST_PLATFORM_BEOS_COMPATIBLE) { 644 # TODO: That's obviously not correct, but in the way the COMPILE_FOR_R5 645 # macro is used, it actually seems to mean r5/bone/dano. 646 # TODO: Deprecated. Remove! 647 HOST_DEFINES += COMPILE_FOR_R5 ; 648} 649 650# for builds of tools in the current environment 651HOST_BUILD_COMPATIBILITY_LIB_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) lib ] ; 652 653# For the generic attributes emulation: Target rm_attrs -- rm replacement that 654# also removes the attributes. 655HOST_RM_ATTRS_TARGET = ; 656 657if $(HOST_PLATFORM_BEOS_COMPATIBLE) { 658 # the C++ standard and support libraries 659 if $(HOST_GCC_VERSION[1]) < 3 { 660 HOST_LIBSTDC++ = stdc++.r4 ; 661 HOST_LIBSUPC++ = ; 662 } else { 663 HOST_LIBSTDC++ = stdc++ ; 664 HOST_LIBSUPC++ = supc++ ; 665 } 666 667 HOST_LIBROOT = root ; 668 HOST_STATIC_LIBROOT = $(HOST_LIBROOT) ; 669 HOST_LIBBE = be ; 670 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR = "export LIBRARY_PATH=$LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ; 671 HOST_LIBRARY_NAME_MAP_input_server = /system/servers/input_server ; 672} else { 673 HOST_LIBSTDC++ = stdc++ ; 674 HOST_LIBROOT = libroot_build.so ; 675 HOST_STATIC_LIBROOT = libroot_build.a ; 676 HOST_LIBBE = libbe_build.so ; 677 if $(HOST_PLATFORM) = cygwin { 678 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR 679 = "export PATH=$PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ; 680 } else if $(HOST_PLATFORM) = darwin { 681 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR 682 = "export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ; 683 } else { 684 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR 685 = "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ; 686 } 687 688 # the C++ support library 689 if $(HOST_GCC_VERSION[1]) < 3 { 690 HOST_LIBSUPC++ = ; 691 } else { 692 HOST_LIBSUPC++ = supc++ ; 693 } 694 695 if $(HOST_PLATFORM) = darwin { 696 # part of the C++ runtime lives in libstdc++ on Darwin 697 HOST_LIBSUPC++ = gcc_s.1 stdc++ ; 698 HOST_LIBSTDC++ = ; 699 } 700 701 # Unlike glibc FreeBSD's libc doesn't have built-in regex support. 702 if $(HOST_PLATFORM) = freebsd { 703 HOST_LIBROOT += /usr/lib/libgnuregex.so ; 704 HOST_STATIC_LIBROOT += /usr/lib/libgnuregex.so ; 705 } else if $(HOST_PLATFORM) = darwin { 706 HOST_LIBROOT += /opt/local/lib/libgnuregex.dylib ; 707 HOST_STATIC_LIBROOT += /opt/local/lib/libgnuregex.dylib ; 708 } 709 710 711 # The BeOS compilers define __INTEL__ respectively __POWERPC__. On the 712 # build platform we need to make sure, this is also defined. 713 if $(HOST_CPU) = x86 { 714 HOST_DEFINES += __INTEL__ ; 715 } else if $(HOST_CPU) = ppc { 716 HOST_DEFINES += __POWERPC__ ; 717 } else if $(HOST_CPU) = m68k { 718 HOST_DEFINES += __M68K__ ; 719 } else if $(HOST_CPU) = mipsel { 720 HOST_DEFINES += __MIPSEL__ ; 721 } 722 723 # Supposing this is a glibc platform, let's try to get features like large 724 # file support, ISO C 99 definitions, etc. On some platforms we need to 725 # request 64 bit off_t support explicitely. 726 HOST_DEFINES += _GNU_SOURCE _FILE_OFFSET_BITS=64 ; 727 728 # On Linux with xattr support we can use it for our attribute emulation, 729 # which is somewhat more robust. 730 if $(HAIKU_HOST_USE_XATTR) = 1 { 731 HOST_DEFINES += HAIKU_HOST_USE_XATTR ; 732 } else { 733 # Otherwise the generic attribute emulation is used, which uses a 734 # directory per file to store its attribute. We need to redefine RM so 735 # that the attributes are removed as well. We use a wrapper script, 736 # which invokes a build tool. If the build tool hasn't been built yet, 737 # the normal "rm" is used and the attributes are leaked (likely there 738 # aren't any yet). 739 RM = $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) ";" 740 [ FDirName $(HAIKU_TOP) build scripts rm_attrs ] 741 [ FDirName $(HAIKU_OBJECT_DIR) $(HOST_PLATFORM) $(HOST_ARCH) release 742 tools rm_attrs ] -f ; 743 # assumes that rm_attrs is built with debugging disabled 744 HOST_RM_ATTRS_TARGET = <build>rm_attrs ; 745 } 746} 747 748# network libraries 749if $(HOST_PLATFORM_HAIKU_COMPATIBLE) { 750 HOST_NETWORK_LIBS = network ; 751 HOST_NETAPI_LIB = bnetapi ; 752 HOST_SELECT_UNAME_ETC_LIB = ; # libroot 753} else if $(HOST_PLATFORM_BONE_COMPATIBLE) { 754 HOST_NETWORK_LIBS = socket bind ; 755 HOST_NETAPI_LIB = bnetapi ; 756 HOST_SELECT_UNAME_ETC_LIB = ; # libroot 757} else if $(HOST_PLATFORM_BEOS_COMPATIBLE) { 758 HOST_NETWORK_LIBS = net ; 759 HOST_NETAPI_LIB = netapi ; 760 HOST_SELECT_UNAME_ETC_LIB = net ; 761} else if $(HOST_PLATFORM) = "sunos" { 762 HOST_NETWORK_LIBS = xnet ; 763 HOST_NETAPI_LIB = ; 764 HOST_SELECT_UNAME_ETC_LIB = ; 765} else { 766 # Linux,... 767 HOST_NETWORK_LIBS = ; 768 HOST_NETAPI_LIB = ; 769 HOST_SELECT_UNAME_ETC_LIB = ; 770} 771 772# define the executable MIME type 773HOST_EXECUTABLE_MIME_TYPE = "application/x-vnd.Be-elfexecutable" ; 774 775if $(METROWERKS) { 776 # at least parts of Haiku still can be compiled with 777 # the Metrowerks compiler on BeOS/PPC 778 HOST_EXECUTABLE_MIME_TYPE = "application/x-be-executable" ; 779} 780 781# Be API compatibility 782HOST_BE_API_HEADERS = ; 783HOST_BE_API_CCFLAGS = ; 784HOST_BE_API_C++FLAGS = ; 785 786if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) { 787 HOST_BE_API_HEADERS = 788 [ FDirName $(HAIKU_TOP) headers build ] 789 [ FDirName $(HAIKU_TOP) headers build os ] 790 [ FDirName $(HAIKU_TOP) headers build os app ] 791 [ FDirName $(HAIKU_TOP) headers build os drivers ] 792 [ FDirName $(HAIKU_TOP) headers build os kernel ] 793 [ FDirName $(HAIKU_TOP) headers build os interface ] 794 [ FDirName $(HAIKU_TOP) headers build os opengl ] 795 [ FDirName $(HAIKU_TOP) headers build os storage ] 796 [ FDirName $(HAIKU_TOP) headers build os support ] 797 ; 798 HOST_BE_API_CCFLAGS = -include BeOSBuildCompatibility.h ; 799 HOST_BE_API_C++FLAGS = $(HOST_BE_API_CCFLAGS) ; 800} 801 802# Add directory with system headers we need when building something for the host 803# platform, e.g. containing missing POSIX/GNU headers. 804HOST_HDRS += [ FDirName $(HAIKU_TOP) headers build host $(HOST_PLATFORM) ] ; 805 806# For all versions of BeOS also add the common beos directory. 807if $(HOST_PLATFORM) in r5 bone dano { 808 HOST_HDRS += [ FDirName $(HAIKU_TOP) headers build host beos_common ] ; 809} 810 811 812#pragma mark - 813 814# target platform settings 815 816# check the target platform compatibility 817SetPlatformCompatibilityFlagVariables TARGET_PLATFORM : TARGET : target ; 818 819# check the compatibility between host and target platform 820if $(TARGET_PLATFORM) != haiku { 821 if ! $(HOST_PLATFORM_($(TARGET_PLATFORM))_COMPATIBLE) { 822 Exit ERROR: The host platform is not compatible with target platform 823 $(TARGET_PLATFORM). ; 824 } 825} 826 827# Set TARGET_* variables either from HAIKU_* or HOST_* depending on the 828# specified TARGET_PLATFORM. 829 830local buildVars = 831 ARCH CPU GCC_VERSION 832 833 AR CC C++ LD OBJCOPY RANLIB 834 835 INCLUDES_SEPARATOR LOCAL_INCLUDES_OPTION SYSTEM_INCLUDES_OPTION 836 837 HDRS CPPFLAGS CCFLAGS C++FLAGS LDFLAGS LINK LINKFLAGS DEFINES 838 ARFLAGS UNARFLAGS 839 KERNEL_DEFINES 840 841 KERNEL_CCFLAGS KERNEL_C++FLAGS 842 KERNEL_PIC_CCFLAGS KERNEL_PIC_LINKFLAGS 843 WARNING_CCFLAGS WARNING_C++FLAGS 844 845 KERNEL_WARNING_CCFLAGS KERNEL_WARNING_C++FLAGS 846 847 DEBUG_FLAGS 848 849 DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS 850 851 KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS 852 KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS 853 854 PRIVATE_KERNEL_HEADERS 855 PRIVATE_SYSTEM_HEADERS 856 857 LIBSTDC++ LIBSUPC++ 858 STATIC_LIBSTDC++ STATIC_LIBSUPC++ 859 860 NETWORK_LIBS NETAPI_LIB SELECT_UNAME_ETC_LIB 861 862 ARCH_MACRO_DEFINE EXECUTABLE_MIME_TYPE 863 864 OBJECT_BASE_DIR COMMON_ARCH_OBJECT_DIR COMMON_DEBUG_OBJECT_DIR 865 DEBUG_$(HAIKU_DEBUG_LEVELS)_OBJECT_DIR 866; 867 868if $(TARGET_PLATFORM) = haiku { 869 local var ; 870 for var in $(buildVars) { 871 TARGET_$(var) = $(HAIKU_$(var)) ; 872 } 873 874 TARGET_GCC_LIB_DIR = $(HAIKU_GCC_LIB_DIR) ; 875 TARGET_GCC_HEADERS_DIR = $(HAIKU_GCC_HEADERS_DIR) ; 876 TARGET_GCC_LIBGCC = $(HAIKU_GCC_LIBGCC) ; 877 TARGET_GCC_LIBGCC_OBJECTS = $(HAIKU_GCC_LIBGCC_OBJECTS) ; 878 879 TARGET_BOOT_PLATFORM ?= $(HAIKU_BOOT_PLATFORM) ; 880 TARGET_BOOT_BOARD ?= $(HAIKU_BOOT_BOARD) ; 881 882 TARGET_LIBRARY_NAME_MAP = HAIKU_LIBRARY_NAME_MAP ; 883 884} else { 885 local var ; 886 for var in $(buildVars) { 887 TARGET_$(var) = $(HOST_$(var)) ; 888 } 889 890 TARGET_GCC_LIB_DIR = ; 891 TARGET_GCC_HEADERS_DIR = ; 892 TARGET_GCC_LIBGCC = ; 893 TARGET_GCC_LIBGCC_OBJECTS = ; 894 895 TARGET_BOOT_PLATFORM = ; 896 TARGET_BOOT_BOARD = ; 897 898 TARGET_LIBRARY_NAME_MAP = HOST_LIBRARY_NAME_MAP ; 899} 900 901# define macro, for identifying the platform 902switch $(TARGET_PLATFORM) { 903 case r5 : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_BEOS ; 904 case bone : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_BONE ; 905 case dano : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_DANO ; 906 case haiku_host : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_HAIKU ; 907 case haiku : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_HAIKU ; 908 case linux : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_LINUX ; 909 case freebsd : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_FREEBSD ; 910 case darwin : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_DARWIN ; 911 case cygwin : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_CYGWIN ; 912 case sunos : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_SUNOS ; 913 case libbe_test : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_LIBBE_TEST ; 914} 915 916# define macro, for identifying the host platform 917switch $(HOST_PLATFORM) { 918 case r5 : HOST_DEFINES += HAIKU_HOST_PLATFORM_BEOS ; 919 case bone : HOST_DEFINES += HAIKU_HOST_PLATFORM_BONE ; 920 case dano : HOST_DEFINES += HAIKU_HOST_PLATFORM_DANO ; 921 case haiku_host : HOST_DEFINES += HAIKU_HOST_PLATFORM_HAIKU ; 922 case linux : HOST_DEFINES += HAIKU_HOST_PLATFORM_LINUX ; 923 case freebsd : HOST_DEFINES += HAIKU_HOST_PLATFORM_FREEBSD ; 924 case darwin : HOST_DEFINES += HAIKU_HOST_PLATFORM_DARWIN ; 925 case cygwin : HOST_DEFINES += HAIKU_HOST_PLATFORM_CYGWIN ; 926 case sunos : HOST_DEFINES += HAIKU_HOST_PLATFORM_SUNOS ; 927} 928 929 930#pragma mark - 931 932# In case we build for a BeOS compatible platform, but not for Haiku, we 933# include the HaikuBuildCompatibility.h header and link against 934# libhaikucompat.a. 935 936if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) && $(TARGET_PLATFORM_BEOS_COMPATIBLE) { 937 # headers and flags 938 local compatibilityHeader = -include [ FDirName $(HAIKU_TOP) headers build 939 HaikuBuildCompatibility.h ] ; 940 TARGET_CCFLAGS += $(compatibilityHeader) ; 941 TARGET_C++FLAGS += $(compatibilityHeader) ; 942 943 # compatibility library 944 TARGET_HAIKU_COMPATIBILITY_LIBS = libhaikucompat.a ; 945} 946 947# special target libbe_test 948 949if $(TARGET_PLATFORM) = libbe_test { 950 # headers and flags 951 TARGET_HDRS += 952 [ PublicHeaders $(DOT) app drivers game interface kernel storage 953 support ] 954 [ PrivateHeaders $(DOT) ] ; 955 TARGET_DEFINES += __HAIKU__ ; 956 957 TARGET_PRIVATE_SYSTEM_HEADERS = 958 [ PrivateHeaders $(DOT) system system/arch/$(TARGET_ARCH) ] ; 959 960 # directories 961 TARGET_OBJECT_BASE_DIR 962 = [ FDirName $(HAIKU_OBJECT_DIR) $(TARGET_PLATFORM) ] ; 963 TARGET_COMMON_ARCH_OBJECT_DIR 964 = [ FDirName $(TARGET_OBJECT_BASE_DIR) common ] ; 965 TARGET_ARCH_OBJECT_DIR 966 = [ FDirName $(TARGET_OBJECT_BASE_DIR) $(TARGET_ARCH) ] ; 967 TARGET_COMMON_DEBUG_OBJECT_DIR 968 = [ FDirName $(TARGET_ARCH_OBJECT_DIR) common ] ; 969 TARGET_DEBUG_0_OBJECT_DIR 970 = [ FDirName $(TARGET_ARCH_OBJECT_DIR) release ] ; 971 972 local level ; 973 for level in $(HAIKU_DEBUG_LEVELS[2-]) { 974 TARGET_DEBUG_$(level)_OBJECT_DIR 975 = [ FDirName $(TARGET_ARCH_OBJECT_DIR) debug_$(level) ] ; 976 } 977 978 # library name map 979 TARGET_LIBRARY_NAME_MAP = LIBBE_LIBRARY_NAME_MAP ; 980 LIBBE_LIBRARY_NAME_MAP_be = libbe_test.so ; 981} 982 983 984#pragma mark - 985 986# common stuff 987 988# start with a clean state 989CCFLAGS = ; 990C++FLAGS = ; 991DEFINES = ; 992 993# Set CC, C++, LINK to invalid values, so that we realize early, that we use 994# the wrong compiler. 995CC = bad-cc ; 996C++ = bad-c++ ; 997LINK = bad-link ; 998 999# Allow compiling unit tests on Zeta. Instead of fixing the PostMessage() 1000# issues, they deprecated that nice function. This will enable it again: 1001C++FLAGS += -D_ZETA_USING_DEPRECATED_API_=1 ; 1002# Same for buggy find_directory threadsafety fixes 1003C++FLAGS += -D_ZETA_TS_FIND_DIR_=1 ; 1004 # TODO: Doesn't really belong here. 1005 1006 1007# Defaults for warnings, optimization, and debugging. 1008# 1009WARNINGS ?= 1 ; 1010OPTIM ?= -O2 ; 1011DEBUG ?= 0 ; 1012 1013 1014# Set the defaults for PLATFORM and SUPPORTED_PLATFORMS. PLATFORM is only 1015# overridden for targets to be built for the host platform. SUPPORTED_PLATFORMS 1016# can be overridden by the author of a component. 1017PLATFORM = $(TARGET_PLATFORM) ; 1018SUPPORTED_PLATFORMS = haiku ; 1019 1020 1021# Instructs the Library rule to not make its object files temporary. 1022# This is needed as some objects are used in a static library and for an 1023# executable. 1024KEEPOBJS = true ; 1025 1026 1027# Set permissions to how they should be on the image. 1028EXEMODE = 755 ; 1029FILEMODE = 644 ; 1030SHELLMODE = 755 ; 1031 1032 1033# output directories 1034# TODO: Review this. 1035HAIKU_DOCUMENTATION_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) documentation ] ; 1036HAIKU_DOCUMENTATION_OBJECT_DIR ?= [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) 1037 documentation ] ; 1038 1039# TODO: Rethink test stuff. 1040HAIKU_TEST_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) tests 1041 $(TARGET_PLATFORM) $(HAIKU_ARCH) ] ; 1042HAIKU_APP_TEST_DIR ?= [ FDirName $(HAIKU_TEST_DIR) apps ] ; 1043HAIKU_APP_TEST_LIB_DIR ?= [ FDirName $(HAIKU_APP_TEST_DIR) lib ] ; 1044HAIKU_TMP_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) tmp ] ; 1045 1046HAIKU_PACKAGE_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) packages ] ; 1047HAIKU_PACKAGE_OBJECT_DIR ?= [ FDirName $(HAIKU_OBJECT_DIR) packages ] ; 1048 1049TARGET_TEST_DIR ?= [ FDirName $(HAIKU_TEST_DIR) 1050 $(TARGET_PLATFORM) ] ; 1051TARGET_UNIT_TEST_DIR ?= [ FDirName $(TARGET_TEST_DIR) unittests ] ; 1052TARGET_UNIT_TEST_LIB_DIR ?= [ FDirName $(TARGET_UNIT_TEST_DIR) lib ] ; 1053 1054# automatically setup the objects directory per subdirectory 1055SUBDIRRULES += SetupObjectsDir ; 1056 1057# Add the standard (userland) warning flags variables to the ones restored in 1058# every subdirectory. Thus we can easily meddle with them in subdirectories 1059# with imported sources. 1060AUTO_SET_UP_CONFIG_VARIABLES += 1061 HOST_WARNING_CCFLAGS HOST_WARNING_C++FLAGS 1062 TARGET_WARNING_CCFLAGS TARGET_WARNING_C++FLAGS 1063 1064 # also add PLATFORM and SUPPORTED_PLATFORMS 1065 PLATFORM SUPPORTED_PLATFORMS 1066; 1067 1068 1069# enable -Werror for certain parts of the source tree 1070 1071if $(HAIKU_GCC_VERSION[1]) = 2 { 1072 rule EnableWerror dirTokens : scope { 1073 AppendToConfigVar CCFLAGS : HAIKU_TOP $(dirTokens) : -Werror 1074 : $(scope) ; 1075 AppendToConfigVar C++FLAGS : HAIKU_TOP $(dirTokens) : -Werror 1076 : $(scope) ; 1077 } 1078} else { 1079 # -Wuninitialized gives too many false positives. 1080 rule EnableWerror dirTokens : scope { 1081 AppendToConfigVar CCFLAGS : HAIKU_TOP $(dirTokens) 1082 : -Werror -Wno-error=uninitialized : $(scope) ; 1083 AppendToConfigVar C++FLAGS : HAIKU_TOP $(dirTokens) 1084 : -Werror -Wno-error=uninitialized : $(scope) ; 1085 } 1086} 1087 1088# Work-around for GCC 2 problem -- despite -Wno-multichar it reports 1089# multichar warnings in headers/private/kernel/debugger_keymaps.h included by 1090# src/system/kernel/arch/x86/arch_debug_console.c. 1091if $(HAIKU_GCC_VERSION[1]) = 2 { 1092 local file = <src!system!kernel!arch!x86>arch_debug_console.o ; 1093 CCFLAGS on $(file) = [ on $(file) return $(CCFLAGS) ] ; 1094} 1095 1096if $(HAIKU_NO_WERROR) != 1 { 1097 EnableWerror src kits app ; 1098 EnableWerror src kits interface ; 1099 EnableWerror src kits storage ; 1100 EnableWerror src kits support ; 1101 EnableWerror src system kernel ; 1102 EnableWerror src system runtime_loader ; 1103 EnableWerror src add-ons kernel file_systems bfs ; 1104 EnableWerror src add-ons kernel file_systems userlandfs ; 1105} 1106 1107