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