From: Earl Chew Date: Sun, 17 Dec 2023 16:37:33 +0000 (-0800) Subject: Augment library_flags() to return libraries X-Git-Tag: tdb-1.4.11~803 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=363c33185779141fdfbda695997d548939a0251f;p=thirdparty%2Fsamba.git Augment library_flags() to return libraries Extend library_flags() to return the libraries provided by pkg-config --libs. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15623 Signed-off-by: Earl Chew Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/buildtools/wafsamba/samba3.py b/buildtools/wafsamba/samba3.py index 227ee27705d..ba0783f0d22 100644 --- a/buildtools/wafsamba/samba3.py +++ b/buildtools/wafsamba/samba3.py @@ -45,25 +45,25 @@ def s3_fix_kwargs(bld, kwargs): '../bin/default/third_party/heimdal/lib/asn1' ] if bld.CONFIG_SET('USING_SYSTEM_TDB'): - (tdb_includes, tdb_ldflags, tdb_cpppath) = library_flags(bld, 'tdb') + (tdb_includes, tdb_ldflags, tdb_cpppath, tdb_libs) = library_flags(bld, 'tdb') extra_includes += tdb_cpppath else: extra_includes += [ '../lib/tdb/include' ] if bld.CONFIG_SET('USING_SYSTEM_TEVENT'): - (tevent_includes, tevent_ldflags, tevent_cpppath) = library_flags(bld, 'tevent') + (tevent_includes, tevent_ldflags, tevent_cpppath, tevent_libs) = library_flags(bld, 'tevent') extra_includes += tevent_cpppath else: extra_includes += [ '../lib/tevent' ] if bld.CONFIG_SET('USING_SYSTEM_TALLOC'): - (talloc_includes, talloc_ldflags, talloc_cpppath) = library_flags(bld, 'talloc') + (talloc_includes, talloc_ldflags, talloc_cpppath, talloc_libs) = library_flags(bld, 'talloc') extra_includes += talloc_cpppath else: extra_includes += [ '../lib/talloc' ] if bld.CONFIG_SET('USING_SYSTEM_POPT'): - (popt_includes, popt_ldflags, popt_cpppath) = library_flags(bld, 'popt') + (popt_includes, popt_ldflags, popt_cpppath, popt_libs) = library_flags(bld, 'popt') extra_includes += popt_cpppath else: extra_includes += [ '../lib/popt' ] diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index 7b383ea0b71..d2e44e83f78 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -91,7 +91,7 @@ def CHECK_HEADER(conf, h, add_headers=False, lib=None): conf.env.hlist.append(h) return True - (ccflags, ldflags, cpppath) = library_flags(conf, lib) + (ccflags, ldflags, cpppath, libs) = library_flags(conf, lib) hdrs = hlist_to_string(conf, headers=h) if lib is None: @@ -435,7 +435,7 @@ def CHECK_CODE(conf, code, define, uselib = TO_LIST(lib) - (ccflags, ldflags, cpppath) = library_flags(conf, uselib) + (ccflags, ldflags, cpppath, libs) = library_flags(conf, uselib) includes = TO_LIST(includes) includes.extend(cpppath) @@ -569,21 +569,24 @@ Build.BuildContext.CONFIG_SET = CONFIG_SET Build.BuildContext.CONFIG_GET = CONFIG_GET -def library_flags(self, libs): +def library_flags(self, library): '''work out flags from pkg_config''' ccflags = [] ldflags = [] cpppath = [] - for lib in TO_LIST(libs): + libs = [] + for lib in TO_LIST(library): # note that we do not add the -I and -L in here, as that is added by the waf # core. Adding it here would just change the order that it is put on the link line # which can cause system paths to be added before internal libraries extra_ccflags = TO_LIST(getattr(self.env, 'CFLAGS_%s' % lib.upper(), [])) extra_ldflags = TO_LIST(getattr(self.env, 'LDFLAGS_%s' % lib.upper(), [])) extra_cpppath = TO_LIST(getattr(self.env, 'CPPPATH_%s' % lib.upper(), [])) + extra_libs = TO_LIST(getattr(self.env, 'LIB_%s' % lib.upper(), [])) ccflags.extend(extra_ccflags) ldflags.extend(extra_ldflags) cpppath.extend(extra_cpppath) + libs.extend(extra_libs) extra_cpppath = TO_LIST(getattr(self.env, 'INCLUDES_%s' % lib.upper(), [])) cpppath.extend(extra_cpppath) @@ -593,11 +596,12 @@ def library_flags(self, libs): ccflags = unique_list(ccflags) ldflags = unique_list(ldflags) cpppath = unique_list(cpppath) - return (ccflags, ldflags, cpppath) + libs = unique_list(libs) + return (ccflags, ldflags, cpppath, libs) @conf -def CHECK_LIB(conf, libs, mandatory=False, empty_decl=True, set_target=True, shlib=False): +def CHECK_LIB(conf, library, mandatory=False, empty_decl=True, set_target=True, shlib=False): '''check if a set of libraries exist as system libraries returns the sublist of libs that do exist as a syslib or [] @@ -611,13 +615,13 @@ int foo() } ''' ret = [] - liblist = TO_LIST(libs) - for lib in liblist[:]: + liblist = TO_LIST(library) + for lib in liblist: if GET_TARGET_TYPE(conf, lib) == 'SYSLIB': ret.append(lib) continue - (ccflags, ldflags, cpppath) = library_flags(conf, lib) + (ccflags, ldflags, cpppath, libs) = library_flags(conf, lib) if shlib: res = conf.check(features='c cshlib', fragment=fragment, lib=lib, uselib_store=lib, cflags=ccflags, ldflags=ldflags, uselib=lib.upper(), mandatory=False) else: diff --git a/buildtools/wafsamba/samba_deps.py b/buildtools/wafsamba/samba_deps.py index 80379d37a9c..6db44cc3a61 100644 --- a/buildtools/wafsamba/samba_deps.py +++ b/buildtools/wafsamba/samba_deps.py @@ -83,9 +83,8 @@ def build_dependencies(self): self.add_objects = list(self.final_objects) # extra link flags from pkg_config - libs = self.final_syslibs.copy() - - (cflags, ldflags, cpppath) = library_flags(self, list(libs)) + (cflags, ldflags, cpppath, libs) = library_flags( + self, list(self.final_syslibs.copy())) new_ldflags = getattr(self, 'samba_ldflags', [])[:] new_ldflags.extend(ldflags) self.ldflags = new_ldflags diff --git a/lib/util/charset/wscript_configure b/lib/util/charset/wscript_configure index 9c27fc664f0..58858f69b31 100644 --- a/lib/util/charset/wscript_configure +++ b/lib/util/charset/wscript_configure @@ -8,7 +8,7 @@ # managed to link when specifying -liconv a executable even if there is no # libiconv.so or libiconv.a -conf.CHECK_LIB(libs="iconv", shlib=True) +conf.CHECK_LIB("iconv", shlib=True) #HP-UX can use libiconv as an add-on package, which has #define iconv_open libiconv_open if (conf.CHECK_FUNCS_IN('iconv_open', 'iconv', checklibc=False, headers='iconv.h') or