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