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