s3:auth Make AUTH_NTLMSSP_STATE a private structure.
[Samba/ekacnet.git] / buildtools / wafsamba / wscript
blobbad65cac245e2a92f3bcb623c5e821a7e94bb65d
1 #!/usr/bin/env python
3 # this is a base set of waf rules that everything else pulls in first
5 import sys, wafsamba, Configure
6 import Options, os, preproc
7 from samba_utils import *
8 from optparse import SUPPRESS_HELP
10 # this forces configure to be re-run if any of the configure
11 # sections of the build scripts change. We have to check
12 # for this in sys.argv as options have not yet been parsed when
13 # we need to set this. This is off by default until some issues
14 # are resolved related to WAFCACHE. It will need a lot of testing
15 # before it is enabled by default.
16 if '--enable-auto-reconfigure' in sys.argv:
17 Configure.autoconfig = True
19 def set_options(opt):
20 opt.tool_options('compiler_cc')
22 opt.tool_options('gnu_dirs')
24 gr = opt.option_group('library handling options')
26 gr.add_option('--bundled-libraries',
27 help=("comma separated list of bundled libraries. May include !LIBNAME to disable bundling a library. Can be 'NONE' or 'ALL' [auto]"),
28 action="store", dest='BUNDLED_LIBS', default='')
30 extension_default = Options.options['BUNDLED_EXTENSION_DEFAULT']
31 gr.add_option('--bundled-library-extension',
32 help=("name extension for bundled libraries [%s]" % extension_default),
33 action="store", dest='BUNDLED_EXTENSION', default=extension_default)
35 extension_exception = Options.options['BUNDLED_EXTENSION_EXCEPTION']
36 gr.add_option('--bundled-extension-exception',
37 help=("comman separated list of libraries to not apply extension to [%s]" % extension_exception),
38 action="store", dest='BUNDLED_EXTENSION_EXCEPTION', default=extension_exception)
40 builtin_defauilt = Options.options['BUILTIN_LIBRARIES_DEFAULT']
41 gr.add_option('--builtin-libraries',
42 help=("command separated list of libraries to build directly into binaries [%s]" % builtin_defauilt),
43 action="store", dest='BUILTIN_LIBRARIES', default=builtin_defauilt)
45 gr.add_option('--minimum-library-version',
46 help=("list of minimum system library versions (LIBNAME1:version,LIBNAME2:version)"),
47 action="store", dest='MINIMUM_LIBRARY_VERSION', default='')
49 gr.add_option('--disable-shared',
50 help=("Disable all use of shared libraries"),
51 action="store_true", dest='disable_shared', default=False)
52 gr.add_option('--disable-rpath',
53 help=("Disable use of rpath for build binaries"),
54 action="store_true", dest='disable_rpath_build', default=False)
55 gr.add_option('--disable-rpath-install',
56 help=("Disable use of rpath for installed binaries"),
57 action="store_true", dest='disable_rpath_install', default=False)
58 gr.add_option('--nonshared-binary',
59 help=("Disable use of shared libs for the listed binaries"),
60 action="store", dest='NONSHARED_BINARIES', default='')
62 opt.add_option('--with-modulesdir',
63 help=("modules directory [PREFIX/modules]"),
64 action="store", dest='MODULESDIR', default='${PREFIX}/modules')
66 gr = opt.option_group('developer options')
68 gr.add_option('-C',
69 help='enable configure cacheing',
70 action='store_true', dest='enable_configure_cache')
71 gr.add_option('--enable-auto-reconfigure',
72 help='enable automatic reconfigure on build',
73 action='store_true', dest='enable_auto_reconfigure')
74 gr.add_option('--enable-developer',
75 help=("Turn on developer warnings and debugging"),
76 action="store_true", dest='developer', default=False)
77 gr.add_option('--picky-developer',
78 help=("Treat all warnings as errors (enable -Werror)"),
79 action="store_true", dest='picky_developer', default=False)
80 gr.add_option('--fatal-errors',
81 help=("Stop compilation on first error (enable -Wfatal-errors)"),
82 action="store_true", dest='fatal_errors', default=False)
83 gr.add_option('--enable-gccdeps',
84 help=("Enable use of gcc -MD dependency module"),
85 action="store_true", dest='enable_gccdeps', default=False)
86 gr.add_option('--timestamp-dependencies',
87 help=("use file timestamps instead of content for build dependencies (BROKEN)"),
88 action="store_true", dest='timestamp_dependencies', default=False)
89 gr.add_option('--pedantic',
90 help=("Enable even more compiler warnings"),
91 action='store_true', dest='pedantic', default=False)
93 gr.add_option('--abi-check',
94 help=("Check ABI signatures for libraries"),
95 action='store_true', dest='ABI_CHECK', default=False)
96 gr.add_option('--abi-check-disable',
97 help=("Disable ABI checking (used with --enable-developer)"),
98 action='store_true', dest='ABI_CHECK_DISABLE', default=False)
99 gr.add_option('--abi-update',
100 help=("Update ABI signature files for libraries"),
101 action='store_true', dest='ABI_UPDATE', default=False)
103 gr = opt.add_option_group('cross compilation options')
105 gr.add_option('--cross-compile',
106 help=("configure for cross-compilation"),
107 action='store_true', dest='CROSS_COMPILE', default=False)
108 gr.add_option('--cross-execute',
109 help=("command prefix to use for cross-execution in configure"),
110 action='store', dest='CROSS_EXECUTE', default='')
111 gr.add_option('--cross-answers',
112 help=("answers to cross-compilation configuration (auto modified)"),
113 action='store', dest='CROSS_ANSWERS', default='')
114 gr.add_option('--hostcc',
115 help=("set host compiler when cross compiling"),
116 action='store', dest='HOSTCC', default=False)
118 # we use SUPPRESS_HELP for these, as they are ignored, and are there only
119 # to allow existing RPM spec files to work
120 opt.add_option('--build',
121 help=SUPPRESS_HELP,
122 action='store', dest='AUTOCONF_BUILD', default='')
123 opt.add_option('--host',
124 help=SUPPRESS_HELP,
125 action='store', dest='AUTOCONF_HOST', default='')
126 opt.add_option('--program-prefix',
127 help=SUPPRESS_HELP,
128 action='store', dest='AUTOCONF_PROGRAM_PREFIX', default='')
129 opt.add_option('--disable-dependency-tracking',
130 help=SUPPRESS_HELP,
131 action='store_true', dest='AUTOCONF_DISABLE_DEPENDENCY_TRACKING', default=False)
133 gr = opt.option_group('dist options')
134 gr.add_option('--sign-release',
135 help='sign the release tarball created by waf dist',
136 action='store_true', dest='SIGN_RELEASE')
137 gr.add_option('--tag',
138 help='tag release in git at the same time',
139 type='string', action='store', dest='TAG_RELEASE')
142 @wafsamba.runonce
143 def configure(conf):
144 conf.env.hlist = []
145 conf.env.srcdir = conf.srcdir
147 if Options.options.timestamp_dependencies:
148 conf.ENABLE_TIMESTAMP_DEPENDENCIES()
150 conf.SETUP_CONFIGURE_CACHE(Options.options.enable_configure_cache)
152 # load our local waf extensions
153 conf.check_tool('gnu_dirs')
154 conf.check_tool('wafsamba')
156 conf.CHECK_CC_ENV()
158 conf.check_tool('compiler_cc')
160 # we need git for 'waf dist'
161 conf.find_program('git', var='GIT')
163 if Options.options.enable_gccdeps:
164 # don't enable gccdeps by default as it needs a very recent version gcc
165 conf.check_tool('gccdeps', tooldir=conf.srcdir + "/buildtools/wafsamba")
167 # make the install paths available in environment
168 conf.env.LIBDIR = Options.options.LIBDIR or '${PREFIX}/lib'
169 conf.env.BINDIR = Options.options.BINDIR or '${PREFIX}/bin'
170 conf.env.SBINDIR = Options.options.SBINDIR or '${PREFIX}/sbin'
171 conf.env.MODULESDIR = Options.options.MODULESDIR
172 conf.env.BUNDLED_LIBS = Options.options.BUNDLED_LIBS.split(',')
173 conf.env.BUILTIN_LIBRARIES = Options.options.BUILTIN_LIBRARIES.split(',')
174 conf.env.DISABLE_SHARED = Options.options.disable_shared
175 conf.env.NONSHARED_BINARIES = Options.options.NONSHARED_BINARIES.split(',')
177 conf.env.BUNDLED_EXTENSION = Options.options.BUNDLED_EXTENSION
178 conf.env.BUNDLED_EXTENSION_EXCEPTION = Options.options.BUNDLED_EXTENSION_EXCEPTION.split(',')
180 conf.env.CROSS_COMPILE = Options.options.CROSS_COMPILE
181 conf.env.CROSS_EXECUTE = Options.options.CROSS_EXECUTE
182 conf.env.CROSS_ANSWERS = Options.options.CROSS_ANSWERS
183 conf.env.HOSTCC = Options.options.HOSTCC
185 conf.env.AUTOCONF_BUILD = Options.options.AUTOCONF_BUILD
186 conf.env.AUTOCONF_HOST = Options.options.AUTOCONF_HOST
187 conf.env.AUTOCONF_PROGRAM_PREFIX = Options.options.AUTOCONF_PROGRAM_PREFIX
189 if (conf.env.AUTOCONF_HOST and
190 conf.env.AUTOCONF_BUILD and
191 conf.env.AUTOCONF_BUILD != conf.env.AUTOCONF_HOST):
192 Logs.error('ERROR: Mismatch between --build and --host. Please use --cross-compile instead')
193 sys.exit(1)
194 if conf.env.AUTOCONF_PROGRAM_PREFIX:
195 Logs.error('ERROR: --program-prefix not supported')
196 sys.exit(1)
198 # enable ABI checking for developers
199 conf.env.ABI_CHECK = Options.options.ABI_CHECK or Options.options.developer
200 if Options.options.ABI_CHECK_DISABLE:
201 conf.env.ABI_CHECK = False
202 try:
203 conf.find_program('gdb', mandatory=True)
204 except:
205 conf.env.ABI_CHECK = False
207 conf.CHECK_COMMAND(['uname', '-a'],
208 msg='Checking build system',
209 define='BUILD_SYSTEM',
210 on_target=False)
211 conf.CHECK_UNAME()
213 # see if we can compile and run a simple C program
214 conf.CHECK_CODE('printf("hello world")',
215 define='HAVE_SIMPLE_C_PROG',
216 mandatory=True,
217 execute=True,
218 headers='stdio.h',
219 msg='Checking simple C program')
221 # see if we can build shared libs
222 if not conf.CHECK_LIBRARY_SUPPORT():
223 conf.env.DISABLE_SHARED = True
225 # check for rpath
226 if not conf.env.DISABLE_SHARED and conf.CHECK_LIBRARY_SUPPORT(rpath=True):
227 conf.env.RPATH_ON_BUILD = not Options.options.disable_rpath_build
228 conf.env.RPATH_ON_INSTALL = (conf.env.RPATH_ON_BUILD and
229 not Options.options.disable_rpath_install)
230 else:
231 conf.env.RPATH_ON_INSTALL = False
232 conf.env.RPATH_ON_BUILD = False
234 # we should use the PIC options in waf instead
235 conf.ADD_CFLAGS('-fPIC', testflags=True)
237 conf.CHECK_INLINE()
239 # check for pkgconfig
240 conf.check_cfg(atleast_pkgconfig_version='0.0.0')
242 conf.DEFINE('_GNU_SOURCE', 1, add_to_cflags=True)
243 conf.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags=True)
245 # get the base headers we'll use for the rest of the tests
246 conf.CHECK_HEADERS('stdio.h sys/types.h sys/stat.h stdlib.h stddef.h memory.h string.h',
247 add_headers=True)
248 conf.CHECK_HEADERS('strings.h inttypes.h stdint.h unistd.h minix/config.h', add_headers=True)
249 conf.CHECK_HEADERS('ctype.h standards.h stdbool.h stdint.h stdarg.h vararg.h', add_headers=True)
250 conf.CHECK_HEADERS('limits.h assert.h')
252 # see if we need special largefile flags
253 conf.CHECK_LARGEFILE()
255 if 'HAVE_STDDEF_H' in conf.env and 'HAVE_STDLIB_H' in conf.env:
256 conf.DEFINE('STDC_HEADERS', 1)
258 conf.CHECK_HEADERS('sys/time.h time.h', together=True)
260 if 'HAVE_SYS_TIME_H' in conf.env and 'HAVE_TIME_H' in conf.env:
261 conf.DEFINE('TIME_WITH_SYS_TIME', 1)
263 conf.define('SHLIBEXT', "so", quote=True)
265 conf.CHECK_CODE('long one = 1; return ((char *)(&one))[0]',
266 execute=True,
267 define='WORDS_BIGENDIAN')
269 # check if signal() takes a void function
270 if conf.CHECK_CODE('return *(signal (0, 0)) (0) == 1',
271 define='RETSIGTYPE_INT',
272 execute=False,
273 headers='signal.h',
274 msg='Checking if signal handlers return int'):
275 conf.DEFINE('RETSIGTYPE', 'int')
276 else:
277 conf.DEFINE('RETSIGTYPE', 'void')
279 conf.CHECK_VARIABLE('__FUNCTION__', define='HAVE_FUNCTION_MACRO')
281 conf.CHECK_CODE('va_list ap1,ap2; va_copy(ap1,ap2)',
282 define="HAVE_VA_COPY",
283 msg="Checking for va_copy")
285 conf.CHECK_CODE('''
286 #define eprintf(...) fprintf(stderr, __VA_ARGS__)
287 eprintf("bla", "bar")
288 ''', define='HAVE__VA_ARGS__MACRO')
290 conf.SAMBA_BUILD_ENV()
293 def build(bld):
294 # give a more useful message if the source directory has moved
295 relpath = os_path_relpath(bld.curdir, bld.srcnode.abspath())
296 if relpath.find('../') != -1:
297 Logs.error('bld.curdir %s is not a child of %s' % (bld.curdir, bld.srcnode.abspath()))
298 raise Utils.WafError('''The top source directory has moved. Please run distclean and reconfigure''')
300 bld.CHECK_MAKEFLAGS()
301 bld.SETUP_BUILD_GROUPS()
302 bld.ENFORCE_GROUP_ORDERING()
303 bld.CHECK_PROJECT_RULES()