def library_flags(self, libs):
    '''work out flags from pkg_config'''
    ccflags = []
    ldflags = []
    cpppath = []
    for lib in TO_LIST(libs):
        # note that we do not add the -I and -L in here, as that is added by the waf
        # core. Adding it here would just change the order that it is put on the link line
        # which can cause system paths to be added before internal libraries
        extra_ccflags = TO_LIST(
            getattr(self.env, 'CFLAGS_%s' % lib.upper(), []))
        extra_ldflags = TO_LIST(
            getattr(self.env, 'LDFLAGS_%s' % lib.upper(), []))
        extra_cpppath = TO_LIST(
            getattr(self.env, 'CPPPATH_%s' % lib.upper(), []))
        ccflags.extend(extra_ccflags)
        ldflags.extend(extra_ldflags)
        cpppath.extend(extra_cpppath)

        extra_cpppath = TO_LIST(
            getattr(self.env, 'INCLUDES_%s' % lib.upper(), []))
        cpppath.extend(extra_cpppath)
    if 'EXTRA_LDFLAGS' in self.env:
        ldflags.extend(self.env['EXTRA_LDFLAGS'])

    ccflags = unique_list(ccflags)
    ldflags = unique_list(ldflags)
    cpppath = unique_list(cpppath)
    return (ccflags, ldflags, cpppath)
Ejemplo n.º 2
0
def CHECK_CFLAGS(conf, cflags, fragment='int main(void) { return 0; }\n'):
    '''check if the given cflags are accepted by the compiler
    '''
    check_cflags = TO_LIST(cflags)
    if 'WERROR_CFLAGS' in conf.env:
        check_cflags.extend(conf.env['WERROR_CFLAGS'])
    return conf.check(fragment=fragment,
                      execute=0,
                      type='nolink',
                      ccflags=check_cflags,
                      msg="Checking compiler accepts %s" % cflags)
def ADD_NAMED_CFLAGS(conf, name, flags, testflags=False, prereq_flags=[]):
    '''add some CFLAGS to the command line
       optionally set testflags to ensure all the flags work
    '''
    prereq_flags = TO_LIST(prereq_flags)
    if testflags:
        ok_flags = []
        for f in flags.split():
            if CHECK_CFLAGS(conf, [f] + prereq_flags):
                ok_flags.append(f)
        flags = ok_flags
    if not name in conf.env:
        conf.env[name] = []
    conf.env[name].extend(TO_LIST(flags))
Ejemplo n.º 4
0
def CHECK_FUNCS_IN(
    conf, list, library, mandatory=False, checklibc=False, headers=None, link=True, empty_decl=True, set_target=True
):
    """
    check that the functions in 'list' are available in 'library'
    if they are, then make that library available as a dependency

    if the library is not available and mandatory==True, then
    raise an error.

    If the library is not available and mandatory==False, then
    add the library to the list of dependencies to remove from
    build rules

    optionally check for the functions first in libc
    """
    remaining = TO_LIST(list)
    liblist = TO_LIST(library)

    # check if some already found
    for f in remaining[:]:
        if CONFIG_SET(conf, "HAVE_%s" % f.upper()):
            remaining.remove(f)

    # see if the functions are in libc
    if checklibc:
        for f in remaining[:]:
            if CHECK_FUNC(conf, f, link=True, headers=headers):
                remaining.remove(f)

    if remaining == []:
        for lib in liblist:
            if GET_TARGET_TYPE(conf, lib) != "SYSLIB" and empty_decl:
                SET_TARGET_TYPE(conf, lib, "EMPTY")
        return True

    checklist = conf.CHECK_LIB(liblist, empty_decl=empty_decl, set_target=set_target)
    for lib in liblist[:]:
        if not lib in checklist and mandatory:
            Logs.error("Mandatory library '%s' not found for functions '%s'" % (lib, list))
            sys.exit(1)

    ret = True
    for f in remaining:
        if not CHECK_FUNC(conf, f, lib=" ".join(checklist), headers=headers, link=link):
            ret = False

    return ret
