s3-smb2_server: SMB2_OP_IOCTL doesn't require at least 1 dyn byte
[Samba/bjacke.git] / wscript
blob8454146ba53e906ec12987690814444a415610f6
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('.')
16 # install in /usr/local/samba by default
17 Options.default_prefix = '/usr/local/samba'
19 os.environ['TOPLEVEL_BUILD'] = '1'
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('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')
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 conf.env.toplevel_build = True
46 version = samba_version.load_version(env=conf.env)
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)
53 if Options.options.developer:
54 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
55 conf.env.DEVELOPER = True
57 # this enables smbtorture.static for s3 in the build farm
58 conf.env.BUILD_FARM = Options.options.BUILD_FARM or os.environ.get('RUN_FROM_BUILD_FARM')
60 conf.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')
62 conf.RECURSE('lib/replace')
64 conf.find_program('python', var='PYTHON', mandatory=True)
65 conf.find_program('perl', var='PERL', mandatory=True)
66 conf.find_program('xsltproc', var='XSLTPROC')
68 # enable tool to build python extensions
69 conf.check_tool('python')
70 conf.check_python_version((2,4,2))
71 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
73 if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']:
74 # Mac OSX needs to have this and it's also needed that the python is compiled with this
75 # otherwise you face errors about common symbols
76 if not conf.CHECK_SHLIB_W_PYTHON("Checking if -fno-common is needed"):
77 conf.ADD_CFLAGS('-fno-common')
78 if not conf.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
79 conf.env.append_value('shlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
81 if sys.platform == 'darwin':
82 conf.ADD_LDFLAGS('-framework CoreFoundation')
84 if int(conf.env['PYTHON_VERSION'][0]) >= 3:
85 raise Utils.WafError('Python version 3.x is not supported by Samba yet')
87 conf.RECURSE('dynconfig')
88 conf.RECURSE('lib/ldb')
89 conf.RECURSE('source4/heimdal_build')
90 conf.RECURSE('source4/lib/tls')
91 conf.RECURSE('source4/ntvfs/sysdep')
92 conf.RECURSE('lib/util')
93 conf.RECURSE('lib/ccan')
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('selftest')
106 conf.RECURSE('source3')
108 # we don't want any libraries or modules to rely on runtime
109 # resolution of symbols
110 if sys.platform != "openbsd4":
111 conf.env.undefined_ldflags = conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
113 if sys.platform != "openbsd4" and conf.env.undefined_ignore_ldflags == []:
114 if conf.CHECK_LDFLAGS(['-undefined', 'dynamic_lookup']):
115 conf.env.undefined_ignore_ldflags = ['-undefined', 'dynamic_lookup']
118 # gentoo always adds this. We want our normal build to be as
119 # strict as the strictest OS we support, so adding this here
120 # allows us to find problems on our development hosts faster.
121 # It also results in faster load time.
123 if sys.platform != "openbsd4":
124 conf.env.asneeded_ldflags = conf.ADD_LDFLAGS('-Wl,--as-needed', testflags=True)
126 if not conf.CHECK_NEED_LC("-lc not needed"):
127 conf.ADD_LDFLAGS('-lc', testflags=False)
129 # we don't want PYTHONDIR in config.h, as otherwise changing
130 # --prefix causes a complete rebuild
131 del(conf.env.defines['PYTHONDIR'])
132 del(conf.env.defines['PYTHONARCHDIR'])
134 conf.SAMBA_CONFIG_H('include/config.h')
137 def etags(ctx):
138 '''build TAGS file using etags'''
139 import Utils
140 source_root = os.path.dirname(Utils.g_module.root_path)
141 cmd = 'etags $(find %s -name "*.[ch]" | egrep -v \.inst\.)' % source_root
142 print("Running: %s" % cmd)
143 os.system(cmd)
145 def ctags(ctx):
146 "build 'tags' file using ctags"
147 import Utils
148 source_root = os.path.dirname(Utils.g_module.root_path)
149 cmd = 'ctags $(find %s -name "*.[ch]" | grep -v "*_proto\.h" | egrep -v \.inst\.)' % source_root
150 print("Running: %s" % cmd)
151 os.system(cmd)
153 # putting this here enabled build in the list
154 # of commands in --help
155 def build(bld):
156 '''build all targets'''
157 samba_version.load_version(env=bld.env, is_install=bld.is_install)
158 pass
161 def pydoctor(ctx):
162 '''build python apidocs'''
163 cmd='PYTHONPATH=bin/python pydoctor --project-name=Samba --project-url=http://www.samba.org --make-html --docformat=restructuredtext --add-package bin/python/samba'
164 print("Running: %s" % cmd)
165 os.system(cmd)
167 def wafdocs(ctx):
168 '''build wafsamba apidocs'''
169 from samba_utils import recursive_dirlist
170 os.system('pwd')
171 list = recursive_dirlist('../buildtools/wafsamba', '.', pattern='*.py')
173 cmd='PYTHONPATH=bin/python pydoctor --project-name=wafsamba --project-url=http://www.samba.org --make-html --docformat=restructuredtext'
174 print(list)
175 for f in list:
176 cmd += ' --add-module %s' % f
177 print("Running: %s" % cmd)
178 os.system(cmd)
181 def dist():
182 '''makes a tarball for distribution'''
183 samba_version.load_version(env=None)
184 samba_dist.dist()
186 def distcheck():
187 '''test that distribution tarball builds and installs'''
188 samba_version.load_version(env=None)
189 import Scripting
190 d = Scripting.distcheck
191 d(subdir='source4')
193 def wildcard_cmd(cmd):
194 '''called on a unknown command'''
195 from samba_wildcard import run_named_build_task
196 run_named_build_task(cmd)
198 def main():
199 from samba_wildcard import wildcard_main
200 wildcard_main(wildcard_cmd)
201 Scripting.main = main
203 def reconfigure(ctx):
204 '''reconfigure if config scripts have changed'''
205 import samba_utils
206 samba_utils.reconfigure(ctx)