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 ?= 300 ; # 300 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# Haiku Anyboot defaults 77HAIKU_DEFAULT_ANYBOOT_NAME = haiku-anyboot.image ; 78HAIKU_DEFAULT_ANYBOOT_DIR = $(HAIKU_OUTPUT_DIR) ; 79HAIKU_DEFAULT_ANYBOOT_LABEL ?= Haiku ; 80 81# analyze and optionally replace jam's target parameters 82ProcessCommandLineArguments ; 83 84 85# include libgccObjects 86{ 87 local libgccObjects = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : libgccObjects ] ; 88 89 if ! $(libgccObjects) { 90 ECHO "No `libgccObjects' found in" 91 "$(HAIKU_BUILD_OUTPUT_DIR)!" ; 92 EXIT "Please run ./configure in the source tree's root directory" 93 "again!" ; 94 } 95 96 LOCATE on libgccObjects = $(HAIKU_BUILD_OUTPUT_DIR) ; 97 98 include libgccObjects ; 99} 100 101 102# supported debug levels 103HAIKU_DEBUG_LEVELS = 0 1 2 3 4 5 ; 104 105# BeOS, BONE, Dan0 compatible platforms 106HAIKU_BEOS_COMPATIBLE_PLATFORMS = haiku r5 bone dano haiku_host ; 107HAIKU_BONE_COMPATIBLE_PLATFORMS = haiku bone dano haiku_host ; 108HAIKU_DANO_COMPATIBLE_PLATFORMS = haiku dano haiku_host ; 109HAIKU_HAIKU_COMPATIBLE_PLATFORMS = haiku haiku_host ; 110 111# configuration header directories 112HAIKU_CONFIG_HEADERS = [ FDirName $(HAIKU_TOP) build user_config_headers ] 113 [ FDirName $(HAIKU_TOP) build config_headers ] ; 114 115 116#pragma mark - 117 118# haiku target platform settings 119 120# analyze GCC version 121HAIKU_GCC_VERSION = [ FAnalyzeGCCVersion HAIKU_GCC_RAW_VERSION ] ; 122 123# enable GCC -pipe option, if requested 124if $(HAIKU_USE_GCC_PIPE) = 1 { 125 HAIKU_GCC_BASE_FLAGS = -pipe ; 126} 127 128# disable strict aliasing on anything newer than gcc 2 as it may lead to 129# unexpected results. also disable the tree-vrp (value range propagation) 130# optimization for now as with the current gcc4 version we are using this 131# results in some broken code. 132# TODO: remove the -fno-strict-aliasing option when all code has been 133# analyzed/fixed with regard to aliasing. 134# TODO: retest/remove the -fno-tree-vrp option as soon as we have updated our 135# gcc4 compiler. 136if $(HAIKU_GCC_VERSION[1]) >= 3 { 137 HAIKU_GCC_BASE_FLAGS += -fno-strict-aliasing -fno-tree-vrp ; 138} 139# TODO: With Haiku as the host platform, this does not appear to be set up 140# correctly, at least when compiling the libbe_test target platform. When 141# enabling the lines below, these flags suddenly appear as link flags passed 142# to ld as well. 143#if $(HOST_GCC_VERSION[1]) >= 3 { 144# HOST_GCC_BASE_FLAGS += -fno-strict-aliasing -fno-tree-vrp ; 145#} 146 147# override gcc 2.95.3's header directory -- strictly necessary only when using 148# the BeOS native compiler (since its headers are incompatible), but it doesn't 149# harm for the cross-compiler either. 150if $(HAIKU_GCC_VERSION[1]) = 2 { 151 HAIKU_GCC_HEADERS_DIR = [ FDirName $(HAIKU_TOP) headers build gcc-2.95.3 ] ; 152} 153 154# the subdirectory into which the alternative GCC libraries are to be installed 155if $(HAIKU_GCC_VERSION[1]) = 2 { 156 HAIKU_ALTERNATIVE_GCC_LIB_SUBDIR = gcc2 ; 157} else { 158 HAIKU_ALTERNATIVE_GCC_LIB_SUBDIR = gcc4 ; 159} 160 161# initial state for flags etc. 162HAIKU_C++ ?= $(HAIKU_CC) ; 163HAIKU_LINK = $(HAIKU_CC) ; 164HAIKU_LINKFLAGS = $(HAIKU_GCC_BASE_FLAGS) ; 165 166HAIKU_HDRS = [ FStandardHeaders ] ; 167HAIKU_KERNEL_CCFLAGS = $(HAIKU_CCFLAGS) $(HAIKU_GCC_BASE_FLAGS) ; 168HAIKU_KERNEL_C++FLAGS = $(HAIKU_C++FLAGS) $(HAIKU_GCC_BASE_FLAGS) ; 169HAIKU_CCFLAGS += $(HAIKU_GCC_BASE_FLAGS) -nostdinc ; 170HAIKU_C++FLAGS += $(HAIKU_GCC_BASE_FLAGS) -nostdinc ; 171HAIKU_DEFINES = __HAIKU__ ; 172HAIKU_NO_WERROR ?= 0 ; 173 174# distro compatibility level defines 175HAIKU_DISTRO_COMPATIBILITY ?= "default" ; 176switch $(HAIKU_DISTRO_COMPATIBILITY) { 177 case official : { 178 HAIKU_DEFINES += HAIKU_DISTRO_COMPATIBILITY_OFFICIAL ; 179 HAIKU_INCLUDE_TRADEMARKS = "" ; 180 } 181 case compatible : { 182 HAIKU_DEFINES += HAIKU_DISTRO_COMPATIBILITY_COMPATIBLE ; 183 HAIKU_INCLUDE_TRADEMARKS = "" ; 184 } 185 case "default" : { 186 HAIKU_DEFINES += HAIKU_DISTRO_COMPATIBILITY_DEFAULT ; 187 HAIKU_INCLUDE_TRADEMARKS = ; 188 } 189 case * : Exit "Invalid value for HAIKU_DISTRO_COMPATIBILITY:" 190 $(HAIKU_DISTRO_COMPATIBILITY) ; 191} 192 193# analyze the gcc machine spec to determine HAIKU_CPU 194switch $(HAIKU_GCC_MACHINE) { 195 case i?86-* : HAIKU_CPU = x86 ; 196 case x86_64-* : HAIKU_CPU = x86_64 ; 197 case powerpc-* : HAIKU_CPU = ppc ; 198 case m68k-* : HAIKU_CPU = m68k ; 199 case mipsel-* : HAIKU_CPU = mipsel ; 200 case arm-* : HAIKU_CPU = arm ; 201 case * : Exit "Unsupported gcc target machine:" 202 $(HAIKU_GCC_MACHINE) ; 203} 204 205# determine the endianness of the host 206switch $(HOST_GCC_MACHINE) { 207 case amd64-* : HAIKU_HOST_IS_BIG_ENDIAN = 0 ; 208 case i?86-* : HAIKU_HOST_IS_BIG_ENDIAN = 0 ; 209 case powerpc-* : HAIKU_HOST_IS_BIG_ENDIAN = 1 ; 210 case x86_64-* : HAIKU_HOST_IS_BIG_ENDIAN = 0 ; 211 212 # the following are rather unlikely as hosts ... 213 case arm-* : HAIKU_HOST_IS_BIG_ENDIAN = 0 ; 214 case m68k-* : HAIKU_HOST_IS_BIG_ENDIAN = 1 ; 215 case mipsel-* : HAIKU_HOST_IS_BIG_ENDIAN = 0 ; 216 case * : Exit "Unsupported gcc host machine:" $(HOST_GCC_MACHINE) ; 217} 218 219switch $(HAIKU_CPU) { 220 case ppc : 221 { 222 HAIKU_DEFINES += __POWERPC__ ; 223 HAIKU_BOOT_PLATFORM = openfirmware ; 224 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; # in kB 225 # offset in floppy image (>= sizeof(haiku_loader)) 226 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet 227 } 228 case arm : 229 { 230 HAIKU_DEFINES += __ARM__ ; 231 HAIKU_BOOT_PLATFORM = u-boot ; 232 HAIKU_BOOT_BOARD ?= verdex ; 233 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; 234 # in kB (there is not really a floppy on the gumstix ;) ) 235 # offset in floppy image (>= sizeof(haiku_loader)) 236 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet 237 HAIKU_NO_WERROR = 1 ; 238 # we use #warning as placeholders for things to write... 239 } 240 case x86 : 241 { 242 HAIKU_DEFINES += __INTEL__ ; 243 HAIKU_BOOT_PLATFORM = bios_ia32 ; 244 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 2880 ; # in kB 245 # offset in floppy image (>= sizeof(haiku_loader)) 246 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 300 ; # in kB 247 248 # yasm is required for target arch x86 249 if ! $(HAIKU_YASM) { 250 Exit "HAIKU_YASM not set. Please re-run configure." ; 251 } 252 } 253 case x86_64 : 254 { 255 HAIKU_DEFINES += __x86_64__ ; 256 HAIKU_BOOT_PLATFORM = bios_ia32 ; 257 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 2880 ; # in kB 258 # offset in floppy image (>= sizeof(haiku_loader)) 259 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 300 ; # in kB 260 261 # yasm is required for target arch x86_64 262 if ! $(HAIKU_YASM) { 263 Exit "HAIKU_YASM not set. Please re-run configure." ; 264 } 265 } 266 case m68k : 267 { 268 HAIKU_DEFINES += __M68K__ ; 269 HAIKU_BOOT_PLATFORM ?= atari_m68k ; 270 switch $(HAIKU_BOOT_PLATFORM) { 271 case atari_m68k : 272 { 273 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; # in kB 274 } 275 case amiga_m68k : 276 { 277 # for now we have trouble reading from double-sided images 278 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 880 ; # in kB 279 } 280 } 281 # offset in floppy image (>= sizeof(haiku_loader)) 282 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 260 ; # in kB 283 HAIKU_NO_WERROR = 1 ; 284 # we use #warning as placeholders for things to write... 285 } 286 case mipsel : 287 { 288 HAIKU_DEFINES += __MIPSEL__ ; 289 # RouterBOARD firmware (ELF image over TFTP) 290 HAIKU_BOOT_PLATFORM = routerboard_mipsel ; 291 # offset in floppy image (>= sizeof(haiku_loader)) 292 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB 293 HAIKU_NO_WERROR = 1 ; 294 # we use #warning as placeholders for things to write... 295 } 296 case * : 297 Exit "Currently unsupported target CPU:" $(HAIKU_CPU) ; 298} 299HAIKU_ARCH ?= $(HAIKU_CPU) ; 300HAIKU_ARCH_MACRO_DEFINE = ARCH_$(HAIKU_ARCH) ; 301HAIKU_DEFINES += $(HAIKU_ARCH_MACRO_DEFINE) ; 302HAIKU_DEFINES += BOOT_ARCHIVE_IMAGE_OFFSET=$(HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET) ; 303HAIKU_ATA_STACK ?= 1 ; 304 305# directories 306HAIKU_OBJECT_BASE_DIR = [ FDirName $(HAIKU_OBJECT_DIR) haiku ] ; 307HAIKU_COMMON_ARCH_OBJECT_DIR = [ FDirName $(HAIKU_OBJECT_BASE_DIR) common ] ; 308HAIKU_ARCH_OBJECT_DIR = [ FDirName $(HAIKU_OBJECT_BASE_DIR) $(HAIKU_ARCH) ] ; 309HAIKU_COMMON_DEBUG_OBJECT_DIR = [ FDirName $(HAIKU_ARCH_OBJECT_DIR) common ] ; 310HAIKU_DEBUG_0_OBJECT_DIR = [ FDirName $(HAIKU_ARCH_OBJECT_DIR) release ] ; 311 312local level ; 313for level in $(HAIKU_DEBUG_LEVELS[2-]) { 314 HAIKU_DEBUG_$(level)_OBJECT_DIR 315 = [ FDirName $(HAIKU_ARCH_OBJECT_DIR) debug_$(level) ] ; 316} 317 318# set variables for gcc header options 319SetIncludePropertiesVariables HAIKU ; 320 321# assembler flags 322HAIKU_ASFLAGS = ; 323 324# C/C++ flags 325HAIKU_KERNEL_CCFLAGS += -finline -fno-builtin ; 326HAIKU_KERNEL_C++FLAGS += -finline -fno-builtin -fno-exceptions ; 327HAIKU_KERNEL_DEFINES += _KERNEL_MODE ; 328 329if $(HAIKU_GCC_VERSION[1]) >= 3 { 330 HAIKU_KERNEL_C++FLAGS += -fno-use-cxa-atexit ; 331} 332 333if $(HAIKU_GCC_VERSION[1]) >= 4 { 334 HAIKU_C++FLAGS += -Wno-deprecated ; 335 336 if $(HAIKU_GCC_VERSION[2]) >= 3 { 337 HAIKU_KERNEL_CCFLAGS += -ffreestanding ; 338 HAIKU_KERNEL_C++FLAGS += -ffreestanding ; 339 } 340} 341 342HAIKU_KERNEL_PIC_CCFLAGS = -fno-pic ; 343HAIKU_KERNEL_PIC_LINKFLAGS = ; 344 345switch $(HAIKU_ARCH) { 346 case ppc : 347 { 348 # Build a position independent PPC kernel. We need to be able to 349 # relocate the kernel, since the virtual address space layout at boot 350 # time is not fixed. 351 HAIKU_KERNEL_PIC_CCFLAGS = -fPIE ; 352 HAIKU_KERNEL_PIC_LINKFLAGS = -shared -fPIE ; 353 } 354 355 case m68k : 356 { 357 # We don't want to have to handle emulating missing FPU opcodes for 040 358 # and 060 in the kernel. 359 HAIKU_KERNEL_CCFLAGS += -m68020-60 ; 360 HAIKU_KERNEL_C++FLAGS += -m68020-60 ; 361 } 362 case x86 : 363 { 364 HAIKU_CCFLAGS += -march=pentium ; 365 HAIKU_C++FLAGS += -march=pentium ; 366 HAIKU_KERNEL_CCFLAGS += -march=pentium ; 367 HAIKU_KERNEL_C++FLAGS += -march=pentium ; 368 369 # Enable use of the gcc built-in atomic functions instead of atomic_*(). 370 # The former are inlined and have thus less overhead. They are not 371 # available with gcc 2, but the header will take care of that. 372 HAIKU_DEFINES += B_USE_BUILTIN_ATOMIC_FUNCTIONS ; 373 } 374 case x86_64 : 375 { 376 # Enable use of the gcc built-in atomic functions instead of atomic_*(). 377 # The former are inlined and have thus less overhead. 378 HAIKU_DEFINES += B_USE_BUILTIN_ATOMIC_FUNCTIONS ; 379 } 380} 381 382# If the environment variable HAIKU_INCLUDE_PATENTED_CODE is defined, we 383# define an equally named macro to the variable value. Some components use the 384# macro to allow compilation of code known to implemented patented ideas and/or 385# techniques, for example the Freetype bytecode hinter or sub-pixel rendering 386# as well as some problematic media codecs. 387if $(HAIKU_INCLUDE_PATENTED_CODE) { 388 HAIKU_DEFINES 389 += HAIKU_INCLUDE_PATENTED_CODE=$(HAIKU_INCLUDE_PATENTED_CODE) ; 390} 391 392# warning flags 393HAIKU_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes 394 -Wpointer-arith -Wcast-align -Wsign-compare -Wno-multichar ; 395HAIKU_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-ctor-dtor-privacy 396 -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare 397 -Wno-multichar ; 398 399HAIKU_KERNEL_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes 400 -Wno-multichar ; 401HAIKU_KERNEL_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-multichar ; 402 403# debug flags 404HAIKU_DEBUG_FLAGS ?= -ggdb ; 405 406# debug 0: suppress asserts 407HAIKU_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 408HAIKU_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 409 410HAIKU_KERNEL_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 411HAIKU_KERNEL_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 412 413local level ; 414for level in $(HAIKU_DEBUG_LEVELS[2-]) { 415 local flags = $(HAIKU_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ; 416 HAIKU_DEBUG_$(level)_CCFLAGS = $(flags) ; 417 HAIKU_DEBUG_$(level)_C++FLAGS = $(flags) ; 418 HAIKU_KERNEL_DEBUG_$(level)_CCFLAGS = $(flags) ; 419 HAIKU_KERNEL_DEBUG_$(level)_C++FLAGS = $(flags) ; 420} 421 422if $(HAIKU_GCC_VERSION[1]) >= 3 { 423 # TODO: Temporary work-around. Should be defined in the compiler specs 424 HAIKU_LINKFLAGS += -Xlinker --no-undefined ; 425} else { 426 HAIKU_DEFINES += _BEOS_R5_COMPATIBLE_ ; 427} 428 429# private shared kernel/libroot headers 430HAIKU_PRIVATE_SYSTEM_HEADERS = 431 [ PrivateHeaders $(DOT) system system/arch/$(HAIKU_ARCH) ] 432; 433 434# private kernel headers to be used when compiling kernel code 435HAIKU_PRIVATE_KERNEL_HEADERS = 436 [ PrivateHeaders $(DOT) kernel libroot shared 437 kernel/boot/platform/$(HAIKU_BOOT_PLATFORM) ] 438 [ ArchHeaders $(HAIKU_ARCH) ] 439 [ FDirName $(HAIKU_COMMON_DEBUG_OBJECT_DIR) system kernel ] 440 $(HAIKU_PRIVATE_SYSTEM_HEADERS) 441; 442 443# Add some grist to the libgcc objects 444HAIKU_GCC_LIBGCC_OBJECTS = $(HAIKU_GCC_LIBGCC_OBJECTS:G=libgcc) ; 445 446# the C++ standard library 447HAIKU_BUILD_SHARED_LIBSTDC++ = ; 448if $(HAIKU_SHARED_LIBSTDC++) { 449 HAIKU_LIBSTDC++ = $(HAIKU_SHARED_LIBSTDC++) ; 450} else { 451 # no shared library available with the compiler -- build it 452 if $(HAIKU_GCC_VERSION[1]) = 2 { 453 HAIKU_LIBSTDC++ = libstdc++.r4.so ; 454 } else { 455 HAIKU_LIBSTDC++ = libstdc++.so ; 456 } 457 HAIKU_SHARED_LIBSTDC++ = $(HAIKU_LIBSTDC++) ; 458 HAIKU_BUILD_SHARED_LIBSTDC++ = 1 ; 459} 460 461# the C++ support (runtime) library 462HAIKU_BUILD_SHARED_LIBSUPC++ = ; 463if $(HAIKU_SHARED_LIBSUPC++) { 464 HAIKU_LIBSUPC++ = $(HAIKU_SHARED_LIBSUPC++) ; 465} else { 466 # no shared library available with the compiler -- build it for gcc 4 467 if $(HAIKU_GCC_VERSION[1]) != 2 { 468 HAIKU_SHARED_LIBSUPC++ = libsupc++.so ; 469 HAIKU_BUILD_SHARED_LIBSUPC++ = 1 ; 470 } 471 472 HAIKU_LIBSUPC++ = $(HAIKU_SHARED_LIBSUPC++) ; 473} 474 475 476# network libraries 477HAIKU_NETWORK_LIBS = network ; 478HAIKU_NETAPI_LIB = bnetapi ; 479HAIKU_SELECT_UNAME_ETC_LIB = ; # libroot, against which we link anyway 480 481 482# locale libraries 483HAIKU_LOCALE_LIBS = liblocale.so liblocalestub.a ; 484 485 486# library and executable glue code 487local commonGlueCode = 488 <src!system!glue>init_term_dyn.o 489 <src!system!glue!arch!$(HAIKU_ARCH)>crti.o 490 <src!system!glue!arch!$(HAIKU_ARCH)>crtn.o 491; 492HAIKU_LIBRARY_BEGIN_GLUE_CODE = 493 <src!system!glue!arch!$(HAIKU_ARCH)>crti.o 494 crtbegin.o 495 <src!system!glue>init_term_dyn.o 496; 497HAIKU_LIBRARY_END_GLUE_CODE = 498 crtend.o 499 <src!system!glue!arch!$(HAIKU_ARCH)>crtn.o 500; 501HAIKU_EXECUTABLE_BEGIN_GLUE_CODE = 502 <src!system!glue!arch!$(HAIKU_ARCH)>crti.o 503 crtbegin.o 504 <src!system!glue>start_dyn.o 505 <src!system!glue>init_term_dyn.o 506; 507HAIKU_EXECUTABLE_END_GLUE_CODE = $(HAIKU_LIBRARY_END_GLUE_CODE) ; 508HAIKU_KERNEL_ADDON_BEGIN_GLUE_CODE = crtbegin.o 509 <src!system!glue>haiku_version_glue.o ; 510HAIKU_KERNEL_ADDON_END_GLUE_CODE = $(HAIKU_GCC_LIBGCC) crtend.o ; 511 512SEARCH on crtbegin.o crtend.o = $(HAIKU_GCC_LIB_DIR) ; 513 514HAIKU_EXECUTABLE_MIME_TYPE = "application/x-vnd.Be-elfexecutable" ; 515 516# TODO: The version stuff should probably go into a separate file and be made 517# available as macro, too. 518# Set our version number if not already set and mark it as a developer build 519if ! $(HAIKU_BUILD_VERSION) { 520 HAIKU_BUILD_VERSION ?= "1 0 0 a 1" ; 521 HAIKU_BUILD_DESCRIPTION ?= "Developer Build" ; 522} 523 524# If HAIKU_BUILD_VERSION is set, but HAIKU_BUILD_DESCRIPTION isn't, mark it as 525# an unknown build. 526HAIKU_BUILD_DESCRIPTION ?= "Unknown Build" ; 527 528# init library name map 529{ 530 local i ; 531 for i in be bnetapi debug game GL locale mail media midi midi2 network 532 opengl package root screensaver textencoding tracker translation 533 z { 534 HAIKU_LIBRARY_NAME_MAP_$(i) = lib$(i).so ; 535 } 536 HAIKU_LIBRARY_NAME_MAP_libstdc++ = $(HAIKU_LIBSTDC++) ; 537 HAIKU_LIBRARY_NAME_MAP_libsupc++ = $(HAIKU_LIBSUPC++) ; 538 HAIKU_LIBRARY_NAME_MAP_input_server = <nogrist>input_server ; 539} 540 541 542#pragma mark - 543 544# host platform settings 545 546# analyze the host gcc machine spec to find out about 64-bitness 547HOST_PLATFORM_IS_64_BIT = ; 548if $(HAIKU_HOST_USE_32BIT) = 1 { 549 # enable GCC -m32 option 550 HOST_GCC_BASE_FLAGS = -m32 ; 551} else { 552 switch $(HOST_GCC_MACHINE) { 553 case amd64-* : HOST_PLATFORM_IS_64_BIT = 1 ; 554 case i686-apple-darwin10 : HOST_PLATFORM_IS_64_BIT = 1 ; 555 case x86_64-* : HOST_PLATFORM_IS_64_BIT = 1 ; 556 } 557} 558 559 560# save jam's variables for the build platform 561HOST_AR ?= $(AR) ; 562HOST_CC ?= $(CC) ; 563HOST_C++ ?= $(C++) ; 564HOST_LINK ?= $(LINK) ; 565HOST_RANLIB ?= $(RANLIB) ; 566HOST_CPPFLAGS ?= $(CPPFLAGS) ; 567HOST_CCFLAGS ?= $(HOST_GCC_BASE_FLAGS) $(CCFLAGS) ; 568HOST_C++FLAGS ?= $(HOST_GCC_BASE_FLAGS) $(C++FLAGS) ; 569HOST_LDFLAGS ?= $(HOST_GCC_BASE_FLAGS) $(LDFLAGS) ; 570HOST_LINKFLAGS ?= $(HOST_GCC_BASE_FLAGS) $(LINKFLAGS) ; 571HOST_DEFINES ?= $(DEFINES) ; 572HOST_HDRS ?= $(HDRS) ; 573 574 575# split up HOST_AR into the command name and flags 576HOST_AR = [ Match "([^ ]*) *(.*)" : $(HOST_AR[1]) ] 577 $(HOST_AR[2-]) ; 578HOST_ARFLAGS = $(HOST_AR[2-]) ; 579HOST_AR = $(HOST_AR[1]) ; 580HOST_UNARFLAGS ?= x ; 581 582# check the host platform compatibility 583SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host 584 : linux openbsd freebsd darwin sunos cygwin ; 585 586if $(HOST_PLATFORM) = linux || $(HOST_PLATFORM) = freebsd 587 || $(HOST_PLATFORM) = darwin || $(HOST_PLATFORM) = cygwin 588 || $(HOST_PLATFORM) = sunos || $(HOST_PLATFORM) = openbsd { 589 # don't use lex: otherwise rc will not work correctly 590 if $(LEX) = lex { 591 LEX = flex ; 592 } 593} 594 595if $(HOST_PLATFORM) = cygwin { 596 HOST_LINKFLAGS += -Xlinker --allow-multiple-definition -Xlinker 597 --enable-auto-import ; 598} 599 600HOST_CPU ?= $(OSPLAT:L) ; 601 602HOST_ARCH ?= $(HOST_CPU) ; 603HOST_ARCH_MACRO_DEFINE = ARCH_$(HOST_CPU) ; 604 605 606# directories 607HOST_OBJECT_BASE_DIR = [ FDirName $(HAIKU_OBJECT_DIR) $(HOST_PLATFORM) ] ; 608HOST_COMMON_ARCH_OBJECT_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) common ] ; 609HOST_ARCH_OBJECT_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) $(HOST_ARCH) ] ; 610HOST_COMMON_DEBUG_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) common ] ; 611HOST_DEBUG_0_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) release ] ; 612 613local level ; 614for level in $(HAIKU_DEBUG_LEVELS[2-]) { 615 HOST_DEBUG_$(level)_OBJECT_DIR 616 = [ FDirName $(HOST_ARCH_OBJECT_DIR) debug_$(level) ] ; 617} 618 619# analyze GCC version 620HOST_GCC_VERSION = [ FAnalyzeGCCVersion HOST_GCC_RAW_VERSION ] ; 621 622# set variables for gcc header options 623SetIncludePropertiesVariables HOST ; 624 625# assembler flags 626HOST_ASFLAGS = ; 627 628# C/C++ flags 629HOST_CCFLAGS += -Wno-multichar ; 630HOST_C++FLAGS += -Wno-multichar ; 631 632if $(HOST_PLATFORM) != cygwin { 633 HOST_PIC_CCFLAGS += -fPIC ; 634 HOST_PIC_C++FLAGS += -fPIC ; 635} 636 637HOST_KERNEL_CCFLAGS += $(HOST_GCC_BASE_FLAGS) -finline -fno-builtin 638 -D_KERNEL_MODE ; 639HOST_KERNEL_C++FLAGS += $(HOST_GCC_BASE_FLAGS) -finline -fno-builtin 640 -fno-exceptions -D_KERNEL_MODE ; 641HOST_KERNEL_DEFINES += _KERNEL_MODE ; 642 643HOST_KERNEL_PIC_CCFLAGS = -fno-pic ; 644HOST_KERNEL_PIC_LINKFLAGS = ; 645if $(HOST_ARCH) = ppc { 646 # Build a position independent PPC kernel. We need to be able to relocate 647 # the kernel, since the virtual address space layout at boot time is not 648 # fixed. 649 HOST_KERNEL_PIC_CCFLAGS = -fPIE ; 650 HOST_KERNEL_PIC_LINKFLAGS = -shared -fPIE ; 651} 652if $(HOST_ARCH) = m68k { 653 # Build a position independent M68K kernel. We need to be able to relocate 654 # the kernel, since the virtual address space layout at boot time is not 655 # fixed. 656 HOST_KERNEL_PIC_CCFLAGS = $(HAIKU_KERNEL_PIC_CCFLAGS) ; 657 HOST_KERNEL_PIC_LINKFLAGS = $(HAIKU_KERNEL_PIC_LINKFLAGS) ; 658} 659 660if $(HOST_PLATFORM) != darwin { 661 # fix for new changes to DSO linking policies 662 HOST_LINKFLAGS += -Xlinker --no-as-needed ; 663} 664 665 666# warning flags 667HOST_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes -Wpointer-arith 668 -Wcast-align -Wsign-compare ; 669HOST_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-ctor-dtor-privacy 670 -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare ; 671 672HOST_KERNEL_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes ; 673HOST_KERNEL_WARNING_C++FLAGS = -Wall -Wno-trigraphs ; 674 675# debug flags 676switch $(HOST_PLATFORM) { 677 case haiku : HOST_DEBUG_FLAGS ?= -ggdb ; 678 case haiku_host : HOST_DEBUG_FLAGS ?= -ggdb ; 679 case linux : HOST_DEBUG_FLAGS ?= -ggdb ; 680 case freebsd : HOST_DEBUG_FLAGS ?= -ggdb ; 681 case darwin : HOST_DEBUG_FLAGS ?= -ggdb ; 682 case * : HOST_DEBUG_FLAGS ?= -g ; 683} 684 685# debug 0: suppress asserts 686HOST_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 687HOST_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 688 689HOST_KERNEL_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 690HOST_KERNEL_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; 691 692local level ; 693for level in $(HAIKU_DEBUG_LEVELS[2-]) { 694 local flags = $(HOST_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ; 695 HOST_DEBUG_$(level)_CCFLAGS = $(flags) ; 696 HOST_DEBUG_$(level)_C++FLAGS = $(flags) ; 697 HOST_KERNEL_DEBUG_$(level)_CCFLAGS = $(flags) ; 698 HOST_KERNEL_DEBUG_$(level)_C++FLAGS = $(flags) ; 699} 700 701# ld flags 702if $(HOST_ARCH) = x86 && $(HAIKU_HOST_USE_32BIT) = 1 { 703 HOST_LDFLAGS += -melf_i386 ; 704} 705 706# private kernel headers do be used when compiling kernel code 707HOST_PRIVATE_KERNEL_HEADERS = ; 708 709# private shared kernel/libroot headers 710HOST_PRIVATE_SYSTEM_HEADERS = ; 711 712# under BeOS use copyattr instead of cp 713if $(HOST_PLATFORM_BEOS_COMPATIBLE) 714{ 715 CP = copyattr --data ; 716} 717 718HOST_DEFINES += $(HOST_ARCH_MACRO_DEFINE) ; 719HOST_DEFINES += _NO_INLINE_ASM ; 720 721if $(HOST_PLATFORM_BEOS_COMPATIBLE) { 722 # TODO: That's obviously not correct, but in the way the COMPILE_FOR_R5 723 # macro is used, it actually seems to mean r5/bone/dano. 724 # TODO: Deprecated. Remove! 725 HOST_DEFINES += COMPILE_FOR_R5 ; 726} 727 728# for builds of tools in the current environment 729HOST_BUILD_COMPATIBILITY_LIB_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) lib ] ; 730 731# For the generic attributes emulation: Target rm_attrs -- rm replacement that 732# also removes the attributes. 733HOST_RM_ATTRS_TARGET = ; 734 735if $(HOST_PLATFORM_BEOS_COMPATIBLE) { 736 # the C++ standard and support libraries 737 if $(HOST_GCC_VERSION[1]) < 3 { 738 HOST_LIBSTDC++ = stdc++.r4 ; 739 HOST_LIBSUPC++ = ; 740 } else { 741 HOST_LIBSTDC++ = stdc++ ; 742 HOST_LIBSUPC++ = supc++ ; 743 } 744 745 HOST_LIBROOT = root ; 746 HOST_STATIC_LIBROOT = $(HOST_LIBROOT) ; 747 HOST_LIBBE = be ; 748 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR = "export LIBRARY_PATH=$LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ; 749 HOST_LIBRARY_NAME_MAP_input_server = /system/servers/input_server ; 750 HOST_DEFINES += __STDC_FORMAT_MACROS __STDC_LIMIT_MACROS ; 751 752 local compatibilityHeader = -include [ FDirName $(HAIKU_TOP) headers build 753 HaikuBuildCompatibility.h ] ; 754 HOST_CCFLAGS += $(compatibilityHeader) ; 755 HOST_C++FLAGS += $(compatibilityHeader) ; 756 757 # compatibility library 758 HOST_HAIKU_COMPATIBILITY_LIBS = libhaikucompat.a ; 759} else { 760 HOST_LIBSTDC++ = stdc++ ; 761 HOST_LIBROOT = libroot_build.so ; 762 HOST_STATIC_LIBROOT = libroot_build.a ; 763 HOST_LIBBE = libbe_build.so ; 764 if $(HOST_PLATFORM) = cygwin { 765 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR 766 = "export PATH=$PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ; 767 } else if $(HOST_PLATFORM) = darwin { 768 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR 769 = "export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ; 770 } else { 771 HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR 772 = "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ; 773 } 774 775 # the C++ support library 776 if $(HOST_GCC_VERSION[1]) < 3 { 777 HOST_LIBSUPC++ = ; 778 } else { 779 HOST_LIBSUPC++ = supc++ ; 780 } 781 782 if $(HOST_PLATFORM) = darwin { 783 # part of the C++ runtime lives in libstdc++ on Darwin 784 HOST_LIBSUPC++ = gcc_s.1 stdc++ ; 785 HOST_LIBSTDC++ = ; 786 } else if $(HOST_PLATFORM) = freebsd { 787 if $(HOST_CPU) = x86 && $(HOST_PLATFORM_IS_64_BIT) = 1 { 788 # amd64 FreeBSD 8 doesn't come without a shared libsupc++, and the 789 # static one prevents us from building shared libraries. So we have 790 # to work around by using the shared libstdc++. 791 HOST_LIBSUPC++ = stdc++ ; 792 HOST_LIBSTDC++ = ; 793 } 794 } 795 796 # Unlike glibc FreeBSD's libc doesn't have built-in regex support. 797 if $(HOST_PLATFORM) = freebsd { 798 HOST_LIBROOT += /usr/lib/libgnuregex.so ; 799 HOST_STATIC_LIBROOT += /usr/lib/libgnuregex.so ; 800 } else if $(HOST_PLATFORM) = darwin { 801 HOST_LIBROOT += /opt/local/lib/libgnuregex.dylib ; 802 HOST_STATIC_LIBROOT += /opt/local/lib/libgnuregex.dylib ; 803 } 804 805 # The BeOS compilers define __INTEL__ respectively __POWERPC__. On the 806 # build platform we need to make sure, this is also defined. 807 if $(HOST_CPU) = x86 { 808 HOST_DEFINES += __INTEL__ ; 809 } else if $(HOST_CPU) = ppc { 810 HOST_DEFINES += __POWERPC__ ; 811 } else if $(HOST_CPU) = m68k { 812 HOST_DEFINES += __M68K__ ; 813 } else if $(HOST_CPU) = mipsel { 814 HOST_DEFINES += __MIPSEL__ ; 815 } 816 817 # Supposing this is a glibc platform, let's try to get features like large 818 # file support, ISO C 99 definitions, etc. On some platforms we need to 819 # request 64 bit off_t support explicitely. 820 HOST_DEFINES += _GNU_SOURCE _FILE_OFFSET_BITS=64 __STDC_FORMAT_MACROS 821 __STDC_LIMIT_MACROS ; 822 823 # On Linux with xattr support we can use it for our attribute emulation, 824 # which is somewhat more robust. 825 if $(HAIKU_HOST_USE_XATTR) = 1 { 826 HOST_DEFINES += HAIKU_HOST_USE_XATTR ; 827 } else { 828 # Otherwise the generic attribute emulation is used, which uses a 829 # directory per file to store its attribute. We need to redefine RM so 830 # that the attributes are removed as well. We use a wrapper script, 831 # which invokes a build tool. If the build tool hasn't been built yet, 832 # the normal "rm" is used and the attributes are leaked (likely there 833 # aren't any yet). 834 RM = $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) ";" 835 [ FDirName $(HAIKU_TOP) build scripts rm_attrs ] 836 [ FDirName $(HAIKU_OBJECT_DIR) $(HOST_PLATFORM) $(HOST_ARCH) release 837 tools rm_attrs ] -f ; 838 # assumes that rm_attrs is built with debugging disabled 839 HOST_RM_ATTRS_TARGET = <build>rm_attrs ; 840 } 841} 842 843# network libraries 844if $(HOST_PLATFORM_HAIKU_COMPATIBLE) { 845 HOST_NETWORK_LIBS = network ; 846 HOST_NETAPI_LIB = bnetapi ; 847 HOST_SELECT_UNAME_ETC_LIB = ; # libroot 848} else if $(HOST_PLATFORM_BONE_COMPATIBLE) { 849 HOST_NETWORK_LIBS = socket bind ; 850 HOST_NETAPI_LIB = bnetapi ; 851 HOST_SELECT_UNAME_ETC_LIB = ; # libroot 852} else if $(HOST_PLATFORM_BEOS_COMPATIBLE) { 853 HOST_NETWORK_LIBS = net ; 854 HOST_NETAPI_LIB = netapi ; 855 HOST_SELECT_UNAME_ETC_LIB = net ; 856} else if $(HOST_PLATFORM) = "sunos" { 857 HOST_NETWORK_LIBS = xnet ; 858 HOST_NETAPI_LIB = ; 859 HOST_SELECT_UNAME_ETC_LIB = ; 860} else { 861 # Linux,... 862 HOST_NETWORK_LIBS = ; 863 HOST_NETAPI_LIB = ; 864 HOST_SELECT_UNAME_ETC_LIB = ; 865} 866 867# define the executable MIME type 868HOST_EXECUTABLE_MIME_TYPE = "application/x-vnd.Be-elfexecutable" ; 869 870if $(METROWERKS) { 871 # at least parts of Haiku still can be compiled with 872 # the Metrowerks compiler on BeOS/PPC 873 HOST_EXECUTABLE_MIME_TYPE = "application/x-be-executable" ; 874} 875 876# Be API compatibility 877HOST_BE_API_HEADERS = ; 878HOST_BE_API_CCFLAGS = ; 879HOST_BE_API_C++FLAGS = ; 880 881if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) { 882 HOST_BE_API_HEADERS = 883 [ FDirName $(HAIKU_TOP) headers build ] 884 [ FDirName $(HAIKU_TOP) headers build os ] 885 [ FDirName $(HAIKU_TOP) headers build os app ] 886 [ FDirName $(HAIKU_TOP) headers build os drivers ] 887 [ FDirName $(HAIKU_TOP) headers build os kernel ] 888 [ FDirName $(HAIKU_TOP) headers build os interface ] 889 [ FDirName $(HAIKU_TOP) headers build os opengl ] 890 [ FDirName $(HAIKU_TOP) headers build os storage ] 891 [ FDirName $(HAIKU_TOP) headers build os support ] 892 [ FDirName $(HAIKU_TOP) headers build private ] 893 ; 894 HOST_BE_API_CCFLAGS = -include BeOSBuildCompatibility.h ; 895 HOST_BE_API_C++FLAGS = $(HOST_BE_API_CCFLAGS) ; 896} 897 898# Add directory with system headers we need when building something for the host 899# platform, e.g. containing missing POSIX/GNU headers. 900HOST_HDRS += [ FDirName $(HAIKU_TOP) headers build host $(HOST_PLATFORM) ] ; 901 902# For all versions of BeOS also add the common beos directory. 903if $(HOST_PLATFORM) in r5 bone dano { 904 HOST_HDRS += [ FDirName $(HAIKU_TOP) headers build host beos_common ] ; 905} 906 907 908#pragma mark - 909 910# target platform settings 911 912# check the target platform compatibility 913SetPlatformCompatibilityFlagVariables TARGET_PLATFORM : TARGET : target ; 914 915# check the compatibility between host and target platform 916if $(TARGET_PLATFORM) != haiku { 917 if ! $(HOST_PLATFORM_($(TARGET_PLATFORM))_COMPATIBLE) { 918 Exit ERROR: The host platform is not compatible with target platform 919 $(TARGET_PLATFORM). ; 920 } 921} 922 923# Set TARGET_* variables either from HAIKU_* or HOST_* depending on the 924# specified TARGET_PLATFORM. 925 926local buildVars = 927 ARCH CPU GCC_VERSION 928 929 AR CC C++ LD OBJCOPY RANLIB 930 931 INCLUDES_SEPARATOR LOCAL_INCLUDES_OPTION SYSTEM_INCLUDES_OPTION 932 933 HDRS CPPFLAGS CCFLAGS C++FLAGS LDFLAGS LINK LINKFLAGS DEFINES 934 ARFLAGS UNARFLAGS 935 KERNEL_DEFINES 936 937 KERNEL_CCFLAGS KERNEL_C++FLAGS 938 KERNEL_PIC_CCFLAGS KERNEL_PIC_LINKFLAGS 939 WARNING_CCFLAGS WARNING_C++FLAGS 940 941 KERNEL_WARNING_CCFLAGS KERNEL_WARNING_C++FLAGS 942 943 DEBUG_FLAGS 944 945 DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS 946 947 KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS 948 KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS 949 950 PRIVATE_KERNEL_HEADERS 951 PRIVATE_SYSTEM_HEADERS 952 953 LIBSTDC++ LIBSUPC++ 954 STATIC_LIBSTDC++ STATIC_LIBSUPC++ 955 956 NETWORK_LIBS NETAPI_LIB SELECT_UNAME_ETC_LIB 957 958 ARCH_MACRO_DEFINE EXECUTABLE_MIME_TYPE 959 960 OBJECT_BASE_DIR COMMON_ARCH_OBJECT_DIR COMMON_DEBUG_OBJECT_DIR 961 DEBUG_$(HAIKU_DEBUG_LEVELS)_OBJECT_DIR 962; 963 964if $(TARGET_PLATFORM) = haiku { 965 local var ; 966 for var in $(buildVars) { 967 TARGET_$(var) = $(HAIKU_$(var)) ; 968 } 969 970 TARGET_GCC_LIB_DIR = $(HAIKU_GCC_LIB_DIR) ; 971 TARGET_GCC_HEADERS_DIR = $(HAIKU_GCC_HEADERS_DIR) ; 972 TARGET_GCC_LIBGCC = $(HAIKU_GCC_LIBGCC) ; 973 TARGET_GCC_LIBGCC_OBJECTS = $(HAIKU_GCC_LIBGCC_OBJECTS) ; 974 975 TARGET_BOOT_PLATFORM ?= $(HAIKU_BOOT_PLATFORM) ; 976 TARGET_BOOT_BOARD ?= $(HAIKU_BOOT_BOARD) ; 977 978 TARGET_LIBRARY_NAME_MAP = HAIKU_LIBRARY_NAME_MAP ; 979 980} else { 981 local var ; 982 for var in $(buildVars) { 983 TARGET_$(var) = $(HOST_$(var)) ; 984 } 985 986 TARGET_GCC_LIB_DIR = ; 987 TARGET_GCC_HEADERS_DIR = ; 988 TARGET_GCC_LIBGCC = ; 989 TARGET_GCC_LIBGCC_OBJECTS = ; 990 991 TARGET_BOOT_PLATFORM = ; 992 TARGET_BOOT_BOARD = ; 993 994 TARGET_LIBRARY_NAME_MAP = HOST_LIBRARY_NAME_MAP ; 995} 996 997# define macro, for identifying the platform 998switch $(TARGET_PLATFORM) { 999 case r5 : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_BEOS ; 1000 case bone : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_BONE ; 1001 case dano : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_DANO ; 1002 case haiku_host : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_HAIKU ; 1003 case haiku : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_HAIKU ; 1004 case linux : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_LINUX ; 1005 case freebsd : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_FREEBSD ; 1006 case darwin : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_DARWIN ; 1007 case cygwin : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_CYGWIN ; 1008 case sunos : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_SUNOS ; 1009 case libbe_test : TARGET_DEFINES += HAIKU_TARGET_PLATFORM_LIBBE_TEST ; 1010} 1011 1012# define macro, for identifying the host platform 1013switch $(HOST_PLATFORM) { 1014 case r5 : HOST_DEFINES += HAIKU_HOST_PLATFORM_BEOS ; 1015 case bone : HOST_DEFINES += HAIKU_HOST_PLATFORM_BONE ; 1016 case dano : HOST_DEFINES += HAIKU_HOST_PLATFORM_DANO ; 1017 case haiku_host : HOST_DEFINES += HAIKU_HOST_PLATFORM_HAIKU ; 1018 case linux : HOST_DEFINES += HAIKU_HOST_PLATFORM_LINUX ; 1019 case freebsd : HOST_DEFINES += HAIKU_HOST_PLATFORM_FREEBSD ; 1020 case darwin : HOST_DEFINES += HAIKU_HOST_PLATFORM_DARWIN ; 1021 case cygwin : HOST_DEFINES += HAIKU_HOST_PLATFORM_CYGWIN ; 1022 case sunos : HOST_DEFINES += HAIKU_HOST_PLATFORM_SUNOS ; 1023} 1024 1025# define host platform 64 bit macro 1026if $(HOST_PLATFORM_IS_64_BIT) { 1027 HOST_DEFINES += HAIKU_HOST_PLATFORM_64_BIT ; 1028} 1029 1030#pragma mark - 1031 1032# In case we build for a BeOS compatible platform, but not for Haiku, we 1033# include the HaikuBuildCompatibility.h header and link against 1034# libhaikucompat.a. 1035 1036if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) && $(TARGET_PLATFORM_BEOS_COMPATIBLE) { 1037 # headers and flags 1038 local compatibilityHeader = -include [ FDirName $(HAIKU_TOP) headers build 1039 HaikuBuildCompatibility.h ] ; 1040 TARGET_CCFLAGS += $(compatibilityHeader) ; 1041 TARGET_C++FLAGS += $(compatibilityHeader) ; 1042 1043 # compatibility library 1044 TARGET_HAIKU_COMPATIBILITY_LIBS = libhaikucompat.a ; 1045} 1046 1047# special target libbe_test 1048 1049if $(TARGET_PLATFORM) = libbe_test { 1050 # headers and flags 1051 TARGET_HDRS += 1052 [ PublicHeaders $(DOT) app drivers game interface kernel storage 1053 support ] 1054 [ PrivateHeaders $(DOT) ] ; 1055 TARGET_DEFINES += __HAIKU__ ; 1056 1057 TARGET_PRIVATE_SYSTEM_HEADERS = 1058 [ PrivateHeaders $(DOT) system system/arch/$(TARGET_ARCH) ] ; 1059 1060 # directories 1061 TARGET_OBJECT_BASE_DIR 1062 = [ FDirName $(HAIKU_OBJECT_DIR) $(TARGET_PLATFORM) ] ; 1063 TARGET_COMMON_ARCH_OBJECT_DIR 1064 = [ FDirName $(TARGET_OBJECT_BASE_DIR) common ] ; 1065 TARGET_ARCH_OBJECT_DIR 1066 = [ FDirName $(TARGET_OBJECT_BASE_DIR) $(TARGET_ARCH) ] ; 1067 TARGET_COMMON_DEBUG_OBJECT_DIR 1068 = [ FDirName $(TARGET_ARCH_OBJECT_DIR) common ] ; 1069 TARGET_DEBUG_0_OBJECT_DIR 1070 = [ FDirName $(TARGET_ARCH_OBJECT_DIR) release ] ; 1071 1072 local level ; 1073 for level in $(HAIKU_DEBUG_LEVELS[2-]) { 1074 TARGET_DEBUG_$(level)_OBJECT_DIR 1075 = [ FDirName $(TARGET_ARCH_OBJECT_DIR) debug_$(level) ] ; 1076 } 1077 1078 # library name map 1079 TARGET_LIBRARY_NAME_MAP = LIBBE_LIBRARY_NAME_MAP ; 1080 LIBBE_LIBRARY_NAME_MAP_be = libbe_test.so ; 1081} 1082 1083 1084#pragma mark - 1085 1086# common stuff 1087 1088# start with a clean state 1089CCFLAGS = ; 1090C++FLAGS = ; 1091DEFINES = ; 1092 1093# Set CC, C++, LINK to invalid values, so that we realize early, that we use 1094# the wrong compiler. 1095CC = bad-cc ; 1096C++ = bad-c++ ; 1097LINK = bad-link ; 1098 1099# Allow compiling unit tests on Zeta. Instead of fixing the PostMessage() 1100# issues, they deprecated that nice function. This will enable it again: 1101C++FLAGS += -D_ZETA_USING_DEPRECATED_API_=1 ; 1102# Same for buggy find_directory threadsafety fixes 1103C++FLAGS += -D_ZETA_TS_FIND_DIR_=1 ; 1104 # TODO: Doesn't really belong here. 1105 1106 1107# Defaults for warnings, optimization, and debugging. 1108# 1109WARNINGS ?= 1 ; 1110OPTIM ?= -O2 ; 1111DEBUG ?= 0 ; 1112 1113 1114# Set the defaults for PLATFORM and SUPPORTED_PLATFORMS. PLATFORM is only 1115# overridden for targets to be built for the host platform. SUPPORTED_PLATFORMS 1116# can be overridden by the author of a component. 1117PLATFORM = $(TARGET_PLATFORM) ; 1118SUPPORTED_PLATFORMS = haiku ; 1119 1120 1121# Instructs the Library rule to not make its object files temporary. 1122# This is needed as some objects are used in a static library and for an 1123# executable. 1124KEEPOBJS = true ; 1125 1126 1127# Set permissions to how they should be on the image. 1128EXEMODE = 755 ; 1129FILEMODE = 644 ; 1130SHELLMODE = 755 ; 1131 1132 1133# output directories 1134# TODO: Review this. 1135HAIKU_DOCUMENTATION_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) documentation ] ; 1136HAIKU_DOCUMENTATION_OBJECT_DIR ?= [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) 1137 documentation ] ; 1138 1139# TODO: Rethink test stuff. 1140HAIKU_TEST_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) tests 1141 $(TARGET_PLATFORM) $(HAIKU_ARCH) ] ; 1142HAIKU_APP_TEST_DIR ?= [ FDirName $(HAIKU_TEST_DIR) apps ] ; 1143HAIKU_APP_TEST_LIB_DIR ?= [ FDirName $(HAIKU_APP_TEST_DIR) lib ] ; 1144HAIKU_TMP_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) tmp ] ; 1145 1146HAIKU_PACKAGE_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) packages ] ; 1147HAIKU_PACKAGE_OBJECT_DIR ?= [ FDirName $(HAIKU_OBJECT_DIR) packages ] ; 1148 1149TARGET_TEST_DIR ?= [ FDirName $(HAIKU_TEST_DIR) 1150 $(TARGET_PLATFORM) ] ; 1151TARGET_UNIT_TEST_DIR ?= [ FDirName $(TARGET_TEST_DIR) unittests ] ; 1152TARGET_UNIT_TEST_LIB_DIR ?= [ FDirName $(TARGET_UNIT_TEST_DIR) lib ] ; 1153 1154# automatically setup the objects directory per subdirectory 1155SUBDIRRULES += SetupObjectsDir ; 1156 1157# Add the standard (userland) warning flags variables to the ones restored in 1158# every subdirectory. Thus we can easily meddle with them in subdirectories 1159# with imported sources. 1160AUTO_SET_UP_CONFIG_VARIABLES += 1161 HOST_WARNING_CCFLAGS HOST_WARNING_C++FLAGS 1162 TARGET_WARNING_CCFLAGS TARGET_WARNING_C++FLAGS 1163 1164 # also add PLATFORM and SUPPORTED_PLATFORMS 1165 PLATFORM SUPPORTED_PLATFORMS 1166; 1167 1168 1169# enable -Werror for certain parts of the source tree 1170 1171if $(HAIKU_GCC_VERSION[1]) = 2 { 1172 rule EnableWerror dirTokens : scope { 1173 AppendToConfigVar CCFLAGS : HAIKU_TOP $(dirTokens) : -Werror 1174 : $(scope) ; 1175 AppendToConfigVar C++FLAGS : HAIKU_TOP $(dirTokens) : -Werror 1176 : $(scope) ; 1177 } 1178} else { 1179 # -Wuninitialized gives too many false positives. 1180 rule EnableWerror dirTokens : scope { 1181 AppendToConfigVar CCFLAGS : HAIKU_TOP $(dirTokens) 1182 : -Werror -Wno-error=uninitialized : $(scope) ; 1183 AppendToConfigVar C++FLAGS : HAIKU_TOP $(dirTokens) 1184 : -Werror -Wno-error=uninitialized : $(scope) ; 1185 } 1186} 1187 1188# Work-around for GCC 2 problem -- despite -Wno-multichar it reports 1189# multichar warnings in headers/private/kernel/debugger_keymaps.h included by 1190# src/system/kernel/arch/x86/arch_debug_console.cpp. 1191if $(HAIKU_GCC_VERSION[1]) = 2 { 1192 local file = <src!system!kernel!arch!x86>arch_debug_console.o ; 1193 C++FLAGS on $(file) = [ on $(file) return $(C++FLAGS) ] ; 1194} 1195 1196if $(HAIKU_NO_WERROR) != 1 { 1197 EnableWerror src add-ons accelerants 3dfx ; 1198 EnableWerror src add-ons accelerants ati ; 1199 EnableWerror src add-ons accelerants common ; 1200 EnableWerror src add-ons accelerants et6x00 ; 1201# EnableWerror src add-ons accelerants intel_extreme ; 1202# EnableWerror src add-ons accelerants matrox ; 1203 EnableWerror src add-ons accelerants neomagic ; 1204# EnableWerror src add-ons accelerants nvidia ; 1205 EnableWerror src add-ons accelerants nvidia_gpgpu ; 1206# EnableWerror src add-ons accelerants radeon ; 1207 EnableWerror src add-ons accelerants radeon_hd ; 1208 EnableWerror src add-ons accelerants s3 ; 1209 EnableWerror src add-ons accelerants skeleton ; 1210 EnableWerror src add-ons accelerants vesa ; 1211 EnableWerror src add-ons accelerants via ; 1212 EnableWerror src add-ons accelerants vmware ; 1213 EnableWerror src add-ons bluetooth ; 1214 EnableWerror src add-ons decorators ; 1215 EnableWerror src add-ons disk_systems ; 1216 EnableWerror src add-ons input_server devices ; 1217# EnableWerror src add-ons input_server filters ; 1218# EnableWerror src add-ons input_server methods ; 1219 EnableWerror src add-ons kernel bluetooth ; 1220# EnableWerror src add-ons kernel bus_managers acpi ; 1221 EnableWerror src add-ons kernel bus_managers agp_gart ; 1222 EnableWerror src add-ons kernel bus_managers ata ; 1223 EnableWerror src add-ons kernel bus_managers config_manager ; 1224 EnableWerror src add-ons kernel bus_managers firewire ; 1225 EnableWerror src add-ons kernel bus_managers isa ; 1226 EnableWerror src add-ons kernel bus_managers pci ; 1227# EnableWerror src add-ons kernel bus_managers ps2 ; # gcc2 1228 EnableWerror src add-ons kernel bus_managers scsi ; 1229 EnableWerror src add-ons kernel bus_managers usb ; 1230 EnableWerror src add-ons kernel busses agp_gart ; 1231 EnableWerror src add-ons kernel busses ata ; 1232 EnableWerror src add-ons kernel busses scsi ; 1233 EnableWerror src add-ons kernel busses usb ; 1234 EnableWerror src add-ons kernel console ; 1235 EnableWerror src add-ons kernel cpu ; 1236# EnableWerror src add-ons kernel debugger ; # gcc2 1237# EnableWerror src add-ons kernel drivers audio ; 1238 EnableWerror src add-ons kernel drivers bluetooth ; 1239 EnableWerror src add-ons kernel drivers bus ; 1240 EnableWerror src add-ons kernel drivers common ; 1241 EnableWerror src add-ons kernel drivers disk ; 1242 EnableWerror src add-ons kernel drivers dvb ; 1243# EnableWerror src add-ons kernel drivers graphics ; 1244# EnableWerror src add-ons kernel drivers input ; 1245 EnableWerror src add-ons kernel drivers joystick ; 1246 EnableWerror src add-ons kernel drivers midi ; 1247 EnableWerror src add-ons kernel drivers misc ; 1248# EnableWerror src add-ons kernel drivers network ; 1249 EnableWerror src add-ons kernel drivers ports ; 1250# EnableWerror src add-ons kernel drivers power ; 1251 EnableWerror src add-ons kernel drivers printer ; 1252 EnableWerror src add-ons kernel drivers random ; 1253 EnableWerror src add-ons kernel drivers tty ; 1254 EnableWerror src add-ons kernel drivers video ; 1255 EnableWerror src add-ons kernel file_systems bfs ; 1256 EnableWerror src add-ons kernel file_systems cdda ; 1257# EnableWerror src add-ons kernel file_systems ext2 ; 1258# EnableWerror src add-ons kernel file_systems fat ; 1259# EnableWerror src add-ons kernel file_systems googlefs ; 1260 EnableWerror src add-ons kernel file_systems iso9660 ; 1261 EnableWerror src add-ons kernel file_systems layers ; 1262 EnableWerror src add-ons kernel file_systems netfs ; 1263 EnableWerror src add-ons kernel file_systems nfs ; 1264# EnableWerror src add-ons kernel file_systems ntfs ; 1265 EnableWerror src add-ons kernel file_systems packagefs ; 1266 EnableWerror src add-ons kernel file_systems ramfs ; 1267# EnableWerror src add-ons kernel file_systems reiserfs ; 1268 EnableWerror src add-ons kernel file_systems udf ; 1269 EnableWerror src add-ons kernel file_systems userlandfs ; 1270 EnableWerror src add-ons kernel generic ; 1271# EnableWerror src add-ons kernel network datalink_protocols ; 1272 EnableWerror src add-ons kernel network devices ; 1273 EnableWerror src add-ons kernel network notifications ; 1274 EnableWerror src add-ons kernel network ppp ; 1275 EnableWerror src add-ons kernel network protocols ; 1276# EnableWerror src add-ons kernel network stack ; 1277 EnableWerror src add-ons kernel partitioning_systems ; 1278 EnableWerror src add-ons locale ; 1279 EnableWerror src add-ons mail_daemon ; 1280 EnableWerror src add-ons media media-add-ons demultiplexer ; 1281 EnableWerror src add-ons media media-add-ons dvb ; 1282 EnableWerror src add-ons media media-add-ons esound_sink ; 1283 EnableWerror src add-ons media media-add-ons finepix_webcam ; 1284 EnableWerror src add-ons media media-add-ons firewire_dv ; 1285 EnableWerror src add-ons media media-add-ons legacy ; 1286 EnableWerror src add-ons media media-add-ons mixer ; 1287 EnableWerror src add-ons media media-add-ons multi_audio ; 1288 EnableWerror src add-ons media media-add-ons opensound ; 1289 EnableWerror src add-ons media media-add-ons radeon ; 1290 EnableWerror src add-ons media media-add-ons reader ; 1291 EnableWerror src add-ons media media-add-ons tone_producer_demo ; 1292 EnableWerror src add-ons media media-add-ons usb_vision ; 1293# EnableWerror src add-ons media media-add-ons usb_webcam ; 1294 EnableWerror src add-ons media media-add-ons video_mixer ; 1295# EnableWerror src add-ons media media-add-ons video_producer_demo ; 1296 EnableWerror src add-ons media media-add-ons videowindow ; 1297 EnableWerror src add-ons media media-add-ons writer ; 1298 EnableWerror src add-ons media plugins ac3_decoder ; 1299 EnableWerror src add-ons media plugins aiff_reader ; 1300 EnableWerror src add-ons media plugins ape_reader ; 1301# EnableWerror src add-ons media plugins asf_reader ; 1302 EnableWerror src add-ons media plugins au_reader ; 1303# EnableWerror src add-ons media plugins avi_reader ; 1304# EnableWerror src add-ons media plugins ffmpeg ; 1305# EnableWerror src add-ons media plugins matroska ; 1306# EnableWerror src add-ons media plugins mov_reader ; 1307 EnableWerror src add-ons media plugins mp3_decoder ; 1308# EnableWerror src add-ons media plugins mp3_reader ; 1309 EnableWerror src add-ons media plugins mp4_reader ; 1310 EnableWerror src add-ons media plugins musepack ; 1311# EnableWerror src add-ons media plugins ogg ; 1312# EnableWerror src add-ons media plugins raw_decoder ; 1313# EnableWerror src add-ons media plugins speex ; 1314 EnableWerror src add-ons media plugins theora ; 1315 EnableWerror src add-ons media plugins vorbis ; 1316# EnableWerror src add-ons media plugins wav_reader ; 1317 EnableWerror src add-ons media plugins xvid_decoder ; 1318 EnableWerror src add-ons opengl ; 1319 EnableWerror src add-ons print ; 1320 EnableWerror src add-ons screen_savers ; 1321 EnableWerror src add-ons tracker ; 1322 EnableWerror src add-ons translators bmp ; 1323# EnableWerror src add-ons translators exr ; 1324 EnableWerror src add-ons translators gif ; 1325 EnableWerror src add-ons translators hpgs ; 1326 EnableWerror src add-ons translators hvif ; 1327 EnableWerror src add-ons translators ico ; 1328# EnableWerror src add-ons translators jpeg ; # gcc2 1329 EnableWerror src add-ons translators jpeg2000 ; 1330 EnableWerror src add-ons translators pcx ; 1331# EnableWerror src add-ons translators png ; # gcc2 1332 EnableWerror src add-ons translators ppm ; 1333 EnableWerror src add-ons translators raw ; 1334 EnableWerror src add-ons translators rtf ; 1335 EnableWerror src add-ons translators sgi ; 1336 EnableWerror src add-ons translators shared ; 1337 EnableWerror src add-ons translators stxt ; 1338 EnableWerror src add-ons translators tga ; 1339 EnableWerror src add-ons translators tiff ; 1340 EnableWerror src add-ons translators wonderbrush ; 1341 EnableWerror src add-ons print ; 1342 EnableWerror src bin package ; 1343 EnableWerror src apps ; 1344 EnableWerror src kits ; 1345 EnableWerror src preferences ; 1346 EnableWerror src servers ; 1347 EnableWerror src system kernel ; 1348 EnableWerror src system runtime_loader ; 1349} 1350 1351