Ejemplo n.º 5
0
def SAMBA_PIDL_LIST(bld,
                    name,
                    source,
                    options='',
                    output_dir='.',
                    generate_tables=True,
                    generate_fuzzers=True):
    '''A wrapper for building a set of IDL files'''
    for p in TO_LIST(source):
        bld.SAMBA_PIDL(name,
                       p,
                       options=options,
                       output_dir=output_dir,
                       generate_tables=generate_tables)

        # Some IDL files don't exactly match between name and
        # "interface" so we need a way to skip those, while other IDL
        # files have the table generation skipped entirely, on which
        # the fuzzers rely
        if generate_tables and generate_fuzzers:
            interface = p[0:-4]  # strip off the .idl suffix
            bld.SAMBA_NDR_FUZZ(interface,
                               auto_deps=True,
                               fuzz_type="TYPE_STRUCT")

            # Only generate the TYPE_STRUCT fuzzer if this isn't
            # really DCE/RPC
            if '--client' in options:
                bld.SAMBA_NDR_FUZZ(interface,
                                   auto_deps=True,
                                   fuzz_type="TYPE_IN")
                bld.SAMBA_NDR_FUZZ(interface,
                                   auto_deps=True,
                                   fuzz_type="TYPE_OUT")
Ejemplo n.º 6
0
def PKG_CONFIG_FILES(bld, pc_files, vnum=None, extra_name=None):
    '''install some pkg_config pc files'''
    dest = '${PKGCONFIGDIR}'
    dest = bld.EXPAND_VARIABLES(dest)
    for f in TO_LIST(pc_files):
        if extra_name:
            target = f.split('.pc')[0] + extra_name + ".pc"
        else:
            target = f
        base=os.path.basename(target)
        t = bld.SAMBA_GENERATOR('PKGCONFIG_%s' % base,
                                rule=subst_at_vars,
                                source=f+'.in',
                                target=target)
        bld.add_manual_dependency(bld.path.find_or_declare(f), bld.env['PREFIX'].encode('utf8'))
        t.vars = []
        if t.env.RPATH_ON_INSTALL:
            t.env.LIB_RPATH = t.env.RPATH_ST % t.env.LIBDIR
        else:
            t.env.LIB_RPATH = ''
        if vnum:
            t.env.PACKAGE_VERSION = vnum
        for v in [ 'PREFIX', 'EXEC_PREFIX', 'LIB_RPATH' ]:
            t.vars.append(t.env[v])
        bld.INSTALL_FILES(dest, target, flat=True, destname=base)
def CHECK_FUNCS(conf, list, link=True, lib=None, headers=None):
    '''check for a list of functions'''
    ret = True
    for f in TO_LIST(list):
        if not CHECK_FUNC(conf, f, link=link, lib=lib, headers=headers):
            ret = False
    return ret
Ejemplo n.º 8
0
def check_syslib_dependencies(bld, t):
    '''check for syslib depenencies'''

    if bld.get_tgen_by_name(t.sname + ".objlist"):
        return

    sname = real_name(t.sname)

    remaining = set()

    features = TO_LIST(t.features)
    if 'pyembed' in features or 'pyext' in features:
        if 'python' in bld.env.public_symbols:
            t.unsatisfied_symbols = t.unsatisfied_symbols.difference(bld.env.public_symbols['python'])

    needed = {}
    for sym in t.unsatisfied_symbols:
        if sym in bld.env.symbol_map:
            dep = bld.env.symbol_map[sym][0]
            if dep == 'c':
                continue
            if not dep in needed:
                needed[dep] = set()
            needed[dep].add(sym)
        else:
            remaining.add(sym)

    for dep in needed:
        Logs.info("Target '%s' should add syslib dep '%s' for symbols %s" % (sname, dep, " ".join(needed[dep])))

    if remaining:
        debug("deps: Target '%s' has unsatisfied symbols: %s" % (sname, " ".join(remaining)))
def CHECK_DECLS(conf, vars, reverse=False, headers=None, always=False):
    '''check a list of variable declarations, using the HAVE_DECL_xxx form
       of define

       When reverse==True then use HAVE_xxx_DECL instead of HAVE_DECL_xxx
       '''
    ret = True
    for v in TO_LIST(vars):
        if not reverse:
            define = 'HAVE_DECL_%s' % v.upper()
        else:
            define = 'HAVE_%s_DECL' % v.upper()
        if not CHECK_VARIABLE(conf,
                              v,
                              define=define,
                              headers=headers,
                              msg='Checking for declaration of %s' % v,
                              always=always):
            if not CHECK_CODE(
                    conf,
                    '''
                      return (int)%s;
                      ''' % (v),
                    execute=False,
                    link=False,
                    msg='Checking for declaration of %s (as enum)' % v,
                    local_include=False,
                    headers=headers,
                    define=define,
                    always=always):
                ret = False
    return ret
