From 03980b1fb07fb591872ef2a3862e653f7dbe5b5d Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 8 Sep 2021 15:03:06 -0400 Subject: [PATCH] build: Make LinkAgainst recursive for static libraries. That is, it will now pull in NEEDLIBS and LINKLIBS set by LinkAgainst from static libraries also built by Jam. This allows specifying what libraries other static libraries need only once (in most cases; occasionally things are not evaluated in a sane order and then this does not quite work.) Use this for libnetservices.a, which needs libshared.a, so that dependencies on it do not have to be declared within most in-tree consumers of libnetservices (e.g. Package Kit, http_streamer, etc.) --- build/jam/MainBuildRules | 20 +++++++++++++++----- src/kits/network/libnetservices/JamCommon | 2 ++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/build/jam/MainBuildRules b/build/jam/MainBuildRules index d168fdb08c..0f8c712d6f 100644 --- a/build/jam/MainBuildRules +++ b/build/jam/MainBuildRules @@ -508,6 +508,9 @@ rule LinkAgainst local libs = $(2) ; local mapLibs = $(3:E=true) ; + local linkLibs ; + local needLibs ; + on $(target) { local i ; @@ -525,11 +528,7 @@ rule LinkAgainst libs = $(mappedLibs) ; } - local linkLibs ; - local needLibs ; - - for i in $(libs) - { + for i in $(libs) { local isfile = ; if $(i:D) || $(i:G) { isfile = true ; @@ -556,7 +555,18 @@ rule LinkAgainst linkLibs += $(i) ; } } + } + # Copy in the library dependencies from any static libraries first. + # (We have to do the [ on ... ] outside the on { } block. ) + for i in $(needLibs) { + if $(i:S) = .a { + needLibs += [ on $(i) return $(NEEDLIBS) ] ; + linkLibs += [ on $(i) return $(LINKLIBS) ] ; + } + } + + on $(target) { NEEDLIBS on $(1) = $(NEEDLIBS) $(needLibs) ; LINKLIBS on $(1) = $(LINKLIBS) -l$(linkLibs) ; diff --git a/src/kits/network/libnetservices/JamCommon b/src/kits/network/libnetservices/JamCommon index 366dea90c2..f58bbf7a0f 100644 --- a/src/kits/network/libnetservices/JamCommon +++ b/src/kits/network/libnetservices/JamCommon @@ -66,6 +66,8 @@ for architectureObject in [ MultiArchSubDirSetup ] { Geolocation.cpp UrlResult.cpp ; + LinkAgainst [ MultiArchDefaultGristFiles libnetservices.a ] : + <$(architecture)>libshared.a ; } SEARCH on [ FGristFiles $(sources) ]