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