smbd: Make parent_override_delete a bit more readable
[samba4-gss.git] / wscript
blob8dd6599cdd7e615392ef6d794450126fb7bb7e68
1 #!/usr/bin/env python
3 top = '.'
4 out = 'bin'
6 APPNAME='samba'
7 VERSION=None
9 import sys, os, tempfile
10 sys.path.insert(0, top+"/buildtools/wafsamba")
11 import shutil
12 import wafsamba, samba_dist, samba_git, samba_version, samba_utils
13 from waflib import Options, Scripting, Logs, Context, Errors
14 from waflib.Tools import bison
16 samba_dist.DIST_DIRS('.')
17 samba_dist.DIST_BLACKLIST('.gitignore .bzrignore source4/selftest/provisions')
19 # A function so the variables are not in global scope
20 def get_default_private_libs():
21 # LDB is used by sssd (was made private by default in Samba 4.21)
22 SSSD_LIBS=["ldb"]
23 # These following libs without ABI checking were made private by default in Samba 4.21
24 # Presumably unused (dcerpc-samr was probably a copy and paste error,
25 # and samba-policy has primary use via python bindings). tevent-util
26 # was for openchange but was for PIDL output that is no longer
27 # generated
28 POSSIBLY_UNUSED_LIBS=["dcerpc-samr","samba-policy","tevent-util"]
29 # These were used by mapiproxy in OpenChange (also used LDB and
30 # the real public libs tdb, talloc, tevent)
31 OPENCHANGE_SERVER_LIBS = ["dcerpc_server","samdb"]
32 # These (plus LDB, ndr, talloc, tevent) are used by the OpenChange
33 # client, which is still in use (Fedora/Red Hat packages it)
34 OPENCHANGE_LIBS = ["dcerpc","samba-hostconfig","samba-credentials"]
35 return SSSD_LIBS + POSSIBLY_UNUSED_LIBS + OPENCHANGE_LIBS + OPENCHANGE_SERVER_LIBS
37 DEFAULT_PRIVATE_LIBS = get_default_private_libs()
39 # install in /usr/local/samba by default
40 default_prefix = Options.default_prefix = '/usr/local/samba'
42 # This callback optionally takes a list of paths as arguments:
43 # --with-system_mitkrb5 /path/to/krb5 /another/path
44 def system_mitkrb5_callback(option, opt, value, parser):
45 setattr(parser.values, option.dest, True)
46 value = []
47 for arg in parser.rargs:
48 # stop on --foo like options
49 if arg[:2] == "--" and len(arg) > 2:
50 break
51 value.append(arg)
52 if len(value)>0:
53 del parser.rargs[:len(value)]
54 setattr(parser.values, option.dest, value)
56 def options(opt):
57 opt.BUILTIN_DEFAULT('NONE')
58 opt.PRIVATE_EXTENSION_DEFAULT('private-samba')
59 opt.RECURSE('lib/replace')
60 opt.RECURSE('dynconfig')
61 opt.RECURSE('packaging')
62 opt.RECURSE('lib/ldb')
63 opt.RECURSE('selftest')
64 opt.RECURSE('source4/dsdb/samdb/ldb_modules')
65 opt.RECURSE('pidl')
66 opt.RECURSE('source3')
67 opt.RECURSE('lib/util')
68 opt.RECURSE('ctdb')
70 # Optional Libraries
71 # ------------------
73 # Most of the calls to opt.add_option() use default=True for the --with case
75 # To assist users and distributors to build Samba with the full feature
76 # set, the build system will abort if our dependent libraries and their
77 # header files are not found on the target system. This will mean for
78 # example, that xattr, acl and ldap headers must be installed for the
79 # default build to complete. The configure system will check for these
80 # headers, and the error message will indicate the option (such as
81 # --without-acl-support) that can be specified to skip this requirement.
83 # This will assist users and in particular distributors in building fully
84 # functional packages, while allowing those on systems truly without these
85 # facilities to continue to build Samba after careful consideration.
87 # It also ensures our container image generation in bootstrap/ is correct
88 # as otherwise a missing package there would just silently work
90 opt.samba_add_onoff_option('pthreadpool', with_name="enable", without_name="disable", default=True)
92 opt.add_option('--with-system-mitkrb5',
93 help='build Samba with system MIT Kerberos. ' +
94 'You may specify list of paths where Kerberos is installed (e.g. /usr/local /usr/kerberos) to search krb5-config',
95 action='callback', callback=system_mitkrb5_callback, dest='with_system_mitkrb5', default=False)
97 opt.add_option('--with-experimental-mit-ad-dc',
98 help='Enable the experimental MIT Kerberos-backed AD DC. ' +
99 'Note that security patches are not issued for this configuration',
100 action='store_true',
101 dest='with_experimental_mit_ad_dc',
102 default=False)
104 opt.add_option('--with-system-mitkdc',
105 help=('Specify the path to the krb5kdc binary from MIT Kerberos'),
106 type="string",
107 dest='with_system_mitkdc',
108 default=None)
110 opt.add_option('--with-system-heimdalkrb5',
111 help=('build Samba with system Heimdal Kerberos. ' +
112 'Requires --without-ad-dc' and
113 'conflicts with --with-system-mitkrb5'),
114 action='store_true',
115 dest='with_system_heimdalkrb5',
116 default=False)
118 opt.add_option('--without-ad-dc',
119 help='disable AD DC functionality (enables only Samba FS (File Server, Winbind, NMBD) and client utilities.',
120 action='store_true', dest='without_ad_dc', default=False)
122 opt.add_option('--with-pie',
123 help=("Build Position Independent Executables " +
124 "(default if supported by compiler)"),
125 action="store_true", dest='enable_pie')
126 opt.add_option('--without-pie',
127 help=("Disable Position Independent Executable builds"),
128 action="store_false", dest='enable_pie')
130 opt.add_option('--with-relro',
131 help=("Build with full RELocation Read-Only (RELRO)" +
132 "(default if supported by compiler)"),
133 action="store_true", dest='enable_relro')
134 opt.add_option('--without-relro',
135 help=("Disable RELRO builds"),
136 action="store_false", dest='enable_relro')
138 opt.add_option('--with-kernel-keyring',
139 help=('Enable kernely keyring support for credential storage ' +
140 '(default if keyutils libraries are available)'),
141 action='store_true', dest='enable_keyring')
142 opt.add_option('--without-kernel-keyring',
143 help=('Disable kernely keyring support for credential storage'),
144 action='store_false', dest='enable_keyring')
146 opt.samba_add_onoff_option('ldap')
148 opt.option_group('developer options')
150 opt.load('python') # options for disabling pyc or pyo compilation
151 # enable options related to building python extensions
153 opt.add_option('--with-json',
154 action='store_true', dest='with_json',
155 help=("Build with JSON support (default=True). This "
156 "requires the jansson development headers."))
157 opt.add_option('--without-json',
158 action='store_false', dest='with_json',
159 help=("Build without JSON support."))
161 opt.samba_add_onoff_option('smb1-server',
162 dest='with_smb1server',
163 help=("Build smbd with SMB1 support (default=yes)."))
165 opt.add_option('--vendor-suffix',
166 help=('Specify a vendor (or packager) name to include in the version string'),
167 type="string",
168 dest='SAMBA_VERSION_VENDOR_SUFFIX',
169 default=None)
172 def configure(conf):
173 if Options.options.SAMBA_VERSION_VENDOR_SUFFIX:
174 conf.env.SAMBA_VERSION_VENDOR_SUFFIX = Options.options.SAMBA_VERSION_VENDOR_SUFFIX
176 version = samba_version.load_version(env=conf.env)
178 conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
179 conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True)
180 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
182 if Options.options.developer:
183 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
184 conf.env.DEVELOPER = True
185 # if we are in a git tree without a pre-commit hook, install a
186 # simple default.
187 # we need git for 'waf dist'
188 githooksdir = None
189 conf.find_program('git', var='GIT')
190 if 'GIT' in conf.env:
191 githooksdir = conf.CHECK_COMMAND('%s rev-parse --git-path hooks' % conf.env.GIT[0],
192 msg='Finding githooks directory',
193 define=None,
194 on_target=False)
195 if githooksdir and os.path.isdir(githooksdir):
196 pre_commit_hook = os.path.join(githooksdir, 'pre-commit')
197 if not os.path.exists(pre_commit_hook):
198 Logs.info("Installing script/git-hooks/pre-commit-hook as %s" %
199 pre_commit_hook)
200 shutil.copy(os.path.join(Context.g_module.top, 'script/git-hooks/pre-commit-hook'),
201 pre_commit_hook)
203 conf.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')
205 conf.env.replace_add_global_pthread = True
206 conf.RECURSE('lib/replace')
208 conf.RECURSE('examples/fuse')
209 conf.RECURSE('examples/winexe')
211 conf.SAMBA_CHECK_PERL(mandatory=True)
212 conf.CHECK_XSLTPROC_MANPAGES()
214 if conf.env.disable_python:
215 if not (Options.options.without_ad_dc):
216 raise Errors.WafError('--disable-python requires --without-ad-dc')
218 conf.SAMBA_CHECK_PYTHON()
219 conf.SAMBA_CHECK_PYTHON_HEADERS()
221 if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']:
222 # Mac OSX needs to have this and it's also needed that the python is compiled with this
223 # otherwise you face errors about common symbols
224 if not conf.CHECK_SHLIB_W_PYTHON("Checking if -fno-common is needed"):
225 conf.ADD_CFLAGS('-fno-common')
226 if not conf.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
227 conf.env.append_value('cshlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
229 if sys.platform == 'darwin':
230 conf.ADD_LDFLAGS('-framework CoreFoundation')
232 conf.RECURSE('dynconfig')
233 conf.RECURSE('selftest')
235 conf.PROCESS_SEPARATE_RULE('system_gnutls')
237 conf.CHECK_CFG(package='zlib', minversion='1.2.3',
238 args='--cflags --libs',
239 mandatory=True)
240 conf.CHECK_FUNCS_IN('inflateInit2', 'z')
242 if Options.options.enable_keyring is not False:
243 conf.env['WITH_KERNEL_KEYRING'] = 'auto'
244 if Options.options.enable_keyring is True:
245 conf.env['WITH_KERNEL_KEYRING'] = True
246 else:
247 conf.env['WITH_KERNEL_KEYRING'] = False
249 if conf.CHECK_FOR_THIRD_PARTY():
250 conf.RECURSE('third_party')
251 else:
253 if not conf.CHECK_POPT():
254 raise Errors.WafError('popt development packages have not been found.\nIf third_party is installed, check that it is in the proper place.')
255 else:
256 conf.define('USING_SYSTEM_POPT', 1)
258 if not conf.CHECK_CMOCKA():
259 raise Errors.WafError('cmocka development packages has not been found.\nIf third_party is installed, check that it is in the proper place.')
260 else:
261 conf.define('USING_SYSTEM_CMOCKA', 1)
263 if conf.CONFIG_GET('ENABLE_SELFTEST'):
264 if not conf.CHECK_SOCKET_WRAPPER():
265 raise Errors.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
266 else:
267 conf.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
269 if not conf.CHECK_NSS_WRAPPER():
270 raise Errors.WafError('nss_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
271 else:
272 conf.define('USING_SYSTEM_NSS_WRAPPER', 1)
274 if not conf.CHECK_RESOLV_WRAPPER():
275 raise Errors.WafError('resolv_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
276 else:
277 conf.define('USING_SYSTEM_RESOLV_WRAPPER', 1)
279 if not conf.CHECK_UID_WRAPPER():
280 raise Errors.WafError('uid_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
281 else:
282 conf.define('USING_SYSTEM_UID_WRAPPER', 1)
284 if not conf.CHECK_PAM_WRAPPER():
285 raise Errors.WafError('pam_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
286 else:
287 conf.define('USING_SYSTEM_PAM_WRAPPER', 1)
289 # Check for LDAP
290 if Options.options.with_ldap:
291 conf.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
292 conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
293 conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
294 conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
296 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
297 # for the samba logs
298 conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
299 define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h')
301 conf.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
302 conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
304 # Check if ldap_set_rebind_proc() takes three arguments
305 if conf.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
306 'LDAP_SET_REBIND_PROC_ARGS',
307 msg="Checking whether ldap_set_rebind_proc takes 3 arguments",
308 headers='ldap.h lber.h', link=False):
309 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
310 else:
311 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
313 # last but not least, if ldap_init() exists, we want to use ldap
314 if conf.CONFIG_SET('HAVE_LDAP_INIT') and conf.CONFIG_SET('HAVE_LDAP_H'):
315 conf.DEFINE('HAVE_LDAP', '1')
316 conf.DEFINE('LDAP_DEPRECATED', '1')
317 conf.env['HAVE_LDAP'] = '1'
318 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
319 # SASL wrapping hooks
320 if conf.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
321 conf.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
322 conf.DEFINE('HAVE_LDAP_TRANSPORT_WRAPPING', 1)
323 conf.env.ENABLE_LDAP_BACKEND = True
324 else:
325 conf.fatal("LDAP support not found. "
326 "Try installing libldap2-dev or openldap-devel. "
327 "Otherwise, use --without-ldap to build without "
328 "LDAP support. "
329 "LDAP support is required for the LDAP passdb backend, "
330 "LDAP idmap backends and ADS. "
331 "ADS support improves communication with "
332 "Active Directory domain controllers.")
333 else:
334 conf.SET_TARGET_TYPE('ldap', 'EMPTY')
335 conf.SET_TARGET_TYPE('lber', 'EMPTY')
337 conf.RECURSE('lib/tdb')
338 conf.RECURSE('lib/tevent')
339 conf.RECURSE('lib/ldb')
341 if conf.CHECK_LDFLAGS(['-Wl,--wrap=test']):
342 conf.env['HAVE_LDWRAP'] = True
343 conf.define('HAVE_LDWRAP', 1)
345 if not (Options.options.without_ad_dc):
346 conf.DEFINE('AD_DC_BUILD_IS_ENABLED', 1)
348 # Check for flex before doing the embedded heimdal checks so we can bail if we don't have it.
349 Logs.info("Checking for flex")
350 conf.find_program('flex', var='FLEX')
351 if conf.env['FLEX']:
352 conf.CHECK_COMMAND('%s --version' % conf.env.FLEX[0],
353 msg='Using flex version',
354 define=None,
355 on_target=False)
356 conf.env.FLEXFLAGS = ['-t']
358 # #line statements in these generated files cause issues for lcov
359 conf.env.FLEXFLAGS += ["--noline"]
361 Logs.info("Checking for bison")
362 bison.configure(conf)
363 if conf.env['BISON']:
364 conf.CHECK_COMMAND('%s --version | head -n1' % conf.env.BISON[0],
365 msg='Using bison version',
366 define=None,
367 on_target=False)
369 # #line statements in these generated files cause issues for lcov
370 conf.env.BISONFLAGS += ["--no-line"]
372 if Options.options.with_system_mitkrb5:
373 if not Options.options.with_experimental_mit_ad_dc and \
374 not Options.options.without_ad_dc:
375 raise Errors.WafError('The MIT Kerberos build of Samba as an AD DC ' +
376 'is experimental. Therefore '
377 '--with-system-mitkrb5 requires either ' +
378 '--with-experimental-mit-ad-dc or ' +
379 '--without-ad-dc')
381 conf.PROCESS_SEPARATE_RULE('system_mitkrb5')
383 if not (Options.options.without_ad_dc or Options.options.with_system_mitkrb5):
384 conf.DEFINE('AD_DC_BUILD_IS_ENABLED', 1)
386 if Options.options.with_system_heimdalkrb5:
387 if Options.options.with_system_mitkrb5:
388 raise Errors.WafError('--with-system-heimdalkrb5 conflicts with ' +
389 '--with-system-mitkrb5')
390 if not Options.options.without_ad_dc:
391 raise Errors.WafError('--with-system-heimdalkrb5 requires ' +
392 '--without-ad-dc')
393 conf.env.SYSTEM_LIBS += ('heimdal', 'asn1', 'com_err', 'roken',
394 'hx509', 'wind', 'gssapi', 'hcrypto',
395 'krb5', 'heimbase', 'asn1_compile',
396 'compile_et', 'kdc', 'hdb', 'heimntlm')
397 conf.PROCESS_SEPARATE_RULE('system_heimdal')
399 if not conf.CONFIG_GET('KRB5_VENDOR'):
400 conf.PROCESS_SEPARATE_RULE('embedded_heimdal')
402 conf.RECURSE('source4/dsdb/samdb/ldb_modules')
403 conf.RECURSE('source4/ntvfs/sysdep')
404 conf.RECURSE('lib/util')
405 conf.RECURSE('lib/util/charset')
406 conf.RECURSE('source4/auth')
407 conf.RECURSE('nsswitch')
408 conf.RECURSE('libcli/smbreadline')
409 conf.RECURSE('pidl')
410 if conf.CONFIG_GET('ENABLE_SELFTEST'):
411 if not (Options.options.without_ad_dc):
412 conf.DEFINE('WITH_NTVFS_FILESERVER', 1)
413 conf.RECURSE('testsuite/unittests')
415 if Options.options.with_pthreadpool:
416 if conf.CONFIG_SET('HAVE_PTHREAD'):
417 conf.DEFINE('WITH_PTHREADPOOL', '1')
418 else:
419 Logs.warn("pthreadpool support cannot be enabled when pthread support was not found")
420 conf.undefine('WITH_PTHREADPOOL')
422 conf.SET_TARGET_TYPE('jansson', 'EMPTY')
424 if Options.options.with_json is not False:
425 if conf.CHECK_CFG(package='jansson', args='--cflags --libs',
426 msg='Checking for jansson'):
427 conf.CHECK_FUNCS_IN('json_object', 'jansson')
429 if not conf.CONFIG_GET('HAVE_JSON_OBJECT'):
430 if Options.options.with_json is not False:
431 conf.fatal("Jansson JSON support not found. "
432 "Try installing libjansson-dev or jansson-devel. "
433 "Otherwise, use --without-json to build without "
434 "JSON support. "
435 "JSON support is required for the JSON "
436 "formatted audit log feature, the AD DC, and "
437 "the JSON printers of the net utility")
438 if not Options.options.without_ad_dc:
439 raise Errors.WafError('--without-json requires --without-ad-dc. '
440 'Jansson JSON library is required for '
441 'building the AD DC')
442 Logs.info("Building without Jansson JSON log support")
444 conf.RECURSE('source3')
445 conf.RECURSE('lib/texpect')
446 conf.RECURSE('lib/tsocket')
447 conf.RECURSE('python')
448 if conf.env.with_ctdb:
449 conf.RECURSE('ctdb')
450 conf.RECURSE('lib/socket')
451 conf.RECURSE('lib/mscat')
452 conf.RECURSE('packaging')
453 conf.RECURSE('lib/krb5_wrap')
455 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
457 # gentoo always adds this. We want our normal build to be as
458 # strict as the strictest OS we support, so adding this here
459 # allows us to find problems on our development hosts faster.
460 # It also results in faster load time.
462 if (not Options.options.address_sanitizer
463 and conf.CHECK_LDFLAGS('-Wl,--as-needed')):
464 conf.env.append_unique('LINKFLAGS', '-Wl,--as-needed')
466 if not conf.CHECK_NEED_LC("-lc not needed"):
467 conf.ADD_LDFLAGS('-lc', testflags=False)
469 if not conf.CHECK_CODE('#include "tests/summary.c"',
470 define='SUMMARY_PASSES',
471 addmain=False,
472 msg='Checking configure summary'):
473 raise Errors.WafError('configure summary failed')
475 if Options.options.enable_pie is not False:
476 if Options.options.enable_pie is True:
477 need_pie = True
478 else:
479 # not specified, only build PIEs if supported by compiler
480 need_pie = False
481 if conf.check_cc(cflags='-fPIE', ldflags='-pie', mandatory=need_pie,
482 msg="Checking compiler for PIE support"):
483 conf.env['ENABLE_PIE'] = True
485 if Options.options.enable_relro is not False:
486 if Options.options.enable_relro is True:
487 need_relro = True
488 else:
489 # not specified, only build RELROs if supported by compiler
490 need_relro = False
491 if conf.check_cc(cflags='', ldflags='-Wl,-z,relro,-z,now', mandatory=need_relro,
492 msg="Checking compiler for full RELRO support"):
493 conf.env['ENABLE_RELRO'] = True
495 if conf.CONFIG_GET('ENABLE_SELFTEST') and \
496 Options.options.with_smb1server is False and \
497 Options.options.without_ad_dc is not True:
498 conf.fatal('--without-smb1-server cannot be specified with '
499 '--enable-selftest/--enable-developer if '
500 '--without-ad-dc is NOT set!')
502 if Options.options.with_smb1server is not False:
503 conf.DEFINE('WITH_SMB1SERVER', '1')
506 # FreeBSD is broken. It doesn't include 'extern char **environ'
507 # in any shared library, but statically inside crt0.o.
509 # If we're running on a FreeBSD with the GNU linker ld we
510 # can get around this by explicitly telling the linker to
511 # ignore 'environ' as an unresolved symbol in a shared library.
513 # However, the clang linker ld.lld-XX is broken in that it
514 # doesn't have that option.
516 # First try to see if have '-Wl,--ignore-unresolved-symbol,environ'
517 # and just use that if so.
519 # If not, we have to use '-Wl,--allow-shlib-undefined' instead
520 # and remove all instances of '-Wl,-no-undefined'.
522 if sys.platform.startswith('freebsd'):
523 # Do we have Wl,--ignore-unresolved-symbol,environ ?
524 flag_added = conf.ADD_LDFLAGS('-Wl,--ignore-unresolved-symbol,environ', testflags=True)
525 if not flag_added:
526 # No, fall back to -Wl,--allow-shlib-undefined.
527 conf.ADD_LDFLAGS('-Wl,--allow-shlib-undefined', testflags=True)
528 # Remove any uses of '-Wl,-no-undefined'
529 conf.env['EXTRA_LDFLAGS'] = list(filter(('-Wl,-no-undefined').__ne__, conf.env['EXTRA_LDFLAGS']))
530 # And make sure we don't try and remove it again when 'allow_undefined_symbols=true'
531 conf.env.undefined_ldflags = []
533 conf.SAMBA_CONFIG_H('include/config.h')
535 def etags(ctx):
536 '''build TAGS file using etags'''
537 source_root = os.path.dirname(Context.g_module.root_path)
538 cmd = r'rm -f %s/TAGS && (find %s -name "*.[ch]" | egrep -v \.inst\. | xargs -n 100 etags -a)' % (source_root, source_root)
539 print("Running: %s" % cmd)
540 status = os.system(cmd)
541 if os.WEXITSTATUS(status):
542 raise Errors.WafError('etags failed')
544 def ctags(ctx):
545 "build 'tags' file using ctags"
546 source_root = os.path.dirname(Context.g_module.root_path)
547 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)
548 print("Running: %s" % cmd)
549 status = os.system(cmd)
550 if os.WEXITSTATUS(status):
551 raise Errors.WafError('ctags failed')
554 # putting this here enabled build in the list
555 # of commands in --help
556 def build(bld):
557 '''build all targets'''
558 samba_version.load_version(env=bld.env, is_install=bld.is_install)
561 def pep8(ctx):
562 '''run pep8 validator'''
563 cmd='PYTHONPATH=bin/python pep8 -r bin/python/samba'
564 print("Running: %s" % cmd)
565 status = os.system(cmd)
566 if os.WEXITSTATUS(status):
567 raise Errors.WafError('pep8 failed')
570 def dist():
571 '''makes a tarball for distribution'''
572 sambaversion = samba_version.load_version(env=None)
574 os.system("make -C ctdb manpages")
575 samba_dist.DIST_FILES('ctdb/doc:ctdb/doc', extend=True)
577 os.system("DOC_VERSION='" + sambaversion.STRING + "' " + Context.g_module.top + "/release-scripts/build-manpages-nogit")
578 samba_dist.DIST_FILES('bin/docs:docs', extend=True)
580 if sambaversion.IS_SNAPSHOT:
581 # write .distversion file and add to tar
582 if not os.path.isdir(Context.g_module.out):
583 os.makedirs(Context.g_module.out)
584 distversionf = tempfile.NamedTemporaryFile(mode='w', prefix='.distversion',dir=Context.g_module.out)
585 for field in sambaversion.vcs_fields:
586 distveroption = field + '=' + str(sambaversion.vcs_fields[field])
587 distversionf.write(distveroption + '\n')
588 distversionf.flush()
589 samba_dist.DIST_FILES('%s:.distversion' % distversionf.name, extend=True)
591 samba_dist.dist()
592 distversionf.close()
593 else:
594 samba_dist.dist()
597 def distcheck():
598 '''test that distribution tarball builds and installs'''
599 samba_version.load_version(env=None)
601 def printversion(ctx):
602 '''print version'''
603 ver = samba_version.load_version(env=None)
604 print('Samba Version: ' + ver.STRING_WITH_NICKNAME)
606 def wildcard_cmd(cmd):
607 '''called on a unknown command'''
608 from samba_wildcard import run_named_build_task
609 run_named_build_task(cmd)
611 def main():
612 from samba_wildcard import wildcard_main
614 wildcard_main(wildcard_cmd)
615 Scripting.main = main
617 def reconfigure(ctx):
618 '''reconfigure if config scripts have changed'''
619 samba_utils.reconfigure(ctx)
622 if os.path.isdir(os.path.join(top, ".git")):
623 # Check if there are submodules that are checked out but out of date.
624 for submodule, status in samba_git.read_submodule_status(top):
625 if status == "out-of-date":
626 raise Errors.WafError("some submodules are out of date. Please run 'git submodule update'")