1rule AddSharedObjectGlueCode 2{ 3 # AddSharedObjectGlueCode <target> : <isExecutable> ; 4 5 # we link with -nostdlib and add the required libs manually, when building 6 # for Haiku 7 local platform ; 8 on $(1) { 9 platform = $(PLATFORM) ; 10 if $(platform) = haiku { 11 local stdLibs = [ MultiArchDefaultGristFiles libroot.so ] ; 12 local type = EXECUTABLE ; 13 if $(2) != true { 14 type = LIBRARY ; 15 16 # special case for libroot: don't link it against itself 17 if $(DONT_LINK_AGAINST_LIBROOT) { 18 stdLibs = ; 19 } 20 } 21 22 local beginGlue 23 = $(HAIKU_$(type)_BEGIN_GLUE_CODE_$(TARGET_PACKAGING_ARCH)) ; 24 local endGlue 25 = $(HAIKU_$(type)_END_GLUE_CODE_$(TARGET_PACKAGING_ARCH)) ; 26 27 LINK_BEGIN_GLUE on $(1) = $(beginGlue) ; 28 LINK_END_GLUE on $(1) = $(endGlue) ; 29 30 NEEDLIBS on $(1) = [ on $(1) return $(NEEDLIBS) ] $(stdLibs) ; 31 Depends $(1) : $(stdLibs) $(beginGlue) $(endGlue) ; 32 LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib 33 -Xlinker --no-undefined ; 34 } 35 } 36 37 # link against the compatibility libraries needed for the target 38 if $(platform) != host && $(TARGET_HAIKU_COMPATIBILITY_LIBS) { 39 LinkAgainst $(1) : $(TARGET_HAIKU_COMPATIBILITY_LIBS) ; 40 } 41} 42 43rule Executable 44{ 45 # Executable <name> : <sources> : <libraries> : <res> ; 46 # 47 if ! [ IsPlatformSupportedForTarget $(1) ] { 48 return ; 49 } 50 51 AddResources $(1) : $(4) ; 52 Main $(1) : $(2) ; 53 LinkAgainst $(1) : $(3) ; 54 LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 55 -Xlinker -soname=_APP_ ; 56 57 # we link with -nostdlib and add the required libs manually, when building 58 # for Haiku 59 AddSharedObjectGlueCode $(1) : true ; 60} 61 62rule Application 63{ 64 # Application <name> : <sources> : <libraries> : <res> ; 65 Executable $(1) : $(2) : $(3) : $(4) ; 66} 67 68rule BinCommand 69{ 70 # BinCommand <name> : <sources> : <libraries> : <res> ; 71 Executable $(1) : $(2) : $(3) : $(4) ; 72} 73 74rule StdBinCommands 75{ 76 # StdBinCommands <sources> : <libs> : <res> ; 77 local libs = $(2) ; 78 local ress = $(3) ; 79 local source ; 80 for source in $(1) 81 { 82 local target = $(source:S=) ; 83 84 BinCommand $(target) : $(source) : $(libs) : $(ress) ; 85 } 86} 87 88rule Preference 89{ 90 # Preference <name> : <sources> : <libraries> : <res> ; 91 Executable $(1) : $(2) : $(3) : $(4) ; 92} 93 94rule Server 95{ 96 # Server <name> : <sources> : <libraries> : <res> ; 97 98 Executable $(1) : $(2) : $(3) : $(4) ; 99} 100 101rule Addon target : sources : libraries : isExecutable 102{ 103 # Addon <target> : <sources> : <is executable> : <libraries> ; 104 # <target>: The add-on. 105 # <sources>: Source files. 106 # <libraries>: Libraries to be linked against. 107 # <isExecutable>: true, if the target shall be executable as well. 108 109 if ! [ IsPlatformSupportedForTarget $(target) ] { 110 return ; 111 } 112 113 Main $(target) : $(sources) ; 114 115 local linkFlags = -Xlinker -soname=\"$(target:G=)\" ; 116 if $(isExecutable) != true { 117 linkFlags = -shared $(linkFlags) ; 118 } 119 LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ] $(linkFlags) ; 120 LinkAgainst $(target) : $(libraries) ; 121 122 AddSharedObjectGlueCode $(target) : $(isExecutable) ; 123} 124 125rule Translator target : sources : libraries : isExecutable 126{ 127 # Translator <target> : <sources> : <libraries> : <isExecutable> ; 128 Addon $(target) : $(sources) : $(libraries) : $(isExecutable) ; 129} 130 131rule ScreenSaver target : sources : libraries 132{ 133 # ScreenSaver <target> : <sources> : <libraries> ; 134 Addon $(target) : $(sources) : $(libraries) : false ; 135} 136 137rule StaticLibrary 138{ 139 # StaticLibrary <lib> : <sources> : <otherObjects> ; 140 # Creates a static library from sources. 141 # <lib>: The static library to be built. 142 # <sources>: List of source files. 143 # <otherObjects>: List of additional object files. 144 # 145 local lib = $(1) ; 146 local sources = [ FGristFiles $(2) ] ; 147 local otherObjects = $(3) ; 148 local objects = $(sources:S=$(SUFOBJ)) ; 149 150 if ! [ IsPlatformSupportedForTarget $(1) ] { 151 return ; 152 } 153 154 InheritPlatform $(objects) : $(lib) ; 155 156 StaticLibraryFromObjects $(lib) : $(objects) $(otherObjects) ; 157 Objects $(2) ; 158} 159 160rule StaticLibraryFromObjects 161{ 162 if ! [ IsPlatformSupportedForTarget $(1) ] { 163 return ; 164 } 165 166 LibraryFromObjects $(1) : $(2) ; 167} 168 169rule AssembleNasm 170{ 171 Depends $(<) : $(>) ; 172} 173 174actions AssembleNasm 175{ 176 if test $(ASFLAGS) ; then 177 $(HAIKU_NASM) -d $(ASFLAGS) -f elf32 -o $(1) $(2); 178 else 179 $(HAIKU_NASM) -f elf32 -o $(1) $(2); 180 fi 181} 182 183rule CompileDTS 184{ 185 Depends $(<) : $(>) ; 186} 187 188actions CompileDTS 189{ 190 dtc -O dtb -o $(1) $(2); 191} 192 193rule Ld 194{ 195 # Ld <name> : <objs> : <linkerscript> : <flags> ; 196 # 197 local target = $(1) ; 198 local objects = $(2) ; 199 local linkerScript = $(3) ; 200 local linkerFlags = $(4) ; 201 202 if $(linkerScript) { 203 linkerFlags += --script=$(linkerScript) ; 204 } 205 206 on $(target) { 207 if $(PLATFORM) = host { 208 LINK on $(target) = $(HOST_LD) ; 209 LINKFLAGS on $(target) = $(HOST_LDFLAGS) $(LINKFLAGS) $(linkerFlags) ; 210 } else { 211 LINK on $(target) = $(TARGET_LD_$(TARGET_PACKAGING_ARCH)) ; 212 LINKFLAGS on $(target) = $(TARGET_LDFLAGS_$(TARGET_PACKAGING_ARCH)) 213 $(LINKFLAGS) $(linkerFlags) ; 214 } 215 216 NEEDLIBS on $(target) = $(NEEDLIBS) ; 217 LINKLIBS on $(target) = $(LINKLIBS) ; 218 } 219 220 LocalClean clean : $(target) ; 221 LocalDepends all : $(target) ; 222 Depends $(target) : $(objects) ; 223 224 MakeLocateDebug $(target) ; 225 226 on $(1) XRes $(1) : $(RESFILES) ; 227 if ! [ on $(1) return $(DONT_USE_BEOS_RULES) ] { 228 SetType $(1) ; 229 MimeSet $(1) ; 230 SetVersion $(1) ; 231 } 232} 233 234actions Ld 235{ 236 $(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" "$(NEEDLIBS)" $(LINKLIBS) 237} 238 239rule CreateAsmStructOffsetsHeader header : source 240{ 241 # CreateAsmStructOffsetsHeader header : source 242 # 243 # Grist will be added to both header and source. 244 245 header = [ FGristFiles $(header) ] ; 246 source = [ FGristFiles $(source) ] ; 247 248 # find out which headers, defines, etc. to use 249 local headers ; 250 local sysHeaders ; 251 local defines ; 252 local flags ; 253 local includesSeparator ; 254 local localIncludesOption ; 255 local systemIncludesOption ; 256 257 on $(header) { # use on $(1) variable values 258 if ! $(PLATFORM) in $(SUPPORTED_PLATFORMS) { 259 return ; 260 } 261 262 # headers and defines 263 headers = $(HAIKU_CONFIG_HEADERS) $(SEARCH_SOURCE) $(SUBDIRHDRS) 264 $(HDRS) ; 265 sysHeaders = $(SUBDIRSYSHDRS) $(SYSHDRS) ; 266 defines = $(DEFINES) ; 267 268 if $(PLATFORM) = host { 269 sysHeaders += $(HOST_HDRS) ; 270 defines += $(HOST_DEFINES) ; 271 272 if $(USES_BE_API) { 273 sysHeaders += $(HOST_BE_API_HEADERS) ; 274 } 275 276 } else { 277 sysHeaders += $(TARGET_HDRS_$(TARGET_PACKAGING_ARCH)) ; 278 defines += $(TARGET_DEFINES_$(TARGET_PACKAGING_ARCH)) 279 $(TARGET_DEFINES) ; 280 } 281 282 # optimization flags 283 if $(DEBUG) = 0 { 284 flags += $(OPTIM) ; 285 } else { 286 flags += -O0 ; 287 } 288 289 if $(PLATFORM) = host { 290 # warning flags 291 if $(WARNINGS) != 0 { 292 flags += $(HOST_WARNING_C++FLAGS) ; 293 if $(WARNINGS) = treatAsErrors { 294 flags += -Werror $(HOST_WERROR_FLAGS) ; 295 } 296 } 297 298 # debug and other flags 299 flags += $(HOST_C++FLAGS) $(HOST_DEBUG_$(DEBUG)_C++FLAGS) 300 $(SUBDIRC++FLAGS) $(C++FLAGS) ; 301 302 if $(USES_BE_API) { 303 flags += $(HOST_BE_API_C++FLAGS) ; 304 } 305 306 C++ on $(header) = $(HOST_C++) ; 307 308 includesSeparator = $(HOST_INCLUDES_SEPARATOR) ; 309 localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ; 310 systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ; 311 312 } else { 313 # warning flags 314 if $(WARNINGS) != 0 { 315 flags += $(TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH)) ; 316 if $(WARNINGS) = treatAsErrors { 317 flags += -Werror 318 $(TARGET_WERROR_FLAGS_$(TARGET_PACKAGING_ARCH)) ; 319 } 320 } 321 322 # debug and other flags 323 flags += $(TARGET_C++FLAGS_$(TARGET_PACKAGING_ARCH)) 324 $(TARGET_DEBUG_$(DEBUG)_C++FLAGS_$(TARGET_PACKAGING_ARCH)) 325 $(SUBDIRC++FLAGS) $(C++FLAGS) ; 326 327 C++ on $(header) = $(TARGET_C++_$(TARGET_PACKAGING_ARCH)) ; 328 329 includesSeparator 330 = $(TARGET_INCLUDES_SEPARATOR_$(TARGET_PACKAGING_ARCH)) ; 331 localIncludesOption 332 = $(TARGET_LOCAL_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ; 333 systemIncludesOption 334 = $(TARGET_SYSTEM_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ; 335 } 336 } 337 338 # Turn off "invalid use of offsetof()" macro warning. We use offsetof() also 339 # for non-PODs. Since we're using the same compiler for the whole kernel and 340 # don't do virtual inheritence, that works well enough. 341 flags += -Wno-invalid-offsetof ; 342 # TODO: Rather get rid of the respective offsetof() instances. 343 344 # locate object, search for source, and set on target variables 345 346 Depends $(header) : $(source) ; 347 SEARCH on $(source) += $(SEARCH_SOURCE) ; 348 MakeLocateArch $(header) ; 349 LocalClean clean : $(header) ; 350 351 HDRRULE on $(source) = HdrRule ; 352 HDRSCAN on $(source) = $(HDRPATTERN) ; 353 HDRSEARCH on $(source) = $(headers) $(sysHeaders) $(STDHDRS) ; 354 HDRGRIST on $(source) = $(HDRGRIST) ; 355 356 C++FLAGS on $(header) = $(flags) ; 357 CCHDRS on $(header) = [ FIncludes $(headers) : $(localIncludesOption) ] 358 $(includesSeparator) 359 [ FSysIncludes $(sysHeaders) : $(systemIncludesOption) ] ; 360 CCDEFS on $(header) = [ FDefines $(defines) ] ; 361 362 CreateAsmStructOffsetsHeader1 $(header) : $(source) ; 363} 364 365actions CreateAsmStructOffsetsHeader1 366{ 367 $(C++) -S "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o - \ 368 | grep "#define" | sed -e 's/[\$\#]\([0-9]\)/\1/' > "$(1)" 369} 370 371rule MergeObjectFromObjects 372{ 373 # MergeObjectFromObjects <name> : <objects> : <other objects> ; 374 # Merges object files to an object file. 375 # <name>: Name of the object file to create. No grist will be added. 376 # <objects>: Object files to be merged. Grist will be added. 377 # <other objects>: Object files or static libraries to be merged. No grist 378 # will be added. 379 # 380 local objects = [ FGristFiles $(2) ] ; 381 382 on $(1) { 383 if ! $(PLATFORM) in $(SUPPORTED_PLATFORMS) { 384 return ; 385 } 386 387 if $(PLATFORM) = host { 388 LINK on $(1) = $(HOST_LD) ; 389 LINKFLAGS on $(target) = $(HOST_LDFLAGS) ; 390 } else { 391 LINK on $(1) = $(TARGET_LD_$(TARGET_PACKAGING_ARCH)) ; 392 LINKFLAGS on $(target) 393 = $(TARGET_LDFLAGS_$(TARGET_PACKAGING_ARCH)) ; 394 } 395 } 396 397 MakeLocateDebug $(1) ; 398 Depends $(1) : $(objects) ; 399 Depends $(1) : $(3) ; 400 LocalDepends obj : $(1) ; 401 MergeObjectFromObjects1 $(1) : $(objects) $(3) ; 402} 403 404actions MergeObjectFromObjects1 405{ 406 $(LINK) $(LINKFLAGS) -r $(2) -o $(1) ; 407} 408 409rule MergeObject 410{ 411 # MergeObject <name> : <sources> : <other objects> ; 412 # Compiles source files and merges the object files to an object file. 413 # <name>: Name of the object file to create. No grist will be added. 414 # <sources>: Sources to be compiled. Grist will be added. 415 # <other objects>: Object files or static libraries to be merged. No grist 416 # will be added. 417 # 418 local target = $(1) ; 419 local sources = [ FGristFiles $(2) ] ; 420 local otherObjects = $(3) ; 421 local objects = $(sources:S=$(SUFOBJ)) ; 422 423 if ! [ IsPlatformSupportedForTarget $(1) ] { 424 return ; 425 } 426 427 InheritPlatform $(objects) : $(target) ; 428 Objects $(sources) ; 429 MergeObjectFromObjects $(target) : $(objects) : $(otherObjects) ; 430} 431 432rule SharedLibraryFromObjects 433{ 434 # SharedLibraryFromObjects <lib> : <objects> : <libraries> ; 435 # 436 local _lib = $(1) ; 437 438 if ! [ IsPlatformSupportedForTarget $(1) ] { 439 return ; 440 } 441 442 local soname = [ on $(_lib) return $(HAIKU_SONAME) ] ; 443 soname ?= $(_lib:BS) ; 444 445 MainFromObjects $(_lib) : $(2) ; 446 LINKFLAGS on $(_lib) = [ on $(_lib) return $(LINKFLAGS) ] 447 -shared -Xlinker -soname=\"$(soname)\" ; 448 LinkAgainst $(_lib) : $(3) ; 449 450 AddSharedObjectGlueCode $(_lib) : false ; 451} 452 453rule SharedLibrary 454{ 455 # SharedLibrary <lib> : <sources> : <libraries> : <abiVersion> ; 456 local lib = $(1) ; 457 local sources = [ FGristFiles $(2) ] ; 458 local objects = $(sources:S=$(SUFOBJ)) ; 459 local libs = $(3) ; 460 local abiVersion = $(4) ; # major ABI (soname) version for lib (if any) 461 462 if ! [ IsPlatformSupportedForTarget $(1) ] { 463 return ; 464 } 465 466 if $(abiVersion) { 467 HAIKU_SONAME on $(lib) = $(lib:BS).$(abiVersion) ; 468 HAIKU_LIB_ABI_VERSION on $(lib) = $(abiVersion) ; 469 } 470 471 InheritPlatform $(objects) : $(lib) ; 472 Objects $(sources) ; 473 SharedLibraryFromObjects $(lib) : $(objects) : $(libs) ; 474} 475 476rule LinkAgainst 477{ 478 # LinkAgainst <name> : <libs> [ : <mapLibs> ] ; 479 # Valid elements for <libs> are e.g. "be" or "libtranslation.so" or 480 # "/boot/.../libfoo.so". If the basename starts with "lib" or the thingy 481 # has a dirname or grist, it is added to the NEEDLIBS variable (i.e. the 482 # file will be bound!), otherwise it is prefixed "-l" and added to 483 # LINKLIBS. If you want to specify a target that isn't a library and 484 # also has neither grist nor a dirname, you can prepend "<nogrist>" as 485 # grist; it will be stripped by this rule. 486 # <mapLibs> specifies whether the to translate library names (e.g. "be" 487 # to "libbe.so" in case of target platform "haiku"). Defaults to "true". 488 # 489 local target = $(1) ; 490 local libs = $(2) ; 491 local mapLibs = $(3:E=true) ; 492 493 on $(target) { 494 # map libraries, if desired and target platform is Haiku 495 local map = $(TARGET_LIBRARY_NAME_MAP_$(TARGET_PACKAGING_ARCH)) ; 496 if $(PLATFORM) != host && $(mapLibs) = true && $(map) { 497 local mappedLibs ; 498 499 for i in $(libs) { 500 local mapped = $($(map)_$(i)) ; 501 mapped ?= $(i) ; 502 mappedLibs += $(mapped) ; 503 } 504 505 libs = $(mappedLibs) ; 506 } 507 508 local linkLibs ; 509 local needLibs ; 510 511 for i in $(libs) 512 { 513 local isfile = ; 514 if $(i:D) || $(i:G) { 515 isfile = true ; 516 if $(i:G) = <nogrist> { 517 i = $(i:G=) ; 518 } 519 } else { 520 switch $(i:B) 521 { 522 # XXX: _APP_ and _KERNEL_ should not be needed for ELF. 523 case _APP_ : isfile = true ; 524 case _KERNEL_ : isfile = true ; 525 case lib* : isfile = true ; 526 case * : isfile = ; 527 } 528 if ! $(isfile) && ( $(i:S) = .so || $(i:S) = .a ) { 529 isfile = true ; 530 } 531 } 532 533 if $(isfile) { 534 needLibs += $(i) ; 535 } else { 536 linkLibs += $(i) ; 537 } 538 } 539 540 NEEDLIBS on $(1) = $(NEEDLIBS) $(needLibs) ; 541 LINKLIBS on $(1) = $(LINKLIBS) -l$(linkLibs) ; 542 543 if $(needLibs) && ! $(NO_LIBRARY_DEPENDENCIES) { 544 Depends $(1) : $(needLibs) ; 545 } 546 } 547} 548 549rule AddResources 550{ 551 # AddResources <name> : <resourcefiles> ; 552 553 # add grist to the resource files which don't have any yet 554 local resfiles ; 555 local file ; 556 for file in $(2) { 557 if ! $(file:G) { 558 file = [ FGristFiles $(file) ] ; 559 } 560 resfiles += $(file) ; 561 } 562 563 SEARCH on $(resfiles) += $(SEARCH_SOURCE) ; 564 565 for file in $(resfiles) { 566 if $(file:S) = .rdef { 567 local rdef = $(file) ; 568 file = $(rdef:S=.rsrc) ; 569 ResComp $(file) : $(rdef) ; 570 } 571 InheritPlatform $(file) : $(1) ; 572 RESFILES on $(1) += $(file) ; 573 } 574} 575 576rule SetVersionScript target : versionScript 577{ 578 # SetVersionScript <target> : <versionScript> 579 # 580 # Sets the version script for <target>. Grist will be added to 581 # <versionScript> and SEARCH will be set on it. 582 583 versionScript = [ FGristFiles $(versionScript) ] ; 584 585 SEARCH on $(versionScript) += $(SEARCH_SOURCE) ; 586 587 VERSION_SCRIPT on $(target) = $(versionScript) ; 588 Depends $(target) : $(versionScript) ; 589} 590 591rule BuildPlatformObjects 592{ 593 # Usage BuildPlatformObjects <sources> ; 594 # <sources> The sources. 595 # 596 local sources = [ FGristFiles $(1) ] ; 597 local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 598 599 PLATFORM on $(objects) = host ; 600 SUPPORTED_PLATFORMS on $(objects) = host ; 601 602 Objects $(sources) ; 603} 604 605actions CygwinExtensionFix 606{ 607 if test -f $(1).exe ; then 608 rm -f $(1) 609 mv $(1).exe $(1) 610 fi 611} 612 613rule BuildPlatformMain 614{ 615 # Usage BuildPlatformMain <target> : <sources> : <libraries> ; 616 # <target> The executable/library. 617 # <sources> The sources. 618 # <libraries> Libraries to link against. 619 # 620 local target = $(1) ; 621 local sources = $(2) ; 622 local libs = $(3) ; 623 local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 624 625 PLATFORM on $(target) = host ; 626 SUPPORTED_PLATFORMS on $(target) = host ; 627 DONT_USE_BEOS_RULES on $(target) = true ; 628 629 local usesBeAPI = [ on $(target) return $(USES_BE_API) ] ; 630 if $(usesBeAPI) { 631 # propagate the flag to the objects 632 USES_BE_API on $(objects) = $(usesBeAPI) ; 633 634 # add the build libroot 635 if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) { 636 local libroot = [ on $(target) return $(HOST_LIBROOT) ] ; 637 Depends $(target) : $(libroot) ; 638 NEEDLIBS on $(target) += $(libroot) ; 639 } 640 } 641 642 Main $(target) : $(sources) ; 643 LinkAgainst $(target) : $(libs) ; 644 if $(HOST_PLATFORM) = cygwin { 645 # Cygwin gcc adds the ".exe" extension. We cannot force 646 # jam to use SUFEXE as haiku target executables are not 647 # supposed to have this extension, thus finding 648 # dependencies will fail for these. 649 # The hack is to remove the extension after a successful 650 # build of the Target. 651 CygwinExtensionFix $(target) ; 652 } 653} 654 655rule BuildPlatformSharedLibrary 656{ 657 # Usage BuildPlatformSharedLibrary <target> : <sources> : <libraries> ; 658 # <target> The library. 659 # <sources> The sources. 660 # <libraries> Libraries to link against. 661 # 662 local target = $(1) ; 663 local sources = $(2) ; 664 local libs = $(3) ; 665 666 BuildPlatformMain $(target) : $(sources) : $(libs) ; 667 668 if $(HOST_PLATFORM) = darwin { 669 LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ] 670 -dynamic -dynamiclib -Xlinker -flat_namespace ; 671 } else if $(HOST_PLATFORM) = cygwin { 672 LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ] 673 -shared -Xlinker --allow-multiple-definition ; 674 } else { 675 LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ] 676 -shared -Xlinker -soname=\"$(target:G=)\" ; 677 } 678 679 local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 680 CCFLAGS on $(objects) += $(HOST_PIC_CCFLAGS) ; 681 C++FLAGS on $(objects) += $(HOST_PIC_C++FLAGS) ; 682} 683 684rule BuildPlatformMergeObject 685{ 686 # BuildPlatformMergeObject <name> : <sources> : <other objects> ; 687 # Compiles source files and merges the object files to an object file. 688 # <name>: Name of the object file to create. No grist will be added. 689 # <sources>: Sources to be compiled. Grist will be added. 690 # <other objects>: Object files or static libraries to be merged. No grist 691 # will be added. 692 # 693 local target = $(1) ; 694 local sources = $(2) ; 695 local otherObjects = $(3) ; 696 local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 697 698 PLATFORM on $(target) = host ; 699 SUPPORTED_PLATFORMS on $(target) = host ; 700 701 local usesBeAPI = [ on $(target[1]) return $(USES_BE_API) ] ; 702 if $(usesBeAPI) { 703 # propagate the flag to the objects 704 USES_BE_API on $(objects) = $(usesBeAPI) ; 705 } 706 707 MergeObject $(target) : $(sources) : $(otherObjects) ; 708} 709 710rule BuildPlatformMergeObjectPIC target : sources : otherObjects 711{ 712 # BuildPlatformMergeObjectPIC <name> : <sources> : <other objects> ; 713 # Compiles source files and merges the object files to an object file. 714 # Same as BuildPlatformMergeObject rule but adds position-independent 715 # flags to the compiler (if any). 716 # <name>: Name of the object file to create. No grist will be added. 717 # <sources>: Sources to be compiled. Grist will be added. 718 # <other objects>: Object files or static libraries to be merged. No grist 719 # will be added. 720 # 721 ObjectCcFlags $(sources) : $(HOST_PIC_CCFLAGS) ; 722 ObjectC++Flags $(sources) : $(HOST_PIC_C++FLAGS) ; 723 724 BuildPlatformMergeObject $(target) : $(sources) : $(otherObjects) ; 725} 726 727rule BuildPlatformStaticLibrary lib : sources : otherObjects 728{ 729 # BuildPlatformStaticLibrary <lib> : <sources> ; 730 # Creates a static library from sources. 731 # <lib>: The static library to be built. 732 # <sources>: List of source files. 733 # <otherObjects>: List of additional object files. 734 # 735 736 local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 737 738 PLATFORM on $(lib) = host ; 739 SUPPORTED_PLATFORMS on $(lib) = host ; 740 741 local usesBeAPI = [ on $(lib) return $(USES_BE_API) ] ; 742 if $(usesBeAPI) { 743 # propagate the flag to the objects 744 USES_BE_API on $(objects) = $(usesBeAPI) ; 745 } 746 747 StaticLibrary $(lib) : $(sources) : $(otherObjects) ; 748} 749 750rule BuildPlatformStaticLibraryPIC target : sources : otherObjects 751{ 752 # Like BuildPlatformStaticLibrary, but producing position independent code. 753 754 ObjectCcFlags $(sources) : $(HOST_PIC_CCFLAGS) ; 755 ObjectC++Flags $(sources) : $(HOST_PIC_C++FLAGS) ; 756 757 BuildPlatformStaticLibrary $(target) : $(sources) : $(otherObjects) ; 758} 759