s4-waf: Look for xsltproc executable, required to build manpages.
[amitay/samba.git] / source4 / wscript
1 #! /usr/bin/env python
2
3 srcdir = '..'
4 blddir = 'bin'
5
6 APPNAME='samba'
7
8 import sys, os
9 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
10 import wafsamba, Options, samba_dist, Scripting
11
12 version = wafsamba.samba_version_file("./VERSION")
13
14 VERSION=version.STRING
15
16 samba_dist.DIST_DIRS('.')
17
18 #This is a list of files that we don't want in the package, for
19 #whatever reason.  Directories should be listed with a trailing / to
20 #avoid over-exclusion.
21
22 #This list includes files that would confuse the recipient of a
23 #samba-4.0.0 branded tarball (until the merge is complete) and the
24 #core elements of the autotools build system (which is known to
25 #produce buggy binaries).
26 samba_dist.DIST_BLACKLIST('README Manifest Read-Manifest-Now Roadmap source3/ ' +
27                           'packaging/ docs-xml/ examples/ swat/ WHATSNEW.txt MAINTAINERS ' +
28                           'source4/autogen-autotools.sh source4/Makefile.in source4/configure.ac')
29 # install in /usr/local/samba by default
30 Options.default_prefix = '/usr/local/samba'
31
32
33 def set_options(opt):
34     opt.BUILTIN_DEFAULT('NONE')
35     opt.BUNDLED_EXTENSION_DEFAULT('samba4')
36     opt.RECURSE('../lib/replace')
37     opt.RECURSE('dynconfig')
38     opt.RECURSE('scripting/python')
39     opt.RECURSE('lib/ldb')
40     opt.RECURSE('selftest')
41     opt.RECURSE('lib/tls')
42     opt.RECURSE('../lib/nss_wrapper')
43     opt.RECURSE('../lib/socket_wrapper')
44     opt.RECURSE('../lib/uid_wrapper')
45     opt.RECURSE('../pidl')
46
47     gr = opt.option_group('developer options')
48     gr.add_option('--enable-build-farm',
49                    help='enable special build farm options',
50                    action='store_true', dest='BUILD_FARM')
51
52
53 def configure(conf):
54     conf.DEFINE('PACKAGE_NAME', 'samba', quote=True)
55     conf.DEFINE('PACKAGE_STRING', 'Samba ' + version.STRING, quote=True)
56     conf.DEFINE('PACKAGE_TARNAME',  'samba', quote=True)
57     conf.DEFINE('PACKAGE_URL', "http://www.samba.org/", quote=True)
58     conf.DEFINE('PACKAGE_VERSION', version.STRING, quote=True)
59     conf.DEFINE('PACKAGE_BUGREPORT', 'http://bugzilla.samba.org/', quote=True)
60
61     conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
62     conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True)
63     conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
64
65     if Options.options.developer:
66         conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
67
68     # this enables smbtorture.static for s3 in the build farm
69     conf.env.BUILD_FARM = Options.options.BUILD_FARM or os.environ.get('RUN_FROM_BUILD_FARM')
70
71     # set a lower limit on recursing in waf preprocessor
72     conf.env.preprocessor_recursion_limit = 10
73
74     conf.ADD_EXTRA_INCLUDES('#source4 #lib #source4/lib #source4/include')
75
76     conf.RECURSE('../lib/replace')
77
78     conf.find_program('python', var='PYTHON', mandatory=True)
79     conf.find_program('perl', var='PERL', mandatory=True)
80     conf.find_program('xsltproc', var='XSLTPROC')
81
82     # enable tool to build python extensions
83     conf.check_tool('python')
84     conf.check_python_version((2,4,2))
85     conf.check_python_headers(mandatory=True)
86
87     conf.RECURSE('dynconfig')
88     conf.RECURSE('scripting/python')
89     conf.RECURSE('lib/ldb')
90     conf.RECURSE('heimdal_build')
91     conf.RECURSE('lib/tls')
92     conf.RECURSE('ntvfs/sysdep')
93     conf.RECURSE('../lib/util')
94     conf.RECURSE('../lib/zlib')
95     conf.RECURSE('../lib/util/charset')
96     conf.RECURSE('auth')
97     conf.RECURSE('../lib/nss_wrapper')
98     conf.RECURSE('../nsswitch')
99     conf.RECURSE('../lib/socket_wrapper')
100     conf.RECURSE('../lib/uid_wrapper')
101     conf.RECURSE('../lib/popt')
102     conf.RECURSE('lib/smbreadline')
103     conf.RECURSE('../pidl')
104     conf.RECURSE('selftest')
105
106     # we don't want PYTHONDIR in config.h, as otherwise changing
107     # --prefix causes a complete rebuild
108     del(conf.env.defines['PYTHONDIR'])
109     conf.SAMBA_CONFIG_H('include/config.h')
110
111
112 def etags(ctx):
113     '''build TAGS file using etags'''
114     import Utils
115     source_root = os.path.dirname(Utils.g_module.root_path)
116     cmd = 'etags $(find %s/.. -name "*.[ch]")' % source_root
117     print("Running: %s" % cmd)
118     os.system(cmd)
119
120 def ctags(ctx):
121     "build 'tags' file using ctags"
122     import Utils
123     source_root = os.path.dirname(Utils.g_module.root_path)
124     cmd = 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
125     print("Running: %s" % cmd)
126     os.system(cmd)
127
128 # putting this here enabled build in the list
129 # of commands in --help
130 def build(bld):
131     '''build all targets'''
132     pass
133
134
135 def pydoctor(ctx):
136     '''build python apidocs'''
137     cmd='LD_LIBRARY_PATH=bin/shared PYTHONPATH=bin/python pydoctor --project-name=Samba --project-url=http://www.samba.org --make-html --docformat=restructuredtext --add-package bin/python/samba'
138     print("Running: %s" % cmd)
139     os.system(cmd)
140
141 def wafdocs(ctx):
142     '''build wafsamba apidocs'''
143     from samba_utils import recursive_dirlist
144     os.system('pwd')
145     list = recursive_dirlist('../buildtools/wafsamba', '.', pattern='*.py')
146
147     cmd='LD_LIBRARY_PATH=bin/shared PYTHONPATH=bin/python pydoctor --project-name=wafsamba --project-url=http://www.samba.org --make-html --docformat=restructuredtext'
148     print(list)
149     for f in list:
150         cmd += ' --add-module %s' % f
151     print("Running: %s" % cmd)
152     os.system(cmd)
153
154
155 def dist():
156     '''makes a tarball for distribution'''
157     samba_dist.dist()
158
159 def distcheck():
160     '''test that distribution tarball builds and installs'''
161     import Scripting
162     d = Scripting.distcheck
163     d(subdir='source4')
164
165 def wildcard_cmd(cmd):
166     '''called on a unknown command'''
167     from samba_wildcard import run_named_build_task
168     run_named_build_task(cmd)
169
170 def main():
171     from samba_wildcard import wildcard_main
172     wildcard_main(wildcard_cmd)
173 Scripting.main = main
174
175 def reconfigure(ctx):
176     '''reconfigure if config scripts have changed'''
177     import samba_utils
178     samba_utils.reconfigure(ctx)