s3: remove prototype of convert_string_error from proto.h
[kai/samba-autobuild/.git] / wscript
1 #! /usr/bin/env python
2
3 srcdir = '.'
4 blddir = 'bin'
5
6 APPNAME='samba'
7 VERSION=None
8
9 import sys, os
10 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
11 import wafsamba, Options, samba_dist, Scripting, Utils, samba_version
12
13
14 samba_dist.DIST_DIRS('.')
15
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.
19
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'
28
29 os.environ['TOPLEVEL_BUILD'] = '1'
30
31 def set_options(opt):
32     opt.BUILTIN_DEFAULT('NONE')
33     opt.PRIVATE_EXTENSION_DEFAULT('samba4')
34     opt.RECURSE('lib/replace')
35     opt.RECURSE('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')
44
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')
49
50     opt.tool_options('python') # options for disabling pyc or pyo compilation
51     # enable options related to building python extensions
52
53
54 def configure(conf):
55     conf.env.toplevel_build = True
56     version = samba_version.load_version(env=conf.env)
57
58     conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
59     conf.DEFINE('_SAMBA_WAF_BUILD_', version.MAJOR)
60     conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True)
61     conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
62
63     if Options.options.developer:
64         conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
65
66     # this enables smbtorture.static for s3 in the build farm
67     conf.env.BUILD_FARM = Options.options.BUILD_FARM or os.environ.get('RUN_FROM_BUILD_FARM')
68
69     conf.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')
70
71     conf.RECURSE('lib/replace')
72
73     conf.find_program('python', var='PYTHON', mandatory=True)
74     conf.find_program('perl', var='PERL', mandatory=True)
75     conf.find_program('xsltproc', var='XSLTPROC')
76
77     # enable tool to build python extensions
78     conf.check_tool('python')
79     conf.check_python_version((2,4,2))
80     conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
81
82     if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']:
83         # Mac OSX needs to have this and it's also needed that the python is compiled with this
84         # otherwise you face errors about common symbols
85         if not conf.CHECK_SHLIB_W_PYTHON("Checking if -fno-common is needed"):
86             conf.ADD_CFLAGS('-fno-common')
87         if not conf.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
88             conf.env.append_value('shlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
89     if int(conf.env['PYTHON_VERSION'][0]) >= 3:
90         raise Utils.WafError('Python version 3.x is not supported by Samba yet')
91
92     conf.RECURSE('dynconfig')
93     conf.RECURSE('source4/lib/ldb')
94     conf.RECURSE('source4/heimdal_build')
95     conf.RECURSE('source4/lib/tls')
96     conf.RECURSE('source4/ntvfs/sysdep')
97     conf.RECURSE('lib/util')
98     conf.RECURSE('lib/ccan')
99     conf.RECURSE('lib/zlib')
100     conf.RECURSE('lib/util/charset')
101     conf.RECURSE('source4/auth')
102     conf.RECURSE('lib/nss_wrapper')
103     conf.RECURSE('nsswitch')
104     conf.RECURSE('lib/socket_wrapper')
105     conf.RECURSE('lib/uid_wrapper')
106     conf.RECURSE('lib/popt')
107     conf.RECURSE('lib/subunit/c')
108     conf.RECURSE('libcli/smbreadline')
109     conf.RECURSE('pidl')
110     conf.RECURSE('selftest')
111     conf.RECURSE('source3')
112
113     # we don't want any libraries or modules to rely on runtime
114     # resolution of symbols
115     if sys.platform != "openbsd4":
116         conf.env.undefined_ldflags = conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
117
118     if sys.platform != "openbsd4" and conf.env.undefined_ignore_ldflags == []:
119         if conf.CHECK_LDFLAGS(['-undefined', 'dynamic_lookup']):
120             conf.env.undefined_ignore_ldflags = ['-undefined', 'dynamic_lookup']
121
122
123     # gentoo always adds this. We want our normal build to be as
124     # strict as the strictest OS we support, so adding this here
125     # allows us to find problems on our development hosts faster.
126     # It also results in faster load time.
127
128     # However, until the source3 waf build settles down, this needs to
129     # be disabled, as the bugs mentioned above are hitting too many of
130     # our users
131
132     #if sys.platform != "openbsd4":
133     #    conf.env.asneeded_ldflags = conf.ADD_LDFLAGS('-Wl,--as-needed', testflags=True)
134
135     if not conf.CHECK_NEED_LC("-lc not needed"):
136         conf.ADD_LDFLAGS('-lc', testflags=False)
137
138     # we don't want PYTHONDIR in config.h, as otherwise changing
139     # --prefix causes a complete rebuild
140     del(conf.env.defines['PYTHONDIR'])
141     del(conf.env.defines['PYTHONARCHDIR'])
142
143     conf.SAMBA_CONFIG_H('include/config.h')
144
145
146 def etags(ctx):
147     '''build TAGS file using etags'''
148     import Utils
149     source_root = os.path.dirname(Utils.g_module.root_path)
150     cmd = 'etags $(find %s -name "*.[ch]" | egrep -v \.inst\.)' % source_root
151     print("Running: %s" % cmd)
152     os.system(cmd)
153
154 def ctags(ctx):
155     "build 'tags' file using ctags"
156     import Utils
157     source_root = os.path.dirname(Utils.g_module.root_path)
158     cmd = 'ctags $(find %s -name "*.[ch]" | grep -v "*_proto\.h" | egrep -v \.inst\.)' % source_root
159     print("Running: %s" % cmd)
160     os.system(cmd)
161
162 # putting this here enabled build in the list
163 # of commands in --help
164 def build(bld):
165     '''build all targets'''
166     samba_version.load_version(env=bld.env, is_install=bld.is_install)
167     pass
168
169
170 def pydoctor(ctx):
171     '''build python apidocs'''
172     cmd='PYTHONPATH=bin/python pydoctor --project-name=Samba --project-url=http://www.samba.org --make-html --docformat=restructuredtext --add-package bin/python/samba'
173     print("Running: %s" % cmd)
174     os.system(cmd)
175
176 def wafdocs(ctx):
177     '''build wafsamba apidocs'''
178     from samba_utils import recursive_dirlist
179     os.system('pwd')
180     list = recursive_dirlist('../buildtools/wafsamba', '.', pattern='*.py')
181
182     cmd='PYTHONPATH=bin/python pydoctor --project-name=wafsamba --project-url=http://www.samba.org --make-html --docformat=restructuredtext'
183     print(list)
184     for f in list:
185         cmd += ' --add-module %s' % f
186     print("Running: %s" % cmd)
187     os.system(cmd)
188
189
190 def dist():
191     '''makes a tarball for distribution'''
192     samba_version.load_version(env=None)
193     samba_dist.dist()
194
195 def distcheck():
196     '''test that distribution tarball builds and installs'''
197     samba_version.load_version(env=None)
198     import Scripting
199     d = Scripting.distcheck
200     d(subdir='source4')
201
202 def wildcard_cmd(cmd):
203     '''called on a unknown command'''
204     from samba_wildcard import run_named_build_task
205     run_named_build_task(cmd)
206
207 def main():
208     from samba_wildcard import wildcard_main
209     wildcard_main(wildcard_cmd)
210 Scripting.main = main
211
212 def reconfigure(ctx):
213     '''reconfigure if config scripts have changed'''
214     import samba_utils
215     samba_utils.reconfigure(ctx)