s3:smb2_break: make use of file_fsp_smb2()
[Samba/gebeck_regimport.git] / buildtools / wafsamba / wscript
blob5e1898c435d77de51076b4566627ff50f3777323
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, Logs
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 gr.add_option('--private-libraries',
31 help=("comma separated list of normally public libraries to build instead as private libraries. May include !LIBNAME to disable making a library private. Can be 'NONE' or 'ALL' [auto]"),
32 action="store", dest='PRIVATE_LIBS', default='')
34 extension_default = Options.options['PRIVATE_EXTENSION_DEFAULT']
35 gr.add_option('--private-library-extension',
36 help=("name extension for private libraries [%s]" % extension_default),
37 action="store", dest='PRIVATE_EXTENSION', default=extension_default)
39 extension_exception = Options.options['PRIVATE_EXTENSION_EXCEPTION']
40 gr.add_option('--private-extension-exception',
41 help=("comma separated list of libraries to not apply extension to [%s]" % extension_exception),
42 action="store", dest='PRIVATE_EXTENSION_EXCEPTION', default=extension_exception)
44 builtin_defauilt = Options.options['BUILTIN_LIBRARIES_DEFAULT']
45 gr.add_option('--builtin-libraries',
46 help=("command separated list of libraries to build directly into binaries [%s]" % builtin_defauilt),
47 action="store", dest='BUILTIN_LIBRARIES', default=builtin_defauilt)
49 gr.add_option('--minimum-library-version',
50 help=("list of minimum system library versions (LIBNAME1:version,LIBNAME2:version)"),
51 action="store", dest='MINIMUM_LIBRARY_VERSION', default='')
53 gr.add_option('--disable-shared',
54 help=("Disable all use of shared libraries"),
55 action="store_true", dest='disable_shared', default=False)
56 gr.add_option('--disable-rpath',
57 help=("Disable use of rpath for build binaries"),
58 action="store_true", dest='disable_rpath_build', default=False)
59 gr.add_option('--disable-rpath-install',
60 help=("Disable use of rpath for library path in installed files"),
61 action="store_true", dest='disable_rpath_install', default=False)
62 gr.add_option('--disable-rpath-private-install',
63 help=("Disable use of rpath for private library path in installed files"),
64 action="store_true", dest='disable_rpath_private_install', default=False)
65 gr.add_option('--nonshared-binary',
66 help=("Disable use of shared libs for the listed binaries"),
67 action="store", dest='NONSHARED_BINARIES', default='')
68 gr.add_option('--disable-symbol-versions',
69 help=("Disable use of the --version-script linker option"),
70 action="store_true", dest='disable_symbol_versions', default=False)
72 opt.add_option('--with-modulesdir',
73 help=("modules directory [PREFIX/modules]"),
74 action="store", dest='MODULESDIR', default='${PREFIX}/modules')
76 opt.add_option('--with-privatelibdir',
77 help=("private library directory [PREFIX/lib/%s]" % Utils.g_module.APPNAME),
78 action="store", dest='PRIVATELIBDIR', default=None)
80 opt.add_option('--with-libiconv',
81 help='additional directory to search for libiconv',
82 action='store', dest='iconv_open', default='/usr/local',
83 match = ['Checking for library iconv', 'Checking for iconv_open', 'Checking for header iconv.h'])
84 opt.add_option('--with-gettext',
85 help='additional directory to search for gettext',
86 action='store', dest='gettext_location', default='/usr/local',
87 match = ['Checking for library intl', 'Checking for header libintl.h'])
89 gr = opt.option_group('developer options')
91 gr.add_option('-C',
92 help='enable configure cacheing',
93 action='store_true', dest='enable_configure_cache')
94 gr.add_option('--enable-auto-reconfigure',
95 help='enable automatic reconfigure on build',
96 action='store_true', dest='enable_auto_reconfigure')
97 gr.add_option('--enable-debug',
98 help=("Turn on debugging symbols"),
99 action="store_true", dest='debug', default=False)
100 gr.add_option('--enable-developer',
101 help=("Turn on developer warnings and debugging"),
102 action="store_true", dest='developer', default=False)
103 gr.add_option('--picky-developer',
104 help=("Treat all warnings as errors (enable -Werror)"),
105 action="store_true", dest='picky_developer', default=False)
106 gr.add_option('--fatal-errors',
107 help=("Stop compilation on first error (enable -Wfatal-errors)"),
108 action="store_true", dest='fatal_errors', default=False)
109 gr.add_option('--enable-gccdeps',
110 help=("Enable use of gcc -MD dependency module"),
111 action="store_true", dest='enable_gccdeps', default=True)
112 gr.add_option('--timestamp-dependencies',
113 help=("use file timestamps instead of content for build dependencies (BROKEN)"),
114 action="store_true", dest='timestamp_dependencies', default=False)
115 gr.add_option('--pedantic',
116 help=("Enable even more compiler warnings"),
117 action='store_true', dest='pedantic', default=False)
118 gr.add_option('--git-local-changes',
119 help=("mark version with + if local git changes"),
120 action='store_true', dest='GIT_LOCAL_CHANGES', default=False)
122 gr.add_option('--abi-check',
123 help=("Check ABI signatures for libraries"),
124 action='store_true', dest='ABI_CHECK', default=False)
125 gr.add_option('--abi-check-disable',
126 help=("Disable ABI checking (used with --enable-developer)"),
127 action='store_true', dest='ABI_CHECK_DISABLE', default=False)
128 gr.add_option('--abi-update',
129 help=("Update ABI signature files for libraries"),
130 action='store_true', dest='ABI_UPDATE', default=False)
132 gr.add_option('--show-deps',
133 help=("Show dependency tree for the given target"),
134 dest='SHOWDEPS', default='')
136 gr.add_option('--symbol-check',
137 help=("check symbols in object files against project rules"),
138 action='store_true', dest='SYMBOLCHECK', default=False)
140 gr.add_option('--dup-symbol-check',
141 help=("check for duplicate symbols in object files and system libs (must be configured with --enable-developer)"),
142 action='store_true', dest='DUP_SYMBOLCHECK', default=False)
144 gr.add_option('--why-needed',
145 help=("TARGET:DEPENDENCY check why TARGET needs DEPENDENCY"),
146 action='store', type='str', dest='WHYNEEDED', default=None)
148 gr.add_option('--show-duplicates',
149 help=("Show objects which are included in multiple binaries or libraries"),
150 action='store_true', dest='SHOW_DUPLICATES', default=False)
152 gr = opt.add_option_group('cross compilation options')
154 gr.add_option('--cross-compile',
155 help=("configure for cross-compilation"),
156 action='store_true', dest='CROSS_COMPILE', default=False)
157 gr.add_option('--cross-execute',
158 help=("command prefix to use for cross-execution in configure"),
159 action='store', dest='CROSS_EXECUTE', default='')
160 gr.add_option('--cross-answers',
161 help=("answers to cross-compilation configuration (auto modified)"),
162 action='store', dest='CROSS_ANSWERS', default='')
163 gr.add_option('--hostcc',
164 help=("set host compiler when cross compiling"),
165 action='store', dest='HOSTCC', default=False)
167 # we use SUPPRESS_HELP for these, as they are ignored, and are there only
168 # to allow existing RPM spec files to work
169 opt.add_option('--build',
170 help=SUPPRESS_HELP,
171 action='store', dest='AUTOCONF_BUILD', default='')
172 opt.add_option('--host',
173 help=SUPPRESS_HELP,
174 action='store', dest='AUTOCONF_HOST', default='')
175 opt.add_option('--target',
176 help=SUPPRESS_HELP,
177 action='store', dest='AUTOCONF_TARGET', default='')
178 opt.add_option('--program-prefix',
179 help=SUPPRESS_HELP,
180 action='store', dest='AUTOCONF_PROGRAM_PREFIX', default='')
181 opt.add_option('--disable-dependency-tracking',
182 help=SUPPRESS_HELP,
183 action='store_true', dest='AUTOCONF_DISABLE_DEPENDENCY_TRACKING', default=False)
184 opt.add_option('--disable-silent-rules',
185 help=SUPPRESS_HELP,
186 action='store_true', dest='AUTOCONF_DISABLE_SILENT_RULES', default=False)
188 gr = opt.option_group('dist options')
189 gr.add_option('--sign-release',
190 help='sign the release tarball created by waf dist',
191 action='store_true', dest='SIGN_RELEASE')
192 gr.add_option('--tag',
193 help='tag release in git at the same time',
194 type='string', action='store', dest='TAG_RELEASE')
197 @wafsamba.runonce
198 def configure(conf):
199 conf.env.hlist = []
200 conf.env.srcdir = conf.srcdir
202 if Options.options.timestamp_dependencies:
203 conf.ENABLE_TIMESTAMP_DEPENDENCIES()
205 conf.SETUP_CONFIGURE_CACHE(Options.options.enable_configure_cache)
207 # load our local waf extensions
208 conf.check_tool('gnu_dirs')
209 conf.check_tool('wafsamba')
211 conf.CHECK_CC_ENV()
213 conf.check_tool('compiler_cc')
215 # we need git for 'waf dist'
216 conf.find_program('git', var='GIT')
218 # older gcc versions (< 4.4) does not work with gccdeps, so we have to see if the .d file is generated
219 if Options.options.enable_gccdeps:
220 from TaskGen import feature, after
221 @feature('testd')
222 @after('apply_core')
223 def check_d(self):
224 tsk = self.compiled_tasks[0]
225 tsk.outputs.append(tsk.outputs[0].change_ext('.d'))
227 import Task
228 cc = Task.TaskBase.classes['cc']
229 oldmeth = cc.run
231 cc.run = Task.compile_fun_noshell('cc', '${CC} ${CCFLAGS} ${CPPFLAGS} ${_CCINCFLAGS} ${_CCDEFFLAGS} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT[0].abspath(env)}')[0]
232 try:
233 try:
234 conf.check(features='cc testd', fragment='int main() {return 0;}\n', ccflags=['-MD'], mandatory=True, msg='Check for -MD')
235 except:
236 pass
237 else:
238 conf.check_tool('gccdeps', tooldir=conf.srcdir + "/buildtools/wafsamba")
239 finally:
240 cc.run = oldmeth
242 # make the install paths available in environment
243 conf.env.LIBDIR = Options.options.LIBDIR or '${PREFIX}/lib'
244 conf.env.BINDIR = Options.options.BINDIR or '${PREFIX}/bin'
245 conf.env.SBINDIR = Options.options.SBINDIR or '${PREFIX}/sbin'
246 conf.env.MODULESDIR = Options.options.MODULESDIR
247 conf.env.PRIVATELIBDIR = Options.options.PRIVATELIBDIR
248 conf.env.BUNDLED_LIBS = Options.options.BUNDLED_LIBS.split(',')
249 conf.env.PRIVATE_LIBS = Options.options.PRIVATE_LIBS.split(',')
250 conf.env.BUILTIN_LIBRARIES = Options.options.BUILTIN_LIBRARIES.split(',')
251 conf.env.DISABLE_SHARED = Options.options.disable_shared
252 conf.env.NONSHARED_BINARIES = Options.options.NONSHARED_BINARIES.split(',')
254 conf.env.PRIVATE_EXTENSION = Options.options.PRIVATE_EXTENSION
255 conf.env.PRIVATE_EXTENSION_EXCEPTION = Options.options.PRIVATE_EXTENSION_EXCEPTION.split(',')
257 conf.env.CROSS_COMPILE = Options.options.CROSS_COMPILE
258 conf.env.CROSS_EXECUTE = Options.options.CROSS_EXECUTE
259 conf.env.CROSS_ANSWERS = Options.options.CROSS_ANSWERS
260 conf.env.HOSTCC = Options.options.HOSTCC
262 conf.env.AUTOCONF_BUILD = Options.options.AUTOCONF_BUILD
263 conf.env.AUTOCONF_HOST = Options.options.AUTOCONF_HOST
264 conf.env.AUTOCONF_PROGRAM_PREFIX = Options.options.AUTOCONF_PROGRAM_PREFIX
266 if (conf.env.AUTOCONF_HOST and
267 conf.env.AUTOCONF_BUILD and
268 conf.env.AUTOCONF_BUILD != conf.env.AUTOCONF_HOST):
269 Logs.error('ERROR: Mismatch between --build and --host. Please use --cross-compile instead')
270 sys.exit(1)
271 if conf.env.AUTOCONF_PROGRAM_PREFIX:
272 Logs.error('ERROR: --program-prefix not supported')
273 sys.exit(1)
275 # enable ABI checking for developers
276 conf.env.ABI_CHECK = Options.options.ABI_CHECK or Options.options.developer
277 if Options.options.ABI_CHECK_DISABLE:
278 conf.env.ABI_CHECK = False
279 try:
280 conf.find_program('gdb', mandatory=True)
281 except:
282 conf.env.ABI_CHECK = False
284 conf.env.GIT_LOCAL_CHANGES = Options.options.GIT_LOCAL_CHANGES
286 conf.CHECK_COMMAND(['uname', '-a'],
287 msg='Checking build system',
288 define='BUILD_SYSTEM',
289 on_target=False)
290 conf.CHECK_UNAME()
292 # see if we can compile and run a simple C program
293 conf.CHECK_CODE('printf("hello world")',
294 define='HAVE_SIMPLE_C_PROG',
295 mandatory=True,
296 execute=True,
297 headers='stdio.h',
298 msg='Checking simple C program')
300 # see if we can build shared libs
301 if not conf.CHECK_LIBRARY_SUPPORT():
302 conf.env.DISABLE_SHARED = True
304 # check for rpath
305 if not conf.env.DISABLE_SHARED and conf.CHECK_LIBRARY_SUPPORT(rpath=True):
306 support_rpath = True
307 conf.env.RPATH_ON_BUILD = not Options.options.disable_rpath_build
308 conf.env.RPATH_ON_INSTALL = (conf.env.RPATH_ON_BUILD and
309 not Options.options.disable_rpath_install)
310 if not conf.env.PRIVATELIBDIR:
311 conf.env.PRIVATELIBDIR = '%s/%s' % (conf.env.LIBDIR, Utils.g_module.APPNAME)
312 conf.env.RPATH_ON_INSTALL_PRIVATE = (
313 not Options.options.disable_rpath_private_install)
314 else:
315 support_rpath = False
316 conf.env.RPATH_ON_INSTALL = False
317 conf.env.RPATH_ON_BUILD = False
318 conf.env.RPATH_ON_INSTALL_PRIVATE = False
319 if not conf.env.PRIVATELIBDIR:
320 # rpath is not possible so there is no sense in having a
321 # private library directory by default.
322 # the user can of course always override it.
323 conf.env.PRIVATELIBDIR = conf.env.LIBDIR
325 if (not conf.env.DISABLE_SHARED and
326 not Options.options.disable_symbol_versions and
327 conf.CHECK_LIBRARY_SUPPORT(rpath=support_rpath,
328 version_script=True,
329 msg='-Wl,--version-script support')):
330 conf.env.HAVE_LD_VERSION_SCRIPT = True
331 else:
332 conf.env.HAVE_LD_VERSION_SCRIPT = False
334 if sys.platform == "aix5":
335 conf.DEFINE('_ALL_SOURCE', 1, add_to_cflags=True)
336 # Might not be needed if ALL_SOURCE is defined
337 # conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
339 # we should use the PIC options in waf instead
340 # Some compilo didn't support -fPIC but just print a warning
341 if conf.env['COMPILER_CC'] == "suncc":
342 conf.ADD_CFLAGS('-KPIC', testflags=True)
343 # we really want define here as we need to have this
344 # define even during the tests otherwise detection of
345 # boolean is broken
346 conf.DEFINE('_STDC_C99', 1, add_to_cflags=True)
347 conf.DEFINE('_XPG6', 1, add_to_cflags=True)
348 else:
349 conf.ADD_CFLAGS('-fPIC', testflags=True)
351 # On Solaris 8 with suncc (at least) the flags for the linker to define the name of the
352 # library are not always working (if the command line is very very long and with a lot
353 # files)
355 if conf.env['COMPILER_CC'] == "suncc":
356 save = conf.env['SONAME_ST']
357 conf.env['SONAME_ST'] = '-Wl,-h,%s'
358 if not conf.CHECK_SHLIB_INTRASINC_NAME_FLAGS("Checking if flags %s are ok" % conf.env['SONAME_ST']):
359 conf.env['SONAME_ST'] = save
361 conf.CHECK_INLINE()
363 # check for pkgconfig
364 conf.check_cfg(atleast_pkgconfig_version='0.0.0')
366 conf.DEFINE('_GNU_SOURCE', 1, add_to_cflags=True)
367 conf.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags=True)
369 # get the base headers we'll use for the rest of the tests
370 conf.CHECK_HEADERS('stdio.h sys/types.h sys/stat.h stdlib.h stddef.h memory.h string.h',
371 add_headers=True)
372 conf.CHECK_HEADERS('strings.h inttypes.h stdint.h unistd.h minix/config.h', add_headers=True)
373 conf.CHECK_HEADERS('ctype.h', add_headers=True)
375 if sys.platform != 'darwin':
376 conf.CHECK_HEADERS('standards.h', add_headers=True)
378 conf.CHECK_HEADERS('stdbool.h stdint.h stdarg.h vararg.h', add_headers=True)
379 conf.CHECK_HEADERS('limits.h assert.h')
381 # see if we need special largefile flags
382 if not conf.CHECK_LARGEFILE():
383 raise Utils.WafError('Samba requires large file support support, but not available on this platform: sizeof(off_t) < 8')
385 if 'HAVE_STDDEF_H' in conf.env and 'HAVE_STDLIB_H' in conf.env:
386 conf.DEFINE('STDC_HEADERS', 1)
388 conf.CHECK_HEADERS('sys/time.h time.h', together=True)
390 if 'HAVE_SYS_TIME_H' in conf.env and 'HAVE_TIME_H' in conf.env:
391 conf.DEFINE('TIME_WITH_SYS_TIME', 1)
393 # cope with different extensions for libraries
394 (root, ext) = os.path.splitext(conf.env.shlib_PATTERN)
395 if ext[0] == '.':
396 conf.define('SHLIBEXT', ext[1:], quote=True)
397 else:
398 conf.define('SHLIBEXT', "so", quote=True)
400 conf.CHECK_CODE('long one = 1; return ((char *)(&one))[0]',
401 execute=True,
402 define='WORDS_BIGENDIAN')
404 # check if signal() takes a void function
405 if conf.CHECK_CODE('return *(signal (0, 0)) (0) == 1',
406 define='RETSIGTYPE_INT',
407 execute=False,
408 headers='signal.h',
409 msg='Checking if signal handlers return int'):
410 conf.DEFINE('RETSIGTYPE', 'int')
411 else:
412 conf.DEFINE('RETSIGTYPE', 'void')
414 conf.CHECK_VARIABLE('__FUNCTION__', define='HAVE_FUNCTION_MACRO')
416 conf.CHECK_CODE('va_list ap1,ap2; va_copy(ap1,ap2)',
417 define="HAVE_VA_COPY",
418 msg="Checking for va_copy")
420 conf.CHECK_CODE('''
421 #define eprintf(...) fprintf(stderr, __VA_ARGS__)
422 eprintf("bla", "bar")
423 ''', define='HAVE__VA_ARGS__MACRO')
425 conf.SAMBA_BUILD_ENV()
428 def build(bld):
429 # give a more useful message if the source directory has moved
430 relpath = os_path_relpath(bld.curdir, bld.srcnode.abspath())
431 if relpath.find('../') != -1:
432 Logs.error('bld.curdir %s is not a child of %s' % (bld.curdir, bld.srcnode.abspath()))
433 raise Utils.WafError('''The top source directory has moved. Please run distclean and reconfigure''')
435 bld.CHECK_MAKEFLAGS()
436 bld.SETUP_BUILD_GROUPS()
437 bld.ENFORCE_GROUP_ORDERING()
438 bld.CHECK_PROJECT_RULES()