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 require_headers
=True):
52 '''check if a library is available as a system library.
53 this first tries via pkg-config, then if that fails
54 tries by testing for a specified function in the specified lib
56 if 'ALL' in conf
.env
.BUNDLED_LIBS
or libname
in conf
.env
.BUNDLED_LIBS
:
58 found
= 'FOUND_SYSTEMLIB_%s' % libname
60 return conf
.env
[found
]
62 # see if the library should only use a system version if another dependent
63 # system version is found. That prevents possible use of mixed library
66 for syslib
in TO_LIST(onlyif
):
67 f
= 'FOUND_SYSTEM_%s' % syslib
69 if 'NONE' in conf
.env
.BUNDLED_LIBS
or '!'+libname
in conf
.env
.BUNDLED_LIBS
:
70 print('ERROR: Use of system library %s depends on missing system library %s' % (libname
, syslib
))
72 conf
.env
[found
] = False
76 if conf
.check_cfg(package
=libname
,
77 args
='"%s >= %s" --cflags --libs' % (libname
, minversion
),
78 msg
='Checking for system %s >= %s' % (libname
, minversion
)):
79 conf
.SET_TARGET_TYPE(libname
, 'SYSLIB')
80 conf
.env
[found
] = True
82 conf
.SET_SYSLIB_DEPS(libname
, implied_deps
)
84 if checkfunctions
is not None:
86 if require_headers
and headers
and not conf
.CHECK_HEADERS(headers
):
88 if headers_ok
and conf
.CHECK_FUNCS_IN(checkfunctions
, libname
, headers
=headers
, empty_decl
=False):
89 conf
.env
[found
] = True
91 conf
.SET_SYSLIB_DEPS(libname
, implied_deps
)
93 conf
.env
[found
] = False
94 if 'NONE' in conf
.env
.BUNDLED_LIBS
or '!'+libname
in conf
.env
.BUNDLED_LIBS
:
95 print('ERROR: System library %s of version %s not found, and bundling disabled' % (libname
, minversion
))