s3:auth Make AUTH_NTLMSSP_STATE a private structure.
[Samba/ekacnet.git] / buildtools / wafsamba / samba_bundled.py
blobf105a2d5ff44aeef2b6c0e250e8e162969af2cb8
1 # functions to support bundled libraries
3 from Configure import conf
4 import Logs
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:
10 return name
11 if name in bld.env.BUNDLED_EXTENSION_EXCEPTION:
12 return name
13 extension = getattr(bld.env, 'BUNDLED_EXTENSION', '')
14 if extension:
15 return name + '-' + extension
16 return name
19 def target_in_list(target, lst, default):
20 for l in lst:
21 if target == l:
22 return True
23 if '!' + target == l:
24 return False
25 if l == 'ALL':
26 return True
27 if l == 'NONE':
28 return False
29 return 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:
36 return True
37 return target_in_list(name, bld.env.BUILTIN_LIBRARIES, False)
38 Build.BuildContext.BUILTIN_LIBRARY = BUILTIN_LIBRARY
41 def BUILTIN_DEFAULT(opt, builtins):
42 '''set a comma separated default list of builtin libraries for this package'''
43 if 'BUILTIN_LIBRARIES_DEFAULT' in Options.options:
44 return
45 Options.options['BUILTIN_LIBRARIES_DEFAULT'] = builtins
46 Options.Handler.BUILTIN_DEFAULT = BUILTIN_DEFAULT
49 def BUNDLED_EXTENSION_DEFAULT(opt, extension, noextenion=''):
50 '''set a default bundled library extension'''
51 if 'BUNDLED_EXTENSION_DEFAULT' in Options.options:
52 return
53 Options.options['BUNDLED_EXTENSION_DEFAULT'] = extension
54 Options.options['BUNDLED_EXTENSION_EXCEPTION'] = noextenion
55 Options.Handler.BUNDLED_EXTENSION_DEFAULT = BUNDLED_EXTENSION_DEFAULT
58 def minimum_library_version(conf, libname, default):
59 '''allow override of mininum system library version'''
61 minlist = Options.options.MINIMUM_LIBRARY_VERSION
62 if not minlist:
63 return default
65 for m in minlist.split(','):
66 a = m.split(':')
67 if len(a) != 2:
68 Logs.error("Bad syntax for --minimum-library-version of %s" % m)
69 sys.exit(1)
70 if a[0] == libname:
71 return a[1]
72 return default
75 @runonce
76 @conf
77 def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
78 checkfunctions=None, headers=None,
79 onlyif=None, implied_deps=None,
80 require_headers=True):
81 '''check if a library is available as a system library.
82 this first tries via pkg-config, then if that fails
83 tries by testing for a specified function in the specified lib
84 '''
85 if 'ALL' in conf.env.BUNDLED_LIBS or libname in conf.env.BUNDLED_LIBS:
86 return False
87 found = 'FOUND_SYSTEMLIB_%s' % libname
88 if found in conf.env:
89 return conf.env[found]
91 # see if the library should only use a system version if another dependent
92 # system version is found. That prevents possible use of mixed library
93 # versions
94 if onlyif:
95 for syslib in TO_LIST(onlyif):
96 f = 'FOUND_SYSTEMLIB_%s' % syslib
97 if not f in conf.env:
98 if 'NONE' in conf.env.BUNDLED_LIBS or '!'+libname in conf.env.BUNDLED_LIBS:
99 Logs.error('ERROR: Use of system library %s depends on missing system library %s' % (libname, syslib))
100 sys.exit(1)
101 conf.env[found] = False
102 return False
104 minversion = minimum_library_version(conf, libname, minversion)
106 # try pkgconfig first
107 if conf.check_cfg(package=libname,
108 args='"%s >= %s" --cflags --libs' % (libname, minversion),
109 msg='Checking for system %s >= %s' % (libname, minversion)):
110 conf.SET_TARGET_TYPE(libname, 'SYSLIB')
111 conf.env[found] = True
112 if implied_deps:
113 conf.SET_SYSLIB_DEPS(libname, implied_deps)
114 return True
115 if checkfunctions is not None:
116 headers_ok = True
117 if require_headers and headers and not conf.CHECK_HEADERS(headers):
118 headers_ok = False
119 if headers_ok and conf.CHECK_FUNCS_IN(checkfunctions, libname, headers=headers, empty_decl=False):
120 conf.env[found] = True
121 if implied_deps:
122 conf.SET_SYSLIB_DEPS(libname, implied_deps)
123 return True
124 conf.env[found] = False
125 if 'NONE' in conf.env.BUNDLED_LIBS or '!'+libname in conf.env.BUNDLED_LIBS:
126 Logs.error('ERROR: System library %s of version %s not found, and bundling disabled' % (libname, minversion))
127 sys.exit(1)
128 return False
130 def NONSHARED_BINARY(bld, name):
131 '''return True if a binary should be built without non-system shared libs'''
132 if bld.env.DISABLE_SHARED:
133 return True
134 return target_in_list(name, bld.env.NONSHARED_BINARIES, False)
135 Build.BuildContext.NONSHARED_BINARY = NONSHARED_BINARY