]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Augment library_flags() to return libraries
authorEarl Chew <earl_chew@yahoo.com>
Sun, 17 Dec 2023 16:37:33 +0000 (08:37 -0800)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 10 May 2024 00:26:35 +0000 (00:26 +0000)
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 <earl_chew@yahoo.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
buildtools/wafsamba/samba3.py
buildtools/wafsamba/samba_autoconf.py
buildtools/wafsamba/samba_deps.py
lib/util/charset/wscript_configure

index 227ee27705da64e8f0a2a2e63a049594e6b9d4c6..ba0783f0d22977caf741d9aa7e63d956a441992a 100644 (file)
@@ -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' ]
index 7b383ea0b7127365f4951c96e6b9acf6aa63555f..d2e44e83f78d237d151d7994d08b676b60ebb4b2 100644 (file)
@@ -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:
index 80379d37a9cd93cd03ce6fa07540c56eeb893422..6db44cc3a612bd064ae6640a432130472f40ab57 100644 (file)
@@ -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
index 9c27fc664f0e06dbe38159b38864cf3bbdc1edec..58858f69b319d45232fc036bc0d973120b846a08 100644 (file)
@@ -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