9 import sys
, os
, tempfile
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 source4/selftest/provisions/alpha13 source4/selftest/provisions/release-4-0-0/')
17 # install in /usr/local/samba by default
18 Options
.default_prefix
= '/usr/local/samba'
20 # This callback optionally takes a list of paths as arguments:
21 # --with-system_mitkrb5 /path/to/krb5 /another/path
22 def system_mitkrb5_callback(option
, opt
, value
, parser
):
23 setattr(parser
.values
, option
.dest
, True)
25 for arg
in parser
.rargs
:
26 # stop on --foo like options
27 if arg
[:2] == "--" and len(arg
) > 2:
31 del parser
.rargs
[:len(value
)]
32 setattr(parser
.values
, option
.dest
, value
)
35 opt
.BUILTIN_DEFAULT('NONE')
36 opt
.PRIVATE_EXTENSION_DEFAULT('samba4')
37 opt
.RECURSE('lib/replace')
38 opt
.RECURSE('dynconfig')
39 opt
.RECURSE('lib/ldb')
40 opt
.RECURSE('lib/ntdb')
41 opt
.RECURSE('selftest')
42 opt
.RECURSE('source4/lib/tls')
43 opt
.RECURSE('lib/nss_wrapper')
44 opt
.RECURSE('lib/socket_wrapper')
45 opt
.RECURSE('lib/uid_wrapper')
47 opt
.RECURSE('source3')
48 opt
.RECURSE('lib/util')
50 opt
.add_option('--with-system-mitkrb5',
51 help='enable system MIT krb5 build (includes Samba 4 client and Samba 3 code base).'+
52 'You may specify list of paths where Kerberos is installed (e.g. /usr/local /usr/kerberos) to search krb5-config',
53 action
='callback', callback
=system_mitkrb5_callback
, dest
='with_system_mitkrb5', default
=False)
55 opt
.add_option('--without-ad-dc',
56 help='disable AD DC functionality (enables Samba 4 client and Samba 3 code base).',
57 action
='store_true', dest
='without_ad_dc', default
=False)
59 opt
.add_option('--with-pie',
60 help=("Build Position Independent Executables (default)"),
61 action
="store_true", dest
='enable_pie', default
=True)
62 opt
.add_option('--without-pie',
63 help=("Disable Position Independent Executable builds"),
64 action
="store_false", dest
='enable_pie')
66 gr
= opt
.option_group('developer options')
68 opt
.add_option('--disable-ntdb',
69 help=("disable ntdb"),
70 action
="store_true", dest
='disable_ntdb', default
=True)
73 opt
.tool_options('python') # options for disabling pyc or pyo compilation
74 # enable options related to building python extensions
78 version
= samba_version
.load_version(env
=conf
.env
)
80 conf
.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
81 conf
.DEFINE('_SAMBA_BUILD_', version
.MAJOR
, add_to_cflags
=True)
82 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
84 if Options
.options
.developer
:
85 conf
.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
86 conf
.env
.DEVELOPER
= True
88 conf
.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')
90 conf
.RECURSE('lib/replace')
92 conf
.find_program('perl', var
='PERL', mandatory
=True)
93 conf
.find_program('xsltproc', var
='XSLTPROC')
95 conf
.SAMBA_CHECK_PYTHON(mandatory
=True)
96 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=True)
98 if sys
.platform
== 'darwin' and not conf
.env
['HAVE_ENVIRON_DECL']:
99 # Mac OSX needs to have this and it's also needed that the python is compiled with this
100 # otherwise you face errors about common symbols
101 if not conf
.CHECK_SHLIB_W_PYTHON("Checking if -fno-common is needed"):
102 conf
.ADD_CFLAGS('-fno-common')
103 if not conf
.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
104 conf
.env
.append_value('shlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
106 if sys
.platform
== 'darwin':
107 conf
.ADD_LDFLAGS('-framework CoreFoundation')
109 if int(conf
.env
['PYTHON_VERSION'][0]) >= 3:
110 raise Utils
.WafError('Python version 3.x is not supported by Samba yet')
112 conf
.RECURSE('dynconfig')
113 conf
.RECURSE('lib/ldb')
115 if Options
.options
.with_system_mitkrb5
:
116 conf
.PROCESS_SEPARATE_RULE('system_mitkrb5')
117 if not (Options
.options
.without_ad_dc
or Options
.options
.with_system_mitkrb5
):
118 conf
.DEFINE('AD_DC_BUILD_IS_ENABLED', 1)
119 # Only process heimdal_build for non-MIT KRB5 builds
120 # When MIT KRB5 checks are done as above, conf.env.KRB5_VENDOR will be set
121 # to the lowcased output of 'krb5-config --vendor'.
122 # If it is not set or the output is 'heimdal', we are dealing with
123 # system-provided or embedded Heimdal build
124 if conf
.CONFIG_GET('KRB5_VENDOR') in (None, 'heimdal'):
125 conf
.RECURSE('source4/heimdal_build')
126 conf
.RECURSE('source4/lib/tls')
127 conf
.RECURSE('source4/ntvfs/sysdep')
128 conf
.RECURSE('lib/util')
129 conf
.RECURSE('lib/ccan')
130 conf
.env
.disable_ntdb
= getattr(Options
.options
, 'disable_ntdb', False)
131 if not Options
.options
.disable_ntdb
:
132 conf
.RECURSE('lib/ntdb')
134 conf
.DEFINE('DISABLE_NTDB', 1)
135 conf
.RECURSE('lib/zlib')
136 conf
.RECURSE('lib/util/charset')
137 conf
.RECURSE('source4/auth')
138 conf
.RECURSE('lib/nss_wrapper')
139 conf
.RECURSE('nsswitch')
140 conf
.RECURSE('lib/socket_wrapper')
141 conf
.RECURSE('lib/uid_wrapper')
142 conf
.RECURSE('lib/popt')
143 conf
.RECURSE('lib/iniparser/src')
144 conf
.RECURSE('lib/subunit/c')
145 conf
.RECURSE('libcli/smbreadline')
146 conf
.RECURSE('lib/crypto')
148 conf
.RECURSE('selftest')
149 conf
.RECURSE('source3')
151 conf
.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
153 # gentoo always adds this. We want our normal build to be as
154 # strict as the strictest OS we support, so adding this here
155 # allows us to find problems on our development hosts faster.
156 # It also results in faster load time.
158 if not sys
.platform
.startswith("openbsd"):
159 conf
.env
.asneeded_ldflags
= conf
.ADD_LDFLAGS('-Wl,--as-needed', testflags
=True)
161 if not conf
.CHECK_NEED_LC("-lc not needed"):
162 conf
.ADD_LDFLAGS('-lc', testflags
=False)
164 # we don't want PYTHONDIR in config.h, as otherwise changing
165 # --prefix causes a complete rebuild
166 del(conf
.env
.defines
['PYTHONDIR'])
167 del(conf
.env
.defines
['PYTHONARCHDIR'])
169 if not conf
.CHECK_CODE('#include "tests/summary.c"',
170 define
='SUMMARY_PASSES',
173 msg
='Checking configure summary'):
174 raise Utils
.WafError('configure summary failed')
176 conf
.SAMBA_CONFIG_H('include/config.h')
178 if Options
.options
.enable_pie
== True:
179 conf
.check_cc(cflags
='-fPIE', ldflags
='-pie', mandatory
=True,
180 msg
="Checking compiler for PIE support")
181 conf
.env
['ENABLE_PIE'] = True
184 '''build TAGS file using etags'''
186 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
187 cmd
= 'rm -f %s/TAGS && (find %s -name "*.[ch]" | egrep -v \.inst\. | xargs -n 100 etags -a)' % (source_root
, source_root
)
188 print("Running: %s" % cmd
)
192 "build 'tags' file using ctags"
194 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
195 cmd
= 'ctags --python-kinds=-i $(find %s -name "*.[ch]" | grep -v "*_proto\.h" | egrep -v \.inst\.) $(find %s -name "*.py")' % (source_root
, source_root
)
196 print("Running: %s" % cmd
)
199 # putting this here enabled build in the list
200 # of commands in --help
202 '''build all targets'''
203 samba_version
.load_version(env
=bld
.env
, is_install
=bld
.is_install
)
208 '''build python apidocs'''
209 bp
= os
.path
.abspath('bin/python')
211 for m
in ['talloc', 'tdb', 'ldb', 'ntdb']:
212 f
= os
.popen("PYTHONPATH=%s python -c 'import %s; print %s.__file__'" % (bp
, m
, m
), 'r')
214 mpaths
[m
] = f
.read().strip()
217 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' % (
218 bp
, mpaths
['tdb'], mpaths
['ldb'], mpaths
['talloc'], mpaths
['ntdb'])
219 print("Running: %s" % cmd
)
224 '''run pep8 validator'''
225 cmd
='PYTHONPATH=bin/python pep8 -r bin/python/samba'
226 print("Running: %s" % cmd
)
231 '''build wafsamba apidocs'''
232 from samba_utils
import recursive_dirlist
234 list = recursive_dirlist('../buildtools/wafsamba', '.', pattern
='*.py')
236 cmd
='PYTHONPATH=bin/python pydoctor --project-name=wafsamba --project-url=http://www.samba.org --make-html --docformat=restructuredtext'
239 cmd
+= ' --add-module %s' % f
240 print("Running: %s" % cmd
)
245 '''makes a tarball for distribution'''
246 sambaversion
= samba_version
.load_version(env
=None)
248 os
.system(srcdir
+ "/release-scripts/build-manpages-nogit")
249 samba_dist
.DIST_FILES('bin/docs:docs', extend
=True)
251 os
.system(srcdir
+ "/source3/autogen.sh")
252 samba_dist
.DIST_FILES('source3/configure', extend
=True)
253 samba_dist
.DIST_FILES('source3/autoconf', extend
=True)
254 samba_dist
.DIST_FILES('source3/include/autoconf', extend
=True)
255 samba_dist
.DIST_FILES('examples/VFS/configure', extend
=True)
256 samba_dist
.DIST_FILES('examples/VFS/module_config.h.in', extend
=True)
258 if sambaversion
.IS_SNAPSHOT
:
259 # write .distversion file and add to tar
260 if not os
.path
.isdir(blddir
):
262 distversionf
= tempfile
.NamedTemporaryFile(mode
='w', prefix
='.distversion',dir=blddir
)
263 for field
in sambaversion
.vcs_fields
:
264 distveroption
= field
+ '=' + str(sambaversion
.vcs_fields
[field
])
265 distversionf
.write(distveroption
+ '\n')
267 samba_dist
.DIST_FILES('%s:.distversion' % distversionf
.name
, extend
=True)
276 '''test that distribution tarball builds and installs'''
277 samba_version
.load_version(env
=None)
279 d
= Scripting
.distcheck
282 def wildcard_cmd(cmd
):
283 '''called on a unknown command'''
284 from samba_wildcard
import run_named_build_task
285 run_named_build_task(cmd
)
288 from samba_wildcard
import wildcard_main
289 wildcard_main(wildcard_cmd
)
290 Scripting
.main
= main
292 def reconfigure(ctx
):
293 '''reconfigure if config scripts have changed'''
295 samba_utils
.reconfigure(ctx
)