build: check that if we provide -liconv we can build shared libs
authorMatthieu Patou <mat@matws.net>
Sun, 31 Oct 2010 13:24:46 +0000 (16:24 +0300)
committerMatthieu Patou <mat@matws.net>
Sun, 31 Oct 2010 15:51:54 +0000 (18:51 +0300)
On Solaris with sun studio compiling an executable with -liconv even if
there is no libiconv.so or libiconv.a will work but not for a shared
lib.

This problem leads to build problem as the linker won't be able to find
libiconv when building shared lib as liconv is wrongly specified

buildtools/wafsamba/samba_autoconf.py
lib/util/charset/wscript_configure

index f987d1d41a21257e70ae9c3ac5b2fc951d06cee1..e84a456287748e5aaeb25fb9ee79f4e86549e51f 100644 (file)
@@ -474,12 +474,19 @@ def library_flags(conf, libs):
 
 
 @conf
-def CHECK_LIB(conf, libs, mandatory=False, empty_decl=True, set_target=True):
+def CHECK_LIB(conf, libs, 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 []
     '''
 
+    fragment= '''
+int foo()
+{
+    int v = 2;
+    return v*2;
+}
+'''
     ret = []
     liblist  = TO_LIST(libs)
     for lib in liblist[:]:
@@ -488,8 +495,12 @@ def CHECK_LIB(conf, libs, mandatory=False, empty_decl=True, set_target=True):
             continue
 
         (ccflags, ldflags) = library_flags(conf, lib)
+        if shlib:
+            res = conf.check(features='cc cshlib', fragment=fragment, lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags)
+        else:
+            res = conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags)
 
-        if not conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags):
+        if not res:
             if mandatory:
                 Logs.error("Mandatory library '%s' not found for functions '%s'" % (lib, list))
                 sys.exit(1)
index 274a2d7630c46a38f123e400fefb00edf7de2f77..e54bfcc92494b60ac709dfaf7c9e91d185b0134b 100644 (file)
@@ -4,6 +4,12 @@
 # as the external libiconv can use a macro to override iconv_open to libiconv_open
 # and then we may find the wrong iconv.h later due to other packages looking
 # in /usr/local
+# We check for the lib iconv when building a shared lib has some compiler/linker
+# 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)
+
 if (conf.CHECK_FUNCS_IN('iconv_open', 'iconv', checklibc=False, headers='iconv.h') or
     conf.CHECK_FUNCS('iconv_open', headers='iconv.h')):
     conf.DEFINE('HAVE_NATIVE_ICONV', 1)