build: auto-detect platforms which don't support shared libs
authorAndrew Tridgell <tridge@samba.org>
Sun, 28 Mar 2010 06:24:05 +0000 (17:24 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 6 Apr 2010 10:27:13 +0000 (20:27 +1000)
buildtools/wafsamba/samba_conftests.py
buildtools/wafsamba/wscript

index 8a9e3f5cd2d384c482c9128d18316568c3098c36..47bef40a3dc39960dff6179d3e2142ea0916f16a 100644 (file)
@@ -1,7 +1,9 @@
 # a set of config tests that use the samba_autoconf functions
 # to test for commonly needed configuration options
+
 import os, Build, shutil, Utils
 from Configure import conf
+from samba_utils import *
 
 @conf
 def CHECK_ICONV(conf, define='HAVE_NATIVE_ICONV'):
@@ -67,8 +69,15 @@ def CHECK_CHARSET_EXISTS(conf, charset, outcharset='UCS-2LE', headers=None, defi
 # 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_RPATH_SUPPORT(conf):
-    '''see if the platform supports rpath for libraries'''
+def CHECK_LIBRARY_SUPPORT(conf, rpath=False, msg=None):
+    '''see if the platform supports building libraries'''
+
+    if msg is None:
+        if rpath:
+            msg = "rpath library support"
+        else:
+            msg = "building library support"
+
     k = 0
     while k < 10000:
         dir = os.path.join(conf.blddir, '.conf_check_%d' % k)
@@ -127,19 +136,28 @@ def CHECK_RPATH_SUPPORT(conf):
     o = bld(features='cc cprogram',
             source='main.c',
             target='prog1',
-            uselib_local='lib1',
-            rpath=os.path.join(bdir, 'default/libdir'))
+            uselib_local='lib1')
+
+    if rpath:
+        o.rpath=os.path.join(bdir, 'default/libdir')
 
     # compile the program
     try:
         bld.compile()
     except:
-        conf.check_message('rpath support', '', False)
+        conf.check_message(msg, '', False)
         return False
 
     # path for execution
     lastprog = o.link_task.outputs[0].abspath(env)
 
+    if not rpath:
+        if 'LD_LIBRARY_PATH' in os.environ:
+            old_ld_library_path = os.environ['LD_LIBRARY_PATH']
+        else:
+            old_ld_library_path = None
+        ADD_LD_LIBRARY_PATH(os.path.join(bdir, 'default/libdir'))
+
     # we need to run the program, try to get its result
     args = []
     proc = Utils.pproc.Popen([lastprog] + args, stdout=Utils.pproc.PIPE, stderr=Utils.pproc.PIPE)
@@ -151,5 +169,8 @@ def CHECK_RPATH_SUPPORT(conf):
     w('\nreturncode %r\n' % proc.returncode)
     ret = (proc.returncode == 0)
 
-    conf.check_message('rpath support', '', ret)
+    if not rpath:
+        os.environ['LD_LIBRARY_PATH'] = old_ld_library_path or ''
+
+    conf.check_message(msg, '', ret)
     return ret
index 5a24eeb28358579fefd742d0f85defc476c5f3e3..b2a11064fe462792c3cd6d686de539bf40351c2e 100644 (file)
@@ -109,8 +109,12 @@ def configure(conf):
                     headers='stdio.h',
                     msg='Checking simple C program')
 
+    # see if we can build shared libs
+    if not conf.CHECK_LIBRARY_SUPPORT():
+        conf.env.DISABLE_SHARED = True
+
     # check for rpath
-    if not conf.env.DISABLE_SHARED and conf.CHECK_RPATH_SUPPORT():
+    if not conf.env.DISABLE_SHARED and conf.CHECK_LIBRARY_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)