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