Ejemplo n.º 10
0
def s3_fix_kwargs(bld, kwargs):
    '''fix the build arguments for s3 build rules to include the
    necessary includes, subdir and cflags options '''
    s3dir = os.path.join(bld.env.srcdir, 'source3')
    s3reldir = os_path_relpath(s3dir, bld.curdir)

    # the extra_includes list is relative to the source3 directory
    extra_includes = ['.', 'include', 'lib', '../lib/tdb_compat']
    # local heimdal paths only included when USING_SYSTEM_KRB5 is not set
    if not bld.CONFIG_SET("USING_SYSTEM_KRB5"):
        extra_includes += [
            '../source4/heimdal/lib/com_err', '../source4/heimdal/lib/krb5',
            '../source4/heimdal/lib/gssapi', '../source4/heimdal_build',
            '../bin/default/source4/heimdal/lib/asn1'
        ]

    if bld.CONFIG_SET('USING_SYSTEM_TDB'):
        (tdb_includes, tdb_ldflags, tdb_cpppath) = library_flags(bld, 'tdb')
        extra_includes += tdb_cpppath
    else:
        extra_includes += ['../lib/tdb/include']

    if bld.CONFIG_SET('USING_SYSTEM_TEVENT'):
        (tevent_includes, tevent_ldflags,
         tevent_cpppath) = library_flags(bld, 'tevent')
        extra_includes += tevent_cpppath
    else:
        extra_includes += ['../lib/tevent']

    if bld.CONFIG_SET('USING_SYSTEM_TALLOC'):
        (talloc_includes, talloc_ldflags,
         talloc_cpppath) = library_flags(bld, 'talloc')
        extra_includes += talloc_cpppath
    else:
        extra_includes += ['../lib/talloc']

    if bld.CONFIG_SET('USING_SYSTEM_POPT'):
        (popt_includes, popt_ldflags,
         popt_cpppath) = library_flags(bld, 'popt')
        extra_includes += popt_cpppath
    else:
        extra_includes += ['../lib/popt']

    if bld.CONFIG_SET('USING_SYSTEM_INIPARSER'):
        (iniparser_includes, iniparser_ldflags,
         iniparser_cpppath) = library_flags(bld, 'iniparser')
        extra_includes += iniparser_cpppath
    else:
        extra_includes += ['../lib/iniparser']

    # s3 builds assume that they will have a bunch of extra include paths
    includes = []
    for d in extra_includes:
        includes += [os.path.join(s3reldir, d)]

    # the rule may already have some includes listed
    if 'includes' in kwargs:
        includes += TO_LIST(kwargs['includes'])
    kwargs['includes'] = includes
Ejemplo n.º 11
0
def CHECK_CC_ENV(conf):
    """trim whitespaces from 'CC'.
    The build farm sometimes puts a space at the start"""
    if os.environ.get('CC'):
        conf.env.CC = TO_LIST(os.environ.get('CC'))
        if len(conf.env.CC) == 1:
            # make for nicer logs if just a single command
            conf.env.CC = conf.env.CC[0]
Ejemplo n.º 12
0
def CHECK_TYPES(conf, list, headers=None, define=None, alternate=None, lib=None):
    '''check for a list of types'''
    ret = True
    for t in TO_LIST(list):
        if not CHECK_TYPE(conf, t, headers=headers,
                          define=define, alternate=alternate, lib=lib):
            ret = False
    return ret
def header_list(conf, headers=None, lib=None):
    '''form a list of headers which exist, as a string'''
    hlist = []
    if headers is not None:
        for h in TO_LIST(headers):
            if CHECK_HEADER(conf, h, add_headers=False, lib=lib):
                hlist.append(h)
    return hlist_to_string(conf, headers=hlist)
