build: Remove support for system libwbclient
[gd/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 samba_dist.DIST_BLACKLIST('.gitignore .bzrignore')
16
17 # install in /usr/local/samba by default
18 Options.default_prefix = '/usr/local/samba'
19
20 def set_options(opt):
21     opt.BUILTIN_DEFAULT('NONE')
22     opt.PRIVATE_EXTENSION_DEFAULT('samba4')
23     opt.RECURSE('lib/replace')
24     opt.RECURSE('dynconfig')
25     opt.RECURSE('lib/ldb')
26     opt.RECURSE('selftest')
27     opt.RECURSE('source4/lib/tls')
28     opt.RECURSE('lib/nss_wrapper')
29     opt.RECURSE('lib/socket_wrapper')
30     opt.RECURSE('lib/uid_wrapper')
31     opt.RECURSE('pidl')
32     opt.RECURSE('source3')
33     opt.RECURSE('lib/util')
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     version = samba_version.load_version(env=conf.env)
46
47     conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
48     conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True)
49     conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
50
51     if Options.options.developer:
52         conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
53         conf.env.DEVELOPER = True
54
55     # this enables smbtorture.static for s3 in the build farm
56     conf.env.BUILD_FARM = Options.options.BUILD_FARM or os.environ.get('RUN_FROM_BUILD_FARM')
57
58     conf.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')
59
60     conf.RECURSE('lib/replace')
61
62     conf.find_program('python', var='PYTHON', mandatory=True)
63     conf.find_program('perl', var='PERL', mandatory=True)
64     conf.find_program('xsltproc', var='XSLTPROC')
65
66     # enable tool to build python extensions
67     conf.check_tool('python')
68     conf.check_python_version((2,4,2))
69     conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
70
71     if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']:
72         # Mac OSX needs to have this and it's also needed that the python is compiled with this
73         # otherwise you face errors about common symbols
74         if not conf.CHECK_SHLIB_W_PYTHON("Checking if -fno-common is needed"):
75             conf.ADD_CFLAGS('-fno-common')
76         if not conf.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
77             conf.env.append_value('shlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
78
79     if sys.platform == 'darwin':
80         conf.ADD_LDFLAGS('-framework CoreFoundation')
81
82     if int(conf.env['PYTHON_VERSION'][0]) >= 3:
83         raise Utils.WafError('Python version 3.x is not supported by Samba yet')
84
85     conf.RECURSE('dynconfig')
86     conf.RECURSE('lib/ldb')
87     if not os.getenv('USING_SYSTEM_KRB5'):
88         conf.RECURSE('source4/heimdal_build')
89     conf.RECURSE('source4/lib/tls')
90     conf.RECURSE('source4/ntvfs/sysdep')
91     conf.RECURSE('lib/util')
92     conf.RECURSE('lib/ccan')
93     conf.RECURSE('lib/zlib')
94     conf.RECURSE('lib/util/charset')
95     conf.RECURSE('source4/auth')
96     conf.RECURSE('lib/nss_wrapper')
97     conf.RECURSE('nsswitch')
98     conf.RECURSE('lib/socket_wrapper')
99     conf.RECURSE('lib/uid_wrapper')
100     conf.RECURSE('lib/popt')
101     conf.RECURSE('lib/subunit/c')
102     conf.RECURSE('libcli/smbreadline')
103     conf.RECURSE('lib/crypto')
104     conf.RECURSE('pidl')
105     conf.RECURSE('selftest')
106     conf.RECURSE('source3')
107     conf.RECURSE('lib/addns')
108     conf.RECURSE('source3/libsmb')
109
110     conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
111
112     # gentoo always adds this. We want our normal build to be as
113     # strict as the strictest OS we support, so adding this here
114     # allows us to find problems on our development hosts faster.
115     # It also results in faster load time.
116
117     if sys.platform != "openbsd4":
118         conf.env.asneeded_ldflags = conf.ADD_LDFLAGS('-Wl,--as-needed', testflags=True)
119
120     if not conf.CHECK_NEED_LC("-lc not needed"):
121         conf.ADD_LDFLAGS('-lc', testflags=False)
122
123     # we don't want PYTHONDIR in config.h, as otherwise changing
124     # --prefix causes a complete rebuild
125     del(conf.env.defines['PYTHONDIR'])
126     del(conf.env.defines['PYTHONARCHDIR'])
127
128     if not conf.CHECK_CODE('#include "tests/summary.c"',
129                            define='SUMMARY_PASSES',
130                            addmain=False,
131                            execute=True,
132                            msg='Checking configure summary'):
133         raise Utils.WafError('configure summary failed')
134     
135     conf.SAMBA_CONFIG_H('include/config.h')
136
137
138 def etags(ctx):
139     '''build TAGS file using etags'''
140     import Utils
141     source_root = os.path.dirname(Utils.g_module.root_path)
142     cmd = 'etags $(find %s -name "*.[ch]" | egrep -v \.inst\.)' % source_root
143     print("Running: %s" % cmd)
144     os.system(cmd)
145
146 def ctags(ctx):
147     "build 'tags' file using ctags"
148     import Utils
149     source_root = os.path.dirname(Utils.g_module.root_path)
150     cmd = 'ctags --python-kinds=-i $(find %s -name "*.[ch]" | grep -v "*_proto\.h" | egrep -v \.inst\.) $(find %s -name "*.py")' % (source_root, source_root)
151     print("Running: %s" % cmd)
152     os.system(cmd)
153
154 # putting this here enabled build in the list
155 # of commands in --help
156 def build(bld):
157     '''build all targets'''
158     samba_version.load_version(env=bld.env, is_install=bld.is_install)
159     pass
160
161
162 def pydoctor(ctx):
163     '''build python apidocs'''
164     bp = os.path.abspath('bin/python')
165     mpaths = {}
166     for m in ['talloc', 'tdb', 'ldb']:
167         f = os.popen("PYTHONPATH=%s python -c 'import %s; print %s.__file__'" % (bp, m, m), 'r')
168         try:
169             mpaths[m] = f.read().strip()
170         finally:
171             f.close()
172     cmd='PYTHONPATH=%s pydoctor --introspect-c-modules --project-name=Samba --project-url=http://www.samba.org --make-html --docformat=restructuredtext --add-package bin/python/samba --add-module %s --add-module %s --add-module %s' % (
173         bp, mpaths['tdb'], mpaths['ldb'], mpaths['talloc'])
174     print("Running: %s" % cmd)
175     os.system(cmd)
176
177
178 def pep8(ctx):
179     '''run pep8 validator'''
180     cmd='PYTHONPATH=bin/python pep8 -r bin/python/samba'
181     print("Running: %s" % cmd)
182     os.system(cmd)
183
184
185 def wafdocs(ctx):
186     '''build wafsamba apidocs'''
187     from samba_utils import recursive_dirlist
188     os.system('pwd')
189     list = recursive_dirlist('../buildtools/wafsamba', '.', pattern='*.py')
190
191     cmd='PYTHONPATH=bin/python pydoctor --project-name=wafsamba --project-url=http://www.samba.org --make-html --docformat=restructuredtext'
192     print(list)
193     for f in list:
194         cmd += ' --add-module %s' % f
195     print("Running: %s" % cmd)
196     os.system(cmd)
197
198
199 def dist():
200     '''makes a tarball for distribution'''
201     samba_version.load_version(env=None)
202     samba_dist.dist()
203
204 def distcheck():
205     '''test that distribution tarball builds and installs'''
206     samba_version.load_version(env=None)
207     import Scripting
208     d = Scripting.distcheck
209     d(subdir='source4')
210
211 def wildcard_cmd(cmd):
212     '''called on a unknown command'''
213     from samba_wildcard import run_named_build_task
214     run_named_build_task(cmd)
215
216 def main():
217     from samba_wildcard import wildcard_main
218     wildcard_main(wildcard_cmd)
219 Scripting.main = main
220
221 def reconfigure(ctx):
222     '''reconfigure if config scripts have changed'''
223     import samba_utils
224     samba_utils.reconfigure(ctx)