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 $(<) : $(>) [ on $(<) return $(PLATFORM) ] ; 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 += [ FStandardHeaders $(TARGET_PACKAGING_ARCH) ] 278 $(TARGET_HDRS_$(TARGET_PACKAGING_ARCH)) ; 279 defines += $(TARGET_DEFINES_$(TARGET_PACKAGING_ARCH)) 280 $(TARGET_DEFINES) ; 281 } 282 283 # optimization flags 284 if $(DEBUG) = 0 { 285 flags += $(OPTIM) ; 286 } else { 287 flags += -O0 ; 288 } 289 290 if $(PLATFORM) = host { 291 # warning flags 292 if $(WARNINGS) != 0 { 293 flags += $(HOST_WARNING_C++FLAGS) ; 294 if $(WARNINGS) = treatAsErrors { 295 flags += -Werror $(HOST_WERROR_FLAGS) ; 296 } 297 } 298 299 # debug and other flags 300 flags += $(HOST_C++FLAGS) $(HOST_DEBUG_$(DEBUG)_C++FLAGS) 301 $(SUBDIRC++FLAGS) $(C++FLAGS) ; 302 303 if $(USES_BE_API) { 304 flags += $(HOST_BE_API_C++FLAGS) ; 305 } 306 307 C++ on $(header) = $(HOST_C++) ; 308 309 includesSeparator = $(HOST_INCLUDES_SEPARATOR) ; 310 localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ; 311 systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ; 312 313 } else { 314 # warning flags 315 if $(WARNINGS) != 0 { 316 flags += $(TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH)) ; 317 if $(WARNINGS) = treatAsErrors { 318 flags += -Werror 319 $(TARGET_WERROR_FLAGS_$(TARGET_PACKAGING_ARCH)) ; 320 } 321 } 322 323 # debug and other flags 324 flags += $(TARGET_C++FLAGS_$(TARGET_PACKAGING_ARCH)) 325 $(TARGET_DEBUG_$(DEBUG)_C++FLAGS_$(TARGET_PACKAGING_ARCH)) 326 $(SUBDIRC++FLAGS) $(C++FLAGS) ; 327 328 C++ on $(header) = $(TARGET_C++_$(TARGET_PACKAGING_ARCH)) ; 329 330 includesSeparator 331 = $(TARGET_INCLUDES_SEPARATOR_$(TARGET_PACKAGING_ARCH)) ; 332 localIncludesOption 333 = $(TARGET_LOCAL_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ; 334 systemIncludesOption 335 = $(TARGET_SYSTEM_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ; 336 } 337 } 338 339 # Turn off "invalid use of offsetof()" macro warning. We use offsetof() also 340 # for non-PODs. Since we're using the same compiler for the whole kernel and 341 # don't do virtual inheritence, that works well enough. 342 flags += -Wno-invalid-offsetof ; 343 # TODO: Rather get rid of the respective offsetof() instances. 344 345 # locate object, search for source, and set on target variables 346 347 Depends $(header) : $(source) $(PLATFORM) ; 348 SEARCH on $(source) += $(SEARCH_SOURCE) ; 349 MakeLocateArch $(header) ; 350 LocalClean clean : $(header) ; 351 352 HDRRULE on $(source) = HdrRule ; 353 HDRSCAN on $(source) = $(HDRPATTERN) ; 354 HDRSEARCH on $(source) = $(headers) $(sysHeaders) $(STDHDRS) ; 355 HDRGRIST on $(source) = $(HDRGRIST) ; 356 357 C++FLAGS on $(header) = $(flags) ; 358 CCHDRS on $(header) = [ FIncludes $(headers) : $(localIncludesOption) ] 359 $(includesSeparator) 360 [ FSysIncludes $(sysHeaders) : $(systemIncludesOption) ] ; 361 CCDEFS on $(header) = [ FDefines $(defines) ] ; 362 363 CreateAsmStructOffsetsHeader1 $(header) : $(source) ; 364} 365 366actions CreateAsmStructOffsetsHeader1 367{ 368 $(C++) -S "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o - \ 369 | grep "#define" | sed -e 's/[\$\#]\([0-9]\)/\1/' > "$(1)" 370} 371 372rule MergeObjectFromObjects 373{ 374 # MergeObjectFromObjects <name> : <objects> : <other objects> ; 375 # Merges object files to an object file. 376 # <name>: Name of the object file to create. No grist will be added. 377 # <objects>: Object files to be merged. Grist will be added. 378 # <other objects>: Object files or static libraries to be merged. No grist 379 # will be added. 380 # 381 local objects = [ FGristFiles $(2) ] ; 382 383 on $(1) { 384 if ! $(PLATFORM) in $(SUPPORTED_PLATFORMS) { 385 return ; 386 } 387 388 if $(PLATFORM) = host { 389 LINK on $(1) = $(HOST_LD) ; 390 LINKFLAGS on $(target) = $(HOST_LDFLAGS) ; 391 } else { 392 LINK on $(1) = $(TARGET_LD_$(TARGET_PACKAGING_ARCH)) ; 393 LINKFLAGS on $(target) 394 = $(TARGET_LDFLAGS_$(TARGET_PACKAGING_ARCH)) ; 395 } 396 } 397 398 MakeLocateDebug $(1) ; 399 Depends $(1) : $(objects) ; 400 Depends $(1) : $(3) ; 401 LocalDepends obj : $(1) ; 402 MergeObjectFromObjects1 $(1) : $(objects) $(3) ; 403} 404 405actions MergeObjectFromObjects1 406{ 407 $(LINK) $(LINKFLAGS) -r $(2) -o $(1) ; 408} 409 410rule MergeObject 411{ 412 # MergeObject <name> : <sources> : <other objects> ; 413 # Compiles source files and merges the object files to an object file. 414 # <name>: Name of the object file to create. No grist will be added. 415 # <sources>: Sources to be compiled. Grist will be added. 416 # <other objects>: Object files or static libraries to be merged. No grist 417 # will be added. 418 # 419 local target = $(1) ; 420 local sources = [ FGristFiles $(2) ] ; 421 local otherObjects = $(3) ; 422 local objects = $(sources:S=$(SUFOBJ)) ; 423 424 if ! [ IsPlatformSupportedForTarget $(1) ] { 425 return ; 426 } 427 428 InheritPlatform $(objects) : $(target) ; 429 Objects $(sources) ; 430 MergeObjectFromObjects $(target) : $(objects) : $(otherObjects) ; 431} 432 433rule SharedLibraryFromObjects 434{ 435 # SharedLibraryFromObjects <lib> : <objects> : <libraries> ; 436 # 437 local _lib = $(1) ; 438 439 if ! [ IsPlatformSupportedForTarget $(1) ] { 440 return ; 441 } 442 443 local soname = [ on $(_lib) return $(HAIKU_SONAME) ] ; 444 soname ?= $(_lib:BS) ; 445 446 MainFromObjects $(_lib) : $(2) ; 447 LINKFLAGS on $(_lib) = [ on $(_lib) return $(LINKFLAGS) ] 448 -shared -Xlinker -soname=\"$(soname)\" ; 449 LinkAgainst $(_lib) : $(3) ; 450 451 AddSharedObjectGlueCode $(_lib) : false ; 452} 453 454rule SharedLibrary 455{ 456 # SharedLibrary <lib> : <sources> : <libraries> : <abiVersion> ; 457 local lib = $(1) ; 458 local sources = [ FGristFiles $(2) ] ; 459 local objects = $(sources:S=$(SUFOBJ)) ; 460 local libs = $(3) ; 461 local abiVersion = $(4) ; # major ABI (soname) version for lib (if any) 462 463 if ! [ IsPlatformSupportedForTarget $(1) ] { 464 return ; 465 } 466 467 if $(abiVersion) { 468 HAIKU_SONAME on $(lib) = $(lib:BS).$(abiVersion) ; 469 HAIKU_LIB_ABI_VERSION on $(lib) = $(abiVersion) ; 470 } 471 472 InheritPlatform $(objects) : $(lib) ; 473 Objects $(sources) ; 474 SharedLibraryFromObjects $(lib) : $(objects) : $(libs) ; 475} 476 477rule LinkAgainst 478{ 479 # LinkAgainst <name> : <libs> [ : <mapLibs> ] ; 480 # Valid elements for <libs> are e.g. "be" or "libtranslation.so" or 481 # "/boot/.../libfoo.so". If the basename starts with "lib" or the thingy 482 # has a dirname or grist, it is added to the NEEDLIBS variable (i.e. the 483 # file will be bound!), otherwise it is prefixed "-l" and added to 484 # LINKLIBS. If you want to specify a target that isn't a library and 485 # also has neither grist nor a dirname, you can prepend "<nogrist>" as 486 # grist; it will be stripped by this rule. 487 # <mapLibs> specifies whether the to translate library names (e.g. "be" 488 # to "libbe.so" in case of target platform "haiku"). Defaults to "true". 489 # 490 local target = $(1) ; 491 local libs = $(2) ; 492 local mapLibs = $(3:E=true) ; 493 494 on $(target) { 495 local i ; 496 497 # map libraries, if desired and target platform is Haiku 498 local map = $(TARGET_LIBRARY_NAME_MAP_$(TARGET_PACKAGING_ARCH)) ; 499 if $(PLATFORM) != host && $(mapLibs) = true && $(map) { 500 local mappedLibs ; 501 502 for i in $(libs) { 503 local mapped = $($(map)_$(i)) ; 504 mapped ?= $(i) ; 505 mappedLibs += $(mapped) ; 506 } 507 508 libs = $(mappedLibs) ; 509 } 510 511 local linkLibs ; 512 local needLibs ; 513 514 for i in $(libs) 515 { 516 local isfile = ; 517 if $(i:D) || $(i:G) { 518 isfile = true ; 519 if $(i:G) = <nogrist> { 520 i = $(i:G=) ; 521 } 522 } else { 523 switch $(i:B) 524 { 525 # XXX: _APP_ and _KERNEL_ should not be needed for ELF. 526 case _APP_ : isfile = true ; 527 case _KERNEL_ : isfile = true ; 528 case lib* : isfile = true ; 529 case * : isfile = ; 530 } 531 if ! $(isfile) && ( $(i:S) = .so || $(i:S) = .a ) { 532 isfile = true ; 533 } 534 } 535 536 if $(isfile) { 537 needLibs += $(i) ; 538 } else { 539 linkLibs += $(i) ; 540 } 541 } 542 543 NEEDLIBS on $(1) = $(NEEDLIBS) $(needLibs) ; 544 LINKLIBS on $(1) = $(LINKLIBS) -l$(linkLibs) ; 545 546 if $(needLibs) && ! $(NO_LIBRARY_DEPENDENCIES) { 547 Depends $(1) : $(needLibs) ; 548 } 549 } 550} 551 552rule AddResources 553{ 554 # AddResources <name> : <resourcefiles> ; 555 556 # add grist to the resource files which don't have any yet 557 local resfiles ; 558 local file ; 559 for file in $(2) { 560 if ! $(file:G) { 561 file = [ FGristFiles $(file) ] ; 562 } 563 resfiles += $(file) ; 564 } 565 566 SEARCH on $(resfiles) += $(SEARCH_SOURCE) ; 567 568 for file in $(resfiles) { 569 if $(file:S) = .rdef { 570 local rdef = $(file) ; 571 file = $(rdef:S=.rsrc) ; 572 ResComp $(file) : $(rdef) ; 573 } 574 InheritPlatform $(file) : $(1) ; 575 RESFILES on $(1) += $(file) ; 576 } 577} 578 579rule SetVersionScript target : versionScript 580{ 581 # SetVersionScript <target> : <versionScript> 582 # 583 # Sets the version script for <target>. Grist will be added to 584 # <versionScript> and SEARCH will be set on it. 585 586 versionScript = [ FGristFiles $(versionScript) ] ; 587 588 SEARCH on $(versionScript) += $(SEARCH_SOURCE) ; 589 590 VERSION_SCRIPT on $(target) = $(versionScript) ; 591 Depends $(target) : $(versionScript) ; 592} 593 594rule BuildPlatformObjects 595{ 596 # Usage BuildPlatformObjects <sources> ; 597 # <sources> The sources. 598 # 599 local sources = [ FGristFiles $(1) ] ; 600 local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 601 602 PLATFORM on $(objects) = host ; 603 SUPPORTED_PLATFORMS on $(objects) = host ; 604 605 Objects $(sources) ; 606} 607 608actions CygwinExtensionFix 609{ 610 if test -f $(1).exe ; then 611 rm -f $(1) 612 mv $(1).exe $(1) 613 fi 614} 615 616rule BuildPlatformMain 617{ 618 # Usage BuildPlatformMain <target> : <sources> : <libraries> ; 619 # <target> The executable/library. 620 # <sources> The sources. 621 # <libraries> Libraries to link against. 622 # 623 local target = $(1) ; 624 local sources = $(2) ; 625 local libs = $(3) ; 626 local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 627 628 PLATFORM on $(target) = host ; 629 SUPPORTED_PLATFORMS on $(target) = host ; 630 DONT_USE_BEOS_RULES on $(target) = true ; 631 632 local usesBeAPI = [ on $(target) return $(USES_BE_API) ] ; 633 if $(usesBeAPI) { 634 # propagate the flag to the objects 635 USES_BE_API on $(objects) = $(usesBeAPI) ; 636 637 # add the build libroot 638 if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) { 639 local libroot = [ on $(target) return $(HOST_LIBROOT) ] ; 640 Depends $(target) : $(libroot) ; 641 NEEDLIBS on $(target) += $(libroot) ; 642 } 643 } 644 645 Main $(target) : $(sources) ; 646 LinkAgainst $(target) : $(libs) ; 647 if $(HOST_PLATFORM) = cygwin { 648 # Cygwin gcc adds the ".exe" extension. We cannot force 649 # jam to use SUFEXE as haiku target executables are not 650 # supposed to have this extension, thus finding 651 # dependencies will fail for these. 652 # The hack is to remove the extension after a successful 653 # build of the Target. 654 CygwinExtensionFix $(target) ; 655 } 656} 657 658rule BuildPlatformSharedLibrary 659{ 660 # Usage BuildPlatformSharedLibrary <target> : <sources> : <libraries> ; 661 # <target> The library. 662 # <sources> The sources. 663 # <libraries> Libraries to link against. 664 # 665 local target = $(1) ; 666 local sources = $(2) ; 667 local libs = $(3) ; 668 669 BuildPlatformMain $(target) : $(sources) : $(libs) ; 670 671 if $(HOST_PLATFORM) = darwin { 672 LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ] 673 -dynamic -dynamiclib -Xlinker -flat_namespace ; 674 } else if $(HOST_PLATFORM) = cygwin { 675 LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ] 676 -shared -Xlinker --allow-multiple-definition ; 677 } else { 678 LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ] 679 -shared -Xlinker -soname=\"$(target:G=)\" ; 680 } 681 682 local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 683 CCFLAGS on $(objects) += $(HOST_PIC_CCFLAGS) ; 684 C++FLAGS on $(objects) += $(HOST_PIC_C++FLAGS) ; 685} 686 687rule BuildPlatformMergeObject 688{ 689 # BuildPlatformMergeObject <name> : <sources> : <other objects> ; 690 # Compiles source files and merges the object files to an object file. 691 # <name>: Name of the object file to create. No grist will be added. 692 # <sources>: Sources to be compiled. Grist will be added. 693 # <other objects>: Object files or static libraries to be merged. No grist 694 # will be added. 695 # 696 local target = $(1) ; 697 local sources = $(2) ; 698 local otherObjects = $(3) ; 699 local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 700 701 PLATFORM on $(target) = host ; 702 SUPPORTED_PLATFORMS on $(target) = host ; 703 704 local usesBeAPI = [ on $(target[1]) return $(USES_BE_API) ] ; 705 if $(usesBeAPI) { 706 # propagate the flag to the objects 707 USES_BE_API on $(objects) = $(usesBeAPI) ; 708 } 709 710 MergeObject $(target) : $(sources) : $(otherObjects) ; 711} 712 713rule BuildPlatformMergeObjectPIC target : sources : otherObjects 714{ 715 # BuildPlatformMergeObjectPIC <name> : <sources> : <other objects> ; 716 # Compiles source files and merges the object files to an object file. 717 # Same as BuildPlatformMergeObject rule but adds position-independent 718 # flags to the compiler (if any). 719 # <name>: Name of the object file to create. No grist will be added. 720 # <sources>: Sources to be compiled. Grist will be added. 721 # <other objects>: Object files or static libraries to be merged. No grist 722 # will be added. 723 # 724 ObjectCcFlags $(sources) : $(HOST_PIC_CCFLAGS) ; 725 ObjectC++Flags $(sources) : $(HOST_PIC_C++FLAGS) ; 726 727 BuildPlatformMergeObject $(target) : $(sources) : $(otherObjects) ; 728} 729 730rule BuildPlatformStaticLibrary lib : sources : otherObjects 731{ 732 # BuildPlatformStaticLibrary <lib> : <sources> ; 733 # Creates a static library from sources. 734 # <lib>: The static library to be built. 735 # <sources>: List of source files. 736 # <otherObjects>: List of additional object files. 737 # 738 739 local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 740 741 PLATFORM on $(lib) = host ; 742 SUPPORTED_PLATFORMS on $(lib) = host ; 743 744 local usesBeAPI = [ on $(lib) return $(USES_BE_API) ] ; 745 if $(usesBeAPI) { 746 # propagate the flag to the objects 747 USES_BE_API on $(objects) = $(usesBeAPI) ; 748 } 749 750 StaticLibrary $(lib) : $(sources) : $(otherObjects) ; 751} 752 753rule BuildPlatformStaticLibraryPIC target : sources : otherObjects 754{ 755 # Like BuildPlatformStaticLibrary, but producing position independent code. 756 757 ObjectCcFlags $(sources) : $(HOST_PIC_CCFLAGS) ; 758 ObjectC++Flags $(sources) : $(HOST_PIC_C++FLAGS) ; 759 760 BuildPlatformStaticLibrary $(target) : $(sources) : $(otherObjects) ; 761} 762