Ejemplo n.º 14
0
def build_direct_deps(bld, tgt_list):
    '''build the direct_objects and direct_libs sets for each target'''

    targets  = LOCAL_CACHE(bld, 'TARGET_TYPE')
    syslib_deps  = LOCAL_CACHE(bld, 'SYSLIB_DEPS')

    global_deps = bld.env.GLOBAL_DEPENDENCIES
    global_deps_exclude = set()
    for dep in global_deps:
        t = bld.get_tgen_by_name(dep)
        for d in t.samba_deps:
            # prevent loops from the global dependencies list
            global_deps_exclude.add(d)
            global_deps_exclude.add(d + '.objlist')

    for t in tgt_list:
        t.direct_objects = set()
        t.direct_libs = set()
        t.direct_syslibs = set()
        deps = t.samba_deps_extended[:]
        if getattr(t, 'samba_use_global_deps', False) and not t.sname in global_deps_exclude:
            deps.extend(global_deps)
        for d in deps:
            if d == t.sname: continue
            if not d in targets:
                Logs.error("Unknown dependency '%s' in '%s'" % (d, t.sname))
                sys.exit(1)
            if targets[d] in [ 'EMPTY', 'DISABLED' ]:
                continue
            if targets[d] == 'PYTHON' and targets[t.sname] != 'PYTHON' and t.sname.find('.objlist') == -1:
                # this check should be more restrictive, but for now we have pidl-generated python
                # code that directly depends on other python modules
                Logs.error('ERROR: Target %s has dependency on python module %s' % (t.sname, d))
                sys.exit(1)
            if targets[d] == 'SYSLIB':
                t.direct_syslibs.add(d)
                if d in syslib_deps:
                    for implied in TO_LIST(syslib_deps[d]):
                        if BUILTIN_LIBRARY(bld, implied):
                            t.direct_objects.add(implied)
                        elif targets[implied] == 'SYSLIB':
                            t.direct_syslibs.add(implied)
                        elif targets[implied] in ['LIBRARY', 'MODULE']:
                            t.direct_libs.add(implied)
                        else:
                            Logs.error('Implied dependency %s in %s is of type %s' % (
                                implied, t.sname, targets[implied]))
                            sys.exit(1)
                continue
            t2 = bld.get_tgen_by_name(d)
            if t2 is None:
                Logs.error("no task %s of type %s in %s" % (d, targets[d], t.sname))
                sys.exit(1)
            if t2.samba_type in [ 'LIBRARY', 'MODULE' ]:
                t.direct_libs.add(d)
            elif t2.samba_type in [ 'SUBSYSTEM', 'ASN1', 'PYTHON' ]:
                t.direct_objects.add(d)
    debug('deps: built direct dependencies')
Ejemplo n.º 15
0
def s3_fix_kwargs(bld, kwargs):
    '''fix the build arguments for s3 build rules to include the
	necessary includes, subdir and cflags options '''
    s3dir = os.path.join(bld.env.srcdir, 'source3')
    s3reldir = os_path_relpath(s3dir, bld.curdir)

    # the extra_includes list is relative to the source3 directory
    extra_includes = ['.', 'include', 'lib', '../lib/tdb_compat']
    if not bld.CONFIG_SET("USING_SYSTEM_KRB5"):
        extra_includes += [
            '../source4/heimdal/lib/com_err', '../source4/heimdal/lib/gssapi',
            '../source4/heimdal_build'
        ]

    if bld.CONFIG_SET('BUILD_TDB2'):
        if not bld.CONFIG_SET('USING_SYSTEM_TDB2'):
            extra_includes += ['../lib/tdb2']
    else:
        if not bld.CONFIG_SET('USING_SYSTEM_TDB'):
            extra_includes += ['../lib/tdb/include']

    if not bld.CONFIG_SET('USING_SYSTEM_TEVENT'):
        extra_includes += ['../lib/tevent']

    if not bld.CONFIG_SET('USING_SYSTEM_TALLOC'):
        extra_includes += ['../lib/talloc']

    if not bld.CONFIG_SET('USING_SYSTEM_POPT'):
        extra_includes += ['../lib/popt']

    # s3 builds assume that they will have a bunch of extra include paths
    includes = []
    for d in extra_includes:
        includes += [os.path.join(s3reldir, d)]

    # the rule may already have some includes listed
    if 'includes' in kwargs:
        includes += TO_LIST(kwargs['includes'])
    kwargs['includes'] = includes

    # some S3 code assumes that CONFIGFILE is set
    cflags = ['-DCONFIGFILE="%s"' % bld.env['CONFIGFILE']]
    if 'cflags' in kwargs:
        cflags += TO_LIST(kwargs['cflags'])
    kwargs['cflags'] = cflags
def hlist_to_string(conf, headers=None):
    '''convert a headers list to a set of #include lines'''
    hlist = conf.env.hlist
    if headers:
        hlist = hlist[:]
        hlist.extend(TO_LIST(headers))
    hdrs = "\n".join('#include <%s>' % h for h in hlist)

    return hdrs
