CVE-2018-16841 heimdal: Fix segfault on PKINIT with mis-matching principal
[Samba.git] / buildtools / wafsamba / wscript
blob164a9ff6dda94bdfd39e9ce23220ab9111670aed
1 #!/usr/bin/env python
3 # this is a base set of waf rules that everything else pulls in first
5 import os, sys
6 from waflib import Configure, Logs, Options, Utils, Context, Errors
7 import wafsamba
8 from samba_utils import os_path_relpath
9 from optparse import SUPPRESS_HELP
11 # this forces configure to be re-run if any of the configure
12 # sections of the build scripts change. We have to check
13 # for this in sys.argv as options have not yet been parsed when
14 # we need to set this. This is off by default until some issues
15 # are resolved related to WAFCACHE. It will need a lot of testing
16 # before it is enabled by default.
17 if '--enable-auto-reconfigure' in sys.argv:
18 Configure.autoconfig = 'clobber'
20 def default_value(option, default=''):
21 if option in Options.options.__dict__:
22 return Options.options.__dict__[option]
23 return default
25 def options(opt):
26 opt.load('compiler_cc')
28 opt.load('gnu_dirs')
30 gr = opt.option_group('library handling options')
32 gr.add_option('--bundled-libraries',
33 help=("comma separated list of bundled libraries. May include !LIBNAME to disable bundling a library. Can be 'NONE' or 'ALL' [auto]"),
34 action="store", dest='BUNDLED_LIBS', default='')
36 gr.add_option('--private-libraries',
37 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]"),
38 action="store", dest='PRIVATE_LIBS', default='')
40 extension_default = default_value('PRIVATE_EXTENSION_DEFAULT')
41 gr.add_option('--private-library-extension',
42 help=("name extension for private libraries [%s]" % extension_default),
43 action="store", dest='PRIVATE_EXTENSION', default=extension_default)
45 extension_exception = default_value('PRIVATE_EXTENSION_EXCEPTION')
46 gr.add_option('--private-extension-exception',
47 help=("comma separated list of libraries to not apply extension to [%s]" % extension_exception),
48 action="store", dest='PRIVATE_EXTENSION_EXCEPTION', default=extension_exception)
50 builtin_default = default_value('BUILTIN_LIBRARIES_DEFAULT')
51 gr.add_option('--builtin-libraries',
52 help=("command separated list of libraries to build directly into binaries [%s]" % builtin_default),
53 action="store", dest='BUILTIN_LIBRARIES', default=builtin_default)
55 gr.add_option('--minimum-library-version',
56 help=("list of minimum system library versions (LIBNAME1:version,LIBNAME2:version)"),
57 action="store", dest='MINIMUM_LIBRARY_VERSION', default='')
59 gr.add_option('--disable-rpath',
60 help=("Disable use of rpath for build binaries"),
61 action="store_true", dest='disable_rpath_build', default=False)
62 gr.add_option('--disable-rpath-install',
63 help=("Disable use of rpath for library path in installed files"),
64 action="store_true", dest='disable_rpath_install', default=False)
65 gr.add_option('--disable-rpath-private-install',
66 help=("Disable use of rpath for private library path in installed files"),
67 action="store_true", dest='disable_rpath_private_install', default=False)
68 gr.add_option('--nonshared-binary',
69 help=("Disable use of shared libs for the listed binaries"),
70 action="store", dest='NONSHARED_BINARIES', default='')
71 gr.add_option('--disable-symbol-versions',
72 help=("Disable use of the --version-script linker option"),
73 action="store_true", dest='disable_symbol_versions', default=False)
75 opt.add_option('--with-modulesdir',
76 help=("modules directory [PREFIX/modules]"),
77 action="store", dest='MODULESDIR', default='${PREFIX}/modules')
79 opt.add_option('--with-privatelibdir',
80 help=("private library directory [PREFIX/lib/%s]" % Context.g_module.APPNAME),
81 action="store", dest='PRIVATELIBDIR', default=None)
83 opt.add_option('--with-libiconv',
84 help='additional directory to search for libiconv',
85 action='store', dest='iconv_open', default='/usr/local',
86 match = ['Checking for library iconv', 'Checking for iconv_open', 'Checking for header iconv.h'])
87 opt.add_option('--without-gettext',
88 help=("Disable use of gettext"),
89 action="store_true", dest='disable_gettext', default=False)
91 gr = opt.option_group('developer options')
93 gr.add_option('-C',
94 help='enable configure cacheing',
95 action='store_true', dest='enable_configure_cache')
96 gr.add_option('--enable-auto-reconfigure',
97 help='enable automatic reconfigure on build',
98 action='store_true', dest='enable_auto_reconfigure')
99 gr.add_option('--enable-debug',
100 help=("Turn on debugging symbols"),
101 action="store_true", dest='debug', default=False)
102 gr.add_option('--enable-developer',
103 help=("Turn on developer warnings and debugging"),
104 action="store_true", dest='developer', default=False)
105 def picky_developer_callback(option, opt_str, value, parser):
106 parser.values.developer = True
107 parser.values.picky_developer = True
108 gr.add_option('--picky-developer',
109 help=("Treat all warnings as errors (enable -Werror)"),
110 action="callback", callback=picky_developer_callback,
111 dest='picky_developer', default=False)
112 gr.add_option('--fatal-errors',
113 help=("Stop compilation on first error (enable -Wfatal-errors)"),
114 action="store_true", dest='fatal_errors', default=False)
115 gr.add_option('--enable-gccdeps',
116 help=("Enable use of gcc -MD dependency module"),
117 action="store_true", dest='enable_gccdeps', default=True)
118 gr.add_option('--timestamp-dependencies',
119 help=("use file timestamps instead of content for build dependencies (BROKEN)"),
120 action="store_true", dest='timestamp_dependencies', default=False)
121 gr.add_option('--pedantic',
122 help=("Enable even more compiler warnings"),
123 action='store_true', dest='pedantic', default=False)
124 gr.add_option('--git-local-changes',
125 help=("mark version with + if local git changes"),
126 action='store_true', dest='GIT_LOCAL_CHANGES', default=False)
127 gr.add_option('--address-sanitizer',
128 help=("Enable address sanitizer compile and linker flags"),
129 action="store_true", dest='address_sanitizer', default=False)
131 gr.add_option('--abi-check',
132 help=("Check ABI signatures for libraries"),
133 action='store_true', dest='ABI_CHECK', default=False)
134 gr.add_option('--abi-check-disable',
135 help=("Disable ABI checking (used with --enable-developer)"),
136 action='store_true', dest='ABI_CHECK_DISABLE', default=False)
137 gr.add_option('--abi-update',
138 help=("Update ABI signature files for libraries"),
139 action='store_true', dest='ABI_UPDATE', default=False)
141 gr.add_option('--show-deps',
142 help=("Show dependency tree for the given target"),
143 dest='SHOWDEPS', default='')
145 gr.add_option('--symbol-check',
146 help=("check symbols in object files against project rules"),
147 action='store_true', dest='SYMBOLCHECK', default=False)
149 gr.add_option('--dup-symbol-check',
150 help=("check for duplicate symbols in object files and system libs (must be configured with --enable-developer)"),
151 action='store_true', dest='DUP_SYMBOLCHECK', default=False)
153 gr.add_option('--why-needed',
154 help=("TARGET:DEPENDENCY check why TARGET needs DEPENDENCY"),
155 action='store', type='str', dest='WHYNEEDED', default=None)
157 gr.add_option('--show-duplicates',
158 help=("Show objects which are included in multiple binaries or libraries"),
159 action='store_true', dest='SHOW_DUPLICATES', default=False)
161 gr = opt.add_option_group('cross compilation options')
163 gr.add_option('--cross-compile',
164 help=("configure for cross-compilation"),
165 action='store_true', dest='CROSS_COMPILE', default=False)
166 gr.add_option('--cross-execute',
167 help=("command prefix to use for cross-execution in configure"),
168 action='store', dest='CROSS_EXECUTE', default='')
169 gr.add_option('--cross-answers',
170 help=("answers to cross-compilation configuration (auto modified)"),
171 action='store', dest='CROSS_ANSWERS', default='')
172 gr.add_option('--hostcc',
173 help=("set host compiler when cross compiling"),
174 action='store', dest='HOSTCC', default=False)
176 # we use SUPPRESS_HELP for these, as they are ignored, and are there only
177 # to allow existing RPM spec files to work
178 opt.add_option('--build',
179 help=SUPPRESS_HELP,
180 action='store', dest='AUTOCONF_BUILD', default='')
181 opt.add_option('--host',
182 help=SUPPRESS_HELP,
183 action='store', dest='AUTOCONF_HOST', default='')
184 opt.add_option('--target',
185 help=SUPPRESS_HELP,
186 action='store', dest='AUTOCONF_TARGET', default='')
187 opt.add_option('--program-prefix',
188 help=SUPPRESS_HELP,
189 action='store', dest='AUTOCONF_PROGRAM_PREFIX', default='')
190 opt.add_option('--disable-dependency-tracking',
191 help=SUPPRESS_HELP,
192 action='store_true', dest='AUTOCONF_DISABLE_DEPENDENCY_TRACKING', default=False)
193 opt.add_option('--disable-silent-rules',
194 help=SUPPRESS_HELP,
195 action='store_true', dest='AUTOCONF_DISABLE_SILENT_RULES', default=False)
197 gr = opt.option_group('dist options')
198 gr.add_option('--sign-release',
199 help='sign the release tarball created by waf dist',
200 action='store_true', dest='SIGN_RELEASE')
201 gr.add_option('--tag',
202 help='tag release in git at the same time',
203 type='string', action='store', dest='TAG_RELEASE')
205 opt.add_option('--disable-python',
206 help='do not generate python modules',
207 action='store_true', dest='disable_python', default=False)
209 opt.add_option('--extra-python', type=str,
210 help=("build selected libraries for the specified "
211 "additional version of Python "
212 "(example: --extra-python=/usr/bin/python3)"),
213 metavar="PYTHON", dest='EXTRA_PYTHON', default=None)
216 @Utils.run_once
217 def configure(conf):
218 conf.env.hlist = []
219 conf.env.srcdir = conf.srcnode.abspath()
221 conf.define('SRCDIR', conf.env['srcdir'])
223 if Options.options.timestamp_dependencies:
224 conf.ENABLE_TIMESTAMP_DEPENDENCIES()
226 conf.SETUP_CONFIGURE_CACHE(Options.options.enable_configure_cache)
228 # load our local waf extensions
229 conf.load('gnu_dirs')
230 conf.load('wafsamba')
232 conf.CHECK_CC_ENV()
234 conf.load('compiler_c')
236 conf.CHECK_STANDARD_LIBPATH()
238 # we need git for 'waf dist'
239 conf.find_program('git', var='GIT')
241 # older gcc versions (< 4.4) does not work with gccdeps, so we have to see if the .d file is generated
242 if Options.options.enable_gccdeps:
243 # stale file removal - the configuration may pick up the old .pyc file
244 p = os.path.join(conf.env.srcdir, 'buildtools/wafsamba/gccdeps.pyc')
245 if os.path.exists(p):
246 os.remove(p)
247 conf.load('gccdeps')
249 # make the install paths available in environment
250 conf.env.LIBDIR = Options.options.LIBDIR or '${PREFIX}/lib'
251 conf.env.BINDIR = Options.options.BINDIR or '${PREFIX}/bin'
252 conf.env.SBINDIR = Options.options.SBINDIR or '${PREFIX}/sbin'
253 conf.env.MODULESDIR = Options.options.MODULESDIR
254 conf.env.PRIVATELIBDIR = Options.options.PRIVATELIBDIR
255 conf.env.BUNDLED_LIBS = Options.options.BUNDLED_LIBS.split(',')
256 conf.env.SYSTEM_LIBS = ()
257 conf.env.PRIVATE_LIBS = Options.options.PRIVATE_LIBS.split(',')
258 conf.env.BUILTIN_LIBRARIES = Options.options.BUILTIN_LIBRARIES.split(',')
259 conf.env.NONSHARED_BINARIES = Options.options.NONSHARED_BINARIES.split(',')
261 conf.env.PRIVATE_EXTENSION = Options.options.PRIVATE_EXTENSION
262 conf.env.PRIVATE_EXTENSION_EXCEPTION = Options.options.PRIVATE_EXTENSION_EXCEPTION.split(',')
264 conf.env.CROSS_COMPILE = Options.options.CROSS_COMPILE
265 conf.env.CROSS_EXECUTE = Options.options.CROSS_EXECUTE
266 conf.env.CROSS_ANSWERS = Options.options.CROSS_ANSWERS
267 conf.env.HOSTCC = Options.options.HOSTCC
269 conf.env.AUTOCONF_BUILD = Options.options.AUTOCONF_BUILD
270 conf.env.AUTOCONF_HOST = Options.options.AUTOCONF_HOST
271 conf.env.AUTOCONF_PROGRAM_PREFIX = Options.options.AUTOCONF_PROGRAM_PREFIX
273 conf.env.disable_python = Options.options.disable_python
275 conf.env.EXTRA_PYTHON = Options.options.EXTRA_PYTHON
277 if (conf.env.disable_python and conf.env.EXTRA_PYTHON):
278 Logs.error('ERROR: cannot specify both --disable-python and --extra-python.')
279 sys.exit(1)
281 if (conf.env.AUTOCONF_HOST and
282 conf.env.AUTOCONF_BUILD and
283 conf.env.AUTOCONF_BUILD != conf.env.AUTOCONF_HOST):
284 Logs.error('ERROR: Mismatch between --build and --host. Please use --cross-compile instead')
285 sys.exit(1)
286 if conf.env.AUTOCONF_PROGRAM_PREFIX:
287 Logs.error('ERROR: --program-prefix not supported')
288 sys.exit(1)
290 # enable ABI checking for developers
291 conf.env.ABI_CHECK = Options.options.ABI_CHECK or Options.options.developer
292 if Options.options.ABI_CHECK_DISABLE:
293 conf.env.ABI_CHECK = False
294 try:
295 conf.find_program('gdb', mandatory=True)
296 except:
297 conf.env.ABI_CHECK = False
299 conf.env.GIT_LOCAL_CHANGES = Options.options.GIT_LOCAL_CHANGES
301 conf.CHECK_UNAME()
303 # see if we can compile and run a simple C program
304 conf.CHECK_CODE('printf("hello world")',
305 define='HAVE_SIMPLE_C_PROG',
306 mandatory=True,
307 execute=True,
308 headers='stdio.h',
309 msg='Checking simple C program')
311 # Try to find the right extra flags for -Werror behaviour
312 for f in ["-Werror", # GCC
313 "-errwarn=%all", # Sun Studio
314 "-qhalt=w", # IBM xlc
315 "-w2", # Tru64
317 if conf.CHECK_CFLAGS([f], '''
318 '''):
319 if not 'WERROR_CFLAGS' in conf.env:
320 conf.env['WERROR_CFLAGS'] = []
321 conf.env['WERROR_CFLAGS'].extend([f])
322 break
324 # check which compiler/linker flags are needed for rpath support
325 if not conf.CHECK_LDFLAGS(['-Wl,-rpath,.']) and conf.CHECK_LDFLAGS(['-Wl,-R,.']):
326 conf.env['RPATH_ST'] = '-Wl,-R,%s'
328 # check for rpath
329 if conf.CHECK_LIBRARY_SUPPORT(rpath=True):
330 support_rpath = True
331 conf.env.RPATH_ON_BUILD = not Options.options.disable_rpath_build
332 conf.env.RPATH_ON_INSTALL = (conf.env.RPATH_ON_BUILD and
333 not Options.options.disable_rpath_install)
334 if not conf.env.PRIVATELIBDIR:
335 conf.env.PRIVATELIBDIR = '%s/%s' % (conf.env.LIBDIR, Context.g_module.APPNAME)
336 conf.env.RPATH_ON_INSTALL_PRIVATE = (
337 not Options.options.disable_rpath_private_install)
338 else:
339 support_rpath = False
340 conf.env.RPATH_ON_INSTALL = False
341 conf.env.RPATH_ON_BUILD = False
342 conf.env.RPATH_ON_INSTALL_PRIVATE = False
343 if not conf.env.PRIVATELIBDIR:
344 # rpath is not possible so there is no sense in having a
345 # private library directory by default.
346 # the user can of course always override it.
347 conf.env.PRIVATELIBDIR = conf.env.LIBDIR
349 if (not Options.options.disable_symbol_versions and
350 conf.CHECK_LIBRARY_SUPPORT(rpath=support_rpath,
351 version_script=True,
352 msg='-Wl,--version-script support')):
353 conf.env.HAVE_LD_VERSION_SCRIPT = True
354 else:
355 conf.env.HAVE_LD_VERSION_SCRIPT = False
357 if conf.CHECK_CFLAGS(['-fvisibility=hidden'] + conf.env.WERROR_CFLAGS):
358 conf.env.VISIBILITY_CFLAGS = '-fvisibility=hidden'
359 conf.CHECK_CODE('''int main(void) { return 0; }
360 __attribute__((visibility("default"))) void vis_foo2(void) {}''',
361 cflags=conf.env.VISIBILITY_CFLAGS,
362 strict=True,
363 define='HAVE_VISIBILITY_ATTR', addmain=False)
365 # check HAVE_CONSTRUCTOR_ATTRIBUTE
366 conf.CHECK_CODE('''
367 void test_constructor_attribute(void) __attribute__ ((constructor));
369 void test_constructor_attribute(void)
371 return;
374 int main(void) {
375 return 0;
377 ''',
378 'HAVE_CONSTRUCTOR_ATTRIBUTE',
379 addmain=False,
380 strict=True,
381 msg='Checking for library constructor support')
383 # check HAVE_DESTRUCTOR_ATTRIBUTE
384 conf.CHECK_CODE('''
385 void test_destructor_attribute(void) __attribute__ ((destructor));
387 void test_destructor_attribute(void)
389 return;
392 int main(void) {
393 return 0;
395 ''',
396 'HAVE_DESTRUCTOR_ATTRIBUTE',
397 addmain=False,
398 strict=True,
399 msg='Checking for library destructor support')
401 conf.CHECK_CODE('''
402 void test_attribute(void) __attribute__ (());
404 void test_attribute(void)
406 return;
409 int main(void) {
410 return 0;
412 ''',
413 'HAVE___ATTRIBUTE__',
414 addmain=False,
415 strict=True,
416 msg='Checking for __attribute__')
418 if sys.platform.startswith('aix'):
419 conf.DEFINE('_ALL_SOURCE', 1, add_to_cflags=True)
420 # Might not be needed if ALL_SOURCE is defined
421 # conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
423 # we should use the PIC options in waf instead
424 # Some compilo didn't support -fPIC but just print a warning
425 if conf.env['COMPILER_CC'] == "suncc":
426 conf.ADD_CFLAGS('-KPIC', testflags=True)
427 # we really want define here as we need to have this
428 # define even during the tests otherwise detection of
429 # boolean is broken
430 conf.DEFINE('_STDC_C99', 1, add_to_cflags=True)
431 conf.DEFINE('_XPG6', 1, add_to_cflags=True)
432 else:
433 conf.ADD_CFLAGS('-fPIC', testflags=True)
435 # On Solaris 8 with suncc (at least) the flags for the linker to define the name of the
436 # library are not always working (if the command line is very very long and with a lot
437 # files)
439 if conf.env['COMPILER_CC'] == "suncc":
440 save = conf.env['SONAME_ST']
441 conf.env['SONAME_ST'] = '-Wl,-h,%s'
442 if not conf.CHECK_SHLIB_INTRASINC_NAME_FLAGS("Checking if flags %s are ok" % conf.env['SONAME_ST']):
443 conf.env['SONAME_ST'] = save
445 conf.CHECK_INLINE()
447 # check for pkgconfig
448 conf.CHECK_CFG(atleast_pkgconfig_version='0.0.0')
450 conf.DEFINE('_GNU_SOURCE', 1, add_to_cflags=True)
451 conf.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags=True)
453 # on Tru64 certain features are only available with _OSF_SOURCE set to 1
454 # and _XOPEN_SOURCE set to 600
455 if conf.env['SYSTEM_UNAME_SYSNAME'] == 'OSF1':
456 conf.DEFINE('_OSF_SOURCE', 1, add_to_cflags=True)
457 conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
459 # SCM_RIGHTS is only avail if _XOPEN_SOURCE iѕ defined on IRIX
460 if conf.env['SYSTEM_UNAME_SYSNAME'] == 'IRIX':
461 conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
462 conf.DEFINE('_BSD_TYPES', 1, add_to_cflags=True)
464 # Try to find the right extra flags for C99 initialisers
465 for f in ["", "-AC99", "-qlanglvl=extc99", "-qlanglvl=stdc99", "-c99"]:
466 if conf.CHECK_CFLAGS([f], '''
467 struct foo {int x;char y;};
468 struct foo bar = { .y = 'X', .x = 1 };
469 '''):
470 if f != "":
471 conf.ADD_CFLAGS(f)
472 break
474 # get the base headers we'll use for the rest of the tests
475 conf.CHECK_HEADERS('stdio.h sys/types.h sys/stat.h stdlib.h stddef.h memory.h string.h',
476 add_headers=True)
477 conf.CHECK_HEADERS('strings.h inttypes.h stdint.h unistd.h minix/config.h', add_headers=True)
478 conf.CHECK_HEADERS('ctype.h', add_headers=True)
480 if sys.platform != 'darwin':
481 conf.CHECK_HEADERS('standards.h', add_headers=True)
483 conf.CHECK_HEADERS('stdbool.h stdint.h stdarg.h vararg.h', add_headers=True)
484 conf.CHECK_HEADERS('limits.h assert.h')
486 # see if we need special largefile flags
487 if not conf.CHECK_LARGEFILE():
488 raise Errors.WafError('Samba requires large file support support, but not available on this platform: sizeof(off_t) < 8')
490 if conf.env.HAVE_STDDEF_H and conf.env.HAVE_STDLIB_H:
491 conf.DEFINE('STDC_HEADERS', 1)
493 conf.CHECK_HEADERS('sys/time.h time.h', together=True)
495 if conf.env.HAVE_SYS_TIME_H and conf.env.HAVE_TIME_H:
496 conf.DEFINE('TIME_WITH_SYS_TIME', 1)
498 # cope with different extensions for libraries
499 (root, ext) = os.path.splitext(conf.env.cshlib_PATTERN)
500 if ext[0] == '.':
501 conf.define('SHLIBEXT', ext[1:], quote=True)
502 else:
503 conf.define('SHLIBEXT', "so", quote=True)
505 # First try a header check for cross-compile friendlyness
506 conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
507 #define B __BYTE_ORDER
508 #elif defined(BYTE_ORDER)
509 #define B BYTE_ORDER
510 #endif
512 #ifdef __LITTLE_ENDIAN
513 #define LITTLE __LITTLE_ENDIAN
514 #elif defined(LITTLE_ENDIAN)
515 #define LITTLE LITTLE_ENDIAN
516 #endif
518 #if !defined(LITTLE) || !defined(B) || LITTLE != B
519 #error Not little endian.
520 #endif
521 int main(void) { return 0; }""",
522 addmain=False,
523 headers="endian.h sys/endian.h",
524 define="HAVE_LITTLE_ENDIAN")
525 conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
526 #define B __BYTE_ORDER
527 #elif defined(BYTE_ORDER)
528 #define B BYTE_ORDER
529 #endif
531 #ifdef __BIG_ENDIAN
532 #define BIG __BIG_ENDIAN
533 #elif defined(BIG_ENDIAN)
534 #define BIG BIG_ENDIAN
535 #endif
537 #if !defined(BIG) || !defined(B) || BIG != B
538 #error Not big endian.
539 #endif
540 int main(void) { return 0; }""",
541 addmain=False,
542 headers="endian.h sys/endian.h",
543 define="HAVE_BIG_ENDIAN")
545 if not conf.CONFIG_SET("HAVE_BIG_ENDIAN") and not conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
546 # That didn't work! Do runtime test.
547 conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
548 u.i = 0x01020304;
549 return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;""",
550 addmain=True, execute=True,
551 define='HAVE_LITTLE_ENDIAN',
552 msg="Checking for HAVE_LITTLE_ENDIAN - runtime")
553 conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
554 u.i = 0x01020304;
555 return u.c[0] == 0x01 && u.c[1] == 0x02 && u.c[2] == 0x03 && u.c[3] == 0x04 ? 0 : 1;""",
556 addmain=True, execute=True,
557 define='HAVE_BIG_ENDIAN',
558 msg="Checking for HAVE_BIG_ENDIAN - runtime")
560 # Extra sanity check.
561 if conf.CONFIG_SET("HAVE_BIG_ENDIAN") == conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
562 Logs.error("Failed endian determination. The PDP-11 is back?")
563 sys.exit(1)
564 else:
565 if conf.CONFIG_SET("HAVE_BIG_ENDIAN"):
566 conf.DEFINE('WORDS_BIGENDIAN', 1)
568 # check if signal() takes a void function
569 if conf.CHECK_CODE('return *(signal (0, 0)) (0) == 1',
570 define='RETSIGTYPE_INT',
571 execute=False,
572 headers='signal.h',
573 msg='Checking if signal handlers return int'):
574 conf.DEFINE('RETSIGTYPE', 'int')
575 else:
576 conf.DEFINE('RETSIGTYPE', 'void')
578 conf.CHECK_VARIABLE('__FUNCTION__', define='HAVE_FUNCTION_MACRO')
580 conf.CHECK_CODE('va_list ap1,ap2; va_copy(ap1,ap2)',
581 define="HAVE_VA_COPY",
582 msg="Checking for va_copy")
584 conf.CHECK_CODE('''
585 #define eprintf(...) fprintf(stderr, __VA_ARGS__)
586 eprintf("bla", "bar")
587 ''', define='HAVE__VA_ARGS__MACRO')
589 conf.SAMBA_BUILD_ENV()
592 def build(bld):
593 # give a more useful message if the source directory has moved
594 curdir = bld.path.abspath()
595 srcdir = bld.srcnode.abspath()
596 relpath = os_path_relpath(curdir, srcdir)
597 if relpath.find('../') != -1:
598 Logs.error('bld.path %s is not a child of %s' % (curdir, srcdir))
599 raise Errors.WafError('''The top source directory has moved. Please run distclean and reconfigure''')
601 bld.SETUP_BUILD_GROUPS()
602 bld.ENFORCE_GROUP_ORDERING()
603 bld.CHECK_PROJECT_RULES()