9 import sys
, os
, tempfile
10 sys
.path
.insert(0, top
+"/buildtools/wafsamba")
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)
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
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)
47 for arg
in parser
.rargs
:
48 # stop on --foo like options
49 if arg
[:2] == "--" and len(arg
) > 2:
53 del parser
.rargs
[:len(value
)]
54 setattr(parser
.values
, option
.dest
, value
)
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')
66 opt
.RECURSE('source3')
67 opt
.RECURSE('lib/util')
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',
101 dest
='with_experimental_mit_ad_dc',
104 opt
.add_option('--with-system-mitkdc',
105 help=('Specify the path to the krb5kdc binary from MIT Kerberos'),
107 dest
='with_system_mitkdc',
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'),
115 dest
='with_system_heimdalkrb5',
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-name',
166 help=('Specify a vendor (or packager) name to include in the version string'),
168 dest
='SAMBA_VERSION_VENDOR_SUFFIX',
171 opt
.add_option('--vendor-patch-revision',
172 help=('Specify a vendor (or packager) patch revision number include in the version string (requires --vendor-name)'),
174 dest
='SAMBA_VERSION_VENDOR_PATCH',
178 if Options
.options
.SAMBA_VERSION_VENDOR_SUFFIX
:
179 conf
.env
.SAMBA_VERSION_VENDOR_SUFFIX
= Options
.options
.SAMBA_VERSION_VENDOR_SUFFIX
181 if Options
.options
.SAMBA_VERSION_VENDOR_PATCH
:
182 if not Options
.options
.SAMBA_VERSION_VENDOR_SUFFIX
:
183 raise conf
.fatal('--vendor-patch-revision requires --vendor-version')
184 conf
.env
.SAMBA_VERSION_VENDOR_PATCH
= Options
.options
.SAMBA_VERSION_VENDOR_PATCH
186 version
= samba_version
.load_version(env
=conf
.env
)
188 conf
.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
189 conf
.DEFINE('_SAMBA_BUILD_', version
.MAJOR
, add_to_cflags
=True)
190 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
192 if Options
.options
.developer
:
193 conf
.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
194 conf
.env
.DEVELOPER
= True
195 # if we are in a git tree without a pre-commit hook, install a
197 # we need git for 'waf dist'
199 conf
.find_program('git', var
='GIT')
200 if 'GIT' in conf
.env
:
201 githooksdir
= conf
.CHECK_COMMAND('%s rev-parse --git-path hooks' % conf
.env
.GIT
[0],
202 msg
='Finding githooks directory',
205 if githooksdir
and os
.path
.isdir(githooksdir
):
206 pre_commit_hook
= os
.path
.join(githooksdir
, 'pre-commit')
207 if not os
.path
.exists(pre_commit_hook
):
208 Logs
.info("Installing script/git-hooks/pre-commit-hook as %s" %
210 shutil
.copy(os
.path
.join(Context
.g_module
.top
, 'script/git-hooks/pre-commit-hook'),
213 conf
.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')
215 conf
.env
.replace_add_global_pthread
= True
216 conf
.RECURSE('lib/replace')
218 conf
.RECURSE('examples/fuse')
219 conf
.RECURSE('examples/winexe')
221 conf
.SAMBA_CHECK_PERL(mandatory
=True)
222 conf
.CHECK_XSLTPROC_MANPAGES()
224 if conf
.env
.disable_python
:
225 if not (Options
.options
.without_ad_dc
):
226 raise Errors
.WafError('--disable-python requires --without-ad-dc')
228 conf
.SAMBA_CHECK_PYTHON()
229 conf
.SAMBA_CHECK_PYTHON_HEADERS()
231 if sys
.platform
== 'darwin' and not conf
.env
['HAVE_ENVIRON_DECL']:
232 # Mac OSX needs to have this and it's also needed that the python is compiled with this
233 # otherwise you face errors about common symbols
234 if not conf
.CHECK_SHLIB_W_PYTHON("Checking if -fno-common is needed"):
235 conf
.ADD_CFLAGS('-fno-common')
236 if not conf
.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
237 conf
.env
.append_value('cshlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
239 if sys
.platform
== 'darwin':
240 conf
.ADD_LDFLAGS('-framework CoreFoundation')
242 conf
.RECURSE('dynconfig')
243 conf
.RECURSE('selftest')
245 conf
.PROCESS_SEPARATE_RULE('system_gnutls')
247 conf
.CHECK_CFG(package
='zlib', minversion
='1.2.3',
248 args
='--cflags --libs',
250 conf
.CHECK_FUNCS_IN('inflateInit2', 'z')
252 if Options
.options
.enable_keyring
is not False:
253 conf
.env
['WITH_KERNEL_KEYRING'] = 'auto'
254 if Options
.options
.enable_keyring
is True:
255 conf
.env
['WITH_KERNEL_KEYRING'] = True
257 conf
.env
['WITH_KERNEL_KEYRING'] = False
259 if conf
.CHECK_FOR_THIRD_PARTY():
260 conf
.RECURSE('third_party')
263 if not conf
.CHECK_POPT():
264 raise Errors
.WafError('popt development packages have not been found.\nIf third_party is installed, check that it is in the proper place.')
266 conf
.define('USING_SYSTEM_POPT', 1)
268 if not conf
.CHECK_CMOCKA():
269 raise Errors
.WafError('cmocka development packages has not been found.\nIf third_party is installed, check that it is in the proper place.')
271 conf
.define('USING_SYSTEM_CMOCKA', 1)
273 if conf
.CONFIG_GET('ENABLE_SELFTEST'):
274 if not conf
.CHECK_SOCKET_WRAPPER():
275 raise Errors
.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
277 conf
.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
279 if not conf
.CHECK_NSS_WRAPPER():
280 raise Errors
.WafError('nss_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
282 conf
.define('USING_SYSTEM_NSS_WRAPPER', 1)
284 if not conf
.CHECK_RESOLV_WRAPPER():
285 raise Errors
.WafError('resolv_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
287 conf
.define('USING_SYSTEM_RESOLV_WRAPPER', 1)
289 if not conf
.CHECK_UID_WRAPPER():
290 raise Errors
.WafError('uid_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
292 conf
.define('USING_SYSTEM_UID_WRAPPER', 1)
294 if not conf
.CHECK_PAM_WRAPPER():
295 raise Errors
.WafError('pam_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
297 conf
.define('USING_SYSTEM_PAM_WRAPPER', 1)
300 if Options
.options
.with_ldap
:
301 conf
.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
302 conf
.CHECK_TYPE('ber_tag_t', 'unsigned int', headers
='ldap.h lber.h')
303 conf
.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
304 conf
.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers
='ldap.h')
306 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
308 conf
.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
309 define
='HAVE_LBER_LOG_PRINT_FN', headers
='lber.h')
311 conf
.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
312 conf
.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
314 # Check if ldap_set_rebind_proc() takes three arguments
315 if conf
.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
316 'LDAP_SET_REBIND_PROC_ARGS',
317 msg
="Checking whether ldap_set_rebind_proc takes 3 arguments",
318 headers
='ldap.h lber.h', link
=False):
319 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
321 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
323 # last but not least, if ldap_init() exists, we want to use ldap
324 if conf
.CONFIG_SET('HAVE_LDAP_INIT') and conf
.CONFIG_SET('HAVE_LDAP_H'):
325 conf
.DEFINE('HAVE_LDAP', '1')
326 conf
.DEFINE('LDAP_DEPRECATED', '1')
327 conf
.env
['HAVE_LDAP'] = '1'
328 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
329 # SASL wrapping hooks
330 if conf
.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
331 conf
.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
332 conf
.DEFINE('HAVE_LDAP_TRANSPORT_WRAPPING', 1)
333 conf
.env
.ENABLE_LDAP_BACKEND
= True
335 conf
.fatal("LDAP support not found. "
336 "Try installing libldap2-dev or openldap-devel. "
337 "Otherwise, use --without-ldap to build without "
339 "LDAP support is required for the LDAP passdb backend, "
340 "LDAP idmap backends and ADS. "
341 "ADS support improves communication with "
342 "Active Directory domain controllers.")
344 conf
.SET_TARGET_TYPE('ldap', 'EMPTY')
345 conf
.SET_TARGET_TYPE('lber', 'EMPTY')
347 conf
.RECURSE('lib/tdb')
348 conf
.RECURSE('lib/tevent')
349 conf
.RECURSE('lib/ldb')
351 if conf
.CHECK_LDFLAGS(['-Wl,--wrap=test']):
352 conf
.env
['HAVE_LDWRAP'] = True
353 conf
.define('HAVE_LDWRAP', 1)
355 if not (Options
.options
.without_ad_dc
):
356 conf
.DEFINE('AD_DC_BUILD_IS_ENABLED', 1)
358 # Check for flex before doing the embedded heimdal checks so we can bail if we don't have it.
359 Logs
.info("Checking for flex")
360 conf
.find_program('flex', var
='FLEX')
362 conf
.CHECK_COMMAND('%s --version' % conf
.env
.FLEX
[0],
363 msg
='Using flex version',
366 conf
.env
.FLEXFLAGS
= ['-t']
368 # #line statements in these generated files cause issues for lcov
369 conf
.env
.FLEXFLAGS
+= ["--noline"]
371 Logs
.info("Checking for bison")
372 bison
.configure(conf
)
373 if conf
.env
['BISON']:
374 conf
.CHECK_COMMAND('%s --version | head -n1' % conf
.env
.BISON
[0],
375 msg
='Using bison version',
379 # #line statements in these generated files cause issues for lcov
380 conf
.env
.BISONFLAGS
+= ["--no-line"]
382 if Options
.options
.with_system_mitkrb5
:
383 if not Options
.options
.with_experimental_mit_ad_dc
and \
384 not Options
.options
.without_ad_dc
:
385 raise Errors
.WafError('The MIT Kerberos build of Samba as an AD DC ' +
386 'is experimental. Therefore '
387 '--with-system-mitkrb5 requires either ' +
388 '--with-experimental-mit-ad-dc or ' +
391 conf
.PROCESS_SEPARATE_RULE('system_mitkrb5')
393 if not (Options
.options
.without_ad_dc
or Options
.options
.with_system_mitkrb5
):
394 conf
.DEFINE('AD_DC_BUILD_IS_ENABLED', 1)
396 if Options
.options
.with_system_heimdalkrb5
:
397 if Options
.options
.with_system_mitkrb5
:
398 raise Errors
.WafError('--with-system-heimdalkrb5 conflicts with ' +
399 '--with-system-mitkrb5')
400 if not Options
.options
.without_ad_dc
:
401 raise Errors
.WafError('--with-system-heimdalkrb5 requires ' +
403 conf
.env
.SYSTEM_LIBS
+= ('heimdal', 'asn1', 'com_err', 'roken',
404 'hx509', 'wind', 'gssapi', 'hcrypto',
405 'krb5', 'heimbase', 'asn1_compile',
406 'compile_et', 'kdc', 'hdb', 'heimntlm')
407 conf
.PROCESS_SEPARATE_RULE('system_heimdal')
409 if not conf
.CONFIG_GET('KRB5_VENDOR'):
410 conf
.PROCESS_SEPARATE_RULE('embedded_heimdal')
412 conf
.RECURSE('source4/dsdb/samdb/ldb_modules')
413 conf
.RECURSE('source4/ntvfs/sysdep')
414 conf
.RECURSE('lib/util')
415 conf
.RECURSE('lib/util/charset')
416 conf
.RECURSE('source4/auth')
417 conf
.RECURSE('nsswitch')
418 conf
.RECURSE('libcli/smbreadline')
420 if conf
.CONFIG_GET('ENABLE_SELFTEST'):
421 if not (Options
.options
.without_ad_dc
):
422 conf
.DEFINE('WITH_NTVFS_FILESERVER', 1)
423 conf
.RECURSE('testsuite/unittests')
425 if Options
.options
.with_pthreadpool
:
426 if conf
.CONFIG_SET('HAVE_PTHREAD'):
427 conf
.DEFINE('WITH_PTHREADPOOL', '1')
429 Logs
.warn("pthreadpool support cannot be enabled when pthread support was not found")
430 conf
.undefine('WITH_PTHREADPOOL')
432 conf
.SET_TARGET_TYPE('jansson', 'EMPTY')
434 if Options
.options
.with_json
is not False:
435 if conf
.CHECK_CFG(package
='jansson', args
='--cflags --libs',
436 msg
='Checking for jansson'):
437 conf
.CHECK_FUNCS_IN('json_object', 'jansson')
439 if not conf
.CONFIG_GET('HAVE_JSON_OBJECT'):
440 if Options
.options
.with_json
is not False:
441 conf
.fatal("Jansson JSON support not found. "
442 "Try installing libjansson-dev or jansson-devel. "
443 "Otherwise, use --without-json to build without "
445 "JSON support is required for the JSON "
446 "formatted audit log feature, the AD DC, and "
447 "the JSON printers of the net utility")
448 if not Options
.options
.without_ad_dc
:
449 raise Errors
.WafError('--without-json requires --without-ad-dc. '
450 'Jansson JSON library is required for '
451 'building the AD DC')
452 Logs
.info("Building without Jansson JSON log support")
454 conf
.RECURSE('source3')
455 conf
.RECURSE('lib/texpect')
456 conf
.RECURSE('lib/tsocket')
457 conf
.RECURSE('python')
458 if conf
.env
.with_ctdb
:
460 conf
.RECURSE('lib/socket')
461 conf
.RECURSE('lib/mscat')
462 conf
.RECURSE('packaging')
463 conf
.RECURSE('lib/krb5_wrap')
465 conf
.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
467 # gentoo always adds this. We want our normal build to be as
468 # strict as the strictest OS we support, so adding this here
469 # allows us to find problems on our development hosts faster.
470 # It also results in faster load time.
472 if (not Options
.options
.address_sanitizer
473 and conf
.CHECK_LDFLAGS('-Wl,--as-needed')):
474 conf
.env
.append_unique('LINKFLAGS', '-Wl,--as-needed')
476 if not conf
.CHECK_NEED_LC("-lc not needed"):
477 conf
.ADD_LDFLAGS('-lc', testflags
=False)
479 if not conf
.CHECK_CODE('#include "tests/summary.c"',
480 define
='SUMMARY_PASSES',
482 msg
='Checking configure summary'):
483 raise Errors
.WafError('configure summary failed')
485 if Options
.options
.enable_pie
is not False:
486 if Options
.options
.enable_pie
is True:
489 # not specified, only build PIEs if supported by compiler
491 if conf
.check_cc(cflags
='-fPIE', ldflags
='-pie', mandatory
=need_pie
,
492 msg
="Checking compiler for PIE support"):
493 conf
.env
['ENABLE_PIE'] = True
495 if Options
.options
.enable_relro
is not False:
496 if Options
.options
.enable_relro
is True:
499 # not specified, only build RELROs if supported by compiler
501 if conf
.check_cc(cflags
='', ldflags
='-Wl,-z,relro,-z,now', mandatory
=need_relro
,
502 msg
="Checking compiler for full RELRO support"):
503 conf
.env
['ENABLE_RELRO'] = True
505 if conf
.CONFIG_GET('ENABLE_SELFTEST') and \
506 Options
.options
.with_smb1server
is False and \
507 Options
.options
.without_ad_dc
is not True:
508 conf
.fatal('--without-smb1-server cannot be specified with '
509 '--enable-selftest/--enable-developer if '
510 '--without-ad-dc is NOT set!')
512 if Options
.options
.with_smb1server
is not False:
513 conf
.DEFINE('WITH_SMB1SERVER', '1')
516 # FreeBSD is broken. It doesn't include 'extern char **environ'
517 # in any shared library, but statically inside crt0.o.
519 # If we're running on a FreeBSD with the GNU linker ld we
520 # can get around this by explicitly telling the linker to
521 # ignore 'environ' as an unresolved symbol in a shared library.
523 # However, the clang linker ld.lld-XX is broken in that it
524 # doesn't have that option.
526 # First try to see if have '-Wl,--ignore-unresolved-symbol,environ'
527 # and just use that if so.
529 # If not, we have to use '-Wl,--allow-shlib-undefined' instead
530 # and remove all instances of '-Wl,-no-undefined'.
532 if sys
.platform
.startswith('freebsd'):
533 # Do we have Wl,--ignore-unresolved-symbol,environ ?
534 flag_added
= conf
.ADD_LDFLAGS('-Wl,--ignore-unresolved-symbol,environ', testflags
=True)
536 # No, fall back to -Wl,--allow-shlib-undefined.
537 conf
.ADD_LDFLAGS('-Wl,--allow-shlib-undefined', testflags
=True)
538 # Remove any uses of '-Wl,-no-undefined'
539 conf
.env
['EXTRA_LDFLAGS'] = list(filter(('-Wl,-no-undefined').__ne
__, conf
.env
['EXTRA_LDFLAGS']))
540 # And make sure we don't try and remove it again when 'allow_undefined_symbols=true'
541 conf
.env
.undefined_ldflags
= []
543 conf
.SAMBA_CONFIG_H('include/config.h')
546 '''build TAGS file using etags'''
547 source_root
= os
.path
.dirname(Context
.g_module
.root_path
)
548 cmd
= r
'rm -f %s/TAGS && (find %s -name "*.[ch]" | egrep -v \.inst\. | xargs -n 100 etags -a)' % (source_root
, source_root
)
549 print("Running: %s" % cmd
)
550 status
= os
.system(cmd
)
551 if os
.WEXITSTATUS(status
):
552 raise Errors
.WafError('etags failed')
555 "build 'tags' file using ctags"
556 source_root
= os
.path
.dirname(Context
.g_module
.root_path
)
557 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
)
558 print("Running: %s" % cmd
)
559 status
= os
.system(cmd
)
560 if os
.WEXITSTATUS(status
):
561 raise Errors
.WafError('ctags failed')
564 # putting this here enabled build in the list
565 # of commands in --help
567 '''build all targets'''
568 samba_version
.load_version(env
=bld
.env
, is_install
=bld
.is_install
)
572 '''run pep8 validator'''
573 cmd
='PYTHONPATH=bin/python pep8 -r bin/python/samba'
574 print("Running: %s" % cmd
)
575 status
= os
.system(cmd
)
576 if os
.WEXITSTATUS(status
):
577 raise Errors
.WafError('pep8 failed')
581 '''makes a tarball for distribution'''
582 sambaversion
= samba_version
.load_version(env
=None)
584 os
.system("make -C ctdb manpages")
585 samba_dist
.DIST_FILES('ctdb/doc:ctdb/doc', extend
=True)
587 os
.system("DOC_VERSION='" + sambaversion
.STRING
+ "' " + Context
.g_module
.top
+ "/release-scripts/build-manpages-nogit")
588 samba_dist
.DIST_FILES('bin/docs:docs', extend
=True)
590 if sambaversion
.IS_SNAPSHOT
:
591 # write .distversion file and add to tar
592 if not os
.path
.isdir(Context
.g_module
.out
):
593 os
.makedirs(Context
.g_module
.out
)
594 distversionf
= tempfile
.NamedTemporaryFile(mode
='w', prefix
='.distversion',dir=Context
.g_module
.out
)
595 for field
in sambaversion
.vcs_fields
:
596 distveroption
= field
+ '=' + str(sambaversion
.vcs_fields
[field
])
597 distversionf
.write(distveroption
+ '\n')
599 samba_dist
.DIST_FILES('%s:.distversion' % distversionf
.name
, extend
=True)
608 '''test that distribution tarball builds and installs'''
609 samba_version
.load_version(env
=None)
611 def printversion(ctx
):
613 ver
= samba_version
.load_version(env
=None)
614 print('Samba Version: ' + ver
.STRING_WITH_NICKNAME
)
616 def wildcard_cmd(cmd
):
617 '''called on a unknown command'''
618 from samba_wildcard
import run_named_build_task
619 run_named_build_task(cmd
)
622 from samba_wildcard
import wildcard_main
624 wildcard_main(wildcard_cmd
)
625 Scripting
.main
= main
627 def reconfigure(ctx
):
628 '''reconfigure if config scripts have changed'''
629 samba_utils
.reconfigure(ctx
)
632 if os
.path
.isdir(os
.path
.join(top
, ".git")):
633 # Check if there are submodules that are checked out but out of date.
634 for submodule
, status
in samba_git
.read_submodule_status(top
):
635 if status
== "out-of-date":
636 raise Errors
.WafError("some submodules are out of date. Please run 'git submodule update'")