Ejemplo n.º 17
0
def PUBLIC_HEADERS(bld, public_headers, header_path=None, public_headers_install=True):
    '''install some headers

    header_path may either be a string that is added to the INCLUDEDIR,
    or it can be a dictionary of wildcard patterns which map to destination
    directories relative to INCLUDEDIR
    '''
    bld.SET_BUILD_GROUP('final')

    if not bld.env.build_public_headers:
        # in this case no header munging neeeded. Used for tdb, talloc etc
        public_headers_simple(bld, public_headers, header_path=header_path,
                              public_headers_install=public_headers_install)
        return

    # create the public header in the given path
    # in the build tree
    for h in TO_LIST(public_headers):
        inst_path = header_install_path(h, header_path)
        if h.find(':') != -1:
            s = h.split(":")
            h_name =  s[0]
            inst_name = s[1]
        else:
            h_name =  h
            inst_name = os.path.basename(h)
        curdir = bld.path.abspath()
        relpath1 = os_path_relpath(bld.srcnode.abspath(), curdir)
        relpath2 = os_path_relpath(curdir, bld.srcnode.abspath())
        targetdir = os.path.normpath(os.path.join(relpath1, bld.env.build_public_headers, inst_path))
        if not os.path.exists(os.path.join(curdir, targetdir)):
            raise Errors.WafError("missing source directory %s for public header %s" % (targetdir, inst_name))
        target = os.path.join(targetdir, inst_name)

        # the source path of the header, relative to the top of the source tree
        src_path = os.path.normpath(os.path.join(relpath2, h_name))

        # the install path of the header, relative to the public include directory
        target_path = os.path.normpath(os.path.join(inst_path, inst_name))

        header_map[src_path] = target_path

        t = bld.SAMBA_GENERATOR('HEADER_%s/%s/%s' % (relpath2, inst_path, inst_name),
                                group='headers',
                                rule=create_public_header,
                                source=h_name,
                                target=target)
        t.env.RELPATH = relpath2
        t.env.TOPDIR  = bld.srcnode.abspath()
        if not bld.env.public_headers_list:
            bld.env.public_headers_list = []
        bld.env.public_headers_list.append(os.path.join(inst_path, inst_name))
        if public_headers_install:
            bld.INSTALL_FILES('${INCLUDEDIR}',
                              target,
                              destname=os.path.join(inst_path, inst_name), flat=True)
def CHECK_FUNCS_IN(conf,
                   list,
                   library,
                   mandatory=False,
                   checklibc=False,
                   headers=None,
                   link=True,
                   empty_decl=True,
                   set_target=True):
    """
    check that the functions in 'list' are available in 'library'
    if they are, then make that library available as a dependency

    if the library is not available and mandatory==True, then
    raise an error.

    If the library is not available and mandatory==False, then
    add the library to the list of dependencies to remove from
    build rules

    optionally check for the functions first in libc
    """
    remaining = TO_LIST(list)
    liblist = TO_LIST(library)

    # check if some already found
    for f in remaining[:]:
        if CONFIG_SET(conf, 'HAVE_%s' % f.upper()):
            remaining.remove(f)

    # see if the functions are in libc
    if checklibc:
        for f in remaining[:]:
            if CHECK_FUNC(conf, f, link=True, headers=headers):
                remaining.remove(f)

    if remaining == []:
        for lib in liblist:
            if GET_TARGET_TYPE(conf, lib) != 'SYSLIB' and empty_decl:
                SET_TARGET_TYPE(conf, lib, 'EMPTY')
        return True

    checklist = conf.CHECK_LIB(liblist,
                               empty_decl=empty_decl,
                               set_target=set_target)
    for lib in liblist[:]:
        if not lib in checklist and mandatory:
            Logs.error("Mandatory library '%s' not found for functions '%s'" %
                       (lib, list))
            sys.exit(1)

    ret = True
    for f in remaining:
        if not CHECK_FUNC(
                conf, f, lib=' '.join(checklist), headers=headers, link=link):
            ret = False

    return ret
Ejemplo n.º 19
0
def hlist_to_string(conf, headers=None):
    '''convert a headers list to a set of #include lines'''
    hdrs = ''
    hlist = conf.env.hlist
    if headers:
        hlist = hlist[:]
        hlist.extend(TO_LIST(headers))
    for h in hlist:
        hdrs += '#include <%s>\n' % h
    return hdrs
Ejemplo n.º 20
0
def check_duplicate_sources(bld, tgt_list):
    '''see if we are compiling the same source file more than once
       without an allow_duplicates attribute'''

    debug('deps: checking for duplicate sources')

    targets = LOCAL_CACHE(bld, 'TARGET_TYPE')
    ret = True

    global tstart

    for t in tgt_list:
        source_list = TO_LIST(getattr(t, 'source', ''))
        tpath = os.path.normpath(
            os_path_relpath(t.path.abspath(bld.env),
                            t.env.BUILD_DIRECTORY + '/default'))
        obj_sources = set()
        for s in source_list:
            p = os.path.normpath(os.path.join(tpath, s))
            if p in obj_sources:
                Logs.error("ERROR: source %s appears twice in target '%s'" %
                           (p, t.sname))
                sys.exit(1)
            obj_sources.add(p)
        t.samba_source_set = obj_sources

    subsystems = {}

    # build a list of targets that each source file is part of
    for t in tgt_list:
        sources = []
        if not targets[t.sname] in ['LIBRARY', 'BINARY', 'PYTHON']:
            continue
        for obj in t.add_objects:
            t2 = t.bld.get_tgen_by_name(obj)
            source_set = getattr(t2, 'samba_source_set', set())
            for s in source_set:
                if not s in subsystems:
                    subsystems[s] = {}
                if not t.sname in subsystems[s]:
                    subsystems[s][t.sname] = []
                subsystems[s][t.sname].append(t2.sname)

    for s in subsystems:
        if len(subsystems[s]) > 1 and Options.options.SHOW_DUPLICATES:
            Logs.warn("WARNING: source %s is in more than one target: %s" %
                      (s, subsystems[s].keys()))
        for tname in subsystems[s]:
            if len(subsystems[s][tname]) > 1:
                raise Utils.WafError(
                    "ERROR: source %s is in more than one subsystem of target '%s': %s"
                    % (s, tname, subsystems[s][tname]))

    return ret
