Ejemplo n.º 1
0
def CHECK_LARGEFILE(conf, define='HAVE_LARGEFILE'):
    '''see what we need for largefile support'''
    if conf.CHECK_CODE('return !(sizeof(off_t) >= 8)',
                       define,
                       execute=True,
                       msg='Checking for large file support'):
        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
    return False
Ejemplo n.º 2
0
 def check_functions_headers_code():
     '''helper function for CHECK_BUNDLED_SYSTEM'''
     if require_headers and headers and not conf.CHECK_HEADERS(headers,
                                                               lib=libname):
         return False
     if checkfunctions is not None:
         ok = conf.CHECK_FUNCS_IN(checkfunctions,
                                  libname,
                                  headers=headers,
                                  empty_decl=False,
                                  set_target=False)
         if not ok:
             return False
     if checkcode is not None:
         define = 'CHECK_BUNDLED_SYSTEM_%s' % libname.upper()
         ok = conf.CHECK_CODE(checkcode,
                              lib=libname,
                              headers=headers,
                              local_include=False,
                              msg=msg,
                              define=define)
         conf.CONFIG_RESET(define)
         if not ok:
             return False
     return True
Ejemplo n.º 3
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.º 4
0
def CHECK_C_PROTOTYPE(conf, function, prototype, define, headers=None, msg=None):
    '''verify that a C prototype matches the one on the current system'''
    if not conf.CHECK_DECLS(function, headers=headers):
        return False
    if not msg:
        msg = 'Checking C prototype for %s' % function
    return conf.CHECK_CODE('%s; void *_x = (void *)%s' % (prototype, function),
                           define=define,
                           local_include=False,
                           headers=headers,
                           link=False,
                           execute=False,
                           msg=msg)
Ejemplo n.º 5
0
def CHECK_CHARSET_EXISTS(conf, charset, outcharset='UCS-2LE', headers=None, define=None):
    '''check that a named charset is able to be used with iconv_open() for conversion
    to a target charset
    '''
    msg = 'Checking if can we convert from %s to %s' % (charset, outcharset)
    if define is None:
        define = 'HAVE_CHARSET_%s' % charset.upper().replace('-','_')
    return conf.CHECK_CODE('''
                           iconv_t cd = iconv_open("%s", "%s");
                           if (cd == 0 || cd == (iconv_t)-1) return -1;
                           ''' % (charset, outcharset),
                           define=define,
                           execute=True,
                           msg=msg,
                           lib='iconv',
                           headers=headers)
Ejemplo n.º 6
0
def CHECK_UNAME(conf):
    '''setup SYSTEM_UNAME_* defines'''
    ret = True
    for v in "sysname machine release version".split():
        if not conf.CHECK_CODE('''
                               struct utsname n;
                               if (uname(&n) == -1) return -1;
                               printf("%%s", n.%s);
                               ''' % v,
                               define='SYSTEM_UNAME_%s' % v.upper(),
                               execute=True,
                               define_ret=True,
                               quote=True,
                               headers='sys/utsname.h',
                               local_include=False,
                               msg="Checking uname %s type" % v):
            ret = False
    return ret
Ejemplo n.º 7
0
def CHECK_INLINE(conf):
    '''check for the right value for inline'''
    conf.COMPOUND_START('Checking for inline')
    for i in ['inline', '__inline__', '__inline']:
        ret = conf.CHECK_CODE('''
        typedef int foo_t;
        static %s foo_t static_foo () {return 0; }
        %s foo_t foo () {return 0; }''' % (i, i),
                              define='INLINE_MACRO',
                              addmain=False,
                              link=False)
        if ret:
            if i != 'inline':
                conf.DEFINE('inline', i, quote=False)
            break
    if not ret:
        conf.COMPOUND_END(ret)
    else:
        conf.COMPOUND_END(i)
    return ret