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