Ejemplo n.º 21
0
def header_install_path(header, header_path):
    '''find the installation path for a header, given a header_path option'''
    if not header_path:
        return ''
    if not isinstance(header_path, list):
        return header_path
    for (p1, dir) in header_path:
        for p2 in TO_LIST(p1):
            if fnmatch.fnmatch(header, p2):
                return dir
    # default to current path
    return ''
Ejemplo n.º 22
0
def CURRENT_CFLAGS(bld, target, cflags, allow_warnings=False, hide_symbols=False):
    '''work out the current flags. local flags are added first'''
    ret = TO_LIST(cflags)
    if not 'EXTRA_CFLAGS' in bld.env:
        list = []
    else:
        list = bld.env['EXTRA_CFLAGS'];
    ret.extend(list)
    if not allow_warnings and 'PICKY_CFLAGS' in bld.env:
        list = bld.env['PICKY_CFLAGS'];
        ret.extend(list)
    if hide_symbols and bld.env.HAVE_VISIBILITY_ATTR:
        ret.append(bld.env.VISIBILITY_CFLAGS)
    return ret
Ejemplo n.º 23
0
def SAMBA_PIDL_LIST(bld,
                    name,
                    source,
                    options='',
                    output_dir='.',
                    generate_tables=True):
    '''A wrapper for building a set of IDL files'''
    for p in TO_LIST(source):
        bld.SAMBA_PIDL(name,
                       p,
                       options=options,
                       output_dir=output_dir,
                       generate_tables=generate_tables)
Ejemplo n.º 24
0
def s3_fix_kwargs(bld, kwargs):
    '''fix the build arguments for s3 build rules to include the
    necessary includes, subdir and cflags options '''
    s3dir = os.path.join(bld.env.srcdir, 'source3')
    s3reldir = os.path.relpath(s3dir, bld.path.abspath())

    # the extra_includes list is relative to the source3 directory
    extra_includes = [ '.', 'include', 'lib' ]
    # local heimdal paths must only be included when using our embedded Heimdal
    if bld.CONFIG_SET("USING_EMBEDDED_HEIMDAL"):
        extra_includes += [ '../third_party/heimdal/lib/com_err',
                            '../third_party/heimdal/lib/base',
                            '../third_party/heimdal/lib/krb5',
                            '../third_party/heimdal/lib/gssapi/gssapi',
                            '../third_party/heimdal_build/include',
                            '../bin/default/third_party/heimdal/lib/asn1' ]

    if bld.CONFIG_SET('USING_SYSTEM_TDB'):
        (tdb_includes, tdb_ldflags, tdb_cpppath) = library_flags(bld, 'tdb')
        extra_includes += tdb_cpppath
    else:
        extra_includes += [ '../lib/tdb/include' ]

    if bld.CONFIG_SET('USING_SYSTEM_TEVENT'):
        (tevent_includes, tevent_ldflags, tevent_cpppath) = library_flags(bld, 'tevent')
        extra_includes += tevent_cpppath
    else:
        extra_includes += [ '../lib/tevent' ]

    if bld.CONFIG_SET('USING_SYSTEM_TALLOC'):
        (talloc_includes, talloc_ldflags, talloc_cpppath) = library_flags(bld, 'talloc')
        extra_includes += talloc_cpppath
    else:
        extra_includes += [ '../lib/talloc' ]

    if bld.CONFIG_SET('USING_SYSTEM_POPT'):
        (popt_includes, popt_ldflags, popt_cpppath) = library_flags(bld, 'popt')
        extra_includes += popt_cpppath
    else:
        extra_includes += [ '../lib/popt' ]

    # s3 builds assume that they will have a bunch of extra include paths
    includes = []
    for d in extra_includes:
        includes += [ os.path.join(s3reldir, d) ]

    # the rule may already have some includes listed
    if 'includes' in kwargs:
        includes += TO_LIST(kwargs['includes'])
    kwargs['includes'] = includes
