util:datablob: data_blob_pad checks its alignment assumption
[samba4-gss.git] / wscript
blobc454a718b7336609a4226333c7ae9cfd9d7dc753
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
15 import ssl
17 samba_dist.DIST_DIRS('.')
18 samba_dist.DIST_BLACKLIST('.gitignore .bzrignore source4/selftest/provisions')
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
38 DEFAULT_PRIVATE_LIBS = get_default_private_libs()
40 # install in /usr/local/samba by default
41 default_prefix = Options.default_prefix = '/usr/local/samba'
43 # This callback optionally takes a list of paths as arguments:
44 # --with-system_mitkrb5 /path/to/krb5 /another/path
45 def system_mitkrb5_callback(option, opt, value, parser):
46 setattr(parser.values, option.dest, True)
47 value = []
48 for arg in parser.rargs:
49 # stop on --foo like options
50 if arg[:2] == "--" and len(arg) > 2:
51 break
52 value.append(arg)
53 if len(value)>0:
54 del parser.rargs[:len(value)]
55 setattr(parser.values, option.dest, value)
57 def options(opt):
58 opt.BUILTIN_DEFAULT('NONE')
59 opt.PRIVATE_EXTENSION_DEFAULT('private-samba')
60 opt.RECURSE('lib/replace')
61 opt.RECURSE('dynconfig')
62 opt.RECURSE('packaging')
63 opt.RECURSE('lib/ldb')
64 opt.RECURSE('selftest')
65 opt.RECURSE('source4/dsdb/samdb/ldb_modules')
66 opt.RECURSE('pidl')
67 opt.RECURSE('source3')
68 opt.RECURSE('lib/util')
69 opt.RECURSE('ctdb')
71 # Optional Libraries
72 # ------------------
74 # Most of the calls to opt.add_option() use default=True for the --with case
76 # To assist users and distributors to build Samba with the full feature
77 # set, the build system will abort if our dependent libraries and their
78 # header files are not found on the target system. This will mean for
79 # example, that xattr, acl and ldap headers must be installed for the
80 # default build to complete. The configure system will check for these
81 # headers, and the error message will indicate the option (such as
82 # --without-acl-support) that can be specified to skip this requirement.
84 # This will assist users and in particular distributors in building fully
85 # functional packages, while allowing those on systems truly without these
86 # facilities to continue to build Samba after careful consideration.
88 # It also ensures our container image generation in bootstrap/ is correct
89 # as otherwise a missing package there would just silently work
91 opt.samba_add_onoff_option('pthreadpool', with_name="enable", without_name="disable", default=True)
93 opt.add_option('--with-system-mitkrb5',
94 help='build Samba with system MIT Kerberos. ' +
95 'You may specify list of paths where Kerberos is installed (e.g. /usr/local /usr/kerberos) to search krb5-config',
96 action='callback', callback=system_mitkrb5_callback, dest='with_system_mitkrb5', default=False)
98 opt.add_option('--with-experimental-mit-ad-dc',
99 help='Enable the experimental MIT Kerberos-backed AD DC. ' +
100 'Note that security patches are not issued for this configuration',
101 action='store_true',
102 dest='with_experimental_mit_ad_dc',
103 default=False)
105 opt.add_option('--with-system-mitkdc',
106 help=('Specify the path to the krb5kdc binary from MIT Kerberos'),
107 type="string",
108 dest='with_system_mitkdc',
109 default=None)
111 opt.add_option('--with-system-heimdalkrb5',
112 help=('build Samba with system Heimdal Kerberos. ' +
113 'Requires --without-ad-dc' and
114 'conflicts with --with-system-mitkrb5'),
115 action='store_true',
116 dest='with_system_heimdalkrb5',
117 default=False)
119 opt.add_option('--without-ad-dc',
120 help='disable AD DC functionality (enables only Samba FS (File Server, Winbind, NMBD) and client utilities.',
121 action='store_true', dest='without_ad_dc', default=False)
123 opt.add_option('--with-pie',
124 help=("Build Position Independent Executables " +
125 "(default if supported by compiler)"),
126 action="store_true", dest='enable_pie')
127 opt.add_option('--without-pie',
128 help=("Disable Position Independent Executable builds"),
129 action="store_false", dest='enable_pie')
131 opt.add_option('--with-relro',
132 help=("Build with full RELocation Read-Only (RELRO)" +
133 "(default if supported by compiler)"),
134 action="store_true", dest='enable_relro')
135 opt.add_option('--without-relro',
136 help=("Disable RELRO builds"),
137 action="store_false", dest='enable_relro')
139 opt.add_option('--with-kernel-keyring',
140 help=('Enable kernely keyring support for credential storage ' +
141 '(default if keyutils libraries are available)'),
142 action='store_true', dest='enable_keyring')
143 opt.add_option('--without-kernel-keyring',
144 help=('Disable kernely keyring support for credential storage'),
145 action='store_false', dest='enable_keyring')
147 opt.samba_add_onoff_option('ldap')
149 opt.option_group('developer options')
151 opt.load('python') # options for disabling pyc or pyo compilation
152 # enable options related to building python extensions
154 opt.add_option('--with-json',
155 action='store_true', dest='with_json',
156 help=("Build with JSON support (default=True). This "
157 "requires the jansson development headers."))
158 opt.add_option('--without-json',
159 action='store_false', dest='with_json',
160 help=("Build without JSON support."))
162 opt.samba_add_onoff_option('smb1-server',
163 dest='with_smb1server',
164 help=("Build smbd with SMB1 support (default=yes)."))
166 opt.add_option('--vendor-suffix',
167 help=('Specify a vendor (or packager) name to include in the version string'),
168 type="string",
169 dest='SAMBA_VERSION_VENDOR_SUFFIX',
170 default=None)
172 opt.add_option('--with-himmelblau', default=False,
173 help=('Build with Azure Entra ID support.'),
174 action='store_true', dest='enable_himmelblau')
177 def configure(conf):
178 if Options.options.SAMBA_VERSION_VENDOR_SUFFIX:
179 conf.env.SAMBA_VERSION_VENDOR_SUFFIX = Options.options.SAMBA_VERSION_VENDOR_SUFFIX
181 version = samba_version.load_version(env=conf.env)
183 conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
184 conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True)
185 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
187 if Options.options.developer:
188 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
189 conf.env.DEVELOPER = True
190 # if we are in a git tree without a pre-commit hook, install a
191 # simple default.
192 # we need git for 'waf dist'
193 githooksdir = None
194 conf.find_program('git', var='GIT')
195 if 'GIT' in conf.env:
196 githooksdir = conf.CHECK_COMMAND('%s rev-parse --git-path hooks' % conf.env.GIT[0],
197 msg='Finding githooks directory',
198 define=None,
199 on_target=False)
200 if githooksdir and os.path.isdir(githooksdir):
201 pre_commit_hook = os.path.join(githooksdir, 'pre-commit')
202 if not os.path.exists(pre_commit_hook):
203 Logs.info("Installing script/git-hooks/pre-commit-hook as %s" %
204 pre_commit_hook)
205 shutil.copy(os.path.join(Context.g_module.top, 'script/git-hooks/pre-commit-hook'),
206 pre_commit_hook)
208 conf.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')
210 conf.env.replace_add_global_pthread = True
211 conf.RECURSE('lib/replace')
213 conf.RECURSE('examples/fuse')
214 conf.RECURSE('examples/winexe')
216 conf.SAMBA_CHECK_PERL(mandatory=True)
217 conf.CHECK_XSLTPROC_MANPAGES()
219 if conf.env.disable_python:
220 if not (Options.options.without_ad_dc):
221 raise Errors.WafError('--disable-python requires --without-ad-dc')
223 conf.SAMBA_CHECK_PYTHON()
224 conf.SAMBA_CHECK_PYTHON_HEADERS()
226 conf.SAMBA_CHECK_RUST()
228 if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']:
229 # Mac OSX needs to have this and it's also needed that the python is compiled with this
230 # otherwise you face errors about common symbols
231 if not conf.CHECK_SHLIB_W_PYTHON("Checking if -fno-common is needed"):
232 conf.ADD_CFLAGS('-fno-common')
233 if not conf.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
234 conf.env.append_value('cshlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
236 if sys.platform == 'darwin':
237 conf.ADD_LDFLAGS('-framework CoreFoundation')
239 conf.RECURSE('dynconfig')
240 conf.RECURSE('selftest')
242 conf.PROCESS_SEPARATE_RULE('system_gnutls')
244 conf.CHECK_CFG(package='zlib', minversion='1.2.3',
245 args='--cflags --libs',
246 mandatory=True)
247 conf.CHECK_FUNCS_IN('inflateInit2', 'z')
249 if Options.options.enable_keyring is not False:
250 conf.env['WITH_KERNEL_KEYRING'] = 'auto'
251 if Options.options.enable_keyring is True:
252 conf.env['WITH_KERNEL_KEYRING'] = True
253 else:
254 conf.env['WITH_KERNEL_KEYRING'] = False
256 if conf.CHECK_FOR_THIRD_PARTY():
257 conf.RECURSE('third_party')
258 else:
260 if not conf.CHECK_POPT():
261 raise Errors.WafError('popt development packages have not been found.\nIf third_party is installed, check that it is in the proper place.')
262 else:
263 conf.define('USING_SYSTEM_POPT', 1)
265 if not conf.CHECK_CMOCKA():
266 raise Errors.WafError('cmocka development packages has not been found.\nIf third_party is installed, check that it is in the proper place.')
267 else:
268 conf.define('USING_SYSTEM_CMOCKA', 1)
270 if conf.CONFIG_GET('ENABLE_SELFTEST'):
271 if not conf.CHECK_SOCKET_WRAPPER():
272 raise Errors.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
273 else:
274 conf.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
276 if not conf.CHECK_NSS_WRAPPER():
277 raise Errors.WafError('nss_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
278 else:
279 conf.define('USING_SYSTEM_NSS_WRAPPER', 1)
281 if not conf.CHECK_RESOLV_WRAPPER():
282 raise Errors.WafError('resolv_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
283 else:
284 conf.define('USING_SYSTEM_RESOLV_WRAPPER', 1)
286 if not conf.CHECK_UID_WRAPPER():
287 raise Errors.WafError('uid_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
288 else:
289 conf.define('USING_SYSTEM_UID_WRAPPER', 1)
291 if not conf.CHECK_PAM_WRAPPER():
292 raise Errors.WafError('pam_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
293 else:
294 conf.define('USING_SYSTEM_PAM_WRAPPER', 1)
296 # Check for LDAP
297 if Options.options.with_ldap:
298 conf.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
299 conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
300 conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
301 conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
303 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
304 # for the samba logs
305 conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
306 define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h')
308 conf.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
309 conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
311 # Check if ldap_set_rebind_proc() takes three arguments
312 if conf.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
313 'LDAP_SET_REBIND_PROC_ARGS',
314 msg="Checking whether ldap_set_rebind_proc takes 3 arguments",
315 headers='ldap.h lber.h', link=False):
316 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
317 else:
318 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
320 # last but not least, if ldap_init() exists, we want to use ldap
321 if conf.CONFIG_SET('HAVE_LDAP_INIT') and conf.CONFIG_SET('HAVE_LDAP_H'):
322 conf.DEFINE('HAVE_LDAP', '1')
323 conf.DEFINE('LDAP_DEPRECATED', '1')
324 conf.env['HAVE_LDAP'] = '1'
325 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
326 # SASL wrapping hooks
327 if conf.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
328 conf.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
329 conf.DEFINE('HAVE_LDAP_TRANSPORT_WRAPPING', 1)
330 conf.env.ENABLE_LDAP_BACKEND = True
331 else:
332 conf.fatal("LDAP support not found. "
333 "Try installing libldap2-dev or openldap-devel. "
334 "Otherwise, use --without-ldap to build without "
335 "LDAP support. "
336 "LDAP support is required for the LDAP passdb backend, "
337 "LDAP idmap backends and ADS. "
338 "ADS support improves communication with "
339 "Active Directory domain controllers.")
340 else:
341 conf.SET_TARGET_TYPE('ldap', 'EMPTY')
342 conf.SET_TARGET_TYPE('lber', 'EMPTY')
344 conf.RECURSE('lib/tdb')
345 conf.RECURSE('lib/tevent')
346 conf.RECURSE('lib/ldb')
348 if conf.CHECK_LDFLAGS(['-Wl,--wrap=test']):
349 conf.env['HAVE_LDWRAP'] = True
350 conf.define('HAVE_LDWRAP', 1)
352 if not (Options.options.without_ad_dc):
353 conf.DEFINE('AD_DC_BUILD_IS_ENABLED', 1)
355 # Check for flex before doing the embedded heimdal checks so we can bail if we don't have it.
356 Logs.info("Checking for flex")
357 conf.find_program('flex', var='FLEX')
358 if conf.env['FLEX']:
359 conf.CHECK_COMMAND('%s --version' % conf.env.FLEX[0],
360 msg='Using flex version',
361 define=None,
362 on_target=False)
363 conf.env.FLEXFLAGS = ['-t']
365 # #line statements in these generated files cause issues for lcov
366 conf.env.FLEXFLAGS += ["--noline"]
368 Logs.info("Checking for bison")
369 bison.configure(conf)
370 if conf.env['BISON']:
371 conf.CHECK_COMMAND('%s --version | head -n1' % conf.env.BISON[0],
372 msg='Using bison version',
373 define=None,
374 on_target=False)
376 # #line statements in these generated files cause issues for lcov
377 conf.env.BISONFLAGS += ["--no-line"]
379 if Options.options.with_system_mitkrb5:
380 if not Options.options.with_experimental_mit_ad_dc and \
381 not Options.options.without_ad_dc:
382 raise Errors.WafError('The MIT Kerberos build of Samba as an AD DC ' +
383 'is experimental. Therefore '
384 '--with-system-mitkrb5 requires either ' +
385 '--with-experimental-mit-ad-dc or ' +
386 '--without-ad-dc')
388 conf.PROCESS_SEPARATE_RULE('system_mitkrb5')
390 if not (Options.options.without_ad_dc or Options.options.with_system_mitkrb5):
391 conf.DEFINE('AD_DC_BUILD_IS_ENABLED', 1)
393 if Options.options.with_system_heimdalkrb5:
394 if Options.options.with_system_mitkrb5:
395 raise Errors.WafError('--with-system-heimdalkrb5 conflicts with ' +
396 '--with-system-mitkrb5')
397 if not Options.options.without_ad_dc:
398 raise Errors.WafError('--with-system-heimdalkrb5 requires ' +
399 '--without-ad-dc')
400 conf.env.SYSTEM_LIBS += ('heimdal', 'asn1', 'com_err', 'roken',
401 'hx509', 'wind', 'gssapi', 'hcrypto',
402 'krb5', 'heimbase', 'asn1_compile',
403 'compile_et', 'kdc', 'hdb', 'heimntlm')
404 conf.PROCESS_SEPARATE_RULE('system_heimdal')
406 if not conf.CONFIG_GET('KRB5_VENDOR'):
407 conf.PROCESS_SEPARATE_RULE('embedded_heimdal')
409 conf.RECURSE('source4/dsdb/samdb/ldb_modules')
410 conf.RECURSE('source4/ntvfs/sysdep')
411 conf.RECURSE('lib/util')
412 conf.RECURSE('lib/util/charset')
413 conf.RECURSE('source4/auth')
414 conf.RECURSE('nsswitch')
415 conf.RECURSE('libcli/smbreadline')
416 conf.RECURSE('pidl')
417 if conf.CONFIG_GET('ENABLE_SELFTEST'):
418 if not (Options.options.without_ad_dc):
419 conf.DEFINE('WITH_NTVFS_FILESERVER', 1)
420 conf.RECURSE('testsuite/unittests')
422 if Options.options.with_pthreadpool:
423 if conf.CONFIG_SET('HAVE_PTHREAD'):
424 conf.DEFINE('WITH_PTHREADPOOL', '1')
425 else:
426 Logs.warn("pthreadpool support cannot be enabled when pthread support was not found")
427 conf.undefine('WITH_PTHREADPOOL')
429 conf.SET_TARGET_TYPE('jansson', 'EMPTY')
431 if Options.options.with_json is not False:
432 if conf.CHECK_CFG(package='jansson', args='--cflags --libs',
433 msg='Checking for jansson'):
434 conf.CHECK_FUNCS_IN('json_object', 'jansson')
436 if not conf.CONFIG_GET('HAVE_JSON_OBJECT'):
437 if Options.options.with_json is not False:
438 conf.fatal("Jansson JSON support not found. "
439 "Try installing libjansson-dev or jansson-devel. "
440 "Otherwise, use --without-json to build without "
441 "JSON support. "
442 "JSON support is required for the JSON "
443 "formatted audit log feature, the AD DC, and "
444 "the JSON printers of the net utility")
445 if not Options.options.without_ad_dc:
446 raise Errors.WafError('--without-json requires --without-ad-dc. '
447 'Jansson JSON library is required for '
448 'building the AD DC')
449 Logs.info("Building without Jansson JSON log support")
451 conf.RECURSE('source3')
452 conf.RECURSE('lib/texpect')
453 conf.RECURSE('lib/tsocket')
454 conf.RECURSE('python')
455 if conf.env.with_ctdb:
456 conf.RECURSE('ctdb')
457 conf.RECURSE('lib/socket')
458 conf.RECURSE('lib/mscat')
459 conf.RECURSE('packaging')
460 conf.RECURSE('lib/krb5_wrap')
462 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
464 # gentoo always adds this. We want our normal build to be as
465 # strict as the strictest OS we support, so adding this here
466 # allows us to find problems on our development hosts faster.
467 # It also results in faster load time.
469 if (not Options.options.address_sanitizer
470 and conf.CHECK_LDFLAGS('-Wl,--as-needed')):
471 conf.env.append_unique('LINKFLAGS', '-Wl,--as-needed')
473 if not conf.CHECK_NEED_LC("-lc not needed"):
474 conf.ADD_LDFLAGS('-lc', testflags=False)
476 if not conf.CHECK_CODE('#include "tests/summary.c"',
477 define='SUMMARY_PASSES',
478 addmain=False,
479 msg='Checking configure summary'):
480 raise Errors.WafError('configure summary failed')
482 if Options.options.enable_pie is not False:
483 if Options.options.enable_pie is True:
484 need_pie = True
485 else:
486 # not specified, only build PIEs if supported by compiler
487 need_pie = False
488 if conf.check_cc(cflags='-fPIE', ldflags='-pie', mandatory=need_pie,
489 msg="Checking compiler for PIE support"):
490 conf.env['ENABLE_PIE'] = True
492 if Options.options.enable_relro is not False:
493 if Options.options.enable_relro is True:
494 need_relro = True
495 else:
496 # not specified, only build RELROs if supported by compiler
497 need_relro = False
498 if conf.check_cc(cflags='', ldflags='-Wl,-z,relro,-z,now', mandatory=need_relro,
499 msg="Checking compiler for full RELRO support"):
500 conf.env['ENABLE_RELRO'] = True
502 if conf.CONFIG_GET('ENABLE_SELFTEST') and \
503 Options.options.with_smb1server is False and \
504 Options.options.without_ad_dc is not True:
505 conf.fatal('--without-smb1-server cannot be specified with '
506 '--enable-selftest/--enable-developer if '
507 '--without-ad-dc is NOT set!')
509 if Options.options.with_smb1server is not False:
510 conf.DEFINE('WITH_SMB1SERVER', '1')
512 conf.env.debug = Options.options.debug
513 conf.env.developer = Options.options.developer
514 conf.env.enable_himmelblau = Options.options.enable_himmelblau
515 if Options.options.enable_himmelblau:
516 if not conf.env.enable_rust:
517 conf.fatal('--with-himmelblau cannot be specified without '
518 '--enable-rust')
519 if ssl.OPENSSL_VERSION_INFO[0] < 3:
520 conf.fatal('--with-himmelblau cannot be specified with '
521 '%s' % ssl.OPENSSL_VERSION)
524 # FreeBSD is broken. It doesn't include 'extern char **environ'
525 # in any shared library, but statically inside crt0.o.
527 # If we're running on a FreeBSD with the GNU linker ld we
528 # can get around this by explicitly telling the linker to
529 # ignore 'environ' as an unresolved symbol in a shared library.
531 # However, the clang linker ld.lld-XX is broken in that it
532 # doesn't have that option.
534 # First try to see if have '-Wl,--ignore-unresolved-symbol,environ'
535 # and just use that if so.
537 # If not, we have to use '-Wl,--allow-shlib-undefined' instead
538 # and remove all instances of '-Wl,-no-undefined'.
540 if sys.platform.startswith('freebsd'):
541 # Do we have Wl,--ignore-unresolved-symbol,environ ?
542 flag_added = conf.ADD_LDFLAGS('-Wl,--ignore-unresolved-symbol,environ', testflags=True)
543 if not flag_added:
544 # No, fall back to -Wl,--allow-shlib-undefined.
545 conf.ADD_LDFLAGS('-Wl,--allow-shlib-undefined', testflags=True)
546 # Remove any uses of '-Wl,-no-undefined'
547 conf.env['EXTRA_LDFLAGS'] = list(filter(('-Wl,-no-undefined').__ne__, conf.env['EXTRA_LDFLAGS']))
548 # And make sure we don't try and remove it again when 'allow_undefined_symbols=true'
549 conf.env.undefined_ldflags = []
551 conf.SAMBA_CONFIG_H('include/config.h')
553 def etags(ctx):
554 '''build TAGS file using etags'''
555 source_root = os.path.dirname(Context.g_module.root_path)
556 cmd = r'rm -f %s/TAGS && (find %s -name "*.[ch]" | egrep -v \.inst\. | xargs -n 100 etags -a)' % (source_root, source_root)
557 print("Running: %s" % cmd)
558 status = os.system(cmd)
559 if os.WEXITSTATUS(status):
560 raise Errors.WafError('etags failed')
562 def ctags(ctx):
563 "build 'tags' file using ctags"
564 source_root = os.path.dirname(Context.g_module.root_path)
565 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)
566 print("Running: %s" % cmd)
567 status = os.system(cmd)
568 if os.WEXITSTATUS(status):
569 raise Errors.WafError('ctags failed')
572 # putting this here enabled build in the list
573 # of commands in --help
574 def build(bld):
575 '''build all targets'''
576 samba_version.load_version(env=bld.env, is_install=bld.is_install)
579 def pep8(ctx):
580 '''run pep8 validator'''
581 cmd='PYTHONPATH=bin/python pep8 -r bin/python/samba'
582 print("Running: %s" % cmd)
583 status = os.system(cmd)
584 if os.WEXITSTATUS(status):
585 raise Errors.WafError('pep8 failed')
588 def dist():
589 '''makes a tarball for distribution'''
590 sambaversion = samba_version.load_version(env=None)
592 os.system("make -C ctdb manpages")
593 samba_dist.DIST_FILES('ctdb/doc:ctdb/doc', extend=True)
595 os.system("DOC_VERSION='" + sambaversion.STRING + "' " + Context.g_module.top + "/release-scripts/build-manpages-nogit")
596 samba_dist.DIST_FILES('bin/docs:docs', extend=True)
598 if sambaversion.IS_SNAPSHOT:
599 # write .distversion file and add to tar
600 if not os.path.isdir(Context.g_module.out):
601 os.makedirs(Context.g_module.out)
602 distversionf = tempfile.NamedTemporaryFile(mode='w', prefix='.distversion',dir=Context.g_module.out)
603 for field in sambaversion.vcs_fields:
604 distveroption = field + '=' + str(sambaversion.vcs_fields[field])
605 distversionf.write(distveroption + '\n')
606 distversionf.flush()
607 samba_dist.DIST_FILES('%s:.distversion' % distversionf.name, extend=True)
609 samba_dist.dist()
610 distversionf.close()
611 else:
612 samba_dist.dist()
615 def distcheck():
616 '''test that distribution tarball builds and installs'''
617 samba_version.load_version(env=None)
619 def printversion(ctx):
620 '''print version'''
621 ver = samba_version.load_version(env=None)
622 print('Samba Version: ' + ver.STRING_WITH_NICKNAME)
624 def wildcard_cmd(cmd):
625 '''called on a unknown command'''
626 from samba_wildcard import run_named_build_task
627 run_named_build_task(cmd)
629 def main():
630 from samba_wildcard import wildcard_main
632 wildcard_main(wildcard_cmd)
633 Scripting.main = main
635 def reconfigure(ctx):
636 '''reconfigure if config scripts have changed'''
637 samba_utils.reconfigure(ctx)
640 if os.path.isdir(os.path.join(top, ".git")):
641 # Check if there are submodules that are checked out but out of date.
642 for submodule, status in samba_git.read_submodule_status(top):
643 if status == "out-of-date":
644 raise Errors.WafError("some submodules are out of date. Please run 'git submodule update'")