1rule ArchitectureSetup architecture 2{ 3 # ArchitectureSetup <architecture> ; 4 # 5 # Initializes all global packaging architecture dependent variables for the 6 # given packaging architecture. Also sets HAIKU_ARCH (to the primary 7 # architecture), if this is the first invocation of the rule, and adds 8 # the architecture to HAIKU_ARCHS, if not yet contained. 9 10 # analyze GCC version 11 local gccVersion 12 = [ FAnalyzeGCCVersion HAIKU_GCC_RAW_VERSION_$(architecture) ] ; 13 HAIKU_GCC_VERSION_$(architecture) = $(gccVersion) ; 14 15 # enable GCC -pipe option, if requested 16 local ccBaseFlags ; 17 if $(HAIKU_USE_GCC_PIPE) = 1 { 18 ccBaseFlags = -pipe ; 19 } 20 21 # disable strict aliasing on anything newer than gcc 2 as it may lead to 22 # unexpected results. 23 # TODO: remove the -fno-strict-aliasing option when all code has been 24 # analyzed/fixed with regard to aliasing. 25 if $(gccVersion[1]) >= 3 { 26 ccBaseFlags += -fno-strict-aliasing ; 27 } 28 29 # Without this flag, GCC deletes many null-pointer checks that are 30 # technically undefined behavior (e.g. passing NULL to strdup, among 31 # others), which breaks both the kernel and various applications. See: 32 # - https://freelists.org/post/haiku-development/hrev45320-Yet-another-nonobvious-effect-of-ftreevrp-optimization 33 # - https://dev.haiku-os.org/ticket/13285#comment:8 (& subsequent comments) 34 # - https://dev.haiku-os.org/ticket/10803#comment:4 (& subsequent comments) 35 # Note that the Linux also does the same: 36 # - https://github.com/torvalds/linux/commit/a3ca86aea507904 37 if $(gccVersion[1]) >= 3 { 38 ccBaseFlags += -fno-delete-null-pointer-checks ; 39 } 40 41 # disable some builtins that are incompatible with our definitions 42 if $(gccVersion[1]) >= 3 { 43 ccBaseFlags += -fno-builtin-fork -fno-builtin-vfork ; 44 } 45 46 # default architecture tuning 47 local cpu = $(HAIKU_CPU_$(architecture)) ; 48 local archFlags ; 49 switch $(cpu) { 50 case ppc : archFlags += -mcpu=440fp ; 51 case arm : archFlags += -march=armv7-a -mfloat-abi=hard ; 52 case x86 : archFlags += -march=pentium ; 53 } 54 if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 { 55 # TODO: This should be included in Clang's compiler specs. 56 archFlags += -fPIC ; 57 } 58 ccBaseFlags += $(archFlags) ; 59 60 if $(cpu) = arm { 61 if $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 { 62 # For stackcrawls - not supported by Clang 63 ccBaseFlags += -mapcs-frame ; 64 } 65 } 66 67 # activating graphite optimizations 68 if $(HAIKU_USE_GCC_GRAPHITE_$(architecture)) = 1 { 69 ccBaseFlags += -floop-interchange -ftree-loop-distribution 70 -floop-strip-mine -floop-block ; 71 } 72 HAIKU_GCC_BASE_FLAGS_$(architecture) = $(ccBaseFlags) ; 73 74 # initial state for flags etc. 75 HAIKU_C++_$(architecture) ?= $(HAIKU_CC_$(architecture)) ; 76 HAIKU_LINK_$(architecture) = $(HAIKU_CC_$(architecture)) ; 77 78 HAIKU_CCFLAGS_$(architecture) += $(ccBaseFlags) -nostdinc ; 79 HAIKU_C++FLAGS_$(architecture) += $(ccBaseFlags) -nostdinc ; 80 HAIKU_LINKFLAGS_$(architecture) += $(ccBaseFlags) ; 81 HAIKU_ASFLAGS_$(architecture) += $(archFlags) -nostdinc ; 82 83 # strip is required 84 if ! $(HAIKU_STRIP_$(architecture)) { 85 Exit "HAIKU_STRIP_$(architecture) not set. Please re-run configure." ; 86 } 87 88 HAIKU_ARCH_$(architecture) = $(cpu) ; 89 HAIKU_ARCH ?= $(cpu) ; 90 # Set only, if not set yet. This way HAIKU_ARCH is set to the primary 91 # architecture. 92 if ! $(cpu) in $(HAIKU_ARCHS) { 93 HAIKU_ARCHS += $(cpu) ; 94 } 95 HAIKU_DEFINES_$(architecture) += ARCH_$(cpu) ; 96 97 # directories 98 HAIKU_ARCH_OBJECT_DIR_$(architecture) 99 = [ FDirName $(HAIKU_OBJECT_BASE_DIR) $(architecture) ] ; 100 HAIKU_COMMON_DEBUG_OBJECT_DIR_$(architecture) 101 = [ FDirName $(HAIKU_ARCH_OBJECT_DIR_$(architecture)) common ] ; 102 HAIKU_DEBUG_0_OBJECT_DIR_$(architecture) 103 = [ FDirName $(HAIKU_ARCH_OBJECT_DIR_$(architecture)) release ] ; 104 105 local level ; 106 for level in $(HAIKU_DEBUG_LEVELS[2-]) { 107 HAIKU_DEBUG_$(level)_OBJECT_DIR_$(architecture) 108 = [ FDirName $(HAIKU_ARCH_OBJECT_DIR_$(architecture)) 109 debug_$(level) ] ; 110 } 111 112 # set variables for gcc header options 113 SetIncludePropertiesVariables HAIKU : _$(architecture) ; 114 115 # C/C++ flags 116 if $(gccVersion[1]) >= 4 { 117 HAIKU_C++FLAGS_$(architecture) += -Wno-deprecated ; 118 } 119 120 # warning flags 121 HAIKU_WARNING_CCFLAGS_$(architecture) 122 = -Wall -Wno-trigraphs -Wmissing-prototypes 123 -Wpointer-arith -Wcast-align -Wsign-compare -Wno-multichar ; 124 HAIKU_WARNING_C++FLAGS_$(architecture) = -Wall -Wno-trigraphs 125 -Wno-ctor-dtor-privacy -Woverloaded-virtual -Wpointer-arith -Wcast-align 126 -Wsign-compare -Wno-multichar ; 127 # disable some Clang warnings that are not very useful 128 if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 { 129 HAIKU_WARNING_CCFLAGS_$(architecture) += -Wno-address-of-packed-member 130 -Wno-unused-private-field -Wno-cast-align -Wno-gnu-designator ; 131 HAIKU_WARNING_C++FLAGS_$(architecture) += -Wno-address-of-packed-member 132 -Wno-unused-private-field -Wno-cast-align -Wno-gnu-designator ; 133 } 134 135 HAIKU_WERROR_FLAGS_$(architecture) = ; 136 137 if $(gccVersion[1]) >= 4 { 138 # -Wuninitialized gives too many false positives. 139 HAIKU_WERROR_FLAGS_$(architecture) += -Wno-error=uninitialized 140 -Wno-error=maybe-uninitialized ; 141 142 # TODO: remove the -Wno-unused-but-set-variable option 143 HAIKU_WERROR_FLAGS_$(architecture) += -Wno-unused-but-set-variable ; 144 } 145 146 # debug flags 147 local debugFlags = -ggdb ; 148 149 # debug 0: suppress asserts 150 HAIKU_DEBUG_0_CCFLAGS_$(architecture) = [ FDefines NDEBUG=$(NDEBUG) ] ; 151 HAIKU_DEBUG_0_C++FLAGS_$(architecture) = [ FDefines NDEBUG=$(NDEBUG) ] ; 152 153 local level ; 154 for level in $(HAIKU_DEBUG_LEVELS[2-]) { 155 local flags = $(debugFlags) [ FDefines DEBUG=$(level) ] ; 156 HAIKU_DEBUG_$(level)_CCFLAGS_$(architecture) = $(flags) ; 157 HAIKU_DEBUG_$(level)_C++FLAGS_$(architecture) = $(flags) ; 158 } 159 160 # TODO: Temporary work-around. Should be defined in the compiler specs 161 HAIKU_LINKFLAGS_$(architecture) += -Xlinker --no-undefined ; 162 163 if $(gccVersion[1]) < 3 { 164 HAIKU_DEFINES_$(architecture) += _BEOS_R5_COMPATIBLE_ ; 165 } 166 167 # private shared kernel/libroot headers 168 HAIKU_PRIVATE_SYSTEM_HEADERS_$(architecture) 169 = [ PrivateHeaders $(DOT) system system/arch/$(cpu) ] ; 170 171 # library and executable glue code 172 local commonGlueCode = 173 <src!system!glue!$(architecture)>init_term_dyn.o 174 <src!system!glue!arch!$(cpu)!$(architecture)>crti.o 175 <src!system!glue!arch!$(cpu)!$(architecture)>crtn.o 176 ; 177 HAIKU_LIBRARY_BEGIN_GLUE_CODE_$(architecture) = 178 <src!system!glue!arch!$(cpu)!$(architecture)>crti.o 179 <$(architecture)>crtbeginS.o 180 <src!system!glue!$(architecture)>init_term_dyn.o 181 ; 182 HAIKU_LIBRARY_END_GLUE_CODE_$(architecture) = 183 <$(architecture)>crtendS.o 184 <src!system!glue!arch!$(cpu)!$(architecture)>crtn.o 185 ; 186 HAIKU_EXECUTABLE_BEGIN_GLUE_CODE_$(architecture) = 187 <src!system!glue!arch!$(cpu)!$(architecture)>crti.o 188 <$(architecture)>crtbeginS.o 189 <src!system!glue!$(architecture)>start_dyn.o 190 <src!system!glue!$(architecture)>init_term_dyn.o 191 ; 192 HAIKU_EXECUTABLE_END_GLUE_CODE_$(architecture) 193 = $(HAIKU_LIBRARY_END_GLUE_CODE_$(architecture)) ; 194 195 SEARCH on <$(architecture)>crtbeginS.o <$(architecture)>crtendS.o 196 = $(HAIKU_GCC_LIB_DIR_$(architecture)) ; 197 198 # init library name map 199 local libraryGrist = "" ; 200 if $(architecture) != $(HAIKU_PACKAGING_ARCHS[1]) { 201 libraryGrist = $(architecture) ; 202 } 203 local i ; 204 for i in be bnetapi debug device game locale mail media midi midi2 205 network package root screensaver textencoding tracker 206 translation z { 207 local library = lib$(i).so ; 208 HAIKU_LIBRARY_NAME_MAP_$(architecture)_$(i) 209 = $(library:G=$(libraryGrist)) ; 210 } 211 HAIKU_LIBRARY_NAME_MAP_$(architecture)_localestub 212 = <$(architecture)>liblocalestub.a ; 213 HAIKU_LIBRARY_NAME_MAP_$(architecture)_shared 214 = <$(architecture)>libshared.a ; 215 if $(architecture) = $(HAIKU_PACKAGING_ARCHS[1]) { 216 HAIKU_LIBRARY_NAME_MAP_$(architecture)_input_server 217 = <nogrist>input_server ; 218 } else { 219 HAIKU_LIBRARY_NAME_MAP_$(architecture)_input_server 220 = <$(architecture)>input_server ; 221 } 222} 223 224 225rule KernelArchitectureSetup architecture 226{ 227 # KernelArchitectureSetup <architecture> ; 228 # 229 # Initializes the global kernel and boot loader related variables. Those 230 # don't have a packaging architecture suffix, since they are only set for 231 # the primary packaging architecture. <architecture> is the primary 232 # packaging architecture (supplied for convenience). 233 234 HAIKU_KERNEL_ARCH = $(HAIKU_ARCH) ; 235 236 local gccVersion = $(HAIKU_GCC_VERSION_$(architecture)) ; 237 local cpu = $(HAIKU_CPU_$(architecture)) ; 238 239 switch $(cpu) { 240 case ppc : 241 HAIKU_BOOT_PLATFORM ?= openfirmware ; 242 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 2880 ; # in kB 243 # offset in floppy image (>= sizeof(haiku_loader)) 244 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 384 ; # in kB 245 246 case arm : 247 HAIKU_BOOT_PLATFORM ?= u-boot ; 248 249 HAIKU_BOOT_SDIMAGE_SIZE ?= 128 ; 250 # SOC's like allwinner need an offset to skip the hardcoded initial loader 251 HAIKU_BOOT_SDIMAGE_BEGIN = 40950 ; # 512-byte sectors (divisible by 63) 252 253 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; 254 # offset in floppy image (>= sizeof(haiku_loader)) 255 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet 256 HAIKU_BOOT_LOADER_BASE ?= 0x1000000 ; 257 258 case arm64 : 259 HAIKU_BOOT_PLATFORM ?= efi ; 260 261 HAIKU_BOOT_SDIMAGE_SIZE ?= 128 ; 262 # SOC's like allwinner need an offset to skip the hardcoded initial loader 263 HAIKU_BOOT_SDIMAGE_BEGIN = 40950 ; # 512-byte sectors (divisible by 63) 264 265 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; 266 # offset in floppy image (>= sizeof(haiku_loader)) 267 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet 268 HAIKU_BOOT_LOADER_BASE ?= 0x1000000 ; 269 270 case x86 : 271 HAIKU_BOOT_PLATFORM ?= bios_ia32 ; 272 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 2880 ; # in kB 273 # offset in floppy image (>= sizeof(haiku_loader)) 274 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 320 ; # in kB 275 276 # nasm is required for target arch x86 277 if ! $(HAIKU_NASM) { 278 Exit "HAIKU_NASM not set. Please re-run configure." ; 279 } 280 281 case x86_64 : 282 # x86_64 completely shares the x86 bootloader. 283 HAIKU_BOOT_PLATFORM ?= bios_ia32 ; 284 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 2880 ; # in kB 285 # offset in floppy image (>= sizeof(haiku_loader)) 286 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 320 ; # in kB 287 288 # x86_64 kernel source is under arch/x86. 289 HAIKU_KERNEL_ARCH = x86 ; 290 291 # nasm is required for target arch x86_64 292 if ! $(HAIKU_NASM) { 293 Exit "HAIKU_NASM not set. Please re-run configure." ; 294 } 295 296 case m68k : 297 HAIKU_BOOT_PLATFORM ?= atari_m68k ; 298 switch $(HAIKU_BOOT_PLATFORM) { 299 case atari_m68k : 300 { 301 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; # in kB 302 } 303 case amiga_m68k : 304 { 305 # for now we have trouble reading from double-sided images 306 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 880 ; # in kB 307 } 308 } 309 # offset in floppy image (>= sizeof(haiku_loader)) 310 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 260 ; # in kB 311 HAIKU_CONTAINER_STRIP_EXECUTABLES on 312 $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME) = 1 ; 313 314 case * : 315 Exit "Currently unsupported target CPU:" $(cpu) ; 316 } 317 318 # private kernel headers to be used when compiling kernel code 319 HAIKU_PRIVATE_KERNEL_HEADERS = 320 [ PrivateHeaders $(DOT) kernel libroot shared 321 kernel/boot/platform/$(HAIKU_BOOT_PLATFORM) ] 322 [ ArchHeaders $(HAIKU_KERNEL_ARCH) ] 323 [ FDirName $(HAIKU_COMMON_DEBUG_OBJECT_DIR_$(architecture)) system 324 kernel ] 325 $(HAIKU_PRIVATE_SYSTEM_HEADERS_$(architecture)) 326 ; 327 328 # C/C++ flags 329 local ccBaseFlags = $(HAIKU_GCC_BASE_FLAGS_$(architecture)) 330 -finline -fno-builtin ; 331 332 if $(gccVersion[1]) >= 4 { 333 ccBaseFlags += -ffreestanding ; 334 } 335 336 local c++BaseFlags = $(ccBaseFlags) -fno-exceptions ; 337 338 if $(gccVersion[1]) >= 3 && $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 { 339 c++BaseFlags += -fno-use-cxa-atexit ; 340 } 341 342 HAIKU_KERNEL_CCFLAGS = $(HAIKU_CCFLAGS_$(architecture)) $(ccBaseFlags) ; 343 HAIKU_KERNEL_C++FLAGS = $(HAIKU_C++FLAGS_$(architecture)) $(c++BaseFlags) ; 344 HAIKU_BOOT_CCFLAGS = $(HAIKU_CCFLAGS_$(architecture)) $(ccBaseFlags) ; 345 HAIKU_BOOT_C++FLAGS = $(HAIKU_C++FLAGS_$(architecture)) $(c++BaseFlags) ; 346 HAIKU_BOOT_LINKFLAGS = ; 347 HAIKU_BOOT_LDFLAGS = -Bstatic ; 348 349 HAIKU_KERNEL_PIC_CCFLAGS = -fno-pic ; 350 HAIKU_KERNEL_PIC_LINKFLAGS = ; 351 HAIKU_KERNEL_ADDON_LINKFLAGS = ; 352 353 # Any special kernel base addresses 354 if $(HAIKU_BOOT_LOADER_BASE) { 355 HAIKU_BOOT_LDFLAGS += 356 --defsym BOOT_LOADER_BASE=$(HAIKU_BOOT_LOADER_BASE) ; 357 } 358 359 switch $(cpu) { 360 case arm : 361 # Workaround for ld using 32k for alignment despite forcing it in the config... 362 # should definitely not be needed! 363 HAIKU_KERNEL_LINKFLAGS += 364 -Wl,-z -Wl,max-page-size=0x1000 365 -Wl,-z -Wl,common-page-size=0x1000 ; 366 367 case ppc : 368 # Build a position independent PPC kernel. We need to be able to 369 # relocate the kernel, since the virtual address space layout at 370 # boot time is not fixed. 371 HAIKU_KERNEL_PIC_CCFLAGS = -fPIE ; 372 HAIKU_KERNEL_PIC_LINKFLAGS = -shared -fPIE ; 373 374 case m68k : 375 # We don't want to have to handle emulating missing FPU opcodes for 376 # 040 and 060 in the kernel. 377 HAIKU_KERNEL_CCFLAGS += -mtune=68020-60 ; 378 HAIKU_KERNEL_C++FLAGS += -mtune=68020-60 ; 379 380 case x86 : 381 # EFI Bootloader 382 if $(HAIKU_BOOT_PLATFORM) = efi { 383 HAIKU_BOOT_CCFLAGS += -mno-red-zone -maccumulate-outgoing-args ; 384 HAIKU_BOOT_C++FLAGS += -mno-red-zone -maccumulate-outgoing-args ; 385 } 386 387 case x86_64 : 388 # Kernel lives in the top 2GB of the address space, use kernel code 389 # model. 390 HAIKU_KERNEL_PIC_CCFLAGS += -mcmodel=kernel ; 391 392 # Disable the red zone, which cannot be used in kernel code due to 393 # interrupts, and always enable the frame pointer so stack traces 394 # are correct. 395 HAIKU_KERNEL_CCFLAGS += -mno-red-zone -fno-omit-frame-pointer ; 396 HAIKU_KERNEL_C++FLAGS += -mno-red-zone -fno-omit-frame-pointer ; 397 HAIKU_KERNEL_PIC_LINKFLAGS += -z max-page-size=0x1000 ; 398 HAIKU_KERNEL_ADDON_LINKFLAGS += -z max-page-size=0x1000 ; 399 400 # BIOS Bootloader is 32-bit. 401 if $(HAIKU_BOOT_PLATFORM) = bios_ia32 { 402 if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 { 403 HAIKU_BOOT_LINKFLAGS += -m elf_i386 ; 404 } else { 405 HAIKU_BOOT_LINKFLAGS += -m elf_i386_haiku ; 406 } 407 HAIKU_BOOT_CCFLAGS += -m32 -march=pentium ; 408 HAIKU_BOOT_C++FLAGS += -m32 -march=pentium ; 409 } 410 411 # EFI Bootloader 412 if $(HAIKU_BOOT_PLATFORM) = efi { 413 HAIKU_BOOT_CCFLAGS += -mno-red-zone -maccumulate-outgoing-args ; 414 HAIKU_BOOT_C++FLAGS += -mno-red-zone -maccumulate-outgoing-args ; 415 } 416 417 if x86 in $(HAIKU_ARCHS[2-]) || x86_gcc2 in $(HAIKU_ARCHS[2-]) { 418 Echo "Enable kernel ia32 compatibility" ; 419 HAIKU_KERNEL_DEFINES += _COMPAT_MODE ; 420 HAIKU_KERNEL_COMPAT_MODE = 1 ; 421 } 422 } 423 424 if $(HAIKU_BOOT_PLATFORM) = efi { 425 HAIKU_BOOT_CCFLAGS += -fpic -fno-stack-protector -fPIC -fshort-wchar 426 -Wno-error=unused-variable ; 427 HAIKU_BOOT_C++FLAGS += -fpic -fno-stack-protector -fPIC -fshort-wchar 428 -Wno-error=unused-variable ; 429 HAIKU_BOOT_LDFLAGS = -Bstatic -Bsymbolic -shared -nostdlib -znocombreloc -nostartfiles -no-undefined ; 430 } else { 431 HAIKU_BOOT_CCFLAGS += -fno-pic ; 432 HAIKU_BOOT_C++FLAGS += -fno-pic ; 433 } 434 435 # warning flags 436 HAIKU_KERNEL_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes 437 -Wno-multichar ; 438 HAIKU_KERNEL_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-multichar ; 439 440 # debug flags 441 local level ; 442 for level in $(HAIKU_DEBUG_LEVELS) { 443 local flags = $(HAIKU_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ; 444 HAIKU_KERNEL_DEBUG_$(level)_CCFLAGS 445 = $(HAIKU_DEBUG_$(level)_CCFLAGS_$(architecture)) ; 446 HAIKU_KERNEL_DEBUG_$(level)_C++FLAGS 447 = $(HAIKU_DEBUG_$(level)_C++FLAGS_$(architecture)) ; 448 } 449 450 # defines 451 HAIKU_KERNEL_DEFINES += _KERNEL_MODE ; 452 453 HAIKU_DEFINES_$(architecture) 454 += BOOT_ARCHIVE_IMAGE_OFFSET=$(HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET) ; 455 # TODO: That doesn't need to be a general define. It's just needed for 456 # compiling (part of) the boot loader. 457 458 # kernel add-on glue code 459 HAIKU_KERNEL_ADDON_BEGIN_GLUE_CODE = <$(architecture)>crtbeginS.o 460 <src!system!glue!$(architecture)>haiku_version_glue.o ; 461 HAIKU_KERNEL_ADDON_END_GLUE_CODE = <$(architecture)>crtendS.o ; 462} 463 464 465rule ArchitectureSetupWarnings architecture 466{ 467 # ArchitectureSetupWarnings <architecture> ; 468 # 469 # Sets up compiler warnings and error flags for various subdirectories for 470 # the given packaging architecture. 471 472 if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 { 473 AppendToConfigVar CCFLAGS : 474 HAIKU_TOP src system libroot posix glibc : 475 -fgnu89-inline -fheinous-gnu-extensions : global ; 476 } 477 478 local cpu = $(HAIKU_CPU_$(architecture)) ; 479 switch $(cpu) { 480 case arm : 481 return ; 482 # we use #warning as placeholders for things to write... 483 case m68k : 484 return ; 485 # we use #warning as placeholders for things to write... 486 case ppc : 487 return ; 488 # we use #warning as placeholders for things to write... 489 } 490 491 # enable -Werror for certain parts of the source tree 492 HAIKU_WERROR_ARCH = $(architecture) ; 493 494 rule EnableWerror dirTokens : scope { 495 # Clang gives way more warnings than GCC, so that code won't compile 496 # with -Werror when using Clang. 497 if $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 { 498 SetConfigVar WARNINGS : HAIKU_TOP $(dirTokens) : treatAsErrors 499 : $(scope) ; 500 } 501 } 502 503 # Work-around for GCC 2 problem -- despite -Wno-multichar it reports 504 # multichar warnings in headers/private/kernel/debugger_keymaps.h included 505 # by src/system/kernel/arch/x86/arch_debug_console.cpp. 506 local gccVersion = $(HAIKU_GCC_VERSION_$(architecture)) ; 507 if $(gccVersion[1]) = 2 { 508 local file = <src!system!kernel!arch!x86>arch_debug_console.o ; 509 WARNINGS on $(file) = $(WARNINGS) ; 510 } 511 512 EnableWerror src add-ons accelerants ; 513 EnableWerror src add-ons bluetooth ; 514 EnableWerror src add-ons decorators ; 515 EnableWerror src add-ons disk_systems ; 516 EnableWerror src add-ons input_server devices ; 517 EnableWerror src add-ons input_server filters ; 518# EnableWerror src add-ons input_server methods pen ; 519 EnableWerror src add-ons input_server methods t9 ; 520 EnableWerror src add-ons kernel bluetooth ; 521 EnableWerror src add-ons kernel bus_managers acpi ; 522 EnableWerror src add-ons kernel bus_managers agp_gart ; 523 EnableWerror src add-ons kernel bus_managers ata ; 524 EnableWerror src add-ons kernel bus_managers config_manager ; 525# EnableWerror src add-ons kernel bus_managers firewire ; 526 EnableWerror src add-ons kernel bus_managers ide ; 527 EnableWerror src add-ons kernel bus_managers isa ; 528 EnableWerror src add-ons kernel bus_managers pci ; 529 EnableWerror src add-ons kernel bus_managers ps2 ; 530 EnableWerror src add-ons kernel bus_managers random ; 531 EnableWerror src add-ons kernel bus_managers scsi ; 532 EnableWerror src add-ons kernel bus_managers tty ; 533 EnableWerror src add-ons kernel bus_managers usb ; 534 EnableWerror src add-ons kernel bus_managers virtio ; 535 EnableWerror src add-ons kernel busses agp_gart ; 536 EnableWerror src add-ons kernel busses ata ; 537 EnableWerror src add-ons kernel busses scsi ; 538 EnableWerror src add-ons kernel busses usb ; 539 EnableWerror src add-ons kernel console ; 540 EnableWerror src add-ons kernel cpu ; 541# EnableWerror src add-ons kernel debugger ; # gcc2 542# EnableWerror src add-ons kernel drivers audio ; 543 EnableWerror src add-ons kernel drivers bluetooth ; 544 EnableWerror src add-ons kernel drivers bus ; 545 EnableWerror src add-ons kernel drivers common ; 546 EnableWerror src add-ons kernel drivers disk ; 547 EnableWerror src add-ons kernel drivers dvb ; 548# EnableWerror src add-ons kernel drivers graphics ; 549 EnableWerror src add-ons kernel drivers graphics intel_extreme ; 550# EnableWerror src add-ons kernel drivers input ; 551 EnableWerror src add-ons kernel drivers joystick ; 552 EnableWerror src add-ons kernel drivers midi ; 553 EnableWerror src add-ons kernel drivers misc ; 554# EnableWerror src add-ons kernel drivers network ; 555 EnableWerror src add-ons kernel drivers ports ; 556# EnableWerror src add-ons kernel drivers power ; 557 EnableWerror src add-ons kernel drivers printer ; 558 EnableWerror src add-ons kernel drivers random ; 559 EnableWerror src add-ons kernel drivers tty ; 560 EnableWerror src add-ons kernel drivers video ; 561 EnableWerror src add-ons kernel file_systems bfs ; 562 EnableWerror src add-ons kernel file_systems cdda ; 563# EnableWerror src add-ons kernel file_systems ext2 ; 564# EnableWerror src add-ons kernel file_systems fat ; 565# EnableWerror src add-ons kernel file_systems googlefs ; 566 EnableWerror src add-ons kernel file_systems iso9660 ; 567 EnableWerror src add-ons kernel file_systems layers ; 568 EnableWerror src add-ons kernel file_systems netfs ; 569 EnableWerror src add-ons kernel file_systems nfs ; 570 EnableWerror src add-ons kernel file_systems nfs4 ; 571# EnableWerror src add-ons kernel file_systems ntfs ; 572 EnableWerror src add-ons kernel file_systems packagefs ; 573# EnableWerror src add-ons kernel file_systems ramfs ; 574# EnableWerror src add-ons kernel file_systems reiserfs ; 575 EnableWerror src add-ons kernel file_systems udf ; 576 EnableWerror src add-ons kernel file_systems userlandfs ; 577 EnableWerror src add-ons kernel generic ; 578# EnableWerror src add-ons kernel network datalink_protocols ; 579 EnableWerror src add-ons kernel network devices ; 580 EnableWerror src add-ons kernel network dns_resolver ; 581 EnableWerror src add-ons kernel network notifications ; 582 EnableWerror src add-ons kernel network ppp ; 583 EnableWerror src add-ons kernel network protocols ; 584# EnableWerror src add-ons kernel network stack ; 585 EnableWerror src add-ons kernel partitioning_systems ; 586 EnableWerror src add-ons kernel power ; 587 EnableWerror src add-ons locale ; 588 EnableWerror src add-ons mail_daemon ; 589 EnableWerror src add-ons media media-add-ons demultiplexer ; 590 EnableWerror src add-ons media media-add-ons dvb ; 591 EnableWerror src add-ons media media-add-ons esound_sink ; 592 EnableWerror src add-ons media media-add-ons finepix_webcam ; 593 EnableWerror src add-ons media media-add-ons firewire_dv ; 594 EnableWerror src add-ons media media-add-ons legacy ; 595 EnableWerror src add-ons media media-add-ons mixer ; 596 EnableWerror src add-ons media media-add-ons multi_audio ; 597 EnableWerror src add-ons media media-add-ons opensound ; 598 EnableWerror src add-ons media media-add-ons radeon ; 599 EnableWerror src add-ons media media-add-ons reader ; 600 EnableWerror src add-ons media media-add-ons tone_producer_demo ; 601 EnableWerror src add-ons media media-add-ons usb_vision ; 602# EnableWerror src add-ons media media-add-ons usb_webcam ; 603 EnableWerror src add-ons media media-add-ons video_mixer ; 604# EnableWerror src add-ons media media-add-ons video_producer_demo ; 605 EnableWerror src add-ons media media-add-ons videowindow ; 606 EnableWerror src add-ons media media-add-ons writer ; 607 EnableWerror src add-ons media plugins aiff_reader ; 608 EnableWerror src add-ons media plugins ape_reader ; 609# EnableWerror src add-ons media plugins asf_reader ; 610 EnableWerror src add-ons media plugins au_reader ; 611# EnableWerror src add-ons media plugins avi_reader ; 612# EnableWerror src add-ons media plugins ffmpeg ; 613# EnableWerror src add-ons media plugins matroska ; 614# EnableWerror src add-ons media plugins mov_reader ; 615 EnableWerror src add-ons media plugins mp3_decoder ; 616# EnableWerror src add-ons media plugins mp3_reader ; 617 EnableWerror src add-ons media plugins mp4_reader ; 618 EnableWerror src add-ons media plugins musepack ; 619# EnableWerror src add-ons media plugins ogg ; 620# EnableWerror src add-ons media plugins raw_decoder ; 621# EnableWerror src add-ons media plugins speex ; 622 EnableWerror src add-ons media plugins theora ; 623 EnableWerror src add-ons media plugins vorbis ; 624# EnableWerror src add-ons media plugins wav_reader ; 625 EnableWerror src add-ons print ; 626 EnableWerror src add-ons screen_savers ; 627 EnableWerror src add-ons tracker ; 628 EnableWerror src add-ons translators bmp ; 629 EnableWerror src add-ons translators exr ; 630 EnableWerror src add-ons translators gif ; 631 EnableWerror src add-ons translators hvif ; 632 EnableWerror src add-ons translators ico ; 633 EnableWerror src add-ons translators jpeg ; 634# EnableWerror src add-ons translators jpeg2000 ; 635 EnableWerror src add-ons translators pcx ; 636 EnableWerror src add-ons translators png ; 637 EnableWerror src add-ons translators ppm ; 638 EnableWerror src add-ons translators raw ; 639 EnableWerror src add-ons translators rtf ; 640 EnableWerror src add-ons translators sgi ; 641 EnableWerror src add-ons translators shared ; 642 EnableWerror src add-ons translators stxt ; 643 EnableWerror src add-ons translators tga ; 644 EnableWerror src add-ons translators tiff ; 645 EnableWerror src add-ons translators wonderbrush ; 646 EnableWerror src add-ons print ; 647 EnableWerror src bin desklink ; 648 EnableWerror src bin multiuser ; 649 EnableWerror src bin package ; 650 EnableWerror src bin package_repo ; 651 EnableWerror src bin pkgman ; 652 EnableWerror src libs bsd ; 653 EnableWerror src apps ; 654 EnableWerror src kits ; 655 EnableWerror src preferences ; 656 EnableWerror src servers ; 657 EnableWerror src system boot ; 658# EnableWerror src system kernel ; 659 EnableWerror src system libroot add-ons ; 660 EnableWerror src system libroot os ; 661 EnableWerror src system libroot posix locale ; 662 EnableWerror src system libroot posix wchar ; 663 EnableWerror src system runtime_loader ; 664} 665 666 667rule MultiArchIfPrimary ifValue : elseValue : architecture 668{ 669 # MultiArchIfPrimary <ifValue> : <elseValue> 670 # [ : <architecture> = $(TARGET_PACKAGING_ARCH) ] ; 671 # 672 # Returns one of the two given values depending on whether 673 # <architecture> is the primary packaging architecture. 674 675 architecture ?= $(TARGET_PACKAGING_ARCH) ; 676 677 if $(architecture) = $(TARGET_PACKAGING_ARCHS[1]) { 678 return $(ifValue) ; 679 } 680 return $(elseValue) ; 681} 682 683 684rule MultiArchConditionalGristFiles files : primaryGrist : secondaryGrist 685 : architecture 686{ 687 # MultiArchConditionalGristFiles <files> : <primaryGrist> 688 # : <secondaryGrist> [ : <architecture> = $(TARGET_PACKAGING_ARCH) ] ; 689 # 690 # Returns <files> with their grist set to either <primaryGrist> or 691 # <secondaryGrist> depending on whether <architecture> is the primary 692 # packaging architecture. 693 694 architecture ?= $(TARGET_PACKAGING_ARCH) ; 695 696 local grist = [ MultiArchIfPrimary $(primaryGrist) : $(secondaryGrist) 697 : $(architecture) ] ; 698 return $(files:G=$(grist:E=)) ; 699} 700 701 702rule MultiArchDefaultGristFiles files : gristPrefix : architecture 703{ 704 # MultiArchDefaultGristFiles <files> : <gristPrefix> 705 # [ : <architecture> = $(TARGET_PACKAGING_ARCH) ] ; 706 # 707 # Convenient shorthand for MultiArchConditionalGristFiles for the common 708 # case that for a secondary packaging architecture the packaging 709 # architecture name shall be appended to the grist while it shall be omitted 710 # for the primary packaging architecture. IOW, if architecture is the 711 # primary packaging architecture, <files> are returned with their grist set 712 # to <gristPrefix>, otherwise <files> are returned with their grist set to 713 # <gristPrefix>!<architecture> respectively <architecture> (if <gristPrefix> 714 # is empty). 715 716 architecture ?= $(TARGET_PACKAGING_ARCH) ; 717 718 local secondaryGrist = $(gristPrefix)!$(architecture) ; 719 secondaryGrist ?= $(architecture) ; 720 721 return [ MultiArchConditionalGristFiles $(files) : $(gristPrefix) : 722 $(secondaryGrist) : $(architecture) ] ; 723} 724 725 726rule MultiArchSubDirSetup architectures 727{ 728 # MultiArchSubDirSetup <architectures> ; 729 # 730 # For each of the given packaging architectures <architectures> that are 731 # in the packaging architectures configured for the build (or all configured 732 # packaging architectures, if <architectures> is empty) an object is 733 # prepared that can be used for an "on ... { ... }" block to set up subdir 734 # variables for the respective packaging architecture. Most notably 735 # TARGET_PACKAGING_ARCH, TARGET_ARCH are set to the values for the 736 # respective packaging architecture. The per-subdir variables SOURCE_GRIST, 737 # LOCATE_TARGET, LOCATE_SOURCE, SEARCH_SOURCE, *_LOCATE_TARGET, are reset. 738 # All SUBDIR* and config variables are set to the values they had when this 739 # rule was invoked. 740 741 local result ; 742 architectures ?= $(TARGET_PACKAGING_ARCHS) ; 743 local architecture ; 744 for architecture in $(architectures) { 745 if ! $(architecture) in $(TARGET_PACKAGING_ARCHS) { 746 continue ; 747 } 748 749 local architectureObject = $(architecture:G=<arch-object>) ; 750 result += $(architectureObject) ; 751 752 # Set the variables that default to the values of the respective 753 # variables for the primary architecture. 754 TARGET_PACKAGING_ARCH on $(architectureObject) = $(architecture) ; 755 756 local var ; 757 for var in TARGET_ARCH { 758 $(var) on $(architectureObject) = $($(var)_$(architecture)) ; 759 } 760 761 # Clone the current config variable values and the variables SubDir 762 # resets. 763 for var in $(AUTO_SET_UP_CONFIG_VARIABLES) SUBDIR$(SUBDIRRESET) { 764 $(var) on $(architectureObject) = $($(var)) ; 765 } 766 767 # adjust SOURCE_GRIST and HDRGRIST 768 SOURCE_GRIST on $(architectureObject) 769 = $(SOURCE_GRIST:E=)!$(architecture) ; 770 771 HDRGRIST on $(architectureObject) 772 = $(HDRGRIST:E=)!$(architecture) ; 773 774 # Adjust the subdir's object dirs that are architecture dependent. To 775 # avoid duplicating the code from SetupObjectsDir, we call it. Since it 776 # sets global variables, we set these variables on our object, call 777 # SetupObjectsDir in an "on" block, and grab the new variable values. 778 local hostTarget = HOST TARGET ; 779 local objectDirVars = 780 COMMON_ARCH COMMON_DEBUG DEBUG_$(HAIKU_DEBUG_LEVELS) 781 ; 782 objectDirVars = 783 COMMON_PLATFORM_LOCATE_TARGET 784 $(hostTarget)_$(objectDirVars)_LOCATE_TARGET 785 LOCATE_TARGET 786 LOCATE_SOURCE 787 SEARCH_SOURCE 788 ; 789 790 for var in $(objectDirVars) { 791 $(var) on $(architectureObject) = ; 792 } 793 794 on $(architectureObject) { 795 SetupObjectsDir ; 796 797 for var in $(objectDirVars) { 798 $(var) on $(architectureObject) = $($(var)) ; 799 } 800 } 801 } 802 803 return $(result) ; 804} 805