s3: Fix Coverity ID 242720 Uninitialized scalar variable
[Samba/gebeck_regimport.git] / wscript
blob15ac7f57c7cd681574482d60cbcc3d6e20c9c6eb
1 #! /usr/bin/env python
3 srcdir = '.'
4 blddir = 'bin'
6 APPNAME='samba'
7 VERSION=None
9 import sys, os
10 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
11 import wafsamba, Options, samba_dist, Scripting, Utils, samba_version
14 samba_dist.DIST_DIRS('.')
15 samba_dist.DIST_BLACKLIST('.gitignore .bzrignore')
17 # install in /usr/local/samba by default
18 Options.default_prefix = '/usr/local/samba'
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')
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')
40 opt.tool_options('python') # options for disabling pyc or pyo compilation
41 # enable options related to building python extensions
44 def configure(conf):
45 version = samba_version.load_version(env=conf.env)
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)
51 if Options.options.developer:
52 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
53 conf.env.DEVELOPER = True
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')
58 conf.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')
60 conf.RECURSE('lib/replace')
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')
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)
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'])
79 if sys.platform == 'darwin':
80 conf.ADD_LDFLAGS('-framework CoreFoundation')
82 if int(conf.env['PYTHON_VERSION'][0]) >= 3:
83 raise Utils.WafError('Python version 3.x is not supported by Samba yet')
85 conf.RECURSE('dynconfig')
86 conf.RECURSE('lib/ldb')
87 if Options.options.with_mit_krb5_checks:
88 conf.PROCESS_SEPARATE_RULE('krb5')
89 # Only process heimdal_build for non-MIT KRB5 builds
90 # When MIT KRB5 checks are done as above, conf.env.KRB5_VENDOR will be set
91 # to the lowcased output of 'krb5-config --vendor'.
92 # If it is not set or the output is 'heimdal', we are dealing with
93 # system-provided or embedded Heimdal build
94 if conf.CONFIG_GET('KRB5_VENDOR') in (None, 'heimdal'):
95 conf.RECURSE('source4/heimdal_build')
96 conf.RECURSE('source4/lib/tls')
97 conf.RECURSE('source4/ntvfs/sysdep')
98 conf.RECURSE('lib/util')
99 conf.RECURSE('lib/ccan')
100 conf.RECURSE('lib/zlib')
101 conf.RECURSE('lib/util/charset')
102 conf.RECURSE('source4/auth')
103 conf.RECURSE('lib/nss_wrapper')
104 conf.RECURSE('nsswitch')
105 conf.RECURSE('lib/socket_wrapper')
106 conf.RECURSE('lib/uid_wrapper')
107 conf.RECURSE('lib/popt')
108 conf.RECURSE('lib/iniparser/src')
109 conf.RECURSE('lib/subunit/c')
110 conf.RECURSE('libcli/smbreadline')
111 conf.RECURSE('lib/crypto')
112 conf.RECURSE('pidl')
113 conf.RECURSE('selftest')
114 conf.RECURSE('source3')
115 conf.RECURSE('lib/addns')
117 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
119 # gentoo always adds this. We want our normal build to be as
120 # strict as the strictest OS we support, so adding this here
121 # allows us to find problems on our development hosts faster.
122 # It also results in faster load time.
124 if sys.platform != "openbsd4":
125 conf.env.asneeded_ldflags = conf.ADD_LDFLAGS('-Wl,--as-needed', testflags=True)
127 if not conf.CHECK_NEED_LC("-lc not needed"):
128 conf.ADD_LDFLAGS('-lc', testflags=False)
130 # we don't want PYTHONDIR in config.h, as otherwise changing
131 # --prefix causes a complete rebuild
132 del(conf.env.defines['PYTHONDIR'])
133 del(conf.env.defines['PYTHONARCHDIR'])
135 if not conf.CHECK_CODE('#include "tests/summary.c"',
136 define='SUMMARY_PASSES',
137 addmain=False,
138 execute=True,
139 msg='Checking configure summary'):
140 raise Utils.WafError('configure summary failed')
142 conf.SAMBA_CONFIG_H('include/config.h')
145 def etags(ctx):
146 '''build TAGS file using etags'''
147 import Utils
148 source_root = os.path.dirname(Utils.g_module.root_path)
149 cmd = 'etags $(find %s -name "*.[ch]" | egrep -v \.inst\.)' % source_root
150 print("Running: %s" % cmd)
151 os.system(cmd)
153 def ctags(ctx):
154 "build 'tags' file using ctags"
155 import Utils
156 source_root = os.path.dirname(Utils.g_module.root_path)
157 cmd = 'ctags --python-kinds=-i $(find %s -name "*.[ch]" | grep -v "*_proto\.h" | egrep -v \.inst\.) $(find %s -name "*.py")' % (source_root, source_root)
158 print("Running: %s" % cmd)
159 os.system(cmd)
161 # putting this here enabled build in the list
162 # of commands in --help
163 def build(bld):
164 '''build all targets'''
165 samba_version.load_version(env=bld.env, is_install=bld.is_install)
166 pass
169 def pydoctor(ctx):
170 '''build python apidocs'''
171 bp = os.path.abspath('bin/python')
172 mpaths = {}
173 for m in ['talloc', 'tdb', 'ldb']:
174 f = os.popen("PYTHONPATH=%s python -c 'import %s; print %s.__file__'" % (bp, m, m), 'r')
175 try:
176 mpaths[m] = f.read().strip()
177 finally:
178 f.close()
179 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' % (
180 bp, mpaths['tdb'], mpaths['ldb'], mpaths['talloc'])
181 print("Running: %s" % cmd)
182 os.system(cmd)
185 def pep8(ctx):
186 '''run pep8 validator'''
187 cmd='PYTHONPATH=bin/python pep8 -r bin/python/samba'
188 print("Running: %s" % cmd)
189 os.system(cmd)
192 def wafdocs(ctx):
193 '''build wafsamba apidocs'''
194 from samba_utils import recursive_dirlist
195 os.system('pwd')
196 list = recursive_dirlist('../buildtools/wafsamba', '.', pattern='*.py')
198 cmd='PYTHONPATH=bin/python pydoctor --project-name=wafsamba --project-url=http://www.samba.org --make-html --docformat=restructuredtext'
199 print(list)
200 for f in list:
201 cmd += ' --add-module %s' % f
202 print("Running: %s" % cmd)
203 os.system(cmd)
206 def dist():
207 '''makes a tarball for distribution'''
208 samba_version.load_version(env=None)
209 samba_dist.dist()
211 def distcheck():
212 '''test that distribution tarball builds and installs'''
213 samba_version.load_version(env=None)
214 import Scripting
215 d = Scripting.distcheck
216 d(subdir='source4')
218 def wildcard_cmd(cmd):
219 '''called on a unknown command'''
220 from samba_wildcard import run_named_build_task
221 run_named_build_task(cmd)
223 def main():
224 from samba_wildcard import wildcard_main
225 wildcard_main(wildcard_cmd)
226 Scripting.main = main
228 def reconfigure(ctx):
229 '''reconfigure if config scripts have changed'''
230 import samba_utils
231 samba_utils.reconfigure(ctx)