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: These should be included in Clang's compiler specs. 56 ccBaseFlags += -fPIC ; 57 HAIKU_LINKFLAGS_$(architecture) += -shared ; 58 } 59 ccBaseFlags += $(archFlags) ; 60 61 if $(cpu) = arm { 62 if $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 { 63 # For stackcrawls - not supported by Clang 64 ccBaseFlags += -mapcs-frame ; 65 } 66 } 67 68 # activating graphite optimizations 69 if $(HAIKU_USE_GCC_GRAPHITE_$(architecture)) = 1 { 70 ccBaseFlags += -floop-interchange -ftree-loop-distribution 71 -floop-strip-mine -floop-block ; 72 } 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 # warning flags 116 HAIKU_WARNING_CCFLAGS_$(architecture) = -Wall 117 -Wno-multichar 118 -Wpointer-arith -Wsign-compare -Wcast-align 119 -Wmissing-prototypes ; 120 HAIKU_WARNING_C++FLAGS_$(architecture) = -Wall 121 -Wno-multichar 122 -Wpointer-arith -Wsign-compare -Wcast-align 123 -Wno-ctor-dtor-privacy -Woverloaded-virtual ; 124 125 # disable some Clang warnings that are not very useful 126 if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 { 127 HAIKU_WARNING_CCFLAGS_$(architecture) += -Wno-address-of-packed-member 128 -Wno-unused-private-field -Wno-cast-align -Wno-gnu-designator 129 -Wno-builtin-requires-header ; 130 HAIKU_WARNING_C++FLAGS_$(architecture) += -Wno-address-of-packed-member 131 -Wno-unused-private-field -Wno-cast-align -Wno-gnu-designator 132 -Wno-builtin-requires-header ; 133 } 134 135 HAIKU_WERROR_FLAGS_$(architecture) = ; 136 137 if $(gccVersion[1]) >= 4 { 138 # TODO: Remove all these. 139 HAIKU_WERROR_FLAGS_$(architecture) += -Wno-error=unused-but-set-variable 140 -Wno-error=deprecated -Wno-error=deprecated-declarations 141 -Wno-error=cpp -Wno-error=trigraphs ; 142 # But these can stay. 143 HAIKU_WERROR_FLAGS_$(architecture) += -Wno-error=cast-align 144 -Wno-error=format-truncation ; 145 } 146 147 # debug flags 148 local debugFlags = -ggdb ; 149 150 # debug 0: suppress asserts 151 HAIKU_DEBUG_0_CCFLAGS_$(architecture) = [ FDefines NDEBUG=$(NDEBUG) ] ; 152 HAIKU_DEBUG_0_C++FLAGS_$(architecture) = [ FDefines NDEBUG=$(NDEBUG) ] ; 153 154 local level ; 155 for level in $(HAIKU_DEBUG_LEVELS[2-]) { 156 local flags = $(debugFlags) [ FDefines DEBUG=$(level) ] ; 157 HAIKU_DEBUG_$(level)_CCFLAGS_$(architecture) = $(flags) ; 158 HAIKU_DEBUG_$(level)_C++FLAGS_$(architecture) = $(flags) ; 159 } 160 161 # TODO: Temporary work-around. Should be defined in the compiler specs 162 HAIKU_LINKFLAGS_$(architecture) += -Xlinker --no-undefined ; 163 164 if $(gccVersion[1]) < 3 { 165 HAIKU_DEFINES_$(architecture) += _BEOS_R5_COMPATIBLE_ ; 166 } 167 168 # private shared kernel/libroot headers 169 HAIKU_PRIVATE_SYSTEM_HEADERS_$(architecture) 170 = [ PrivateHeaders $(DOT) system system/arch/$(cpu) ] ; 171 172 # library and executable glue code 173 local commonGlueCode = 174 <src!system!glue!$(architecture)>init_term_dyn.o 175 <src!system!glue!arch!$(cpu)!$(architecture)>crti.o 176 <src!system!glue!arch!$(cpu)!$(architecture)>crtn.o 177 ; 178 HAIKU_LIBRARY_BEGIN_GLUE_CODE_$(architecture) = 179 <src!system!glue!arch!$(cpu)!$(architecture)>crti.o 180 <$(architecture)>crtbeginS.o 181 <src!system!glue!$(architecture)>init_term_dyn.o 182 ; 183 HAIKU_LIBRARY_END_GLUE_CODE_$(architecture) = 184 <$(architecture)>crtendS.o 185 <src!system!glue!arch!$(cpu)!$(architecture)>crtn.o 186 ; 187 HAIKU_EXECUTABLE_BEGIN_GLUE_CODE_$(architecture) = 188 <src!system!glue!arch!$(cpu)!$(architecture)>crti.o 189 <$(architecture)>crtbeginS.o 190 <src!system!glue!$(architecture)>start_dyn.o 191 <src!system!glue!$(architecture)>init_term_dyn.o 192 ; 193 HAIKU_EXECUTABLE_END_GLUE_CODE_$(architecture) 194 = $(HAIKU_LIBRARY_END_GLUE_CODE_$(architecture)) ; 195 196 SEARCH on <$(architecture)>crtbeginS.o <$(architecture)>crtendS.o 197 = $(HAIKU_GCC_LIB_DIR_$(architecture)) ; 198 199 # init library name map 200 local libraryGrist = "" ; 201 if $(architecture) != $(HAIKU_PACKAGING_ARCHS[1]) { 202 libraryGrist = $(architecture) ; 203 } 204 local i ; 205 for i in be bnetapi debug device game locale mail media midi midi2 206 network package root screensaver textencoding tracker 207 translation z { 208 local library = lib$(i).so ; 209 HAIKU_LIBRARY_NAME_MAP_$(architecture)_$(i) 210 = $(library:G=$(libraryGrist)) ; 211 } 212 HAIKU_LIBRARY_NAME_MAP_$(architecture)_localestub 213 = <$(architecture)>liblocalestub.a ; 214 HAIKU_LIBRARY_NAME_MAP_$(architecture)_shared 215 = <$(architecture)>libshared.a ; 216 if $(architecture) = $(HAIKU_PACKAGING_ARCHS[1]) { 217 HAIKU_LIBRARY_NAME_MAP_$(architecture)_input_server 218 = <nogrist>input_server ; 219 } else { 220 HAIKU_LIBRARY_NAME_MAP_$(architecture)_input_server 221 = <$(architecture)>input_server ; 222 } 223} 224 225 226rule KernelArchitectureSetup architecture 227{ 228 # KernelArchitectureSetup <architecture> ; 229 # 230 # Initializes the global kernel and boot loader related variables. Those 231 # don't have a packaging architecture suffix, since they are only set for 232 # the primary packaging architecture. <architecture> is the primary 233 # packaging architecture (supplied for convenience). 234 235 HAIKU_KERNEL_ARCH = $(HAIKU_ARCH) ; 236 237 local gccVersion = $(HAIKU_GCC_VERSION_$(architecture)) ; 238 local cpu = $(HAIKU_CPU_$(architecture)) ; 239 240 switch $(cpu) { 241 case ppc : 242 HAIKU_KERNEL_PLATFORM ?= openfirmware ; 243 HAIKU_BOOT_TARGETS += openfirmware ; 244 245 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; # in kB 246 # offset in floppy image (>= sizeof(haiku_loader)) 247 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 384 ; # in kB 248 249 case sparc : 250 HAIKU_KERNEL_PLATFORM ?= openfirmware ; 251 HAIKU_BOOT_TARGETS += openfirmware ; 252 253 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; # in kB 254 # offset in floppy image (>= sizeof(haiku_loader)) 255 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 384 ; # in kB 256 257 case arm : 258 HAIKU_KERNEL_PLATFORM ?= u-boot ; 259 HAIKU_BOOT_TARGETS += u-boot ; 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 # Modern u-boot fill in sane addresses for us. 271 # We only need to fill in the FDT dtb 272 HAIKU_MMC_UBOOT_SCRIPT = "\ 273 test -e mmc 0 uEnv.txt && fatload mmc 0 ${scriptaddr} uEnv.txt && env import -t ${scriptaddr} ${filesize} \ 274 fatload mmc 0 ${kernel_addr_r} haiku_loader.u-boot \ 275 fatload mmc 0 ${ramdisk_addr_r} haiku-floppyboot.tgz.u-boot \ 276 fatload mmc 0 ${fdt_addr_r} ${dtb} \ 277 fdt addr ${fdt_addr_r} \ 278 bootm ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}" ; 279 280 case arm64 : 281 HAIKU_KERNEL_PLATFORM ?= efi ; 282 283 HAIKU_BOOT_SDIMAGE_SIZE ?= 128 ; 284 # SOC's like allwinner need an offset to skip the hardcoded initial loader 285 HAIKU_BOOT_SDIMAGE_BEGIN = 40950 ; # 512-byte sectors (divisible by 63) 286 287 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; 288 # offset in floppy image (>= sizeof(haiku_loader)) 289 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet 290 HAIKU_BOOT_LOADER_BASE ?= 0x1000000 ; 291 292 case x86 : 293 HAIKU_KERNEL_PLATFORM ?= bios_ia32 ; 294 HAIKU_BOOT_TARGETS += bios_ia32 pxe_ia32 ; 295 HAIKU_ANYBOOT_LEGACY = 1 ; 296 297 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 2880 ; # in kB 298 # offset in floppy image (>= sizeof(haiku_loader)) 299 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 320 ; # in kB 300 301 # nasm is required for target arch x86 302 if ! $(HAIKU_NASM) { 303 Exit "HAIKU_NASM not set. Please re-run configure." ; 304 } 305 306 case riscv64 : 307 HAIKU_KERNEL_PLATFORM ?= u-boot ; 308 HAIKU_BOOT_TARGETS += u-boot ; 309 310 HAIKU_BOOT_SDIMAGE_SIZE ?= 128 ; 311 # SOC's like allwinner need an offset to skip the hardcoded initial loader 312 HAIKU_BOOT_SDIMAGE_BEGIN = 40950 ; # 512-byte sectors (divisible by 63) 313 314 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; 315 # offset in floppy image (>= sizeof(haiku_loader)) 316 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet 317 HAIKU_BOOT_LOADER_BASE ?= 0x1000000 ; 318 319 case x86_64 : 320 # x86_64 completely shares the x86 bootloader for MBR. 321 HAIKU_KERNEL_PLATFORM ?= bios_ia32 ; 322 HAIKU_BOOT_TARGETS += bios_ia32 efi pxe_ia32 ; 323 324 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 2880 ; # in kB 325 # offset in floppy image (>= sizeof(haiku_loader)) 326 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 320 ; # in kB 327 328 # x86_64 kernel source is under arch/x86. 329 HAIKU_KERNEL_ARCH = x86 ; 330 331 # nasm is required for target arch x86_64 332 if ! $(HAIKU_NASM) { 333 Exit "HAIKU_NASM not set. Please re-run configure." ; 334 } 335 336 case m68k : 337 HAIKU_KERNEL_PLATFORM ?= atari_m68k ; 338 HAIKU_BOOT_TARGETS += atari_m68k ; 339 switch $(HAIKU_KERNEL_PLATFORM) { 340 case atari_m68k : 341 { 342 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; # in kB 343 } 344 case amiga_m68k : 345 { 346 # for now we have trouble reading from double-sided images 347 HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 880 ; # in kB 348 } 349 } 350 # offset in floppy image (>= sizeof(haiku_loader)) 351 HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 260 ; # in kB 352 HAIKU_CONTAINER_STRIP_EXECUTABLES on 353 $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME) = 1 ; 354 355 case * : 356 Exit "Currently unsupported target CPU:" $(cpu) ; 357 } 358 359 # private kernel headers to be used when compiling kernel code 360 HAIKU_PRIVATE_KERNEL_HEADERS = 361 [ PrivateHeaders $(DOT) kernel libroot shared 362 kernel/boot/platform/$(HAIKU_KERNEL_PLATFORM) ] 363 [ ArchHeaders $(HAIKU_KERNEL_ARCH) ] 364 [ FDirName $(HAIKU_COMMON_DEBUG_OBJECT_DIR_$(architecture)) system 365 kernel ] 366 $(HAIKU_PRIVATE_SYSTEM_HEADERS_$(architecture)) 367 ; 368 369 # C/C++ flags 370 local ccBaseFlags = -finline -fno-builtin ; 371 372 if $(gccVersion[1]) >= 4 { 373 ccBaseFlags += -ffreestanding ; 374 } 375 376 local c++BaseFlags = $(ccBaseFlags) -fno-exceptions ; 377 378 if $(gccVersion[1]) >= 3 && $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 { 379 c++BaseFlags += -fno-use-cxa-atexit ; 380 } 381 382 HAIKU_KERNEL_CCFLAGS = $(HAIKU_CCFLAGS_$(architecture)) $(ccBaseFlags) ; 383 HAIKU_KERNEL_C++FLAGS = $(HAIKU_C++FLAGS_$(architecture)) $(c++BaseFlags) ; 384 HAIKU_KERNEL_PIC_CCFLAGS = -fno-pic ; 385 HAIKU_KERNEL_PIC_LINKFLAGS = ; 386 HAIKU_KERNEL_ADDON_LINKFLAGS = ; 387 388 # Common boot-related cflags which apply to all loaders 389 HAIKU_BOOT_CCFLAGS = $(HAIKU_CCFLAGS_$(architecture)) $(ccBaseFlags) ; 390 HAIKU_BOOT_C++FLAGS = $(HAIKU_C++FLAGS_$(architecture)) $(c++BaseFlags) ; 391 HAIKU_BOOT_LINKFLAGS = ; 392 HAIKU_BOOT_LDFLAGS = -Bstatic ; 393 394 # Remove -fPIC and other unwanted options from the BOOT flags (they are sometimes 395 # added to force PIC in general.) 396 local fixedBootCCFlags ; 397 local fixedBootC++Flags ; 398 for flag in $(HAIKU_BOOT_CCFLAGS) { 399 if $(flag) = "-fpic" || $(flag) = "-fPIC" { 400 continue ; 401 } 402 fixedBootCCFlags += $(flag) ; 403 } 404 for flag in $(HAIKU_BOOT_C++FLAGS) { 405 if $(flag) = "-fpic" || $(flag) = "-fPIC" { 406 continue ; 407 } 408 fixedBootC++Flags += $(flag) ; 409 } 410 HAIKU_BOOT_CCFLAGS = $(fixedBootCCFlags) ; 411 HAIKU_BOOT_C++FLAGS = $(fixedBootC++Flags) ; 412 413 # Any special kernel base addresses 414 if $(HAIKU_BOOT_LOADER_BASE) { 415 HAIKU_BOOT_LDFLAGS += 416 --defsym BOOT_LOADER_BASE=$(HAIKU_BOOT_LOADER_BASE) ; 417 } 418 419 switch $(cpu) { 420 case arm : 421 # Workaround for ld using 32k for alignment despite forcing it in the config... 422 # should definitely not be needed! 423 HAIKU_KERNEL_LINKFLAGS += 424 -Wl,-z -Wl,max-page-size=0x1000 425 -Wl,-z -Wl,common-page-size=0x1000 ; 426 427 case ppc : 428 # Build a position independent PPC kernel. We need to be able to 429 # relocate the kernel, since the virtual address space layout at 430 # boot time is not fixed. 431 HAIKU_KERNEL_PIC_CCFLAGS = -fPIE ; 432 HAIKU_KERNEL_PIC_LINKFLAGS = -shared -fPIE ; 433 434 case m68k : 435 # We don't want to have to handle emulating missing FPU opcodes for 436 # 040 and 060 in the kernel. 437 HAIKU_KERNEL_CCFLAGS += -mtune=68020-60 ; 438 HAIKU_KERNEL_C++FLAGS += -mtune=68020-60 ; 439 440 case riscv64 : 441 # Kernel lives within any single 2 GiB address space. 442 # Default is medlow (-2GiB / +2GiB) 443 HAIKU_KERNEL_CCFLAGS += -mcmodel=medany ; 444 HAIKU_KERNEL_C++FLAGS += -mcmodel=medany ; 445 446 case x86 : 447 HAIKU_KERNEL_CCFLAGS += -march=pentium ; 448 HAIKU_KERNEL_C++FLAGS += -march=pentium ; 449 450 case x86_64 : 451 # Kernel lives in the top 2GB of the address space, use kernel code 452 # model. 453 HAIKU_KERNEL_PIC_CCFLAGS += -mcmodel=kernel ; 454 455 # Disable the red zone, which cannot be used in kernel code due to 456 # interrupts, and always enable the frame pointer so stack traces 457 # are correct. 458 HAIKU_KERNEL_CCFLAGS += -mno-red-zone -fno-omit-frame-pointer ; 459 HAIKU_KERNEL_C++FLAGS += -mno-red-zone -fno-omit-frame-pointer ; 460 HAIKU_KERNEL_PIC_LINKFLAGS += -z max-page-size=0x1000 ; 461 HAIKU_KERNEL_ADDON_LINKFLAGS += -z max-page-size=0x1000 ; 462 463 if x86 in $(HAIKU_ARCHS[2-]) || x86_gcc2 in $(HAIKU_ARCHS[2-]) { 464 Echo "Enable kernel ia32 compatibility" ; 465 HAIKU_KERNEL_DEFINES += _COMPAT_MODE ; 466 HAIKU_KERNEL_COMPAT_MODE = 1 ; 467 } 468 } 469 470 # bootloader-centric flags 471 local bootTarget ; 472 for bootTarget in $(HAIKU_BOOT_TARGETS) { 473 switch $(bootTarget) { 474 case efi : 475 # efi bootloader is PIC 476 HAIKU_BOOT_$(bootTarget:U)_CCFLAGS += -fpic -fno-stack-protector 477 -fPIC -fshort-wchar -Wno-error=unused-variable -Wno-error=main 478 -mno-red-zone ; 479 HAIKU_BOOT_$(bootTarget:U)_C++FLAGS += -fpic -fno-stack-protector 480 -fPIC -fshort-wchar -Wno-error=unused-variable -Wno-error=main 481 -mno-red-zone ; 482 if $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 { 483 HAIKU_BOOT_$(bootTarget:U)_CCFLAGS += -maccumulate-outgoing-args ; 484 HAIKU_BOOT_$(bootTarget:U)_C++FLAGS += -maccumulate-outgoing-args ; 485 } 486 HAIKU_BOOT_$(bootTarget:U)_LDFLAGS = -Bstatic -Bsymbolic 487 -nostdlib -znocombreloc -no-undefined ; 488 case bios_ia32 : 489 # bios_ia32 is non-PIC 490 HAIKU_BOOT_$(bootTarget:U)_CCFLAGS += -fno-pic -march=pentium ; 491 HAIKU_BOOT_$(bootTarget:U)_C++FLAGS += -fno-pic -march=pentium ; 492 if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 { 493 HAIKU_BOOT_$(bootTarget:U)_LDFLAGS += -m elf_i386 ; 494 } else { 495 HAIKU_BOOT_$(bootTarget:U)_LDFLAGS += -m elf_i386_haiku ; 496 } 497 if $(gccVersion[1]) >= 3 { 498 HAIKU_BOOT_$(bootTarget:U)_CCFLAGS += -Wno-error=main -m32 ; 499 HAIKU_BOOT_$(bootTarget:U)_C++FLAGS += -Wno-error=main -m32 ; 500 } 501 case pxe_ia32 : 502 # pxe_ia32 is non-PIC 503 HAIKU_BOOT_$(bootTarget:U)_CCFLAGS += -fno-pic -march=pentium ; 504 HAIKU_BOOT_$(bootTarget:U)_C++FLAGS += -fno-pic -march=pentium ; 505 if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 { 506 HAIKU_BOOT_$(bootTarget:U)_LDFLAGS += -m elf_i386 ; 507 } else { 508 HAIKU_BOOT_$(bootTarget:U)_LDFLAGS += -m elf_i386_haiku ; 509 } 510 if $(gccVersion[1]) >= 3 { 511 HAIKU_BOOT_$(bootTarget:U)_CCFLAGS += -Wno-error=main -m32 ; 512 HAIKU_BOOT_$(bootTarget:U)_C++FLAGS += -Wno-error=main -m32 ; 513 } 514 case * : 515 # all other bootloaders are non-PIC 516 HAIKU_BOOT_$(bootTarget:U)_CCFLAGS += -fno-pic -Wno-error=main ; 517 HAIKU_BOOT_$(bootTarget:U)_C++FLAGS += -fno-pic -Wno-error=main ; 518 } 519 } 520 521 # warning flags 522 HAIKU_KERNEL_WARNING_CCFLAGS = $(HAIKU_WARNING_CCFLAGS_$(architecture)) ; 523 HAIKU_KERNEL_WARNING_C++FLAGS = $(HAIKU_WARNING_C++FLAGS_$(architecture)) ; 524 525 # debug flags 526 local level ; 527 for level in $(HAIKU_DEBUG_LEVELS) { 528 local flags = $(HAIKU_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ; 529 HAIKU_KERNEL_DEBUG_$(level)_CCFLAGS 530 = $(HAIKU_DEBUG_$(level)_CCFLAGS_$(architecture)) ; 531 HAIKU_KERNEL_DEBUG_$(level)_C++FLAGS 532 = $(HAIKU_DEBUG_$(level)_C++FLAGS_$(architecture)) ; 533 } 534 535 # defines 536 HAIKU_KERNEL_DEFINES += _KERNEL_MODE ; 537 538 HAIKU_DEFINES_$(architecture) 539 += BOOT_ARCHIVE_IMAGE_OFFSET=$(HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET) ; 540 # TODO: That doesn't need to be a general define. It's just needed for 541 # compiling (part of) the boot loader. 542 543 # kernel add-on glue code 544 HAIKU_KERNEL_ADDON_BEGIN_GLUE_CODE = <$(architecture)>crtbeginS.o 545 <src!system!glue!$(architecture)>haiku_version_glue.o ; 546 HAIKU_KERNEL_ADDON_END_GLUE_CODE = <$(architecture)>crtendS.o ; 547} 548 549 550rule ArchitectureSetupWarnings architecture 551{ 552 # ArchitectureSetupWarnings <architecture> ; 553 # 554 # Sets up compiler warnings and error flags for various subdirectories for 555 # the given packaging architecture. 556 557 if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 { 558 AppendToConfigVar CCFLAGS : 559 HAIKU_TOP src system libroot posix glibc : 560 -fgnu89-inline -fheinous-gnu-extensions : global ; 561 } 562 563 local cpu = $(HAIKU_CPU_$(architecture)) ; 564 switch $(cpu) { 565 case arm : 566 return ; 567 # we use #warning as placeholders for things to write... 568 case m68k : 569 return ; 570 # we use #warning as placeholders for things to write... 571 case ppc : 572 return ; 573 # we use #warning as placeholders for things to write... 574 } 575 576 # enable -Werror for certain parts of the source tree 577 HAIKU_WERROR_ARCH = $(architecture) ; 578 579 rule EnableWerror dirTokens : scope { 580 # Clang gives way more warnings than GCC, so that code won't compile 581 # with -Werror when using Clang. 582 if $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 { 583 SetConfigVar WARNINGS : HAIKU_TOP $(dirTokens) : treatAsErrors 584 : $(scope) ; 585 } 586 } 587 588 # Work-around for GCC 2 problem -- despite -Wno-multichar it reports 589 # multichar warnings in headers/private/kernel/debugger_keymaps.h included 590 # by src/system/kernel/arch/x86/arch_debug_console.cpp. 591 local gccVersion = $(HAIKU_GCC_VERSION_$(architecture)) ; 592 if $(gccVersion[1]) = 2 { 593 local file = <src!system!kernel!arch!x86>arch_debug_console.o ; 594 WARNINGS on $(file) = $(WARNINGS) ; 595 } 596 597 EnableWerror src add-ons accelerants ; 598 EnableWerror src add-ons bluetooth ; 599 EnableWerror src add-ons decorators ; 600 EnableWerror src add-ons disk_systems ; 601 EnableWerror src add-ons input_server devices ; 602 EnableWerror src add-ons input_server filters ; 603# EnableWerror src add-ons input_server methods pen ; 604 EnableWerror src add-ons input_server methods t9 ; 605 EnableWerror src add-ons kernel bluetooth ; 606 EnableWerror src add-ons kernel bus_managers acpi ; 607 EnableWerror src add-ons kernel bus_managers agp_gart ; 608 EnableWerror src add-ons kernel bus_managers ata ; 609 EnableWerror src add-ons kernel bus_managers config_manager ; 610# EnableWerror src add-ons kernel bus_managers firewire ; 611 EnableWerror src add-ons kernel bus_managers ide ; 612 EnableWerror src add-ons kernel bus_managers isa ; 613 EnableWerror src add-ons kernel bus_managers pci ; 614 EnableWerror src add-ons kernel bus_managers ps2 ; 615 EnableWerror src add-ons kernel bus_managers random ; 616 EnableWerror src add-ons kernel bus_managers scsi ; 617 EnableWerror src add-ons kernel bus_managers tty ; 618 EnableWerror src add-ons kernel bus_managers usb ; 619 EnableWerror src add-ons kernel bus_managers virtio ; 620 EnableWerror src add-ons kernel busses agp_gart ; 621 EnableWerror src add-ons kernel busses ata ; 622 EnableWerror src add-ons kernel busses scsi ; 623 EnableWerror src add-ons kernel busses usb ; 624 EnableWerror src add-ons kernel console ; 625 EnableWerror src add-ons kernel cpu ; 626# EnableWerror src add-ons kernel debugger ; # gcc2 627# EnableWerror src add-ons kernel drivers audio ; 628 EnableWerror src add-ons kernel drivers bluetooth ; 629# EnableWerror src add-ons kernel drivers bus ; 630 EnableWerror src add-ons kernel drivers common ; 631# EnableWerror src add-ons kernel drivers disk ; 632 EnableWerror src add-ons kernel drivers dvb ; 633# EnableWerror src add-ons kernel drivers graphics ; 634 EnableWerror src add-ons kernel drivers graphics intel_extreme ; 635# EnableWerror src add-ons kernel drivers input ; 636 EnableWerror src add-ons kernel drivers joystick ; 637 EnableWerror src add-ons kernel drivers midi ; 638 EnableWerror src add-ons kernel drivers misc ; 639# EnableWerror src add-ons kernel drivers network ; 640 EnableWerror src add-ons kernel drivers ports ; 641# EnableWerror src add-ons kernel drivers power ; 642 EnableWerror src add-ons kernel drivers printer ; 643 EnableWerror src add-ons kernel drivers random ; 644 EnableWerror src add-ons kernel drivers tty ; 645 EnableWerror src add-ons kernel drivers video ; 646 EnableWerror src add-ons kernel file_systems bfs ; 647 EnableWerror src add-ons kernel file_systems cdda ; 648# EnableWerror src add-ons kernel file_systems ext2 ; 649# EnableWerror src add-ons kernel file_systems fat ; 650# EnableWerror src add-ons kernel file_systems googlefs ; 651 EnableWerror src add-ons kernel file_systems iso9660 ; 652 EnableWerror src add-ons kernel file_systems layers ; 653 EnableWerror src add-ons kernel file_systems netfs ; 654# EnableWerror src add-ons kernel file_systems nfs ; 655 EnableWerror src add-ons kernel file_systems nfs4 ; 656# EnableWerror src add-ons kernel file_systems ntfs ; 657 EnableWerror src add-ons kernel file_systems packagefs ; 658# EnableWerror src add-ons kernel file_systems ramfs ; 659# EnableWerror src add-ons kernel file_systems reiserfs ; 660 EnableWerror src add-ons kernel file_systems udf ; 661 EnableWerror src add-ons kernel file_systems userlandfs ; 662 EnableWerror src add-ons kernel generic ; 663# EnableWerror src add-ons kernel network datalink_protocols ; 664 EnableWerror src add-ons kernel network devices ; 665 EnableWerror src add-ons kernel network dns_resolver ; 666 EnableWerror src add-ons kernel network notifications ; 667 EnableWerror src add-ons kernel network ppp ; 668 EnableWerror src add-ons kernel network protocols ; 669# EnableWerror src add-ons kernel network stack ; 670 EnableWerror src add-ons kernel partitioning_systems ; 671 EnableWerror src add-ons kernel power ; 672 EnableWerror src add-ons locale ; 673 EnableWerror src add-ons mail_daemon ; 674 EnableWerror src add-ons media media-add-ons demultiplexer ; 675 EnableWerror src add-ons media media-add-ons dvb ; 676 EnableWerror src add-ons media media-add-ons esound_sink ; 677 EnableWerror src add-ons media media-add-ons finepix_webcam ; 678 EnableWerror src add-ons media media-add-ons firewire_dv ; 679 EnableWerror src add-ons media media-add-ons legacy ; 680 EnableWerror src add-ons media media-add-ons mixer ; 681 EnableWerror src add-ons media media-add-ons multi_audio ; 682 EnableWerror src add-ons media media-add-ons opensound ; 683 EnableWerror src add-ons media media-add-ons radeon ; 684 EnableWerror src add-ons media media-add-ons reader ; 685 EnableWerror src add-ons media media-add-ons tone_producer_demo ; 686 EnableWerror src add-ons media media-add-ons usb_vision ; 687# EnableWerror src add-ons media media-add-ons usb_webcam ; 688 EnableWerror src add-ons media media-add-ons video_mixer ; 689# EnableWerror src add-ons media media-add-ons video_producer_demo ; 690 EnableWerror src add-ons media media-add-ons videowindow ; 691 EnableWerror src add-ons media media-add-ons writer ; 692 EnableWerror src add-ons media plugins ape_reader ; 693 EnableWerror src add-ons media plugins au_reader ; 694# EnableWerror src add-ons media plugins ffmpeg ; 695# EnableWerror src add-ons media plugins raw_decoder ; 696 EnableWerror src add-ons print ; 697 EnableWerror src add-ons screen_savers ; 698 EnableWerror src add-ons tracker ; 699 EnableWerror src add-ons translators bmp ; 700 EnableWerror src add-ons translators exr ; 701 EnableWerror src add-ons translators gif ; 702 EnableWerror src add-ons translators hvif ; 703 EnableWerror src add-ons translators ico ; 704 EnableWerror src add-ons translators jpeg ; 705# EnableWerror src add-ons translators jpeg2000 ; 706 EnableWerror src add-ons translators pcx ; 707 EnableWerror src add-ons translators png ; 708 EnableWerror src add-ons translators ppm ; 709 EnableWerror src add-ons translators raw ; 710 EnableWerror src add-ons translators rtf ; 711 EnableWerror src add-ons translators sgi ; 712 EnableWerror src add-ons translators shared ; 713 EnableWerror src add-ons translators stxt ; 714 EnableWerror src add-ons translators tga ; 715 EnableWerror src add-ons translators tiff ; 716 EnableWerror src add-ons translators wonderbrush ; 717 EnableWerror src add-ons print ; 718 EnableWerror src bin desklink ; 719 EnableWerror src bin multiuser ; 720 EnableWerror src bin package ; 721 EnableWerror src bin package_repo ; 722 EnableWerror src bin pkgman ; 723 EnableWerror src libs bsd ; 724 EnableWerror src apps ; 725 EnableWerror src kits ; 726 EnableWerror src preferences ; 727 EnableWerror src servers ; 728 EnableWerror src system boot ; 729 EnableWerror src system kernel ; 730 EnableWerror src system libroot add-ons ; 731 EnableWerror src system libroot os ; 732 EnableWerror src system libroot posix locale ; 733 EnableWerror src system libroot posix wchar ; 734 EnableWerror src system runtime_loader ; 735} 736 737 738rule MultiArchIfPrimary ifValue : elseValue : architecture 739{ 740 # MultiArchIfPrimary <ifValue> : <elseValue> 741 # [ : <architecture> = $(TARGET_PACKAGING_ARCH) ] ; 742 # 743 # Returns one of the two given values depending on whether 744 # <architecture> is the primary packaging architecture. 745 746 architecture ?= $(TARGET_PACKAGING_ARCH) ; 747 748 if $(architecture) = $(TARGET_PACKAGING_ARCHS[1]) { 749 return $(ifValue) ; 750 } 751 return $(elseValue) ; 752} 753 754 755rule MultiArchConditionalGristFiles files : primaryGrist : secondaryGrist 756 : architecture 757{ 758 # MultiArchConditionalGristFiles <files> : <primaryGrist> 759 # : <secondaryGrist> [ : <architecture> = $(TARGET_PACKAGING_ARCH) ] ; 760 # 761 # Returns <files> with their grist set to either <primaryGrist> or 762 # <secondaryGrist> depending on whether <architecture> is the primary 763 # packaging architecture. 764 765 architecture ?= $(TARGET_PACKAGING_ARCH) ; 766 767 local grist = [ MultiArchIfPrimary $(primaryGrist) : $(secondaryGrist) 768 : $(architecture) ] ; 769 return $(files:G=$(grist:E=)) ; 770} 771 772 773rule MultiArchDefaultGristFiles files : gristPrefix : architecture 774{ 775 # MultiArchDefaultGristFiles <files> : <gristPrefix> 776 # [ : <architecture> = $(TARGET_PACKAGING_ARCH) ] ; 777 # 778 # Convenient shorthand for MultiArchConditionalGristFiles for the common 779 # case that for a secondary packaging architecture the packaging 780 # architecture name shall be appended to the grist while it shall be omitted 781 # for the primary packaging architecture. IOW, if architecture is the 782 # primary packaging architecture, <files> are returned with their grist set 783 # to <gristPrefix>, otherwise <files> are returned with their grist set to 784 # <gristPrefix>!<architecture> respectively <architecture> (if <gristPrefix> 785 # is empty). 786 787 architecture ?= $(TARGET_PACKAGING_ARCH) ; 788 789 local secondaryGrist = $(gristPrefix)!$(architecture) ; 790 secondaryGrist ?= $(architecture) ; 791 792 return [ MultiArchConditionalGristFiles $(files) : $(gristPrefix) : 793 $(secondaryGrist) : $(architecture) ] ; 794} 795 796 797rule MultiArchSubDirSetup architectures 798{ 799 # MultiArchSubDirSetup <architectures> ; 800 # 801 # For each of the given packaging architectures <architectures> that are 802 # in the packaging architectures configured for the build (or all configured 803 # packaging architectures, if <architectures> is empty) an object is 804 # prepared that can be used for an "on ... { ... }" block to set up subdir 805 # variables for the respective packaging architecture. Most notably 806 # TARGET_PACKAGING_ARCH, TARGET_ARCH are set to the values for the 807 # respective packaging architecture. The per-subdir variables SOURCE_GRIST, 808 # LOCATE_TARGET, LOCATE_SOURCE, SEARCH_SOURCE, *_LOCATE_TARGET, are reset. 809 # All SUBDIR* and config variables are set to the values they had when this 810 # rule was invoked. 811 812 local result ; 813 architectures ?= $(TARGET_PACKAGING_ARCHS) ; 814 local architecture ; 815 for architecture in $(architectures) { 816 if ! $(architecture) in $(TARGET_PACKAGING_ARCHS) { 817 continue ; 818 } 819 820 local architectureObject = $(architecture:G=<arch-object>) ; 821 result += $(architectureObject) ; 822 823 # Set the variables that default to the values of the respective 824 # variables for the primary architecture. 825 TARGET_PACKAGING_ARCH on $(architectureObject) = $(architecture) ; 826 827 local var ; 828 for var in TARGET_ARCH { 829 $(var) on $(architectureObject) = $($(var)_$(architecture)) ; 830 } 831 832 # Clone the current config variable values and the variables SubDir 833 # resets. 834 for var in $(AUTO_SET_UP_CONFIG_VARIABLES) SUBDIR$(SUBDIRRESET) { 835 $(var) on $(architectureObject) = $($(var)) ; 836 } 837 838 # adjust SOURCE_GRIST and HDRGRIST 839 SOURCE_GRIST on $(architectureObject) 840 = $(SOURCE_GRIST:E=)!$(architecture) ; 841 842 HDRGRIST on $(architectureObject) 843 = $(HDRGRIST:E=)!$(architecture) ; 844 845 # Adjust the subdir's object dirs that are architecture dependent. To 846 # avoid duplicating the code from SetupObjectsDir, we call it. Since it 847 # sets global variables, we set these variables on our object, call 848 # SetupObjectsDir in an "on" block, and grab the new variable values. 849 local hostTarget = HOST TARGET ; 850 local objectDirVars = 851 COMMON_ARCH COMMON_DEBUG DEBUG_$(HAIKU_DEBUG_LEVELS) 852 ; 853 objectDirVars = 854 COMMON_PLATFORM_LOCATE_TARGET 855 $(hostTarget)_$(objectDirVars)_LOCATE_TARGET 856 LOCATE_TARGET 857 LOCATE_SOURCE 858 SEARCH_SOURCE 859 ; 860 861 for var in $(objectDirVars) { 862 $(var) on $(architectureObject) = ; 863 } 864 865 on $(architectureObject) { 866 SetupObjectsDir ; 867 868 for var in $(objectDirVars) { 869 $(var) on $(architectureObject) = $($(var)) ; 870 } 871 } 872 } 873 874 return $(result) ; 875} 876