2010-03-17 21:46:38 +11:00
#! /usr/bin/env python
2010-03-17 20:26:03 +11:00
srcdir = '..'
blddir = 'bin'
2010-04-04 09:57:33 +10:00
APPNAME='samba'
2010-06-28 13:40:32 +10:00
VERSION=None
2010-04-04 09:57:33 +10:00
2010-03-18 13:17:43 +11:00
import sys, os
2010-02-26 22:21:50 +11:00
sys.path.insert(0, srcdir+"/buildtools/wafsamba")
2010-10-12 13:05:36 +11:00
import wafsamba, Options, samba_dist, Scripting, Utils
2010-03-17 20:26:03 +11:00
2010-05-28 15:20:03 +10:00
2010-06-28 13:40:32 +10:00
def load_version(have_git=False):
'''load samba versions either from ./VERSION or git
return a version object for detailed breakdown'''
import samba_utils, Utils
if not have_git:
env = samba_utils.LOAD_ENVIRONMENT()
have_git = 'GIT' in env
version = wafsamba.samba_version_file("./VERSION", have_git=have_git)
Utils.g_module.VERSION = version.STRING
return version
2010-05-28 15:20:03 +10:00
2010-04-04 11:00:42 +10:00
samba_dist.DIST_DIRS('.')
2010-05-28 18:50:25 +10:00
#This is a list of files that we don't want in the package, for
#whatever reason. Directories should be listed with a trailing / to
#avoid over-exclusion.
2010-05-28 18:54:57 +10:00
#This list includes files that would confuse the recipient of a
#samba-4.0.0 branded tarball (until the merge is complete) and the
#core elements of the autotools build system (which is known to
#produce buggy binaries).
2010-05-28 18:50:25 +10:00
samba_dist.DIST_BLACKLIST('README Manifest Read-Manifest-Now Roadmap source3/ ' +
2010-05-28 18:54:57 +10:00
'packaging/ docs-xml/ examples/ swat/ WHATSNEW.txt MAINTAINERS ' +
'source4/autogen-autotools.sh source4/Makefile.in source4/configure.ac')
2010-03-29 22:05:54 +11:00
# install in /usr/local/samba by default
Options.default_prefix = '/usr/local/samba'
2010-03-17 20:26:03 +11:00
def set_options(opt):
2010-10-30 14:16:07 +11:00
opt.BUILTIN_DEFAULT('NONE')
2010-10-23 23:26:43 +02:00
opt.PRIVATE_EXTENSION_DEFAULT('samba4')
2010-04-04 13:08:05 +10:00
opt.RECURSE('../lib/replace')
opt.RECURSE('dynconfig')
opt.RECURSE('scripting/python')
opt.RECURSE('lib/ldb')
opt.RECURSE('selftest')
opt.RECURSE('lib/tls')
opt.RECURSE('../lib/nss_wrapper')
opt.RECURSE('../lib/socket_wrapper')
opt.RECURSE('../lib/uid_wrapper')
opt.RECURSE('../pidl')
2010-03-17 20:38:03 +11:00
2010-04-29 07:47:57 +10:00
gr = opt.option_group('developer options')
gr.add_option('--enable-build-farm',
help='enable special build farm options',
action='store_true', dest='BUILD_FARM')
2010-03-17 20:26:03 +11:00
def configure(conf):
2010-06-28 13:40:32 +10:00
version = load_version(have_git=True)
2010-03-20 16:27:48 +11:00
conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
2010-05-28 15:20:03 +10:00
conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True)
2010-03-20 16:27:48 +11:00
conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
2010-03-28 14:10:15 +11:00
2010-03-20 16:27:48 +11:00
if Options.options.developer:
conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
2010-04-29 07:47:57 +10:00
# this enables smbtorture.static for s3 in the build farm
conf.env.BUILD_FARM = Options.options.BUILD_FARM or os.environ.get('RUN_FROM_BUILD_FARM')
2010-03-28 14:16:12 +11:00
conf.ADD_EXTRA_INCLUDES('#source4 #lib #source4/lib #source4/include')
2010-03-20 16:27:48 +11:00
2010-04-04 13:08:05 +10:00
conf.RECURSE('../lib/replace')
2010-03-20 16:27:48 +11:00
2010-03-17 21:46:38 +11:00
conf.find_program('python', var='PYTHON', mandatory=True)
2010-03-17 21:53:29 +11:00
conf.find_program('perl', var='PERL', mandatory=True)
2010-05-31 01:25:56 +02:00
conf.find_program('xsltproc', var='XSLTPROC')
2010-03-20 16:27:48 +11:00
# enable tool to build python extensions
conf.check_tool('python')
conf.check_python_version((2,4,2))
2010-04-21 16:21:30 +10:00
conf.check_python_headers(mandatory=True)
2010-03-20 16:27:48 +11:00
2010-10-30 20:22:22 +04:00
if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']:
2010-10-30 16:50:33 +04:00
if not conf.CHECK_SHLIB_W_PYTHON("Checking if -single_module is not needed"):
conf.env.append_value('shlib_LINKFLAGS', ['-single_module'])
if not conf.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
conf.env.append_value('shlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
2010-10-12 13:05:36 +11:00
if int(conf.env['PYTHON_VERSION'][0]) >= 3:
raise Utils.WafError('Python version 3.x is not supported by Samba yet')
2010-04-04 13:08:05 +10:00
conf.RECURSE('dynconfig')
conf.RECURSE('scripting/python')
conf.RECURSE('lib/ldb')
conf.RECURSE('heimdal_build')
conf.RECURSE('lib/tls')
conf.RECURSE('ntvfs/sysdep')
conf.RECURSE('../lib/util')
conf.RECURSE('../lib/zlib')
conf.RECURSE('../lib/util/charset')
conf.RECURSE('auth')
conf.RECURSE('../lib/nss_wrapper')
conf.RECURSE('../nsswitch')
conf.RECURSE('../lib/socket_wrapper')
conf.RECURSE('../lib/uid_wrapper')
conf.RECURSE('../lib/popt')
2010-09-22 20:18:45 -07:00
conf.RECURSE('../lib/subunit/c')
2010-10-01 10:34:14 +02:00
conf.RECURSE('../libcli/smbreadline')
2010-04-04 13:08:05 +10:00
conf.RECURSE('../pidl')
2010-04-15 08:28:20 +02:00
conf.RECURSE('selftest')
2010-03-17 20:26:03 +11:00
2010-10-25 11:29:12 +11:00
# we don't want any libraries or modules to rely on runtime
# resolution of symbols
conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
2010-11-03 10:50:16 +11:00
# gentoo always adds this. We want our normal build to be as
# strict as the strictest OS we support, so adding this here
# allows us to find problems on our development hosts faster.
# It also results in faster load time.
conf.ADD_LDFLAGS('-Wl,--as-needed', testflags=True)
2010-03-31 18:05:57 +11:00
# we don't want PYTHONDIR in config.h, as otherwise changing
# --prefix causes a complete rebuild
del(conf.env.defines['PYTHONDIR'])
2010-02-23 08:09:46 +11:00
conf.SAMBA_CONFIG_H('include/config.h')
2010-03-17 10:58:07 +11:00
2010-03-18 13:17:43 +11:00
def etags(ctx):
'''build TAGS file using etags'''
import Utils
source_root = os.path.dirname(Utils.g_module.root_path)
cmd = 'etags $(find %s/.. -name "*.[ch]")' % source_root
2010-04-08 07:45:46 +10:00
print("Running: %s" % cmd)
2010-03-18 13:17:43 +11:00
os.system(cmd)
2010-03-19 10:10:36 +01:00
def ctags(ctx):
2010-03-19 20:30:14 +11:00
"build 'tags' file using ctags"
2010-03-19 10:10:36 +01:00
import Utils
source_root = os.path.dirname(Utils.g_module.root_path)
cmd = 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
2010-04-08 07:45:46 +10:00
print("Running: %s" % cmd)
2010-03-19 10:10:36 +01:00
os.system(cmd)
2010-03-19 09:10:59 +11:00
# putting this here enabled build in the list
# of commands in --help
def build(bld):
'''build all targets'''
2010-06-28 13:40:32 +10:00
load_version()
2010-03-19 09:10:59 +11:00
pass
2010-03-29 17:12:04 +11:00
def pydoctor(ctx):
'''build python apidocs'''
cmd='LD_LIBRARY_PATH=bin/shared PYTHONPATH=bin/python pydoctor --project-name=Samba --project-url=http://www.samba.org --make-html --docformat=restructuredtext --add-package bin/python/samba'
2010-04-08 07:45:46 +10:00
print("Running: %s" % cmd)
2010-03-29 17:12:04 +11:00
os.system(cmd)
def wafdocs(ctx):
'''build wafsamba apidocs'''
from samba_utils import recursive_dirlist
os.system('pwd')
list = recursive_dirlist('../buildtools/wafsamba', '.', pattern='*.py')
cmd='LD_LIBRARY_PATH=bin/shared PYTHONPATH=bin/python pydoctor --project-name=wafsamba --project-url=http://www.samba.org --make-html --docformat=restructuredtext'
2010-04-08 07:45:46 +10:00
print(list)
2010-03-29 17:12:04 +11:00
for f in list:
cmd += ' --add-module %s' % f
2010-04-08 07:45:46 +10:00
print("Running: %s" % cmd)
2010-03-29 17:12:04 +11:00
os.system(cmd)
2010-04-04 09:57:33 +10:00
def dist():
'''makes a tarball for distribution'''
2010-06-28 13:40:32 +10:00
load_version()
2010-04-04 09:57:33 +10:00
samba_dist.dist()
2010-04-05 11:26:24 +10:00
def distcheck():
'''test that distribution tarball builds and installs'''
2010-06-28 13:40:32 +10:00
load_version()
2010-04-05 11:26:24 +10:00
import Scripting
d = Scripting.distcheck
d(subdir='source4')
2010-05-04 10:08:43 +02:00
def wildcard_cmd(cmd):
'''called on a unknown command'''
from samba_wildcard import run_named_build_task
run_named_build_task(cmd)
def main():
from samba_wildcard import wildcard_main
wildcard_main(wildcard_cmd)
Scripting.main = main
2010-04-05 11:26:24 +10:00
2010-05-06 14:51:28 +02:00
def reconfigure(ctx):
'''reconfigure if config scripts have changed'''
import samba_utils
samba_utils.reconfigure(ctx)