]>
Commit | Line | Data |
---|---|---|
45a596fb | 1 | #!/usr/bin/env python |
72e1a39e | 2 | |
699977a2 AB |
3 | top = '.' |
4 | out = 'bin' | |
72e1a39e AT |
5 | |
6 | APPNAME='samba' | |
7 | VERSION=None | |
8 | ||
921b927d | 9 | import sys, os, tempfile |
699977a2 | 10 | sys.path.insert(0, top+"/buildtools/wafsamba") |
8649e216 | 11 | import shutil |
c73b7795 | 12 | import wafsamba, samba_dist, samba_git, samba_version, samba_utils |
699977a2 | 13 | from waflib import Options, Scripting, Logs, Context, Errors |
e45980ff | 14 | from waflib.Tools import bison |
72e1a39e AT |
15 | |
16 | samba_dist.DIST_DIRS('.') | |
7c2bf8d2 | 17 | samba_dist.DIST_BLACKLIST('.gitignore .bzrignore source4/selftest/provisions') |
72e1a39e | 18 | |
9b5d226a AB |
19 | DEFAULT_PRIVATE_LIBS = ["ldb"] |
20 | ||
72e1a39e | 21 | # install in /usr/local/samba by default |
71a168eb | 22 | default_prefix = Options.default_prefix = '/usr/local/samba' |
72e1a39e | 23 | |
27503cea AB |
24 | # This callback optionally takes a list of paths as arguments: |
25 | # --with-system_mitkrb5 /path/to/krb5 /another/path | |
26 | def system_mitkrb5_callback(option, opt, value, parser): | |
27 | setattr(parser.values, option.dest, True) | |
28 | value = [] | |
29 | for arg in parser.rargs: | |
30 | # stop on --foo like options | |
31 | if arg[:2] == "--" and len(arg) > 2: | |
32 | break | |
33 | value.append(arg) | |
34 | if len(value)>0: | |
35 | del parser.rargs[:len(value)] | |
36 | setattr(parser.values, option.dest, value) | |
37 | ||
c73b7795 | 38 | def options(opt): |
72e1a39e | 39 | opt.BUILTIN_DEFAULT('NONE') |
f22df59b | 40 | opt.PRIVATE_EXTENSION_DEFAULT('private-samba') |
72e1a39e | 41 | opt.RECURSE('lib/replace') |
35a9c23a | 42 | opt.RECURSE('dynconfig') |
080d590d | 43 | opt.RECURSE('packaging') |
8420a36d | 44 | opt.RECURSE('lib/ldb') |
47b7c6fc | 45 | opt.RECURSE('selftest') |
81190f91 | 46 | opt.RECURSE('source4/dsdb/samdb/ldb_modules') |
72e1a39e | 47 | opt.RECURSE('pidl') |
f180e1ab | 48 | opt.RECURSE('source3') |
b9902793 | 49 | opt.RECURSE('lib/util') |
e94422a8 | 50 | opt.RECURSE('ctdb') |
080d590d | 51 | |
6446e86b AB |
52 | # Optional Libraries |
53 | # ------------------ | |
54 | # | |
55 | # Most of the calls to opt.add_option() use default=True for the --with case | |
56 | # | |
57 | # To assist users and distributors to build Samba with the full feature | |
58 | # set, the build system will abort if our dependent libraries and their | |
59 | # header files are not found on the target system. This will mean for | |
60 | # example, that xattr, acl and ldap headers must be installed for the | |
61 | # default build to complete. The configure system will check for these | |
62 | # headers, and the error message will indicate the option (such as | |
63 | # --without-acl-support) that can be specified to skip this requirement. | |
64 | # | |
65 | # This will assist users and in particular distributors in building fully | |
66 | # functional packages, while allowing those on systems truly without these | |
67 | # facilities to continue to build Samba after careful consideration. | |
68 | # | |
69 | # It also ensures our container image generation in bootstrap/ is correct | |
70 | # as otherwise a missing package there would just silently work | |
080d590d | 71 | |
dd25d75b | 72 | opt.samba_add_onoff_option('pthreadpool', with_name="enable", without_name="disable", default=True) |
72e1a39e | 73 | |
2ddf89a2 | 74 | opt.add_option('--with-system-mitkrb5', |
a0464e3f | 75 | help='build Samba with system MIT Kerberos. ' + |
27503cea AB |
76 | 'You may specify list of paths where Kerberos is installed (e.g. /usr/local /usr/kerberos) to search krb5-config', |
77 | action='callback', callback=system_mitkrb5_callback, dest='with_system_mitkrb5', default=False) | |
07c49d25 AB |
78 | |
79 | opt.add_option('--with-experimental-mit-ad-dc', | |
80 | help='Enable the experimental MIT Kerberos-backed AD DC. ' + | |
81 | 'Note that security patches are not issued for this configuration', | |
82 | action='store_true', | |
83 | dest='with_experimental_mit_ad_dc', | |
84 | default=False) | |
85 | ||
b5a67b9d AS |
86 | opt.add_option('--with-system-mitkdc', |
87 | help=('Specify the path to the krb5kdc binary from MIT Kerberos'), | |
88 | type="string", | |
89 | dest='with_system_mitkdc', | |
90 | default=None) | |
2ddf89a2 | 91 | |
5c58ccba CS |
92 | opt.add_option('--with-system-heimdalkrb5', |
93 | help=('build Samba with system Heimdal Kerberos. ' + | |
94 | 'Requires --without-ad-dc' and | |
95 | 'conflicts with --with-system-mitkrb5'), | |
96 | action='store_true', | |
97 | dest='with_system_heimdalkrb5', | |
98 | default=False) | |
99 | ||
2ddf89a2 | 100 | opt.add_option('--without-ad-dc', |
a0464e3f | 101 | help='disable AD DC functionality (enables only Samba FS (File Server, Winbind, NMBD) and client utilities.', |
23aac203 | 102 | action='store_true', dest='without_ad_dc', default=False) |
2ddf89a2 | 103 | |
d47c1245 | 104 | opt.add_option('--with-pie', |
b48ceef1 DD |
105 | help=("Build Position Independent Executables " + |
106 | "(default if supported by compiler)"), | |
107 | action="store_true", dest='enable_pie') | |
d47c1245 DD |
108 | opt.add_option('--without-pie', |
109 | help=("Disable Position Independent Executable builds"), | |
110 | action="store_false", dest='enable_pie') | |
111 | ||
191e6b94 AS |
112 | opt.add_option('--with-relro', |
113 | help=("Build with full RELocation Read-Only (RELRO)" + | |
114 | "(default if supported by compiler)"), | |
115 | action="store_true", dest='enable_relro') | |
116 | opt.add_option('--without-relro', | |
117 | help=("Disable RELRO builds"), | |
118 | action="store_false", dest='enable_relro') | |
119 | ||
bb463798 ŁS |
120 | opt.add_option('--with-kernel-keyring', |
121 | help=('Enable kernely keyring support for credential storage ' + | |
122 | '(default if keyutils libraries are available)'), | |
123 | action='store_true', dest='enable_keyring') | |
124 | opt.add_option('--without-kernel-keyring', | |
125 | help=('Disable kernely keyring support for credential storage'), | |
126 | action='store_false', dest='enable_keyring') | |
127 | ||
b8361414 AB |
128 | opt.samba_add_onoff_option('ldap') |
129 | ||
b5cc15fd | 130 | opt.option_group('developer options') |
7b43053a | 131 | |
c73b7795 | 132 | opt.load('python') # options for disabling pyc or pyo compilation |
72e1a39e AT |
133 | # enable options related to building python extensions |
134 | ||
c98f9971 PG |
135 | opt.add_option('--with-json', |
136 | action='store_true', dest='with_json', | |
137 | help=("Build with JSON support (default=True). This " | |
138 | "requires the jansson development headers.")) | |
139 | opt.add_option('--without-json', | |
140 | action='store_false', dest='with_json', | |
141 | help=("Build without JSON support.")) | |
72e1a39e | 142 | |
a9b57276 DM |
143 | opt.samba_add_onoff_option('smb1-server', |
144 | dest='with_smb1server', | |
145 | help=("Build smbd with SMB1 support (default=yes).")) | |
146 | ||
72e1a39e AT |
147 | def configure(conf): |
148 | version = samba_version.load_version(env=conf.env) | |
149 | ||
150 | conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1) | |
151 | conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True) | |
152 | conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True) | |
153 | ||
154 | if Options.options.developer: | |
155 | conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD') | |
30e11d55 | 156 | conf.env.DEVELOPER = True |
8649e216 RB |
157 | # if we are in a git tree without a pre-commit hook, install a |
158 | # simple default. | |
8858cf72 SM |
159 | # we need git for 'waf dist' |
160 | githooksdir = None | |
161 | conf.find_program('git', var='GIT') | |
162 | if 'GIT' in conf.env: | |
163 | githooksdir = conf.CHECK_COMMAND('%s rev-parse --git-path hooks' % conf.env.GIT[0], | |
164 | msg='Finding githooks directory', | |
165 | define=None, | |
166 | on_target=False) | |
167 | if githooksdir and os.path.isdir(githooksdir): | |
168 | pre_commit_hook = os.path.join(githooksdir, 'pre-commit') | |
169 | if not os.path.exists(pre_commit_hook): | |
170 | Logs.info("Installing script/git-hooks/pre-commit-hook as %s" % | |
171 | pre_commit_hook) | |
172 | shutil.copy(os.path.join(Context.g_module.top, 'script/git-hooks/pre-commit-hook'), | |
173 | pre_commit_hook) | |
72e1a39e | 174 | |
d526f861 | 175 | conf.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace') |
72e1a39e | 176 | |
469e2fc3 | 177 | conf.env.replace_add_global_pthread = True |
72e1a39e AT |
178 | conf.RECURSE('lib/replace') |
179 | ||
3b97211d | 180 | conf.RECURSE('examples/fuse') |
ffa1c040 | 181 | conf.RECURSE('examples/winexe') |
3b97211d | 182 | |
7bf9e937 | 183 | conf.SAMBA_CHECK_PERL(mandatory=True) |
9fe559ec | 184 | conf.CHECK_XSLTPROC_MANPAGES() |
72e1a39e | 185 | |
7d5db908 IS |
186 | if conf.env.disable_python: |
187 | if not (Options.options.without_ad_dc): | |
699977a2 | 188 | raise Errors.WafError('--disable-python requires --without-ad-dc') |
7d5db908 | 189 | |
a574e8f5 AB |
190 | conf.SAMBA_CHECK_PYTHON() |
191 | conf.SAMBA_CHECK_PYTHON_HEADERS() | |
72e1a39e AT |
192 | |
193 | if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']: | |
194 | # Mac OSX needs to have this and it's also needed that the python is compiled with this | |
195 | # otherwise you face errors about common symbols | |
196 | if not conf.CHECK_SHLIB_W_PYTHON("Checking if -fno-common is needed"): | |
197 | conf.ADD_CFLAGS('-fno-common') | |
198 | if not conf.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"): | |
8077f462 | 199 | conf.env.append_value('cshlib_LINKFLAGS', ['-undefined', 'dynamic_lookup']) |
2a789c84 AB |
200 | |
201 | if sys.platform == 'darwin': | |
202 | conf.ADD_LDFLAGS('-framework CoreFoundation') | |
203 | ||
35a9c23a | 204 | conf.RECURSE('dynconfig') |
22bf36c8 | 205 | conf.RECURSE('selftest') |
f46b79bd | 206 | |
efc2de0d AS |
207 | conf.PROCESS_SEPARATE_RULE('system_gnutls') |
208 | ||
2b7224ab AB |
209 | conf.CHECK_CFG(package='zlib', minversion='1.2.3', |
210 | args='--cflags --libs', | |
f8e79be2 | 211 | mandatory=True) |
2b7224ab AB |
212 | conf.CHECK_FUNCS_IN('inflateInit2', 'z') |
213 | ||
c6d0323b | 214 | if Options.options.enable_keyring is not False: |
bb463798 | 215 | conf.env['WITH_KERNEL_KEYRING'] = 'auto' |
c6d0323b | 216 | if Options.options.enable_keyring is True: |
bb463798 ŁS |
217 | conf.env['WITH_KERNEL_KEYRING'] = True |
218 | else: | |
219 | conf.env['WITH_KERNEL_KEYRING'] = False | |
220 | ||
f46b79bd | 221 | if conf.CHECK_FOR_THIRD_PARTY(): |
e50342f3 | 222 | conf.RECURSE('third_party') |
f46b79bd | 223 | else: |
38de110b IC |
224 | |
225 | if not conf.CHECK_POPT(): | |
699977a2 | 226 | raise Errors.WafError('popt development packages have not been found.\nIf third_party is installed, check that it is in the proper place.') |
38de110b IC |
227 | else: |
228 | conf.define('USING_SYSTEM_POPT', 1) | |
ba8ee8c9 | 229 | |
94b7672d | 230 | if not conf.CHECK_CMOCKA(): |
699977a2 | 231 | raise Errors.WafError('cmocka development packages has not been found.\nIf third_party is installed, check that it is in the proper place.') |
94b7672d AS |
232 | else: |
233 | conf.define('USING_SYSTEM_CMOCKA', 1) | |
234 | ||
22bf36c8 AS |
235 | if conf.CONFIG_GET('ENABLE_SELFTEST'): |
236 | if not conf.CHECK_SOCKET_WRAPPER(): | |
699977a2 | 237 | raise Errors.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.') |
22bf36c8 AS |
238 | else: |
239 | conf.define('USING_SYSTEM_SOCKET_WRAPPER', 1) | |
94b7672d | 240 | |
5d2b5e98 | 241 | if not conf.CHECK_NSS_WRAPPER(): |
699977a2 | 242 | raise Errors.WafError('nss_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.') |
5d2b5e98 AS |
243 | else: |
244 | conf.define('USING_SYSTEM_NSS_WRAPPER', 1) | |
245 | ||
ac650704 | 246 | if not conf.CHECK_RESOLV_WRAPPER(): |
699977a2 | 247 | raise Errors.WafError('resolv_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.') |
ac650704 AS |
248 | else: |
249 | conf.define('USING_SYSTEM_RESOLV_WRAPPER', 1) | |
250 | ||
6fbc8b81 | 251 | if not conf.CHECK_UID_WRAPPER(): |
699977a2 | 252 | raise Errors.WafError('uid_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.') |
6fbc8b81 AS |
253 | else: |
254 | conf.define('USING_SYSTEM_UID_WRAPPER', 1) | |
255 | ||
8635465d | 256 | if not conf.CHECK_PAM_WRAPPER(): |
699977a2 | 257 | raise Errors.WafError('pam_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.') |
8635465d AS |
258 | else: |
259 | conf.define('USING_SYSTEM_PAM_WRAPPER', 1) | |
260 | ||
b8361414 AB |
261 | # Check for LDAP |
262 | if Options.options.with_ldap: | |
263 | conf.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h') | |
264 | conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h') | |
265 | conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber') | |
266 | conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h') | |
267 | ||
268 | # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out | |
269 | # for the samba logs | |
270 | conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN', | |
271 | define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h') | |
272 | ||
273 | conf.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap') | |
274 | conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap') | |
275 | ||
276 | # Check if ldap_set_rebind_proc() takes three arguments | |
277 | if conf.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)', | |
278 | 'LDAP_SET_REBIND_PROC_ARGS', | |
279 | msg="Checking whether ldap_set_rebind_proc takes 3 arguments", | |
280 | headers='ldap.h lber.h', link=False): | |
281 | conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3') | |
282 | else: | |
283 | conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2') | |
284 | ||
285 | # last but not least, if ldap_init() exists, we want to use ldap | |
286 | if conf.CONFIG_SET('HAVE_LDAP_INIT') and conf.CONFIG_SET('HAVE_LDAP_H'): | |
287 | conf.DEFINE('HAVE_LDAP', '1') | |
288 | conf.DEFINE('LDAP_DEPRECATED', '1') | |
289 | conf.env['HAVE_LDAP'] = '1' | |
290 | # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add | |
291 | # SASL wrapping hooks | |
292 | if conf.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \ | |
293 | conf.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'): | |
f1a83feb | 294 | conf.DEFINE('HAVE_LDAP_TRANSPORT_WRAPPING', 1) |
b8361414 AB |
295 | conf.env.ENABLE_LDAP_BACKEND = True |
296 | else: | |
297 | conf.fatal("LDAP support not found. " | |
298 | "Try installing libldap2-dev or openldap-devel. " | |
299 | "Otherwise, use --without-ldap to build without " | |
300 | "LDAP support. " | |
301 | "LDAP support is required for the LDAP passdb backend, " | |
302 | "LDAP idmap backends and ADS. " | |
303 | "ADS support improves communication with " | |
304 | "Active Directory domain controllers.") | |
305 | else: | |
306 | conf.SET_TARGET_TYPE('ldap', 'EMPTY') | |
307 | conf.SET_TARGET_TYPE('lber', 'EMPTY') | |
308 | ||
309 | conf.RECURSE('lib/tdb') | |
310 | conf.RECURSE('lib/tevent') | |
8420a36d | 311 | conf.RECURSE('lib/ldb') |
2ddf89a2 | 312 | |
8e17be1c CS |
313 | if conf.CHECK_LDFLAGS(['-Wl,--wrap=test']): |
314 | conf.env['HAVE_LDWRAP'] = True | |
315 | conf.define('HAVE_LDWRAP', 1) | |
316 | ||
7feb650a AS |
317 | if not (Options.options.without_ad_dc): |
318 | conf.DEFINE('AD_DC_BUILD_IS_ENABLED', 1) | |
319 | ||
942c0d21 AB |
320 | # Check for flex before doing the embedded heimdal checks so we can bail if we don't have it. |
321 | Logs.info("Checking for flex") | |
322 | conf.find_program('flex', var='FLEX') | |
323 | if conf.env['FLEX']: | |
324 | conf.CHECK_COMMAND('%s --version' % conf.env.FLEX[0], | |
325 | msg='Using flex version', | |
326 | define=None, | |
327 | on_target=False) | |
328 | conf.env.FLEXFLAGS = ['-t'] | |
329 | ||
330 | # #line statements in these generated files cause issues for lcov | |
331 | conf.env.FLEXFLAGS += ["--noline"] | |
332 | ||
e45980ff AB |
333 | Logs.info("Checking for bison") |
334 | bison.configure(conf) | |
335 | if conf.env['BISON']: | |
336 | conf.CHECK_COMMAND('%s --version | head -n1' % conf.env.BISON[0], | |
337 | msg='Using bison version', | |
338 | define=None, | |
339 | on_target=False) | |
340 | ||
341 | # #line statements in these generated files cause issues for lcov | |
342 | conf.env.BISONFLAGS += ["--no-line"] | |
343 | ||
2ddf89a2 | 344 | if Options.options.with_system_mitkrb5: |
07c49d25 AB |
345 | if not Options.options.with_experimental_mit_ad_dc and \ |
346 | not Options.options.without_ad_dc: | |
347 | raise Errors.WafError('The MIT Kerberos build of Samba as an AD DC ' + | |
348 | 'is experimental. Therefore ' | |
349 | '--with-system-mitkrb5 requires either ' + | |
350 | '--with-experimental-mit-ad-dc or ' + | |
351 | '--without-ad-dc') | |
352 | ||
2ddf89a2 | 353 | conf.PROCESS_SEPARATE_RULE('system_mitkrb5') |
07c49d25 | 354 | |
23aac203 | 355 | if not (Options.options.without_ad_dc or Options.options.with_system_mitkrb5): |
2ddf89a2 | 356 | conf.DEFINE('AD_DC_BUILD_IS_ENABLED', 1) |
71dcc76b | 357 | |
5c58ccba CS |
358 | if Options.options.with_system_heimdalkrb5: |
359 | if Options.options.with_system_mitkrb5: | |
dfbfb7eb SS |
360 | raise Errors.WafError('--with-system-heimdalkrb5 conflicts with ' + |
361 | '--with-system-mitkrb5') | |
5c58ccba | 362 | if not Options.options.without_ad_dc: |
dfbfb7eb SS |
363 | raise Errors.WafError('--with-system-heimdalkrb5 requires ' + |
364 | '--without-ad-dc') | |
5c58ccba CS |
365 | conf.env.SYSTEM_LIBS += ('heimdal', 'asn1', 'com_err', 'roken', |
366 | 'hx509', 'wind', 'gssapi', 'hcrypto', | |
367 | 'krb5', 'heimbase', 'asn1_compile', | |
368 | 'compile_et', 'kdc', 'hdb', 'heimntlm') | |
8061983d SM |
369 | conf.PROCESS_SEPARATE_RULE('system_heimdal') |
370 | ||
371 | if not conf.CONFIG_GET('KRB5_VENDOR'): | |
372 | conf.PROCESS_SEPARATE_RULE('embedded_heimdal') | |
5c58ccba | 373 | |
81190f91 | 374 | conf.RECURSE('source4/dsdb/samdb/ldb_modules') |
72e1a39e AT |
375 | conf.RECURSE('source4/ntvfs/sysdep') |
376 | conf.RECURSE('lib/util') | |
72e1a39e AT |
377 | conf.RECURSE('lib/util/charset') |
378 | conf.RECURSE('source4/auth') | |
72e1a39e | 379 | conf.RECURSE('nsswitch') |
72e1a39e AT |
380 | conf.RECURSE('libcli/smbreadline') |
381 | conf.RECURSE('pidl') | |
c0a463d9 | 382 | if conf.CONFIG_GET('ENABLE_SELFTEST'): |
ef8623c1 AB |
383 | if not (Options.options.without_ad_dc): |
384 | conf.DEFINE('WITH_NTVFS_FILESERVER', 1) | |
25ef27b2 | 385 | conf.RECURSE('testsuite/unittests') |
71dcc76b | 386 | |
dd25d75b | 387 | if Options.options.with_pthreadpool: |
991ca9b5 | 388 | if conf.CONFIG_SET('HAVE_PTHREAD'): |
dd25d75b MP |
389 | conf.DEFINE('WITH_PTHREADPOOL', '1') |
390 | else: | |
991ca9b5 | 391 | Logs.warn("pthreadpool support cannot be enabled when pthread support was not found") |
dd25d75b MP |
392 | conf.undefine('WITH_PTHREADPOOL') |
393 | ||
c98f9971 PG |
394 | conf.SET_TARGET_TYPE('jansson', 'EMPTY') |
395 | ||
c6d0323b | 396 | if Options.options.with_json is not False: |
c98f9971 PG |
397 | if conf.CHECK_CFG(package='jansson', args='--cflags --libs', |
398 | msg='Checking for jansson'): | |
399 | conf.CHECK_FUNCS_IN('json_object', 'jansson') | |
400 | ||
401 | if not conf.CONFIG_GET('HAVE_JSON_OBJECT'): | |
c6d0323b | 402 | if Options.options.with_json is not False: |
c98f9971 PG |
403 | conf.fatal("Jansson JSON support not found. " |
404 | "Try installing libjansson-dev or jansson-devel. " | |
405 | "Otherwise, use --without-json to build without " | |
406 | "JSON support. " | |
407 | "JSON support is required for the JSON " | |
408 | "formatted audit log feature, the AD DC, and " | |
409 | "the JSON printers of the net utility") | |
410 | if not Options.options.without_ad_dc: | |
411 | raise Errors.WafError('--without-json requires --without-ad-dc. ' | |
412 | 'Jansson JSON library is required for ' | |
413 | 'building the AD DC') | |
414 | Logs.info("Building without Jansson JSON log support") | |
415 | ||
14f99167 | 416 | conf.RECURSE('source3') |
3ba74c83 | 417 | conf.RECURSE('lib/texpect') |
1625dc4b | 418 | conf.RECURSE('lib/tsocket') |
fecbc81c | 419 | conf.RECURSE('python') |
69c0c43d | 420 | if conf.env.with_ctdb: |
e94422a8 | 421 | conf.RECURSE('ctdb') |
1862aa6c | 422 | conf.RECURSE('lib/socket') |
8479401b | 423 | conf.RECURSE('lib/mscat') |
080d590d | 424 | conf.RECURSE('packaging') |
7d3416e8 | 425 | conf.RECURSE('lib/krb5_wrap') |
72e1a39e | 426 | |
86afe83d | 427 | conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS() |
3a88d49d | 428 | |
72e1a39e AT |
429 | # gentoo always adds this. We want our normal build to be as |
430 | # strict as the strictest OS we support, so adding this here | |
431 | # allows us to find problems on our development hosts faster. | |
432 | # It also results in faster load time. | |
577034b3 | 433 | |
6b9018d3 AS |
434 | if (not Options.options.address_sanitizer |
435 | and conf.CHECK_LDFLAGS('-Wl,--as-needed')): | |
ff1c3af6 | 436 | conf.env.append_unique('LINKFLAGS', '-Wl,--as-needed') |
72e1a39e AT |
437 | |
438 | if not conf.CHECK_NEED_LC("-lc not needed"): | |
439 | conf.ADD_LDFLAGS('-lc', testflags=False) | |
440 | ||
52113b3b AB |
441 | if not conf.CHECK_CODE('#include "tests/summary.c"', |
442 | define='SUMMARY_PASSES', | |
443 | addmain=False, | |
52113b3b | 444 | msg='Checking configure summary'): |
699977a2 | 445 | raise Errors.WafError('configure summary failed') |
72e1a39e | 446 | |
c6d0323b JS |
447 | if Options.options.enable_pie is not False: |
448 | if Options.options.enable_pie is True: | |
b48ceef1 DD |
449 | need_pie = True |
450 | else: | |
451 | # not specified, only build PIEs if supported by compiler | |
452 | need_pie = False | |
453 | if conf.check_cc(cflags='-fPIE', ldflags='-pie', mandatory=need_pie, | |
454 | msg="Checking compiler for PIE support"): | |
1ef2f39c | 455 | conf.env['ENABLE_PIE'] = True |
72e1a39e | 456 | |
c6d0323b JS |
457 | if Options.options.enable_relro is not False: |
458 | if Options.options.enable_relro is True: | |
191e6b94 AS |
459 | need_relro = True |
460 | else: | |
461 | # not specified, only build RELROs if supported by compiler | |
462 | need_relro = False | |
463 | if conf.check_cc(cflags='', ldflags='-Wl,-z,relro,-z,now', mandatory=need_relro, | |
464 | msg="Checking compiler for full RELRO support"): | |
465 | conf.env['ENABLE_RELRO'] = True | |
466 | ||
b6d41620 | 467 | if conf.CONFIG_GET('ENABLE_SELFTEST') and \ |
c6d0323b JS |
468 | Options.options.with_smb1server is False and \ |
469 | Options.options.without_ad_dc is not True: | |
b6d41620 DM |
470 | conf.fatal('--without-smb1-server cannot be specified with ' |
471 | '--enable-selftest/--enable-developer if ' | |
472 | '--without-ad-dc is NOT set!') | |
473 | ||
c6d0323b | 474 | if Options.options.with_smb1server is not False: |
a9b57276 DM |
475 | conf.DEFINE('WITH_SMB1SERVER', '1') |
476 | ||
9be3be8a JA |
477 | # |
478 | # FreeBSD is broken. It doesn't include 'extern char **environ' | |
479 | # in any shared library, but statically inside crt0.o. | |
480 | # | |
481 | # If we're running on a FreeBSD with the GNU linker ld we | |
482 | # can get around this by explicitly telling the linker to | |
483 | # ignore 'environ' as an unresolved symbol in a shared library. | |
484 | # | |
485 | # However, the clang linker ld.lld-XX is broken in that it | |
486 | # doesn't have that option. | |
487 | # | |
488 | # First try to see if have '-Wl,--ignore-unresolved-symbol,environ' | |
489 | # and just use that if so. | |
490 | # | |
491 | # If not, we have to use '-Wl,--allow-shlib-undefined' instead | |
492 | # and remove all instances of '-Wl,-no-undefined'. | |
493 | ||
494 | if sys.platform.startswith('freebsd'): | |
495 | # Do we have Wl,--ignore-unresolved-symbol,environ ? | |
496 | flag_added = conf.ADD_LDFLAGS('-Wl,--ignore-unresolved-symbol,environ', testflags=True) | |
497 | if not flag_added: | |
498 | # No, fall back to -Wl,--allow-shlib-undefined. | |
499 | conf.ADD_LDFLAGS('-Wl,--allow-shlib-undefined', testflags=True) | |
500 | # Remove any uses of '-Wl,-no-undefined' | |
501 | conf.env['EXTRA_LDFLAGS'] = list(filter(('-Wl,-no-undefined').__ne__, conf.env['EXTRA_LDFLAGS'])) | |
502 | # And make sure we don't try and remove it again when 'allow_undefined_symbols=true' | |
503 | conf.env.undefined_ldflags = [] | |
504 | ||
aa8c8a7b AB |
505 | conf.SAMBA_CONFIG_H('include/config.h') |
506 | ||
72e1a39e AT |
507 | def etags(ctx): |
508 | '''build TAGS file using etags''' | |
699977a2 | 509 | source_root = os.path.dirname(Context.g_module.root_path) |
d8d872e0 | 510 | cmd = r'rm -f %s/TAGS && (find %s -name "*.[ch]" | egrep -v \.inst\. | xargs -n 100 etags -a)' % (source_root, source_root) |
72e1a39e | 511 | print("Running: %s" % cmd) |
a0ab8cb5 BB |
512 | status = os.system(cmd) |
513 | if os.WEXITSTATUS(status): | |
699977a2 | 514 | raise Errors.WafError('etags failed') |
72e1a39e AT |
515 | |
516 | def ctags(ctx): | |
517 | "build 'tags' file using ctags" | |
699977a2 | 518 | source_root = os.path.dirname(Context.g_module.root_path) |
d8d872e0 | 519 | cmd = r'ctags --python-kinds=-i $(find %s -name "*.[ch]" | grep -v "*_proto\.h" | egrep -v \.inst\.) $(find %s -name "*.py")' % (source_root, source_root) |
72e1a39e | 520 | print("Running: %s" % cmd) |
a0ab8cb5 BB |
521 | status = os.system(cmd) |
522 | if os.WEXITSTATUS(status): | |
699977a2 | 523 | raise Errors.WafError('ctags failed') |
72e1a39e | 524 | |
5e082120 | 525 | |
72e1a39e AT |
526 | # putting this here enabled build in the list |
527 | # of commands in --help | |
528 | def build(bld): | |
529 | '''build all targets''' | |
d2bc45e7 | 530 | samba_version.load_version(env=bld.env, is_install=bld.is_install) |
72e1a39e AT |
531 | |
532 | ||
0e9b0925 JV |
533 | def pep8(ctx): |
534 | '''run pep8 validator''' | |
535 | cmd='PYTHONPATH=bin/python pep8 -r bin/python/samba' | |
536 | print("Running: %s" % cmd) | |
a0ab8cb5 BB |
537 | status = os.system(cmd) |
538 | if os.WEXITSTATUS(status): | |
699977a2 | 539 | raise Errors.WafError('pep8 failed') |
0e9b0925 JV |
540 | |
541 | ||
72e1a39e AT |
542 | def dist(): |
543 | '''makes a tarball for distribution''' | |
f48f65e6 BB |
544 | sambaversion = samba_version.load_version(env=None) |
545 | ||
a9211ec2 | 546 | os.system("make -C ctdb manpages") |
0f7aae85 AI |
547 | samba_dist.DIST_FILES('ctdb/doc:ctdb/doc', extend=True) |
548 | ||
699977a2 | 549 | os.system("DOC_VERSION='" + sambaversion.STRING + "' " + Context.g_module.top + "/release-scripts/build-manpages-nogit") |
6895875b MA |
550 | samba_dist.DIST_FILES('bin/docs:docs', extend=True) |
551 | ||
f48f65e6 BB |
552 | if sambaversion.IS_SNAPSHOT: |
553 | # write .distversion file and add to tar | |
699977a2 AB |
554 | if not os.path.isdir(Context.g_module.out): |
555 | os.makedirs(Context.g_module.out) | |
556 | distversionf = tempfile.NamedTemporaryFile(mode='w', prefix='.distversion',dir=Context.g_module.out) | |
f48f65e6 BB |
557 | for field in sambaversion.vcs_fields: |
558 | distveroption = field + '=' + str(sambaversion.vcs_fields[field]) | |
559 | distversionf.write(distveroption + '\n') | |
921b927d | 560 | distversionf.flush() |
3821defe | 561 | samba_dist.DIST_FILES('%s:.distversion' % distversionf.name, extend=True) |
921b927d AB |
562 | |
563 | samba_dist.dist() | |
f48f65e6 | 564 | distversionf.close() |
921b927d AB |
565 | else: |
566 | samba_dist.dist() | |
f48f65e6 | 567 | |
72e1a39e AT |
568 | |
569 | def distcheck(): | |
570 | '''test that distribution tarball builds and installs''' | |
571 | samba_version.load_version(env=None) | |
72e1a39e | 572 | |
e2ace2d6 CS |
573 | def printversion(ctx): |
574 | '''print version''' | |
575 | ver = samba_version.load_version(env=None) | |
576 | print('Samba Version: ' + ver.STRING_WITH_NICKNAME) | |
577 | ||
72e1a39e AT |
578 | def wildcard_cmd(cmd): |
579 | '''called on a unknown command''' | |
580 | from samba_wildcard import run_named_build_task | |
581 | run_named_build_task(cmd) | |
582 | ||
583 | def main(): | |
584 | from samba_wildcard import wildcard_main | |
5e082120 | 585 | |
72e1a39e AT |
586 | wildcard_main(wildcard_cmd) |
587 | Scripting.main = main | |
588 | ||
589 | def reconfigure(ctx): | |
590 | '''reconfigure if config scripts have changed''' | |
72e1a39e | 591 | samba_utils.reconfigure(ctx) |
5e082120 JV |
592 | |
593 | ||
699977a2 | 594 | if os.path.isdir(os.path.join(top, ".git")): |
5e082120 | 595 | # Check if there are submodules that are checked out but out of date. |
699977a2 | 596 | for submodule, status in samba_git.read_submodule_status(top): |
5e082120 | 597 | if status == "out-of-date": |
699977a2 | 598 | raise Errors.WafError("some submodules are out of date. Please run 'git submodule update'") |