Ejemplo n.º 25
0
def add_samba_attributes(bld, tgt_list):
    '''ensure a target has a the required samba attributes'''

    targets = LOCAL_CACHE(bld, 'TARGET_TYPE')

    for t in tgt_list:
        if t.name != '':
            t.sname = t.name
        else:
            t.sname = t.target
        t.samba_type = targets[t.sname]
        t.samba_abspath = t.path.abspath(bld.env)
        t.samba_deps_extended = t.samba_deps[:]
        t.samba_includes_extended = TO_LIST(t.samba_includes)[:]
        t.cflags = getattr(t, 'samba_cflags', '')
Ejemplo n.º 26
0
def public_headers_simple(bld, public_headers, header_path=None, public_headers_install=True):
    '''install some headers - simple version, no munging needed
    '''
    if not public_headers_install:
        return
    for h in TO_LIST(public_headers):
        inst_path = header_install_path(h, header_path)
        if h.find(':') != -1:
            s = h.split(":")
            h_name =  s[0]
            inst_name = s[1]
        else:
            h_name =  h
            inst_name = os.path.basename(h)
        bld.INSTALL_FILES('${INCLUDEDIR}', h_name, destname=inst_name)
def ADD_LDFLAGS(conf, flags, testflags=False):
    '''add some LDFLAGS to the command line
       optionally set testflags to ensure all the flags work

       this will return the flags that are added, if any
    '''
    if testflags:
        ok_flags = []
        for f in flags.split():
            if CHECK_LDFLAGS(conf, f):
                ok_flags.append(f)
        flags = ok_flags
    if not 'EXTRA_LDFLAGS' in conf.env:
        conf.env['EXTRA_LDFLAGS'] = []
    conf.env['EXTRA_LDFLAGS'].extend(TO_LIST(flags))
    return flags
def CHECK_HEADERS(conf, headers, add_headers=False, together=False, lib=None):
    '''check for a list of headers

    when together==True, then the headers accumulate within this test.
    This is useful for interdependent headers
    '''
    ret = True
    if not add_headers and together:
        saved_hlist = conf.env.hlist[:]
        set_add_headers = True
    else:
        set_add_headers = add_headers
    for hdr in TO_LIST(headers):
        if not CHECK_HEADER(conf, hdr, set_add_headers, lib=lib):
            ret = False
    if not add_headers and together:
        conf.env.hlist = saved_hlist
    return ret
Ejemplo n.º 29
0
def CHECK_LARGEFILE(conf, define='HAVE_LARGEFILE'):
    '''see what we need for largefile support'''
    getconf_cflags = conf.CHECK_COMMAND(['getconf', 'LFS_CFLAGS'])
    if getconf_cflags is not False:
        if (conf.CHECK_CODE(
                'return !(sizeof(off_t) >= 8)',
                define='WORKING_GETCONF_LFS_CFLAGS',
                execute=True,
                cflags=getconf_cflags,
                msg='Checking getconf large file support flags work')):
            conf.ADD_CFLAGS(getconf_cflags)
            getconf_cflags_list = TO_LIST(getconf_cflags)
            for flag in getconf_cflags_list:
                if flag[:2] == "-D":
                    flag_split = flag[2:].split('=')
                    if len(flag_split) == 1:
                        conf.DEFINE(flag_split[0], '1')
                    else:
                        conf.DEFINE(flag_split[0], flag_split[1])

    if conf.CHECK_CODE(
            'return !(sizeof(off_t) >= 8)',
            define,
            execute=True,
            msg='Checking for large file support without additional flags'):
        return True

    if conf.CHECK_CODE('return !(sizeof(off_t) >= 8)',
                       define,
                       execute=True,
                       cflags='-D_FILE_OFFSET_BITS=64',
                       msg='Checking for -D_FILE_OFFSET_BITS=64'):
        conf.DEFINE('_FILE_OFFSET_BITS', 64)
        return True

    if conf.CHECK_CODE('return !(sizeof(off_t) >= 8)',
                       define,
                       execute=True,
                       cflags='-D_LARGE_FILES',
                       msg='Checking for -D_LARGE_FILES'):
        conf.DEFINE('_LARGE_FILES', 1)
        return True
    return False
