waf: added configure test for -Wl,--version-script
authorAndrew Tridgell <tridge@samba.org>
Wed, 8 Dec 2010 00:26:32 +0000 (11:26 +1100)
committerAndrew Tridgell <tridge@samba.org>
Wed, 8 Dec 2010 04:26:06 +0000 (05:26 +0100)
this checks that the linker supports --version-script

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

buildtools/wafsamba/samba_conftests.py
buildtools/wafsamba/samba_install.py
buildtools/wafsamba/wscript

index 4811614ab73701497a89909e34185dd39375e737..2246ac3fa5cb0016ca63e028aa1e7f2f5ac1d07a 100644 (file)
@@ -133,7 +133,7 @@ int foo(int v) {
 # into several parts. I'd quite like to create a set of CHECK_COMPOUND()
 # functions that make writing complex compound tests like this much easier
 @conf
-def CHECK_LIBRARY_SUPPORT(conf, rpath=False, msg=None):
+def CHECK_LIBRARY_SUPPORT(conf, rpath=False, version_script=False, msg=None):
     '''see if the platform supports building libraries'''
 
     if msg is None:
@@ -171,9 +171,17 @@ def CHECK_LIBRARY_SUPPORT(conf, rpath=False, msg=None):
 
     bld.rescan(bld.srcnode)
 
+    ldflags = []
+    if version_script:
+        ldflags.append("-Wl,--version-script=%s/vscript" % bld.path.abspath())
+        dest = open(os.path.join(dir,'vscript'), 'w')
+        dest.write('TEST_1.0A2 { global: *; };\n')
+        dest.close()
+
     bld(features='cc cshlib',
         source='libdir/lib1.c',
         target='libdir/lib1',
+        ldflags=ldflags,
         name='lib1')
 
     o = bld(features='cc cprogram',
index fcbf4ea40f4dc118c1be9de3f32b24f7357f7ccc..327227f7f50350315e3b2ababc4d038f9cdd5624 100644 (file)
@@ -128,6 +128,9 @@ def install_library(self):
         t.env.append_value('LINKFLAGS', t.env.SONAME_ST % install_link)
         t.env.SONAME_ST = ''
 
+    if install_name == install_link:
+        install_link = None
+
     # tell waf to install the library
     bld.install_as(os.path.join(install_path, install_name),
                    os.path.join(self.path.abspath(bld.env), inst_name))
index 0d91237d482894a2a2c3f4b4d3f37216f3163301..f3551253c62c309edf558632e1295a0b41d2a504 100644 (file)
@@ -269,6 +269,7 @@ def configure(conf):
 
     # check for rpath
     if not conf.env.DISABLE_SHARED and conf.CHECK_LIBRARY_SUPPORT(rpath=True):
+        support_rpath = True
         conf.env.RPATH_ON_BUILD   = not Options.options.disable_rpath_build
         conf.env.RPATH_ON_INSTALL = (conf.env.RPATH_ON_BUILD and
                                      not Options.options.disable_rpath_install)
@@ -277,6 +278,7 @@ def configure(conf):
         conf.env.RPATH_ON_INSTALL_PRIVATE = (
             not Options.options.disable_rpath_private_install)
     else:
+        support_rpath = False
         conf.env.RPATH_ON_INSTALL = False
         conf.env.RPATH_ON_BUILD   = False
         conf.env.RPATH_ON_INSTALL_PRIVATE = False
@@ -286,6 +288,13 @@ def configure(conf):
             # the user can of course always override it.
             conf.env.PRIVATELIBDIR = conf.env.LIBDIR
 
+    if not conf.env.DISABLE_SHARED and conf.CHECK_LIBRARY_SUPPORT(rpath=support_rpath,
+                                                                  version_script=True,
+                                                                  msg='-Wl,--version-script support'):
+        conf.env.HAVE_LD_VERSION_SCRIPT = True
+    else:
+        conf.env.HAVE_LD_VERSION_SCRIPT = False
+
     # we should use the PIC options in waf instead
     # Some compilo didn't support -fPIC but just print a warning
     if conf.env['COMPILER_CC'] == "suncc":