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.º 2
0
def SAMBA_AUTOPROTO(bld, header, source):
    '''rule for samba prototype generation'''
    bld.SET_BUILD_GROUP('prototypes')
    relpath = os_path_relpath(bld.path.abspath(), bld.srcnode.abspath())
    name = os.path.join(relpath, header)
    SET_TARGET_TYPE(bld, name, 'PROTOTYPE')
    t = bld(
        name = name,
        source = source,
        target = header,
        update_outputs=True,
        ext_out='.c',
        before ='c',
        rule = '${PERL} "${SCRIPT}/mkproto.pl" --srcdir=.. --builddir=. --public=/dev/null --private="${TGT}" ${SRC}'
        )
    t.env.SCRIPT = os.path.join(bld.srcnode.abspath(), 'source4/script')
Ejemplo n.º 3
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.º 4
0
def SAMBA_PIDL(bld,
               pname,
               source,
               options='',
               output_dir='.',
               generate_tables=True):
    '''Build a IDL file using pidl.
       This will produce up to 13 output files depending on the options used'''

    bname = source[0:-4]
    # strip off the .idl suffix
    bname = os.path.basename(bname)
    name = "%s_%s" % (pname, bname.upper())

    if not SET_TARGET_TYPE(bld, name, 'PIDL'):
        return

    bld.SET_BUILD_GROUP('build_source')

    # the output files depend on the options used. Use this dictionary
    # to map between the options and the resulting file names
    options_map = {
        '--header': '%s.h',
        '--ndr-parser': 'ndr_%s.c ndr_%s.h',
        '--samba3-ndr-server': 'srv_%s.c srv_%s.h',
        '--samba3-ndr-client': 'cli_%s.c cli_%s.h',
        '--server': 'ndr_%s_s.c',
        '--client': 'ndr_%s_c.c ndr_%s_c.h',
        '--python': 'py_%s.c',
        '--tdr-parser': 'tdr_%s.c tdr_%s.h',
        '--dcom-proxy': '%s_p.c',
        '--com-header': 'com_%s.h'
    }

    table_header_idx = None
    out_files = []
    options_list = TO_LIST(options)

    for o in options_list:
        if o in options_map:
            ofiles = TO_LIST(options_map[o])
            for f in ofiles:
                out_files.append(os.path.join(output_dir, f % bname))
                if f == 'ndr_%s.h':
                    # remember this one for the tables generation
                    table_header_idx = len(out_files) - 1

    # depend on the full pidl sources
    source = TO_LIST(source)
    try:
        pidl_src_nodes = bld.pidl_files_cache
    except AttributeError:
        bld.pidl_files_cache = bld.srcnode.ant_glob('pidl/lib/Parse/**/*.pm',
                                                    flat=False)
        bld.pidl_files_cache.extend(bld.srcnode.ant_glob('pidl', flat=False))
        pidl_src_nodes = bld.pidl_files_cache

    # the cd .. is needed because pidl currently is sensitive to the directory it is run in
    cpp = ""
    cc = ""
    if bld.CONFIG_SET("CPP") and bld.CONFIG_GET("CPP") != "":
        if isinstance(bld.CONFIG_GET("CPP"), list):
            cpp = 'CPP="%s"' % " ".join(bld.CONFIG_GET("CPP"))
        else:
            cpp = 'CPP="%s"' % bld.CONFIG_GET("CPP")

    if cpp == "CPP=xlc_r":
        cpp = ""

    if bld.env['PIDL_DEVELOPER_MODE']:
        pidl_dev = 'PIDL_DEVELOPER=1 '
    else:
        pidl_dev = ''

    if bld.CONFIG_SET("CC"):
        if isinstance(bld.CONFIG_GET("CC"), list):
            cc = 'CC="%s"' % " ".join(bld.CONFIG_GET("CC"))
        else:
            cc = 'CC="%s"' % bld.CONFIG_GET("CC")

    t = bld(
        rule=
        'cd ${PIDL_LAUNCH_DIR} && %s%s %s ${PERL} ${PIDL} --quiet ${OPTIONS} --outputdir ${OUTPUTDIR} -- "${IDLSRC}"'
        % (pidl_dev, cpp, cc),
        ext_out='.c',
        before='c',
        update_outputs=True,
        shell=True,
        source=source,
        target=out_files,
        name=name,
        samba_type='PIDL')

    t.env.PIDL_LAUNCH_DIR = bld.srcnode.path_from(bld.bldnode)
    pnode = bld.srcnode.find_resource('pidl/pidl')
    t.env.PIDL = pnode.path_from(bld.srcnode)
    t.env.OPTIONS = TO_LIST(options)
    snode = t.path.find_resource(source[0])
    t.env.IDLSRC = snode.path_from(bld.srcnode)
    t.env.OUTPUTDIR = bld.bldnode.path_from(
        bld.srcnode) + '/' + bld.path.find_dir(output_dir).path_from(
            bld.srcnode)

    bld.add_manual_dependency(snode, pidl_src_nodes)

    if generate_tables and table_header_idx is not None:
        pidl_headers = LOCAL_CACHE(bld, 'PIDL_HEADERS')
        pidl_headers[name] = [
            bld.path.find_or_declare(out_files[table_header_idx])
        ]

    t.more_includes = '#' + bld.path.path_from(bld.srcnode)