Debian Codegraph @

wscript

raw
1 #!/usr/bin/env python
2
3 top = '.'
4 out = 'bin'
5
6 APPNAME='samba'
7 VERSION=None
8
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
15 import ssl
16
17 samba_dist.DIST_DIRS('.')
18 samba_dist.DIST_BLACKLIST('.gitignore .bzrignore source4/selftest/provisions')
19
20 # A function so the variables are not in global scope
21 def get_default_private_libs():
22 # LDB is used by sssd (was made private by default in Samba 4.21)
23 SSSD_LIBS=["ldb"]
24 # These following libs without ABI checking were made private by default in Samba 4.21
25 # Presumably unused (dcerpc-samr was probably a copy and paste error,
26 # and samba-policy has primary use via python bindings). tevent-util
27 # was for openchange but was for PIDL output that is no longer
28 # generated
29 POSSIBLY_UNUSED_LIBS=["dcerpc-samr","samba-policy","tevent-util"]
30 # These were used by mapiproxy in OpenChange (also used LDB and
31 # the real public libs tdb, talloc, tevent)
32 OPENCHANGE_SERVER_LIBS = ["dcerpc_server","samdb"]
33 # These (plus LDB, ndr, talloc, tevent) are used by the OpenChange
34 # client, which is still in use (Fedora/Red Hat packages it)
35 OPENCHANGE_LIBS = ["dcerpc","samba-hostconfig","samba-credentials"]
36 return SSSD_LIBS + POSSIBLY_UNUSED_LIBS + OPENCHANGE_LIBS + OPENCHANGE_SERVER_LIBS
37
38 DEFAULT_PRIVATE_LIBS = get_default_private_libs()
39
40 # install in /usr/local/samba by default
41 default_prefix = Options.default_prefix = '/usr/local/samba'
42
43 def options(opt):
44 opt.BUILTIN_DEFAULT('NONE')
45 opt.PRIVATE_EXTENSION_DEFAULT('private-samba')
46 opt.RECURSE('lib/replace')
47 opt.RECURSE('dynconfig')
48 opt.RECURSE('packaging')
49 opt.RECURSE('lib/ldb')
50 opt.RECURSE('selftest')
51 opt.RECURSE('source4/dsdb/samdb/ldb_modules')
52 opt.RECURSE('pidl')
53 opt.RECURSE('source3')
54 opt.RECURSE('lib/util')
55 opt.RECURSE('ctdb')
56
57 # Optional Libraries
58 # ------------------
59 #
60 # Most of the calls to opt.add_option() use default=True for the --with case
61 #
62 # To assist users and distributors to build Samba with the full feature
63 # set, the build system will abort if our dependent libraries and their
64 # header files are not found on the target system. This will mean for
65 # example, that xattr, acl and ldap headers must be installed for the
66 # default build to complete. The configure system will check for these
67 # headers, and the error message will indicate the option (such as
68 # --without-acl-support) that can be specified to skip this requirement.
69 #
70 # This will assist users and in particular distributors in building fully
71 # functional packages, while allowing those on systems truly without these
72 # facilities to continue to build Samba after careful consideration.
73 #
74 # It also ensures our container image generation in bootstrap/ is correct
75 # as otherwise a missing package there would just silently work
76
77 opt.samba_add_onoff_option('pthreadpool', with_name="enable", without_name="disable", default=True)
78
79 opt.add_option('--with-system-mitkrb5',
80 help='build Samba with system MIT Kerberos.',
81 action='store_true',
82 dest='with_system_mitkrb5',
83 default=False)
84
85 opt.add_option('--with-experimental-mit-ad-dc',
86 help='Enable the experimental MIT Kerberos-backed AD DC. ' +
87 'Note that security patches are not issued for this configuration',
88 action='store_true',
89 dest='with_experimental_mit_ad_dc',
90 default=False)
91
92 opt.add_option('--with-system-mitkdc',
93 help=('Specify the path to the krb5kdc binary from MIT Kerberos'),
94 type=str,
95 dest='with_system_mitkdc',
96 default=None)
97
98 opt.add_option('--with-system-heimdalkrb5',
99 help=('build Samba with system Heimdal Kerberos. ' +
100 'Requires --without-ad-dc' and
101 'conflicts with --with-system-mitkrb5'),
102 action='store_true',
103 dest='with_system_heimdalkrb5',
104 default=False)
105
106 opt.add_option('--without-ad-dc',
107 help='disable AD DC functionality (enables only Samba FS (File Server, Winbind, NMBD) and client utilities.',
108 action='store_true', dest='without_ad_dc', default=False)
109
110 opt.add_option('--with-pie',
111 help=("Build Position Independent Executables " +
112 "(default if supported by compiler)"),
113 action="store_true", dest='enable_pie')
114 opt.add_option('--without-pie',
115 help=("Disable Position Independent Executable builds"),
116 action="store_false", dest='enable_pie')
117
118 opt.add_option('--with-relro',
119 help=("Build with full RELocation Read-Only (RELRO)" +
120 "(default if supported by compiler)"),
121 action="store_true", dest='enable_relro')
122 opt.add_option('--without-relro',
123 help=("Disable RELRO builds"),
124 action="store_false", dest='enable_relro')
125
126 opt.add_option('--with-kernel-keyring',
127 help=('Enable kernel keyring support for credential storage ' +
128 '(default if keyutils libraries are available)'),
129 action='store_true', dest='enable_keyring')
130 opt.add_option('--without-kernel-keyring',
131 help=('Disable kernel keyring support for credential storage'),
132 action='store_false', dest='enable_keyring')
133
134 opt.samba_add_onoff_option('ldap')
135
136 opt.option_group('developer options')
137
138 opt.load('python') # options for disabling pyc or pyo compilation
139 # enable options related to building python extensions
140
141 opt.add_option('--with-json',
142 action='store_true', dest='with_json', default=True,
143 help=("Build with JSON support (default=True). This "
144 "requires the jansson development headers."))
145 opt.add_option('--without-json',
146 action='store_false', dest='with_json',
147 help=("Build without JSON support."))
148
149 opt.samba_add_onoff_option('smb1-server',
150 dest='with_smb1server',
151 help=("Build smbd with SMB1 support (default=yes)."))
152
153 opt.add_option('--vendor-suffix',
154 help=('Specify a vendor (or packager) name to include in the version string'),
155 type=str,
156 dest='SAMBA_VERSION_VENDOR_SUFFIX',
157 default=None)
158
159 opt.samba_add_onoff_option('systemd-userdb',
160 help=("Build winbind with support for systemd "
161 "User/Group Record Lookup API via "
162 "Varlink"),
163 default=False)
164
165 opt.add_option('--with-varlink',
166 help=("Build with Varlink support"),
167 action='store_true',
168 dest='with_varlink')
169
170 def configure(conf):
171 if Options.options.SAMBA_VERSION_VENDOR_SUFFIX:
172 conf.env.SAMBA_VERSION_VENDOR_SUFFIX = Options.options.SAMBA_VERSION_VENDOR_SUFFIX
173
174 version = samba_version.load_version(env=conf.env)
175
176 conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
177 conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True)
178 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
179
180 if Options.options.developer:
181 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
182 conf.env.DEVELOPER = True
183 # if we are in a git tree without a pre-commit hook, install a
184 # simple default.
185 # we need git for 'waf dist'
186 githooksdir = None
187 conf.find_program('git', var='GIT')
188 if 'GIT' in conf.env:
189 githooksdir = conf.CHECK_COMMAND('%s rev-parse --git-path hooks' % conf.env.GIT[0],
190 msg='Finding githooks directory',
191 define=None,
192 on_target=False)
193 if githooksdir and os.path.isdir(githooksdir):
194 pre_commit_hook = os.path.join(githooksdir, 'pre-commit')
195 if not os.path.exists(pre_commit_hook):
196 Logs.info("Installing script/git-hooks/pre-commit-hook as %s" %
197 pre_commit_hook)
198 shutil.copy(os.path.join(Context.g_module.top, 'script/git-hooks/pre-commit-hook'),
199 pre_commit_hook)
200
201 conf.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')
202
203 conf.env.replace_add_global_pthread = True
204 conf.RECURSE('lib/replace')
205
206 conf.RECURSE('examples/fuse')
207 conf.RECURSE('examples/winexe')
208
209 conf.SAMBA_CHECK_PERL(mandatory=True)
210 conf.CHECK_XSLTPROC_MANPAGES()
211
212 if conf.env.disable_python:
213 if not (Options.options.without_ad_dc):
214 raise Errors.WafError('--disable-python requires --without-ad-dc')
215
216 conf.SAMBA_CHECK_PYTHON()
217 conf.SAMBA_CHECK_PYTHON_HEADERS()
218
219 conf.SAMBA_CHECK_RUST()
220
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'])
228
229 if sys.platform == 'darwin':
230 conf.ADD_LDFLAGS('-framework CoreFoundation')
231
232 conf.RECURSE('dynconfig')
233 conf.RECURSE('selftest')
234
235 conf.PROCESS_SEPARATE_RULE('system_gnutls')
236
237 conf.CHECK_CFG(package='zlib', minversion='1.2.3',
238 args='--cflags --libs',
239 mandatory=True)
240 conf.CHECK_FUNCS_IN('inflateInit2', 'z')
241
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
248
249 if conf.CHECK_FOR_THIRD_PARTY():
250 conf.RECURSE('third_party')
251 else:
252
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)
257
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)
262
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)
268
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)
273
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)
278
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)
283
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)
288
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')
295
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')
300
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')
303
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')
312
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')
336
337 conf.RECURSE('lib/tdb')
338 conf.RECURSE('lib/tevent')
339 conf.RECURSE('lib/ldb')
340
341 if conf.CHECK_LDFLAGS(['-Wl,--wrap=test']):
342 conf.env['HAVE_LDWRAP'] = True
343 conf.define('HAVE_LDWRAP', 1)
344
345 if not (Options.options.without_ad_dc):
346 conf.DEFINE('AD_DC_BUILD_IS_ENABLED', 1)
347
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']
357
358 # #line statements in these generated files cause issues for lcov
359 conf.env.FLEXFLAGS += ["--noline"]
360
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)
368
369 # #line statements in these generated files cause issues for lcov
370 conf.env.BISONFLAGS += ["--no-line"]
371
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')
380
381 conf.PROCESS_SEPARATE_RULE('system_mitkrb5')
382
383 if not (Options.options.without_ad_dc or Options.options.with_system_mitkrb5):
384 conf.DEFINE('AD_DC_BUILD_IS_ENABLED', 1)
385
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')
398
399 if not conf.CONFIG_GET('KRB5_VENDOR'):
400 conf.PROCESS_SEPARATE_RULE('embedded_heimdal')
401
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')
414
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')
421
422 conf.SET_TARGET_TYPE('jansson', 'EMPTY')
423
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')
428
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")
443
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')
454
455 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
456
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.
461
462 if (not Options.options.address_sanitizer
463 and conf.CHECK_LDFLAGS('-Wl,--as-needed')):
464 conf.env.append_unique('LINKFLAGS', '-Wl,--as-needed')
465
466 if not conf.CHECK_NEED_LC("-lc not needed"):
467 conf.ADD_LDFLAGS('-lc', testflags=False)
468
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')
474
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
484
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
494
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!')
501
502 if Options.options.with_smb1server is not False:
503 conf.DEFINE('WITH_SMB1SERVER', '1')
504
505 conf.env.debug = Options.options.debug
506 conf.env.developer = Options.options.developer
507
508 #
509 # FreeBSD is broken. It doesn't include 'extern char **environ'
510 # in any shared library, but statically inside crt0.o.
511 #
512 # If we're running on a FreeBSD with the GNU linker ld we
513 # can get around this by explicitly telling the linker to
514 # ignore 'environ' as an unresolved symbol in a shared library.
515 #
516 # However, the clang linker ld.lld-XX is broken in that it
517 # doesn't have that option.
518 #
519 # First try to see if have '-Wl,--ignore-unresolved-symbol,environ'
520 # and just use that if so.
521 #
522 # If not, we have to use '-Wl,--allow-shlib-undefined' instead
523 # and remove all instances of '-Wl,-no-undefined'.
524
525 if sys.platform.startswith('freebsd'):
526 # Do we have Wl,--ignore-unresolved-symbol,environ ?
527 flag_added = conf.ADD_LDFLAGS('-Wl,--ignore-unresolved-symbol,environ', testflags=True)
528 if not flag_added:
529 # No, fall back to -Wl,--allow-shlib-undefined.
530 conf.ADD_LDFLAGS('-Wl,--allow-shlib-undefined', testflags=True)
531 # Remove any uses of '-Wl,-no-undefined'
532 conf.env['EXTRA_LDFLAGS'] = list(filter(('-Wl,-no-undefined').__ne__, conf.env['EXTRA_LDFLAGS']))
533 # And make sure we don't try and remove it again when 'allow_undefined_symbols=true'
534 conf.env.undefined_ldflags = []
535
536 conf.SAMBA_CONFIG_H('include/config.h')
537
538 def etags(ctx):
539 '''build TAGS file using etags'''
540 source_root = os.path.dirname(Context.g_module.root_path)
541 cmd = r'rm -f %s/TAGS && (find %s -name "*.[ch]" | egrep -v \.inst\. | xargs -n 100 etags -a)' % (source_root, source_root)
542 print("Running: %s" % cmd)
543 status = os.system(cmd)
544 if os.WEXITSTATUS(status):
545 raise Errors.WafError('etags failed')
546
547 def ctags(ctx):
548 "build 'tags' file using ctags"
549 source_root = os.path.dirname(Context.g_module.root_path)
550 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)
551 print("Running: %s" % cmd)
552 status = os.system(cmd)
553 if os.WEXITSTATUS(status):
554 raise Errors.WafError('ctags failed')
555
556
557 # putting this here enabled build in the list
558 # of commands in --help
559 def build(bld):
560 '''build all targets'''
561 samba_version.load_version(env=bld.env, is_install=bld.is_install)
562
563
564 def pep8(ctx):
565 '''run pep8 validator'''
566 cmd='PYTHONPATH=bin/python pep8 -r bin/python/samba'
567 print("Running: %s" % cmd)
568 status = os.system(cmd)
569 if os.WEXITSTATUS(status):
570 raise Errors.WafError('pep8 failed')
571
572
573 def dist():
574 '''makes a tarball for distribution'''
575 sambaversion = samba_version.load_version(env=None)
576
577 os.system("make -C ctdb manpages")
578 samba_dist.DIST_FILES('ctdb/doc:ctdb/doc', extend=True)
579
580 os.system("DOC_VERSION='" + sambaversion.STRING + "' " + Context.g_module.top + "/release-scripts/build-manpages-nogit")
581 samba_dist.DIST_FILES('bin/docs:docs', extend=True)
582
583 if sambaversion.IS_SNAPSHOT:
584 # write .distversion file and add to tar
585 if not os.path.isdir(Context.g_module.out):
586 os.makedirs(Context.g_module.out)
587 distversionf = tempfile.NamedTemporaryFile(mode='w', prefix='.distversion',dir=Context.g_module.out)
588 for field in sambaversion.vcs_fields:
589 distveroption = field + '=' + str(sambaversion.vcs_fields[field])
590 distversionf.write(distveroption + '\n')
591 distversionf.flush()
592 samba_dist.DIST_FILES('%s:.distversion' % distversionf.name, extend=True)
593
594 samba_dist.dist()
595 distversionf.close()
596 else:
597 samba_dist.dist()
598
599
600 def distcheck():
601 '''test that distribution tarball builds and installs'''
602 samba_version.load_version(env=None)
603
604 def printversion(ctx):
605 '''print version'''
606 ver = samba_version.load_version(env=None)
607 print('Samba Version: ' + ver.STRING_WITH_NICKNAME)
608
609 def wildcard_cmd(cmd):
610 '''called on a unknown command'''
611 from samba_wildcard import run_named_build_task
612 run_named_build_task(cmd)
613
614 def main():
615 from samba_wildcard import wildcard_main
616
617 wildcard_main(wildcard_cmd)
618 Scripting.main = main
619
620 def reconfigure(ctx):
621 '''reconfigure if config scripts have changed'''
622 samba_utils.reconfigure(ctx)
623
624
625 if os.path.isdir(os.path.join(top, ".git")):
626 # Check if there are submodules that are checked out but out of date.
627 for submodule, status in samba_git.read_submodule_status(top):
628 if status == "out-of-date":
629 raise Errors.WafError("some submodules are out of date. Please run 'git submodule update'")