1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-13 13:18:06 +03:00
samba-mirror/lib/ccan/wscript
Rusty Russell 8150f69dc4 ccan: make it a grouping library.
Andrew Bartlett pointed out that making CCAN a non-library will break
the build in a different way in future: when two separate private
libraries start using the same CCAN module, the symbol duplicate
detection will fire (since private libaries don't use any symbol
hiding).  That doesn't happen yet, but it will surely happen
eventually.

So, for now at least, we build as a private library again.  This
unfortunately means the top-level build creates a libccan.so, which
contains all the ccan modules whether you need them or not.  Given the
size of the library, I don't think this is a win.  But it's simple.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

Autobuild-User(master): Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date(master): Sat Jun 30 11:19:04 CEST 2012 on sn-devel-104
2012-06-30 11:19:03 +02:00

172 lines
7.8 KiB
Python

#!/usr/bin/env python
import Logs, sys, Options
def configure(conf):
conf.DEFINE('HAVE_CCAN', 1)
conf.CHECK_HEADERS('err.h')
# FIXME: if they don't have -Werror, these will all fail. But they
# probably will anyway...
conf.CHECK_CODE('int __attribute__((cold)) func(int x) { return x; }',
addmain=False, link=False, cflags="-Werror",
define='HAVE_ATTRIBUTE_COLD')
conf.CHECK_CODE('int __attribute__((const)) func(int x) { return x; }',
addmain=False, link=False, cflags="-Werror",
define='HAVE_ATTRIBUTE_CONST')
conf.CHECK_CODE('void __attribute__((noreturn)) func(int x) { exit(x); }',
addmain=False, link=False, cflags="-Werror",
define='HAVE_ATTRIBUTE_NORETURN')
conf.CHECK_CODE('void __attribute__((format(__printf__, 1, 2))) func(const char *fmt, ...) { }',
addmain=False, link=False, cflags="-Werror",
define='HAVE_ATTRIBUTE_PRINTF')
conf.CHECK_CODE('int __attribute__((unused)) func(int x) { return x; }',
addmain=False, link=False, cflags="-Werror",
define='HAVE_ATTRIBUTE_UNUSED')
conf.CHECK_CODE('int __attribute__((used)) func(int x) { return x; }',
addmain=False, link=False, cflags="-Werror",
define='HAVE_ATTRIBUTE_USED')
# We try to use headers for a compile-time test.
conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
#define B __BYTE_ORDER
#elif defined(BYTE_ORDER)
#define B BYTE_ORDER
#endif
#ifdef __LITTLE_ENDIAN
#define LITTLE __LITTLE_ENDIAN
#elif defined(LITTLE_ENDIAN)
#define LITTLE LITTLE_ENDIAN
#endif
#if !defined(LITTLE) || !defined(B) || LITTLE != B
#error Not little endian.
#endif""",
headers="endian.h sys/endian.h",
define="HAVE_LITTLE_ENDIAN")
conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
#define B __BYTE_ORDER
#elif defined(BYTE_ORDER)
#define B BYTE_ORDER
#endif
#ifdef __BIG_ENDIAN
#define BIG __BIG_ENDIAN
#elif defined(BIG_ENDIAN)
#define BIG BIG_ENDIAN
#endif
#if !defined(BIG) || !defined(B) || BIG != B
#error Not big endian.
#endif""",
headers="endian.h sys/endian.h",
define="HAVE_BIG_ENDIAN")
if not conf.CONFIG_SET("HAVE_BIG_ENDIAN") and not conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
# That didn't work! Do runtime test.
conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
u.i = 0x01020304;
return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;""",
addmain=True, execute=True,
define='HAVE_LITTLE_ENDIAN',
msg="Checking for HAVE_LITTLE_ENDIAN - runtime")
conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
u.i = 0x01020304;
return u.c[0] == 0x01 && u.c[1] == 0x02 && u.c[2] == 0x03 && u.c[3] == 0x04 ? 0 : 1;""",
addmain=True, execute=True,
define='HAVE_BIG_ENDIAN',
msg="Checking for HAVE_BIG_ENDIAN - runtime")
# Extra sanity check.
if conf.CONFIG_SET("HAVE_BIG_ENDIAN") == conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
Logs.error("Failed endian determination. The PDP-11 is back?")
sys.exit(1)
conf.CHECK_CODE('return __builtin_choose_expr(1, 0, "garbage");',
link=True,
define='HAVE_BUILTIN_CHOOSE_EXPR')
conf.CHECK_CODE('return __builtin_clz(1) == (sizeof(int)*8 - 1) ? 0 : 1;',
link=True,
define='HAVE_BUILTIN_CLZ')
conf.CHECK_CODE('return __builtin_clzl(1) == (sizeof(long)*8 - 1) ? 0 : 1;',
link=True,
define='HAVE_BUILTIN_CLZL')
conf.CHECK_CODE('return __builtin_clzll(1) == (sizeof(long long)*8 - 1) ? 0 : 1;',
link=True,
define='HAVE_BUILTIN_CLZLL')
conf.CHECK_CODE('return __builtin_constant_p(1) ? 0 : 1;',
link=True,
define='HAVE_BUILTIN_CONSTANT_P')
conf.CHECK_CODE('return __builtin_expect(main != 0, 1) ? 0 : 1;',
link=True,
define='HAVE_BUILTIN_EXPECT')
conf.CHECK_CODE('return __builtin_popcountl(255L) == 8 ? 0 : 1;',
link=True,
define='HAVE_BUILTIN_POPCOUNTL')
conf.CHECK_CODE('return __builtin_types_compatible_p(char *, int) ? 1 : 0;',
link=True,
define='HAVE_BUILTIN_TYPES_COMPATIBLE_P')
conf.CHECK_CODE('int *foo = (int[]) { 1, 2, 3, 4 }; return foo[0] ? 0 : 1;',
define='HAVE_COMPOUND_LITERALS')
conf.CHECK_CODE("""#include <ctype.h>
int main(void) { return isblank(' ') ? 0 : 1; }""",
link=True, addmain=False, add_headers=False,
define='HAVE_ISBLANK')
conf.CHECK_CODE('int x = 1; __typeof__(x) i; i = x; return i == x ? 0 : 1;',
link=True,
define='HAVE_TYPEOF')
conf.CHECK_CODE('int __attribute__((warn_unused_result)) func(int x) { return x; }',
addmain=False, link=False, cflags="-Werror",
define='HAVE_WARN_UNUSED_RESULT')
# backtrace could be in libexecinfo or in libc
conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo', checklibc=True, headers='execinfo.h')
def ccan_module(bld, name, deps=''):
bld.SAMBA_SUBSYSTEM('ccan-%s' % name,
source=bld.path.ant_glob('%s/*.c' % name),
deps=deps)
bld.env.CCAN_MODS += 'ccan-%s ' % name
def build(bld):
bld.env.CCAN_MODS = ""
# These have actual C files.
ccan_module(bld, 'hash', 'ccan-build_assert')
ccan_module(bld, 'ilog', 'ccan-compiler');
ccan_module(bld, 'read_write_all')
ccan_module(bld, 'str', 'ccan-build_assert')
ccan_module(bld, 'tally', 'ccan-build_assert ccan-likely')
# These are headers only.
ccan_module(bld, 'array_size', 'ccan-build_assert')
ccan_module(bld, 'asearch','ccan-typesafe_cb ccan-array_size')
ccan_module(bld, 'build_assert')
ccan_module(bld, 'cast', 'ccan-build_assert')
ccan_module(bld, 'check_type', 'ccan-build_assert')
ccan_module(bld, 'compiler')
ccan_module(bld, 'endian')
ccan_module(bld, 'likely', 'ccan-str')
ccan_module(bld, 'typesafe_cb')
# Failtest pulls in a lot of stuff, and it's only for unit tests.
if bld.env.DEVELOPER_MODE:
ccan_module(bld, 'container_of', 'ccan-check_type')
ccan_module(bld, 'err', 'ccan-compiler')
ccan_module(bld, 'htable', 'ccan-compiler')
ccan_module(bld, 'list', 'ccan-container_of')
ccan_module(bld, 'time')
ccan_module(bld, 'tcon')
ccan_module(bld, 'tlist', 'ccan-list ccan-tcon')
ccan_module(bld, 'failtest',
'''
ccan-err ccan-hash ccan-htable ccan-list
ccan-read_write_all ccan-str ccan-time execinfo
''')
# This is the complete CCAN collection as one group.
bld.SAMBA_LIBRARY('ccan',
source='',
deps=bld.env.CCAN_MODS,
private_library=True,
grouping_library=True)