lib/util: remove unneeded else branch in directory_create_or_exist()
[Samba.git] / wscript
blobe1fe95363e818ca8c48f3726132fae966f43eccc
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')
34 gr = opt.option_group('developer options')
35 gr.add_option('--enable-build-farm',
36 help='enable special build farm options',
37 action='store_true', dest='BUILD_FARM')
39 opt.tool_options('python') # options for disabling pyc or pyo compilation
40 # enable options related to building python extensions
43 def configure(conf):
44 version = samba_version.load_version(env=conf.env)
46 conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
47 conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True)
48 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
50 if Options.options.developer:
51 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
52 conf.env.DEVELOPER = True
54 # this enables smbtorture.static for s3 in the build farm
55 conf.env.BUILD_FARM = Options.options.BUILD_FARM or os.environ.get('RUN_FROM_BUILD_FARM')
57 conf.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')
59 conf.RECURSE('lib/replace')
61 conf.find_program('python', var='PYTHON', mandatory=True)
62 conf.find_program('perl', var='PERL', mandatory=True)
63 conf.find_program('xsltproc', var='XSLTPROC')
65 # enable tool to build python extensions
66 conf.check_tool('python')
67 conf.check_python_version((2,4,2))
68 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
70 if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']:
71 # Mac OSX needs to have this and it's also needed that the python is compiled with this
72 # otherwise you face errors about common symbols
73 if not conf.CHECK_SHLIB_W_PYTHON("Checking if -fno-common is needed"):
74 conf.ADD_CFLAGS('-fno-common')
75 if not conf.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
76 conf.env.append_value('shlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
78 if sys.platform == 'darwin':
79 conf.ADD_LDFLAGS('-framework CoreFoundation')
81 if int(conf.env['PYTHON_VERSION'][0]) >= 3:
82 raise Utils.WafError('Python version 3.x is not supported by Samba yet')
84 conf.RECURSE('dynconfig')
85 conf.RECURSE('lib/ldb')
86 conf.RECURSE('source4/heimdal_build')
87 conf.RECURSE('source4/lib/tls')
88 conf.RECURSE('source4/ntvfs/sysdep')
89 conf.RECURSE('lib/util')
90 conf.RECURSE('lib/ccan')
91 conf.RECURSE('lib/zlib')
92 conf.RECURSE('lib/util/charset')
93 conf.RECURSE('source4/auth')
94 conf.RECURSE('lib/nss_wrapper')
95 conf.RECURSE('nsswitch')
96 conf.RECURSE('lib/socket_wrapper')
97 conf.RECURSE('lib/uid_wrapper')
98 conf.RECURSE('lib/popt')
99 conf.RECURSE('lib/subunit/c')
100 conf.RECURSE('libcli/smbreadline')
101 conf.RECURSE('lib/crypto')
102 conf.RECURSE('pidl')
103 conf.RECURSE('selftest')
104 conf.RECURSE('source3')
105 conf.RECURSE('lib/addns')
107 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
109 # gentoo always adds this. We want our normal build to be as
110 # strict as the strictest OS we support, so adding this here
111 # allows us to find problems on our development hosts faster.
112 # It also results in faster load time.
114 if sys.platform != "openbsd4":
115 conf.env.asneeded_ldflags = conf.ADD_LDFLAGS('-Wl,--as-needed', testflags=True)
117 if not conf.CHECK_NEED_LC("-lc not needed"):
118 conf.ADD_LDFLAGS('-lc', testflags=False)
120 # we don't want PYTHONDIR in config.h, as otherwise changing
121 # --prefix causes a complete rebuild
122 del(conf.env.defines['PYTHONDIR'])
123 del(conf.env.defines['PYTHONARCHDIR'])
125 conf.SAMBA_CONFIG_H('include/config.h')
128 def etags(ctx):
129 '''build TAGS file using etags'''
130 import Utils
131 source_root = os.path.dirname(Utils.g_module.root_path)
132 cmd = 'etags $(find %s -name "*.[ch]" | egrep -v \.inst\.)' % source_root
133 print("Running: %s" % cmd)
134 os.system(cmd)
136 def ctags(ctx):
137 "build 'tags' file using ctags"
138 import Utils
139 source_root = os.path.dirname(Utils.g_module.root_path)
140 cmd = 'ctags --python-kinds=-i $(find %s -name "*.[ch]" | grep -v "*_proto\.h" | egrep -v \.inst\.) $(find %s -name "*.py")' % (source_root, source_root)
141 print("Running: %s" % cmd)
142 os.system(cmd)
144 # putting this here enabled build in the list
145 # of commands in --help
146 def build(bld):
147 '''build all targets'''
148 samba_version.load_version(env=bld.env, is_install=bld.is_install)
149 pass
152 def pydoctor(ctx):
153 '''build python apidocs'''
154 bp = os.path.abspath('bin/python')
155 mpaths = {}
156 for m in ['talloc', 'tdb', 'ldb']:
157 f = os.popen("PYTHONPATH=%s python -c 'import %s; print %s.__file__'" % (bp, m, m), 'r')
158 try:
159 mpaths[m] = f.read().strip()
160 finally:
161 f.close()
162 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' % (
163 bp, mpaths['tdb'], mpaths['ldb'], mpaths['talloc'])
164 print("Running: %s" % cmd)
165 os.system(cmd)
168 def pep8(ctx):
169 '''run pep8 validator'''
170 cmd='PYTHONPATH=bin/python pep8 -r bin/python/samba'
171 print("Running: %s" % cmd)
172 os.system(cmd)
175 def wafdocs(ctx):
176 '''build wafsamba apidocs'''
177 from samba_utils import recursive_dirlist
178 os.system('pwd')
179 list = recursive_dirlist('../buildtools/wafsamba', '.', pattern='*.py')
181 cmd='PYTHONPATH=bin/python pydoctor --project-name=wafsamba --project-url=http://www.samba.org --make-html --docformat=restructuredtext'
182 print(list)
183 for f in list:
184 cmd += ' --add-module %s' % f
185 print("Running: %s" % cmd)
186 os.system(cmd)
189 def dist():
190 '''makes a tarball for distribution'''
191 samba_version.load_version(env=None)
192 samba_dist.dist()
194 def distcheck():
195 '''test that distribution tarball builds and installs'''
196 samba_version.load_version(env=None)
197 import Scripting
198 d = Scripting.distcheck
199 d(subdir='source4')
201 def wildcard_cmd(cmd):
202 '''called on a unknown command'''
203 from samba_wildcard import run_named_build_task
204 run_named_build_task(cmd)
206 def main():
207 from samba_wildcard import wildcard_main
208 wildcard_main(wildcard_cmd)
209 Scripting.main = main
211 def reconfigure(ctx):
212 '''reconfigure if config scripts have changed'''
213 import samba_utils
214 samba_utils.reconfigure(ctx)