smbprinting: fix wrong == in shell tests
[Samba/gebeck_regimport.git] / source4 / wscript
blob48f340cf09bf82163c6ead046429796b8c308771
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
14 def load_version(env=None):
15 '''load samba versions either from ./VERSION or git
16 return a version object for detailed breakdown'''
17 import samba_utils, Utils
18 if not env:
19 env = samba_utils.LOAD_ENVIRONMENT()
21 version = wafsamba.samba_version_file("./VERSION", "..", env)
22 Utils.g_module.VERSION = version.STRING
23 return version
26 samba_dist.DIST_DIRS('.')
28 #This is a list of files that we don't want in the package, for
29 #whatever reason. Directories should be listed with a trailing / to
30 #avoid over-exclusion.
32 #This list includes files that would confuse the recipient of a
33 #samba-4.0.0 branded tarball (until the merge is complete) and the
34 #core elements of the autotools build system (which is known to
35 #produce buggy binaries).
36 samba_dist.DIST_BLACKLIST('README Manifest Read-Manifest-Now Roadmap source3/ ' +
37 'packaging/ docs-xml/ examples/ swat/ WHATSNEW.txt MAINTAINERS ' +
38 'source4/autogen-autotools.sh source4/Makefile.in source4/configure.ac')
39 # install in /usr/local/samba by default
40 Options.default_prefix = '/usr/local/samba'
43 def set_options(opt):
44 opt.BUILTIN_DEFAULT('NONE')
45 opt.PRIVATE_EXTENSION_DEFAULT('samba4')
46 opt.RECURSE('../lib/replace')
47 opt.RECURSE('dynconfig')
48 opt.RECURSE('scripting/python')
49 opt.RECURSE('lib/ldb')
50 opt.RECURSE('selftest')
51 opt.RECURSE('lib/tls')
52 opt.RECURSE('../lib/nss_wrapper')
53 opt.RECURSE('../lib/socket_wrapper')
54 opt.RECURSE('../lib/uid_wrapper')
55 opt.RECURSE('../pidl')
57 gr = opt.option_group('developer options')
58 gr.add_option('--enable-build-farm',
59 help='enable special build farm options',
60 action='store_true', dest='BUILD_FARM')
63 def configure(conf):
64 version = load_version(env=conf.env)
66 conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
67 conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True)
68 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
70 if Options.options.developer:
71 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
73 # this enables smbtorture.static for s3 in the build farm
74 conf.env.BUILD_FARM = Options.options.BUILD_FARM or os.environ.get('RUN_FROM_BUILD_FARM')
76 conf.ADD_EXTRA_INCLUDES('#source4 #lib #source4/lib #source4/include')
78 conf.RECURSE('../lib/replace')
80 conf.find_program('python', var='PYTHON', mandatory=True)
81 conf.find_program('perl', var='PERL', mandatory=True)
82 conf.find_program('xsltproc', var='XSLTPROC')
84 # enable tool to build python extensions
85 conf.check_tool('python')
86 conf.check_python_version((2,4,2))
87 conf.check_python_headers(mandatory=True)
89 if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']:
90 # Mac OSX needs to have this and it's also needed that the python is compiled with this
91 # otherwise you face errors about common symbols
92 if not conf.CHECK_SHLIB_W_PYTHON("Checking if -fno-common is needed"):
93 conf.ADD_CFLAGS('-fno-common')
94 if not conf.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
95 conf.env.append_value('shlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
96 if int(conf.env['PYTHON_VERSION'][0]) >= 3:
97 raise Utils.WafError('Python version 3.x is not supported by Samba yet')
99 conf.RECURSE('dynconfig')
100 conf.RECURSE('scripting/python')
101 conf.RECURSE('lib/ldb')
102 conf.RECURSE('heimdal_build')
103 conf.RECURSE('lib/tls')
104 conf.RECURSE('ntvfs/sysdep')
105 conf.RECURSE('../lib/util')
106 conf.RECURSE('../lib/zlib')
107 conf.RECURSE('../lib/util/charset')
108 conf.RECURSE('auth')
109 conf.RECURSE('../lib/nss_wrapper')
110 conf.RECURSE('../nsswitch')
111 conf.RECURSE('../lib/socket_wrapper')
112 conf.RECURSE('../lib/uid_wrapper')
113 conf.RECURSE('../lib/popt')
114 conf.RECURSE('../lib/subunit/c')
115 conf.RECURSE('../libcli/smbreadline')
116 conf.RECURSE('../pidl')
117 conf.RECURSE('selftest')
119 # we don't want any libraries or modules to rely on runtime
120 # resolution of symbols
121 conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
123 # gentoo always adds this. We want our normal build to be as
124 # strict as the strictest OS we support, so adding this here
125 # allows us to find problems on our development hosts faster.
126 # It also results in faster load time.
127 conf.ADD_LDFLAGS('-Wl,--as-needed', testflags=True)
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 conf.SAMBA_CONFIG_H('include/config.h')
135 def etags(ctx):
136 '''build TAGS file using etags'''
137 import Utils
138 source_root = os.path.dirname(Utils.g_module.root_path)
139 cmd = 'etags $(find %s/.. -name "*.[ch]" | egrep -v \.inst\.)' % source_root
140 print("Running: %s" % cmd)
141 os.system(cmd)
143 def ctags(ctx):
144 "build 'tags' file using ctags"
145 import Utils
146 source_root = os.path.dirname(Utils.g_module.root_path)
147 cmd = 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h" | egrep -v \.inst\.)' % source_root
148 print("Running: %s" % cmd)
149 os.system(cmd)
151 # putting this here enabled build in the list
152 # of commands in --help
153 def build(bld):
154 '''build all targets'''
155 load_version(env=bld.env)
156 pass
159 def pydoctor(ctx):
160 '''build python apidocs'''
161 cmd='PYTHONPATH=bin/python pydoctor --project-name=Samba --project-url=http://www.samba.org --make-html --docformat=restructuredtext --add-package bin/python/samba'
162 print("Running: %s" % cmd)
163 os.system(cmd)
165 def wafdocs(ctx):
166 '''build wafsamba apidocs'''
167 from samba_utils import recursive_dirlist
168 os.system('pwd')
169 list = recursive_dirlist('../buildtools/wafsamba', '.', pattern='*.py')
171 cmd='PYTHONPATH=bin/python pydoctor --project-name=wafsamba --project-url=http://www.samba.org --make-html --docformat=restructuredtext'
172 print(list)
173 for f in list:
174 cmd += ' --add-module %s' % f
175 print("Running: %s" % cmd)
176 os.system(cmd)
179 def dist():
180 '''makes a tarball for distribution'''
181 load_version(env=None)
182 samba_dist.dist()
184 def distcheck():
185 '''test that distribution tarball builds and installs'''
186 load_version(env=None)
187 import Scripting
188 d = Scripting.distcheck
189 d(subdir='source4')
191 def wildcard_cmd(cmd):
192 '''called on a unknown command'''
193 from samba_wildcard import run_named_build_task
194 run_named_build_task(cmd)
196 def main():
197 from samba_wildcard import wildcard_main
198 wildcard_main(wildcard_cmd)
199 Scripting.main = main
201 def reconfigure(ctx):
202 '''reconfigure if config scripts have changed'''
203 import samba_utils
204 samba_utils.reconfigure(ctx)