tevent: Fix a typo
[Samba.git] / wscript
blob04c4e9140b209ecdb726e019ed86a5d5227e632d
1 #! /usr/bin/env python
3 srcdir = '.'
4 blddir = 'bin'
6 APPNAME='samba'
7 VERSION=None
9 import sys, os
10 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
11 import wafsamba, Options, samba_dist, Scripting, Utils, samba_version
14 samba_dist.DIST_DIRS('.')
16 #This is a list of files that we don't want in the package, for
17 #whatever reason. Directories should be listed with a trailing / to
18 #avoid over-exclusion.
20 #This list includes files that would confuse the recipient of a
21 #samba-4.0.0 branded tarball (until the merge is complete) and the
22 #core elements of the autotools build system (which is known to
23 #produce buggy binaries).
24 samba_dist.DIST_BLACKLIST('README Manifest Read-Manifest-Now Roadmap ' +
25 'packaging/ docs-xml/ examples/ swat/ WHATSNEW.txt MAINTAINERS ')
26 # install in /usr/local/samba by default
27 Options.default_prefix = '/usr/local/samba'
29 os.environ['TOPLEVEL_BUILD'] = '1'
31 def set_options(opt):
32 opt.BUILTIN_DEFAULT('NONE')
33 opt.PRIVATE_EXTENSION_DEFAULT('samba4')
34 opt.RECURSE('lib/replace')
35 opt.RECURSE('source4/dynconfig')
36 opt.RECURSE('source4/lib/ldb')
37 opt.RECURSE('selftest')
38 opt.RECURSE('source4/lib/tls')
39 opt.RECURSE('lib/nss_wrapper')
40 opt.RECURSE('lib/socket_wrapper')
41 opt.RECURSE('lib/uid_wrapper')
42 opt.RECURSE('pidl')
43 opt.RECURSE('source3')
45 gr = opt.option_group('developer options')
46 gr.add_option('--enable-build-farm',
47 help='enable special build farm options',
48 action='store_true', dest='BUILD_FARM')
50 gr.add_option('--disable-s3build',
51 help='disable build of s3 binaries',
52 action='store_true', dest='S3BUILD')
54 opt.tool_options('python') # options for disabling pyc or pyo compilation
55 # enable options related to building python extensions
58 def configure(conf):
59 conf.env.toplevel_build = True
60 version = samba_version.load_version(env=conf.env)
62 conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
63 conf.DEFINE('_SAMBA_WAF_BUILD_', version.MAJOR)
64 conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True)
65 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
67 if Options.options.developer:
68 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
70 conf.env.enable_s3build = True
71 if Options.options.S3BUILD:
72 conf.env.enable_s3build = False
74 # this enables smbtorture.static for s3 in the build farm
75 conf.env.BUILD_FARM = Options.options.BUILD_FARM or os.environ.get('RUN_FROM_BUILD_FARM')
77 conf.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')
79 conf.RECURSE('lib/replace')
81 conf.find_program('python', var='PYTHON', mandatory=True)
82 conf.find_program('perl', var='PERL', mandatory=True)
83 conf.find_program('xsltproc', var='XSLTPROC')
85 # enable tool to build python extensions
86 conf.check_tool('python')
87 conf.check_python_version((2,4,2))
88 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
90 if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']:
91 # Mac OSX needs to have this and it's also needed that the python is compiled with this
92 # otherwise you face errors about common symbols
93 if not conf.CHECK_SHLIB_W_PYTHON("Checking if -fno-common is needed"):
94 conf.ADD_CFLAGS('-fno-common')
95 if not conf.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
96 conf.env.append_value('shlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
97 if int(conf.env['PYTHON_VERSION'][0]) >= 3:
98 raise Utils.WafError('Python version 3.x is not supported by Samba yet')
100 conf.RECURSE('source4/dynconfig')
101 conf.RECURSE('source4/lib/ldb')
102 conf.RECURSE('source4/heimdal_build')
103 conf.RECURSE('source4/lib/tls')
104 conf.RECURSE('source4/ntvfs/sysdep')
105 conf.RECURSE('lib/util')
106 conf.RECURSE('lib/zlib')
107 conf.RECURSE('lib/util/charset')
108 conf.RECURSE('source4/auth')
109 conf.RECURSE('lib/nss_wrapper')
110 conf.RECURSE('nsswitch')
111 conf.RECURSE('lib/socket_wrapper')
112 conf.RECURSE('lib/uid_wrapper')
113 conf.RECURSE('lib/popt')
114 conf.RECURSE('lib/subunit/c')
115 conf.RECURSE('libcli/smbreadline')
116 conf.RECURSE('pidl')
117 conf.RECURSE('selftest')
118 if conf.env.enable_s3build:
119 conf.RECURSE('source3')
121 # we don't want any libraries or modules to rely on runtime
122 # resolution of symbols
123 if sys.platform != "openbsd4":
124 conf.env.undefined_ldflags = conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
126 if sys.platform != "openbsd4" and conf.env.undefined_ignore_ldflags == []:
127 if conf.CHECK_LDFLAGS(['-undefined', 'dynamic_lookup']):
128 conf.env.undefined_ignore_ldflags = ['-undefined', 'dynamic_lookup']
131 # gentoo always adds this. We want our normal build to be as
132 # strict as the strictest OS we support, so adding this here
133 # allows us to find problems on our development hosts faster.
134 # It also results in faster load time.
135 if sys.platform != "openbsd4":
136 conf.env.asneeded_ldflags = conf.ADD_LDFLAGS('-Wl,--as-needed', testflags=True)
138 if not conf.CHECK_NEED_LC("-lc not needed"):
139 conf.ADD_LDFLAGS('-lc', testflags=False)
141 # we don't want PYTHONDIR in config.h, as otherwise changing
142 # --prefix causes a complete rebuild
143 del(conf.env.defines['PYTHONDIR'])
144 del(conf.env.defines['PYTHONARCHDIR'])
146 conf.SAMBA_CONFIG_H('include/config.h')
149 def etags(ctx):
150 '''build TAGS file using etags'''
151 import Utils
152 source_root = os.path.dirname(Utils.g_module.root_path)
153 cmd = 'etags $(find %s -name "*.[ch]" | egrep -v \.inst\.)' % source_root
154 print("Running: %s" % cmd)
155 os.system(cmd)
157 def ctags(ctx):
158 "build 'tags' file using ctags"
159 import Utils
160 source_root = os.path.dirname(Utils.g_module.root_path)
161 cmd = 'ctags $(find %s -name "*.[ch]" | grep -v "*_proto\.h" | egrep -v \.inst\.)' % source_root
162 print("Running: %s" % cmd)
163 os.system(cmd)
165 # putting this here enabled build in the list
166 # of commands in --help
167 def build(bld):
168 '''build all targets'''
169 samba_version.load_version(env=bld.env)
170 pass
173 def pydoctor(ctx):
174 '''build python apidocs'''
175 cmd='PYTHONPATH=bin/python pydoctor --project-name=Samba --project-url=http://www.samba.org --make-html --docformat=restructuredtext --add-package bin/python/samba'
176 print("Running: %s" % cmd)
177 os.system(cmd)
179 def wafdocs(ctx):
180 '''build wafsamba apidocs'''
181 from samba_utils import recursive_dirlist
182 os.system('pwd')
183 list = recursive_dirlist('../buildtools/wafsamba', '.', pattern='*.py')
185 cmd='PYTHONPATH=bin/python pydoctor --project-name=wafsamba --project-url=http://www.samba.org --make-html --docformat=restructuredtext'
186 print(list)
187 for f in list:
188 cmd += ' --add-module %s' % f
189 print("Running: %s" % cmd)
190 os.system(cmd)
193 def dist():
194 '''makes a tarball for distribution'''
195 samba_version.load_version(env=None)
196 samba_dist.dist()
198 def distcheck():
199 '''test that distribution tarball builds and installs'''
200 samba_version.load_version(env=None)
201 import Scripting
202 d = Scripting.distcheck
203 d(subdir='source4')
205 def wildcard_cmd(cmd):
206 '''called on a unknown command'''
207 from samba_wildcard import run_named_build_task
208 run_named_build_task(cmd)
210 def main():
211 from samba_wildcard import wildcard_main
212 wildcard_main(wildcard_cmd)
213 Scripting.main = main
215 def reconfigure(ctx):
216 '''reconfigure if config scripts have changed'''
217 import samba_utils
218 samba_utils.reconfigure(ctx)