build: introduce SAMBA_CHECK_PYTHON_HEADERS
[Samba/gebeck_regimport.git] / source4 / wscript
blobfb0491972bd606cf2d9a0a74a9bc130cd0823952
1 #! /usr/bin/env python
3 srcdir = '..'
4 blddir = 'bin'
6 APPNAME='samba'
7 VERSION=None
9 import sys, os
10 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
11 import wafsamba, Options, samba_dist, Scripting, Utils, samba_version
14 samba_dist.DIST_DIRS('.')
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.
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 source3/ ' +
25 'packaging/ docs-xml/ examples/ swat/ WHATSNEW.txt MAINTAINERS ' +
26 'source4/autogen-autotools.sh source4/Makefile.in source4/configure.ac')
27 # install in /usr/local/samba by default
28 Options.default_prefix = '/usr/local/samba'
31 def set_options(opt):
32 opt.BUILTIN_DEFAULT('NONE')
33 opt.PRIVATE_EXTENSION_DEFAULT('samba4')
34 opt.RECURSE('../lib/replace')
35 opt.RECURSE('dynconfig')
36 opt.RECURSE('lib/ldb')
37 opt.RECURSE('selftest')
38 opt.RECURSE('lib/tls')
39 opt.RECURSE('../lib/nss_wrapper')
40 opt.RECURSE('../lib/socket_wrapper')
41 opt.RECURSE('../lib/uid_wrapper')
42 opt.RECURSE('../pidl')
44 gr = opt.option_group('developer options')
45 gr.add_option('--enable-build-farm',
46 help='enable special build farm options',
47 action='store_true', dest='BUILD_FARM')
49 opt.tool_options('python') # options for disabling pyc or pyo compilation
50 # enable options related to building python extensions
53 def configure(conf):
54 version = samba_version.load_version(env=conf.env)
56 conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
57 conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True)
58 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
60 if Options.options.developer:
61 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
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('#source4 #lib #source4/lib #source4/include')
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'])
86 if int(conf.env['PYTHON_VERSION'][0]) >= 3:
87 raise Utils.WafError('Python version 3.x is not supported by Samba yet')
89 conf.RECURSE('dynconfig')
90 conf.RECURSE('lib/ldb')
91 conf.RECURSE('heimdal_build')
92 conf.RECURSE('lib/tls')
93 conf.RECURSE('ntvfs/sysdep')
94 conf.RECURSE('../lib/util')
95 conf.RECURSE('../lib/zlib')
96 conf.RECURSE('../lib/util/charset')
97 conf.RECURSE('auth')
98 conf.RECURSE('../lib/nss_wrapper')
99 conf.RECURSE('../nsswitch')
100 conf.RECURSE('../lib/socket_wrapper')
101 conf.RECURSE('../lib/uid_wrapper')
102 conf.RECURSE('../lib/popt')
103 conf.RECURSE('../lib/subunit/c')
104 conf.RECURSE('../libcli/smbreadline')
105 conf.RECURSE('../pidl')
106 conf.RECURSE('selftest')
108 # we don't want any libraries or modules to rely on runtime
109 # resolution of symbols
110 conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
112 # gentoo always adds this. We want our normal build to be as
113 # strict as the strictest OS we support, so adding this here
114 # allows us to find problems on our development hosts faster.
115 # It also results in faster load time.
116 conf.ADD_LDFLAGS('-Wl,--as-needed', testflags=True)
118 # we don't want PYTHONDIR in config.h, as otherwise changing
119 # --prefix causes a complete rebuild
120 del(conf.env.defines['PYTHONDIR'])
121 conf.SAMBA_CONFIG_H('include/config.h')
124 def etags(ctx):
125 '''build TAGS file using etags'''
126 import Utils
127 source_root = os.path.dirname(Utils.g_module.root_path)
128 cmd = 'etags $(find %s/.. -name "*.[ch]" | egrep -v \.inst\.)' % source_root
129 print("Running: %s" % cmd)
130 os.system(cmd)
132 def ctags(ctx):
133 "build 'tags' file using ctags"
134 import Utils
135 source_root = os.path.dirname(Utils.g_module.root_path)
136 cmd = 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h" | egrep -v \.inst\.)' % source_root
137 print("Running: %s" % cmd)
138 os.system(cmd)
140 # putting this here enabled build in the list
141 # of commands in --help
142 def build(bld):
143 '''build all targets'''
144 samba_version.load_version(env=bld.env)
145 pass
148 def pydoctor(ctx):
149 '''build python apidocs'''
150 cmd='PYTHONPATH=bin/python pydoctor --project-name=Samba --project-url=http://www.samba.org --make-html --docformat=restructuredtext --add-package bin/python/samba'
151 print("Running: %s" % cmd)
152 os.system(cmd)
154 def wafdocs(ctx):
155 '''build wafsamba apidocs'''
156 from samba_utils import recursive_dirlist
157 os.system('pwd')
158 list = recursive_dirlist('../buildtools/wafsamba', '.', pattern='*.py')
160 cmd='PYTHONPATH=bin/python pydoctor --project-name=wafsamba --project-url=http://www.samba.org --make-html --docformat=restructuredtext'
161 print(list)
162 for f in list:
163 cmd += ' --add-module %s' % f
164 print("Running: %s" % cmd)
165 os.system(cmd)
168 def dist():
169 '''makes a tarball for distribution'''
170 samba_version.load_version(env=None)
171 samba_dist.dist()
173 def distcheck():
174 '''test that distribution tarball builds and installs'''
175 samba_version.load_version(env=None)
176 import Scripting
177 d = Scripting.distcheck
178 d(subdir='source4')
180 def wildcard_cmd(cmd):
181 '''called on a unknown command'''
182 from samba_wildcard import run_named_build_task
183 run_named_build_task(cmd)
185 def main():
186 from samba_wildcard import wildcard_main
187 wildcard_main(wildcard_cmd)
188 Scripting.main = main
190 def reconfigure(ctx):
191 '''reconfigure if config scripts have changed'''
192 import samba_utils
193 samba_utils.reconfigure(ctx)