1 # functions to support bundled libraries
3 from Configure import conf
5 from samba_utils import *
7 def BUNDLED_NAME(bld, name, bundled_extension):
8 '''possibly rename a library to include a bundled extension'''
9 if bld.env.DISABLE_SHARED or not bundled_extension:
11 if name in bld.env.BUNDLED_EXTENSION_EXCEPTION:
13 extension = getattr(bld.env, 'BUNDLED_EXTENSION', '')
15 return name + '-' + extension
19 def target_in_list(target, lst, default):
32 def BUILTIN_LIBRARY(bld, name):
33 '''return True if a library should be builtin
34 instead of being built as a shared lib'''
35 if bld.env.DISABLE_SHARED:
37 return target_in_list(name, bld.env.BUILTIN_LIBRARIES, False)
40 def BUILTIN_DEFAULT(opt, builtins):
41 '''set a comma separated default list of builtin libraries for this package'''
42 if 'BUILTIN_LIBRARIES_DEFAULT' in Options.options:
44 Options.options['BUILTIN_LIBRARIES_DEFAULT'] = builtins
45 Options.Handler.BUILTIN_DEFAULT = BUILTIN_DEFAULT
48 def BUNDLED_EXTENSION_DEFAULT(opt, extension, noextenion=''):
49 '''set a default bundled library extension'''
50 if 'BUNDLED_EXTENSION_DEFAULT' in Options.options:
52 Options.options['BUNDLED_EXTENSION_DEFAULT'] = extension
53 Options.options['BUNDLED_EXTENSION_EXCEPTION'] = noextenion
54 Options.Handler.BUNDLED_EXTENSION_DEFAULT = BUNDLED_EXTENSION_DEFAULT
60 def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
61 checkfunctions=None, headers=None,
62 onlyif=None, implied_deps=None,
63 require_headers=True):
64 '''check if a library is available as a system library.
65 this first tries via pkg-config, then if that fails
66 tries by testing for a specified function in the specified lib
68 if 'ALL' in conf.env.BUNDLED_LIBS or libname in conf.env.BUNDLED_LIBS:
70 found = 'FOUND_SYSTEMLIB_%s' % libname
72 return conf.env[found]
74 # see if the library should only use a system version if another dependent
75 # system version is found. That prevents possible use of mixed library
78 for syslib in TO_LIST(onlyif):
79 f = 'FOUND_SYSTEM_%s' % syslib
81 if 'NONE' in conf.env.BUNDLED_LIBS or '!'+libname in conf.env.BUNDLED_LIBS:
82 Logs.error('ERROR: Use of system library %s depends on missing system library %s' % (libname, syslib))
84 conf.env[found] = False
88 if conf.check_cfg(package=libname,
89 args='"%s >= %s" --cflags --libs' % (libname, minversion),
90 msg='Checking for system %s >= %s' % (libname, minversion)):
91 conf.SET_TARGET_TYPE(libname, 'SYSLIB')
92 conf.env[found] = True
94 conf.SET_SYSLIB_DEPS(libname, implied_deps)
96 if checkfunctions is not None:
98 if require_headers and headers and not conf.CHECK_HEADERS(headers):
100 if headers_ok and conf.CHECK_FUNCS_IN(checkfunctions, libname, headers=headers, empty_decl=False):
101 conf.env[found] = True
103 conf.SET_SYSLIB_DEPS(libname, implied_deps)
105 conf.env[found] = False
106 if 'NONE' in conf.env.BUNDLED_LIBS or '!'+libname in conf.env.BUNDLED_LIBS:
107 Logs.error('ERROR: System library %s of version %s not found, and bundling disabled' % (libname, minversion))