Ejemplo n.º 30
0
def CHECK_LIB(conf, libs, mandatory=False, empty_decl=True, set_target=True, shlib=False):
    '''check if a set of libraries exist as system libraries

    returns the sublist of libs that do exist as a syslib or []
    '''

    fragment= '''
int foo()
{
    int v = 2;
    return v*2;
}
'''
    ret = []
    liblist  = TO_LIST(libs)
    for lib in liblist[:]:
        if GET_TARGET_TYPE(conf, lib) == 'SYSLIB':
            ret.append(lib)
            continue

        (ccflags, ldflags, cpppath) = library_flags(conf, lib)
        if shlib:
            res = conf.check(features='c cshlib', fragment=fragment, lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper(), mandatory=False)
        else:
            res = conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper(), mandatory=False)

        if not res:
            if mandatory:
                Logs.error("Mandatory library '%s' not found for functions '%s'" % (lib, list))
                sys.exit(1)
            if empty_decl:
                # if it isn't a mandatory library, then remove it from dependency lists
                if set_target:
                    SET_TARGET_TYPE(conf, lib, 'EMPTY')
        else:
            conf.define('HAVE_LIB%s' % lib.upper().replace('-','_').replace('.','_'), 1)
            conf.env['LIB_' + lib.upper()] = lib
            if set_target:
                conf.SET_TARGET_TYPE(lib, 'SYSLIB')
            ret.append(lib)

    return ret
Ejemplo n.º 31
0
def CHECK_SIZEOF(conf, vars, headers=None, define=None, critical=True):
    '''check the size of a type'''
    for v in TO_LIST(vars):
        v_define = define
        ret = False
        if v_define is None:
            v_define = 'SIZEOF_%s' % v.upper().replace(' ', '_')
        for size in list((1, 2, 4, 8, 16, 32)):
            if CHECK_CODE(conf,
                      'static int test_array[1 - 2 * !(((long int)(sizeof(%s))) <= %d)];' % (v, size),
                      define=v_define,
                      quote=False,
                      headers=headers,
                      local_include=False,
                      msg="Checking if size of %s == %d" % (v, size)):
                conf.DEFINE(v_define, size)
                ret = True
                break
        if not ret and critical:
            Logs.error("Couldn't determine size of '%s'" % v)
            sys.exit(1)
    return ret
Ejemplo n.º 32
0
def CHECK_CODE(conf, code, define,
               always=False, execute=False, addmain=True,
               add_headers=True, mandatory=False,
               headers=None, msg=None, cflags='', includes='# .',
               local_include=True, lib=None, link=True,
               define_ret=False, quote=False,
               on_target=True):
    '''check if some code compiles and/or runs'''

    if CONFIG_SET(conf, define):
        return True

    if headers is not None:
        CHECK_HEADERS(conf, headers=headers, lib=lib)

    if add_headers:
        hdrs = header_list(conf, headers=headers, lib=lib)
    else:
        hdrs = ''
    if execute:
        execute = 1
    else:
        execute = 0

    defs = conf.get_config_header()

    if addmain:
        fragment='%s\n%s\n int main(void) { %s; return 0; }\n' % (defs, hdrs, code)
    else:
        fragment='%s\n%s\n%s\n' % (defs, hdrs, code)

    if msg is None:
        msg="Checking for %s" % define

    cflags = TO_LIST(cflags)

    if local_include:
        cflags.append('-I%s' % conf.curdir)

    if not link:
        type='nolink'
    else:
        type='cprogram'

    uselib = TO_LIST(lib)

    (ccflags, ldflags, cpppath) = library_flags(conf, uselib)

    includes = TO_LIST(includes)
    includes.extend(cpppath)

    uselib = [l.upper() for l in uselib]

    cflags.extend(ccflags)

    if on_target:
        exec_args = conf.SAMBA_CROSS_ARGS(msg=msg)
    else:
        exec_args = []

    conf.COMPOUND_START(msg)

    ret = conf.check(fragment=fragment,
                     execute=execute,
                     define_name = define,
                     mandatory = mandatory,
                     ccflags=cflags,
                     ldflags=ldflags,
                     includes=includes,
                     uselib=uselib,
                     type=type,
                     msg=msg,
                     quote=quote,
                     exec_args=exec_args,
                     define_ret=define_ret)
    if not ret and CONFIG_SET(conf, define):
        # sometimes conf.check() returns false, but it
        # sets the define. Maybe a waf bug?
        ret = True
    if ret:
        if not define_ret:
            conf.DEFINE(define, 1)
            conf.COMPOUND_END(True)
        else:
            conf.COMPOUND_END(conf.env[define])
        return True
    if always:
        conf.DEFINE(define, 0)
    conf.COMPOUND_END(False)
    return False