9 import sys
, os
, tempfile
10 sys
.path
.insert(0, srcdir
+"/buildtools/wafsamba")
11 import wafsamba
, Options
, samba_dist
, samba_git
, Scripting
, Utils
, samba_version
12 import Logs
, samba_utils
15 samba_dist
.DIST_DIRS('.')
16 samba_dist
.DIST_BLACKLIST('.gitignore .bzrignore source4/selftest/provisions')
18 # install in /usr/local/samba by default
19 default_prefix
= Options
.default_prefix
= '/usr/local/samba'
21 # This callback optionally takes a list of paths as arguments:
22 # --with-system_mitkrb5 /path/to/krb5 /another/path
23 def system_mitkrb5_callback(option
, opt
, value
, parser
):
24 setattr(parser
.values
, option
.dest
, True)
26 for arg
in parser
.rargs
:
27 # stop on --foo like options
28 if arg
[:2] == "--" and len(arg
) > 2:
32 del parser
.rargs
[:len(value
)]
33 setattr(parser
.values
, option
.dest
, value
)
36 opt
.BUILTIN_DEFAULT('NONE')
37 opt
.PRIVATE_EXTENSION_DEFAULT('samba4')
38 opt
.RECURSE('lib/replace')
39 opt
.RECURSE('dynconfig')
40 opt
.RECURSE('lib/ldb')
41 opt
.RECURSE('selftest')
42 opt
.RECURSE('source4/lib/tls')
43 opt
.RECURSE('source4/dsdb/samdb/ldb_modules')
45 opt
.RECURSE('source3')
46 opt
.RECURSE('lib/util')
48 opt
.samba_add_onoff_option('pthreadpool', with_name
="enable", without_name
="disable", default
=True)
50 opt
.add_option('--with-system-mitkrb5',
51 help='build Samba with system MIT Kerberos. ' +
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)
54 opt
.add_option('--with-system-mitkdc',
55 help=('Specify the path to the krb5kdc binary from MIT Kerberos'),
57 dest
='with_system_mitkdc',
60 opt
.add_option('--without-ad-dc',
61 help='disable AD DC functionality (enables only Samba FS (File Server, Winbind, NMBD) and client utilities.',
62 action
='store_true', dest
='without_ad_dc', default
=False)
64 opt
.add_option('--with-ntvfs-fileserver',
65 help='enable the depricated NTVFS file server from the original Samba4 branch (default if --enable-selftest specicifed). Conflicts with --with-system-mitkrb5 and --without-ad-dc',
66 action
='store_true', dest
='with_ntvfs_fileserver')
68 opt
.add_option('--without-ntvfs-fileserver',
69 help='disable the depricated NTVFS file server from the original Samba4 branch',
70 action
='store_false', dest
='with_ntvfs_fileserver')
72 opt
.add_option('--with-pie',
73 help=("Build Position Independent Executables " +
74 "(default if supported by compiler)"),
75 action
="store_true", dest
='enable_pie')
76 opt
.add_option('--without-pie',
77 help=("Disable Position Independent Executable builds"),
78 action
="store_false", dest
='enable_pie')
80 opt
.add_option('--with-relro',
81 help=("Build with full RELocation Read-Only (RELRO)" +
82 "(default if supported by compiler)"),
83 action
="store_true", dest
='enable_relro')
84 opt
.add_option('--without-relro',
85 help=("Disable RELRO builds"),
86 action
="store_false", dest
='enable_relro')
88 gr
= opt
.option_group('developer options')
90 opt
.tool_options('python') # options for disabling pyc or pyo compilation
91 # enable options related to building python extensions
95 version
= samba_version
.load_version(env
=conf
.env
)
97 conf
.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
98 conf
.DEFINE('_SAMBA_BUILD_', version
.MAJOR
, add_to_cflags
=True)
99 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
101 if Options
.options
.developer
:
102 conf
.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
103 conf
.env
.DEVELOPER
= True
105 conf
.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')
107 conf
.env
.replace_add_global_pthread
= True
108 conf
.RECURSE('lib/replace')
110 conf
.RECURSE('examples/fuse')
112 conf
.SAMBA_CHECK_PERL(mandatory
=True)
113 conf
.find_program('xsltproc', var
='XSLTPROC')
115 if conf
.env
.disable_python
:
116 if not (Options
.options
.without_ad_dc
):
117 raise Utils
.WafError('--disable-python requires --without-ad-dc')
119 conf
.SAMBA_CHECK_PYTHON(mandatory
=True, version
=(2, 6, 0))
120 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=(not conf
.env
.disable_python
))
122 if sys
.platform
== 'darwin' and not conf
.env
['HAVE_ENVIRON_DECL']:
123 # Mac OSX needs to have this and it's also needed that the python is compiled with this
124 # otherwise you face errors about common symbols
125 if not conf
.CHECK_SHLIB_W_PYTHON("Checking if -fno-common is needed"):
126 conf
.ADD_CFLAGS('-fno-common')
127 if not conf
.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
128 conf
.env
.append_value('shlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
130 if sys
.platform
== 'darwin':
131 conf
.ADD_LDFLAGS('-framework CoreFoundation')
133 if int(conf
.env
['PYTHON_VERSION'][0]) >= 3:
134 raise Utils
.WafError('Python version 3.x is not supported by Samba yet')
136 conf
.RECURSE('dynconfig')
138 if conf
.CHECK_FOR_THIRD_PARTY():
139 conf
.RECURSE('third_party')
141 if not conf
.CHECK_ZLIB():
142 raise Utils
.WafError('zlib development packages have not been found.\nIf third_party is installed, check that it is in the proper place.')
144 conf
.define('USING_SYSTEM_ZLIB',1)
146 if not conf
.CHECK_POPT():
147 raise Utils
.WafError('popt development packages have not been found.\nIf third_party is installed, check that it is in the proper place.')
149 conf
.define('USING_SYSTEM_POPT', 1)
151 if not conf
.CHECK_CMOCKA():
152 raise Utils
.WafError('cmocka development packages has not been found.\nIf third_party is installed, check that it is in the proper place.')
154 conf
.define('USING_SYSTEM_CMOCKA', 1)
157 conf
.RECURSE('lib/ldb')
159 if not (Options
.options
.without_ad_dc
):
160 conf
.DEFINE('AD_DC_BUILD_IS_ENABLED', 1)
162 if Options
.options
.with_system_mitkrb5
:
163 conf
.PROCESS_SEPARATE_RULE('system_mitkrb5')
164 if not (Options
.options
.without_ad_dc
or Options
.options
.with_system_mitkrb5
):
165 conf
.DEFINE('AD_DC_BUILD_IS_ENABLED', 1)
167 # Only process heimdal_build for non-MIT KRB5 builds
168 # When MIT KRB5 checks are done as above, conf.env.KRB5_VENDOR will be set
169 # to the lowcased output of 'krb5-config --vendor'.
170 # If it is not set or the output is 'heimdal', we are dealing with
171 # system-provided or embedded Heimdal build
172 if conf
.CONFIG_GET('KRB5_VENDOR') in (None, 'heimdal'):
173 conf
.RECURSE('source4/heimdal_build')
174 conf
.RECURSE('source4/lib/tls')
175 conf
.RECURSE('source4/dsdb/samdb/ldb_modules')
176 conf
.RECURSE('source4/ntvfs/sysdep')
177 conf
.RECURSE('lib/util')
178 conf
.RECURSE('lib/util/charset')
179 conf
.RECURSE('source4/auth')
180 conf
.RECURSE('nsswitch')
181 conf
.RECURSE('libcli/smbreadline')
182 conf
.RECURSE('lib/crypto')
184 conf
.RECURSE('selftest')
185 if conf
.CONFIG_GET('ENABLE_SELFTEST'):
186 conf
.RECURSE('lib/nss_wrapper')
187 conf
.RECURSE('lib/resolv_wrapper')
188 conf
.RECURSE('lib/socket_wrapper')
189 conf
.RECURSE('lib/uid_wrapper')
190 if Options
.options
.with_pam
:
191 conf
.RECURSE('lib/pam_wrapper')
192 if Options
.options
.with_ntvfs_fileserver
!= False:
193 if not (Options
.options
.without_ad_dc
):
194 conf
.DEFINE('WITH_NTVFS_FILESERVER', 1)
195 if Options
.options
.with_ntvfs_fileserver
== False:
196 if not (Options
.options
.without_ad_dc
):
197 raise Utils
.WafError('--without-ntvfs-fileserver conflicts with --enable-selftest while building the AD DC')
199 if Options
.options
.with_ntvfs_fileserver
== True:
200 if Options
.options
.without_ad_dc
:
201 raise Utils
.WafError('--with-ntvfs-fileserver conflicts with --without-ad-dc')
202 conf
.DEFINE('WITH_NTVFS_FILESERVER', 1)
204 if Options
.options
.with_pthreadpool
:
205 if conf
.CONFIG_SET('HAVE_PTHREAD'):
206 conf
.DEFINE('WITH_PTHREADPOOL', '1')
208 Logs
.warn("pthreadpool support cannot be enabled when pthread support was not found")
209 conf
.undefine('WITH_PTHREADPOOL')
211 conf
.RECURSE('source3')
212 conf
.RECURSE('lib/texpect')
213 if conf
.env
.with_ctdb
:
215 conf
.RECURSE('lib/socket')
216 conf
.RECURSE('testsuite/unittests')
219 conf
.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
221 # gentoo always adds this. We want our normal build to be as
222 # strict as the strictest OS we support, so adding this here
223 # allows us to find problems on our development hosts faster.
224 # It also results in faster load time.
226 conf
.env
.asneeded_ldflags
= conf
.ADD_LDFLAGS('-Wl,--as-needed', testflags
=True)
228 if not conf
.CHECK_NEED_LC("-lc not needed"):
229 conf
.ADD_LDFLAGS('-lc', testflags
=False)
231 if not conf
.CHECK_CODE('#include "tests/summary.c"',
232 define
='SUMMARY_PASSES',
234 msg
='Checking configure summary'):
235 raise Utils
.WafError('configure summary failed')
237 if Options
.options
.enable_pie
!= False:
238 if Options
.options
.enable_pie
== True:
241 # not specified, only build PIEs if supported by compiler
243 if conf
.check_cc(cflags
='-fPIE', ldflags
='-pie', mandatory
=need_pie
,
244 msg
="Checking compiler for PIE support"):
245 conf
.env
['ENABLE_PIE'] = True
247 if Options
.options
.enable_relro
!= False:
248 if Options
.options
.enable_relro
== True:
251 # not specified, only build RELROs if supported by compiler
253 if conf
.check_cc(cflags
='', ldflags
='-Wl,-z,relro,-z,now', mandatory
=need_relro
,
254 msg
="Checking compiler for full RELRO support"):
255 conf
.env
['ENABLE_RELRO'] = True
257 conf
.SAMBA_CONFIG_H('include/config.h')
260 '''build TAGS file using etags'''
262 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
263 cmd
= 'rm -f %s/TAGS && (find %s -name "*.[ch]" | egrep -v \.inst\. | xargs -n 100 etags -a)' % (source_root
, source_root
)
264 print("Running: %s" % cmd
)
265 status
= os
.system(cmd
)
266 if os
.WEXITSTATUS(status
):
267 raise Utils
.WafError('etags failed')
270 "build 'tags' file using ctags"
272 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
273 cmd
= 'ctags --python-kinds=-i $(find %s -name "*.[ch]" | grep -v "*_proto\.h" | egrep -v \.inst\.) $(find %s -name "*.py")' % (source_root
, source_root
)
274 print("Running: %s" % cmd
)
275 status
= os
.system(cmd
)
276 if os
.WEXITSTATUS(status
):
277 raise Utils
.WafError('ctags failed')
280 # putting this here enabled build in the list
281 # of commands in --help
283 '''build all targets'''
284 samba_version
.load_version(env
=bld
.env
, is_install
=bld
.is_install
)
288 '''build python apidocs'''
289 bp
= os
.path
.abspath('bin/python')
291 modules
= ['talloc', 'tdb', 'ldb']
293 f
= os
.popen("PYTHONPATH=%s python -c 'import %s; print %s.__file__'" % (bp
, m
, m
), 'r')
295 mpaths
[m
] = f
.read().strip()
299 cmd
= ('PYTHONPATH=%(main)s pydoctor --introspect-c-modules --project-name=Samba '
300 '--project-url=http://www.samba.org --make-html --docformat=restructuredtext '
301 '--add-package bin/python/samba ' + ''.join('--add-module %s ' % n
for n
in modules
))
303 print("Running: %s" % cmd
)
304 status
= os
.system(cmd
)
305 if os
.WEXITSTATUS(status
):
306 raise Utils
.WafError('pydoctor failed')
310 '''run pep8 validator'''
311 cmd
='PYTHONPATH=bin/python pep8 -r bin/python/samba'
312 print("Running: %s" % cmd
)
313 status
= os
.system(cmd
)
314 if os
.WEXITSTATUS(status
):
315 raise Utils
.WafError('pep8 failed')
319 '''build wafsamba apidocs'''
320 from samba_utils
import recursive_dirlist
322 list = recursive_dirlist('../buildtools/wafsamba', '.', pattern
='*.py')
324 cmd
='PYTHONPATH=bin/python pydoctor --project-name=wafsamba --project-url=http://www.samba.org --make-html --docformat=restructuredtext'
327 cmd
+= ' --add-module %s' % f
328 print("Running: %s" % cmd
)
329 status
= os
.system(cmd
)
330 if os
.WEXITSTATUS(status
):
331 raise Utils
.WafError('wafdocs failed')
335 '''makes a tarball for distribution'''
336 sambaversion
= samba_version
.load_version(env
=None)
338 os
.system("make -C ctdb manpages")
339 samba_dist
.DIST_FILES('ctdb/doc:ctdb/doc', extend
=True)
341 os
.system(srcdir
+ "/release-scripts/build-manpages-nogit")
342 samba_dist
.DIST_FILES('bin/docs:docs', extend
=True)
344 if sambaversion
.IS_SNAPSHOT
:
345 # write .distversion file and add to tar
346 if not os
.path
.isdir(blddir
):
348 distversionf
= tempfile
.NamedTemporaryFile(mode
='w', prefix
='.distversion',dir=blddir
)
349 for field
in sambaversion
.vcs_fields
:
350 distveroption
= field
+ '=' + str(sambaversion
.vcs_fields
[field
])
351 distversionf
.write(distveroption
+ '\n')
353 samba_dist
.DIST_FILES('%s:.distversion' % distversionf
.name
, extend
=True)
362 '''test that distribution tarball builds and installs'''
363 samba_version
.load_version(env
=None)
365 d
= Scripting
.distcheck
368 def wildcard_cmd(cmd
):
369 '''called on a unknown command'''
370 from samba_wildcard
import run_named_build_task
371 run_named_build_task(cmd
)
374 from samba_wildcard
import wildcard_main
376 wildcard_main(wildcard_cmd
)
377 Scripting
.main
= main
379 def reconfigure(ctx
):
380 '''reconfigure if config scripts have changed'''
382 samba_utils
.reconfigure(ctx
)
385 if os
.path
.isdir(os
.path
.join(srcdir
, ".git")):
386 # Check if there are submodules that are checked out but out of date.
387 for submodule
, status
in samba_git
.read_submodule_status(srcdir
):
388 if status
== "out-of-date":
389 raise Utils
.WafError("some submodules are out of date. Please run 'git submodule update'")