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'
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')
32 opt
.RECURSE('source3')
33 opt
.RECURSE('lib/util')
35 opt
.add_option('--with-system-mitkrb5',
36 help='enable system MIT krb5 build (includes Samba 4 client and Samba 3 code base)',
37 action
='store_true', dest
='with_system_mitkrb5', default
=False)
39 opt
.add_option('--without-ad-dc',
40 help='disable AD DC functionality (enables Samba 4 client and Samba 3 code base). Requires system MIT krb5',
41 action
='store_true', dest
='with_system_mitkrb5', default
=False)
43 gr
= opt
.option_group('developer options')
44 gr
.add_option('--enable-build-farm',
45 help='enable special build farm options',
46 action
='store_true', dest
='BUILD_FARM')
48 opt
.tool_options('python') # options for disabling pyc or pyo compilation
49 # enable options related to building python extensions
53 version
= samba_version
.load_version(env
=conf
.env
)
55 conf
.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
56 conf
.DEFINE('_SAMBA_BUILD_', version
.MAJOR
, add_to_cflags
=True)
57 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
59 if Options
.options
.developer
:
60 conf
.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
61 conf
.env
.DEVELOPER
= True
63 # this enables smbtorture.static for s3 in the build farm
64 conf
.env
.BUILD_FARM
= Options
.options
.BUILD_FARM
or os
.environ
.get('RUN_FROM_BUILD_FARM')
66 conf
.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')
68 conf
.RECURSE('lib/replace')
70 conf
.find_program('python', var
='PYTHON', mandatory
=True)
71 conf
.find_program('perl', var
='PERL', mandatory
=True)
72 conf
.find_program('xsltproc', var
='XSLTPROC')
74 # enable tool to build python extensions
75 conf
.check_tool('python')
76 conf
.check_python_version((2,4,2))
77 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=True)
79 if sys
.platform
== 'darwin' and not conf
.env
['HAVE_ENVIRON_DECL']:
80 # Mac OSX needs to have this and it's also needed that the python is compiled with this
81 # otherwise you face errors about common symbols
82 if not conf
.CHECK_SHLIB_W_PYTHON("Checking if -fno-common is needed"):
83 conf
.ADD_CFLAGS('-fno-common')
84 if not conf
.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
85 conf
.env
.append_value('shlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
87 if sys
.platform
== 'darwin':
88 conf
.ADD_LDFLAGS('-framework CoreFoundation')
90 if int(conf
.env
['PYTHON_VERSION'][0]) >= 3:
91 raise Utils
.WafError('Python version 3.x is not supported by Samba yet')
93 conf
.RECURSE('dynconfig')
94 conf
.RECURSE('lib/ldb')
96 if Options
.options
.with_system_mitkrb5
:
97 conf
.PROCESS_SEPARATE_RULE('system_mitkrb5')
99 conf
.DEFINE('AD_DC_BUILD_IS_ENABLED', 1)
100 # Only process heimdal_build for non-MIT KRB5 builds
101 # When MIT KRB5 checks are done as above, conf.env.KRB5_VENDOR will be set
102 # to the lowcased output of 'krb5-config --vendor'.
103 # If it is not set or the output is 'heimdal', we are dealing with
104 # system-provided or embedded Heimdal build
105 if conf
.CONFIG_GET('KRB5_VENDOR') in (None, 'heimdal'):
106 conf
.RECURSE('source4/heimdal_build')
107 conf
.RECURSE('source4/lib/tls')
108 conf
.RECURSE('source4/ntvfs/sysdep')
109 conf
.RECURSE('lib/util')
110 conf
.RECURSE('lib/ccan')
111 conf
.RECURSE('lib/zlib')
112 conf
.RECURSE('lib/util/charset')
113 conf
.RECURSE('source4/auth')
114 conf
.RECURSE('lib/nss_wrapper')
115 conf
.RECURSE('nsswitch')
116 conf
.RECURSE('lib/socket_wrapper')
117 conf
.RECURSE('lib/uid_wrapper')
118 conf
.RECURSE('lib/popt')
119 conf
.RECURSE('lib/iniparser/src')
120 conf
.RECURSE('lib/subunit/c')
121 conf
.RECURSE('libcli/smbreadline')
122 conf
.RECURSE('lib/crypto')
124 conf
.RECURSE('selftest')
125 conf
.RECURSE('source3')
126 conf
.RECURSE('lib/addns')
128 conf
.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
130 # gentoo always adds this. We want our normal build to be as
131 # strict as the strictest OS we support, so adding this here
132 # allows us to find problems on our development hosts faster.
133 # It also results in faster load time.
135 if sys
.platform
!= "openbsd4":
136 conf
.env
.asneeded_ldflags
= conf
.ADD_LDFLAGS('-Wl,--as-needed', testflags
=True)
138 if not conf
.CHECK_NEED_LC("-lc not needed"):
139 conf
.ADD_LDFLAGS('-lc', testflags
=False)
141 # we don't want PYTHONDIR in config.h, as otherwise changing
142 # --prefix causes a complete rebuild
143 del(conf
.env
.defines
['PYTHONDIR'])
144 del(conf
.env
.defines
['PYTHONARCHDIR'])
146 if not conf
.CHECK_CODE('#include "tests/summary.c"',
147 define
='SUMMARY_PASSES',
150 msg
='Checking configure summary'):
151 raise Utils
.WafError('configure summary failed')
153 conf
.SAMBA_CONFIG_H('include/config.h')
157 '''build TAGS file using etags'''
159 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
160 cmd
= 'etags $(find %s -name "*.[ch]" | egrep -v \.inst\.)' % source_root
161 print("Running: %s" % cmd
)
165 "build 'tags' file using ctags"
167 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
168 cmd
= 'ctags --python-kinds=-i $(find %s -name "*.[ch]" | grep -v "*_proto\.h" | egrep -v \.inst\.) $(find %s -name "*.py")' % (source_root
, source_root
)
169 print("Running: %s" % cmd
)
172 # putting this here enabled build in the list
173 # of commands in --help
175 '''build all targets'''
176 samba_version
.load_version(env
=bld
.env
, is_install
=bld
.is_install
)
181 '''build python apidocs'''
182 bp
= os
.path
.abspath('bin/python')
184 for m
in ['talloc', 'tdb', 'ldb']:
185 f
= os
.popen("PYTHONPATH=%s python -c 'import %s; print %s.__file__'" % (bp
, m
, m
), 'r')
187 mpaths
[m
] = f
.read().strip()
190 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' % (
191 bp
, mpaths
['tdb'], mpaths
['ldb'], mpaths
['talloc'])
192 print("Running: %s" % cmd
)
197 '''run pep8 validator'''
198 cmd
='PYTHONPATH=bin/python pep8 -r bin/python/samba'
199 print("Running: %s" % cmd
)
204 '''build wafsamba apidocs'''
205 from samba_utils
import recursive_dirlist
207 list = recursive_dirlist('../buildtools/wafsamba', '.', pattern
='*.py')
209 cmd
='PYTHONPATH=bin/python pydoctor --project-name=wafsamba --project-url=http://www.samba.org --make-html --docformat=restructuredtext'
212 cmd
+= ' --add-module %s' % f
213 print("Running: %s" % cmd
)
218 '''makes a tarball for distribution'''
219 samba_version
.load_version(env
=None)
223 '''test that distribution tarball builds and installs'''
224 samba_version
.load_version(env
=None)
226 d
= Scripting
.distcheck
229 def wildcard_cmd(cmd
):
230 '''called on a unknown command'''
231 from samba_wildcard
import run_named_build_task
232 run_named_build_task(cmd
)
235 from samba_wildcard
import wildcard_main
236 wildcard_main(wildcard_cmd
)
237 Scripting
.main
= main
239 def reconfigure(ctx
):
240 '''reconfigure if config scripts have changed'''
242 samba_utils
.reconfigure(ctx
)