1 # functions to support bundled libraries
3 from Configure import conf
4 from samba_utils import *
6 def BUNDLED_NAME(bld, name, bundled_extension):
7 '''possibly rename a library to include a bundled extension'''
8 if bld.env.DISABLE_SHARED or not bundled_extension:
10 if name in bld.env.BUNDLED_EXTENSION_EXCEPTION:
12 extension = getattr(bld.env, 'BUNDLED_EXTENSION', '')
14 return name + '-' + extension
18 def BUILTIN_LIBRARY(bld, name):
19 '''return True if a library should be builtin
20 instead of being built as a shared lib'''
21 if bld.env.DISABLE_SHARED:
23 if name in bld.env.BUILTIN_LIBRARIES:
28 def BUILTIN_DEFAULT(opt, builtins):
29 '''set a comma separated default list of builtin libraries for this package'''
30 if 'BUILTIN_LIBRARIES_DEFAULT' in Options.options:
32 Options.options['BUILTIN_LIBRARIES_DEFAULT'] = builtins
33 Options.Handler.BUILTIN_DEFAULT = BUILTIN_DEFAULT
36 def BUNDLED_EXTENSION_DEFAULT(opt, extension, noextenion=''):
37 '''set a default bundled library extension'''
38 if 'BUNDLED_EXTENSION_DEFAULT' in Options.options:
40 Options.options['BUNDLED_EXTENSION_DEFAULT'] = extension
41 Options.options['BUNDLED_EXTENSION_EXCEPTION'] = noextenion
42 Options.Handler.BUNDLED_EXTENSION_DEFAULT = BUNDLED_EXTENSION_DEFAULT
48 def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
49 checkfunctions=None, headers=None,
50 onlyif=None, implied_deps=None):
51 '''check if a library is available as a system library.
52 this first tries via pkg-config, then if that fails
53 tries by testing for a specified function in the specified lib
55 if 'ALL' in conf.env.BUNDLED_LIBS or libname in conf.env.BUNDLED_LIBS:
57 found = 'FOUND_SYSTEMLIB_%s' % libname
59 return conf.env[found]
61 # see if the library should only use a system version if another dependent
62 # system version is found. That prevents possible use of mixed library
65 for syslib in TO_LIST(onlyif):
66 f = 'FOUND_SYSTEM_%s' % syslib
68 if 'NONE' in conf.env.BUNDLED_LIBS or '!'+libname in conf.env.BUNDLED_LIBS:
69 print('ERROR: Use of system library %s depends on missing system library %s' % (libname, syslib))
71 conf.env[found] = False
75 if conf.check_cfg(package=libname,
76 args='"%s >= %s" --cflags --libs' % (libname, minversion),
77 msg='Checking for system %s >= %s' % (libname, minversion)):
78 conf.SET_TARGET_TYPE(libname, 'SYSLIB')
79 conf.env[found] = True
81 conf.SET_SYSLIB_DEPS(libname, implied_deps)
83 if checkfunctions is not None:
84 if conf.CHECK_FUNCS_IN(checkfunctions, libname, headers=headers, empty_decl=False):
85 conf.env[found] = True
87 conf.SET_SYSLIB_DEPS(libname, implied_deps)
89 conf.env[found] = False
90 if 'NONE' in conf.env.BUNDLED_LIBS or '!'+libname in conf.env.BUNDLED_LIBS:
91 print('ERROR: System library %s of version %s not found, and bundling disabled' % (libname, minversion))