]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Improve CHECK_LIB interaction with CHECK_PKG
authorEarl Chew <earl_chew@yahoo.com>
Sun, 17 Dec 2023 01:47:09 +0000 (17:47 -0800)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 10 May 2024 00:26:35 +0000 (00:26 +0000)
When checking for shared libraries, only name the target library
if it was not previously discoverd by pkg-config --libs and now
available from uselib_store. This avoids using both sources of
information which results in the library being named twice on
the command line.

Once the library is confirmed by CHECK_LIB, append the library if
not already present, to avoid dropping libraries that were
previously discovered by CHECK_PKG.

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/samba_autoconf.py

index d2e44e83f78d237d151d7994d08b676b60ebb4b2..802cbaced521dd4b2aea2d38762867611cb9898e 100644 (file)
@@ -623,7 +623,12 @@ int foo()
 
         (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)
+            # Avoid repeating the library if it is already named by
+            # pkg-config --libs.
+            kw = {}
+            if lib not in libs:
+                kw['lib'] = lib
+            res = conf.check(features='c cshlib', fragment=fragment, uselib_store=lib, cflags=ccflags, ldflags=ldflags, uselib=lib.upper(), mandatory=False, **kw)
         else:
             res = conf.check(lib=lib, uselib_store=lib, cflags=ccflags, ldflags=ldflags, uselib=lib.upper(), mandatory=False)
 
@@ -637,7 +642,10 @@ int foo()
                     SET_TARGET_TYPE(conf, lib, 'EMPTY')
         else:
             conf.define('HAVE_LIB%s' % lib.upper().replace('-','_').replace('.','_'), 1)
-            conf.env['LIB_' + lib.upper()] = lib
+            # To avoid losing information from pkg-config, append the library
+            # only it is not already present.
+            if lib not in libs:
+                conf.env.append_value('LIB_' + lib.upper(), lib)
             if set_target:
                 conf.SET_TARGET_TYPE(lib, 'SYSLIB')
             ret.append(lib)