#!/usr/bin/env python # tastes like -*- python -*- Import('hostenv') def _CheckIconvPath(context,path): # Some systems have iconv in libc, some have it in libiconv (OSF/1 and # those with the standalone portable libiconv installed). if path: context.Message("checking for iconv in " + path + " ... ") context.env.Append(LIBPATH=path) else: context.Message("checking for iconv in default path ... ") for l in [None,'giconv','iconv']: for h in ['giconv.h','iconv.h']: if l: context.env['LIBS'] = [l] if context.TryLink(""" #include #include <%s> int main() { iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd); return 0; }""" % h, '.c'): context.Result(1) return True context.Result(0) return False def CheckIconv(context): look_dirs = [None, '/usr','/usr/local','/sw'] for p in look_dirs: if _CheckIconvPath(context,p): break if context.TryRun(""" #include main() { iconv_t cd = iconv_open("ASCII", "UCS-2LE"); if (cd == 0 || cd == (iconv_t)-1) return -1; return 0; } """, '.c'): return (1,[]) return (0,[]) if hostenv['configure']: conf = hostenv.Configure( custom_tests = { 'CheckIconv' : CheckIconv }) (have_iconv,iconv) = conf.CheckIconv() conf.Finish() if not have_iconv: print "Install iconv for better charset compatibility" else: iconv = [] # FIXME charset = hostenv.StaticLibrary('charset',['iconv.c','charcnv.c',iconv]) Export('charset')