2010-03-25 06:58:35 -06:00
# tests for charsets for Samba3
2018-02-02 16:34:32 +02:00
from waflib . Configure import conf
2010-03-25 06:58:35 -06:00
2018-07-30 18:20:39 +12:00
2010-03-25 06:58:35 -06:00
@conf
def CHECK_SAMBA3_CHARSET ( conf , crossbuild = False ) :
''' Check for default charsets for Samba3
'''
if conf . CHECK_ICONV ( define = ' HAVE_NATIVE_ICONV ' ) :
2018-07-30 18:18:03 +12:00
default_dos_charset = False
default_unix_charset = False
2010-03-25 06:58:35 -06:00
# check for default dos charset name
for charset in [ ' CP850 ' , ' IBM850 ' ] :
2010-03-26 00:55:25 -06:00
if conf . CHECK_CHARSET_EXISTS ( charset , headers = ' iconv.h ' ) :
2018-07-30 18:18:03 +12:00
default_dos_charset = charset
2010-03-25 06:58:35 -06:00
break
# check for default unix charset name
for charset in [ ' UTF-8 ' , ' UTF8 ' ] :
2010-03-26 00:55:25 -06:00
if conf . CHECK_CHARSET_EXISTS ( charset , headers = ' iconv.h ' ) :
2018-07-30 18:18:03 +12:00
default_unix_charset = charset
2010-03-25 06:58:35 -06:00
break
2018-07-30 18:13:51 +12:00
# At this point, we have a libiconv candidate. We know that
# we have the right headers and libraries, but we don't know
# whether it does the conversions we want. We can't test this
# because we are cross-compiling. This is not necessarily a big
# deal, since we can't guarantee that the results we get now will
# match the results we get at runtime anyway.
if crossbuild :
2018-07-30 18:18:03 +12:00
default_dos_charset = " CP850 "
default_unix_charset = " UTF-8 "
2010-03-25 06:58:35 -06:00
# TODO: this used to warn about the set charset on cross builds
2013-12-04 22:50:11 +01:00
if default_dos_charset is False or default_unix_charset is False :
2018-07-30 18:14:00 +12:00
# we found iconv, but it failed to convert anything (e.g. on AIX)
2018-07-30 18:22:11 +12:00
conf . undefine ( ' HAVE_NATIVE_ICONV ' )
2013-12-04 22:50:11 +01:00
default_dos_charset = " ASCII "
default_unix_charset = " UTF-8 "
2010-03-26 01:05:37 -06:00
conf . DEFINE ( ' DEFAULT_DOS_CHARSET ' , default_dos_charset , quote = True )
conf . DEFINE ( ' DEFAULT_UNIX_CHARSET ' , default_unix_charset , quote = True )
2010-03-25 06:58:35 -06:00
else :
2010-03-26 01:05:37 -06:00
conf . DEFINE ( ' DEFAULT_DOS_CHARSET ' , " ASCII " , quote = True )
conf . DEFINE ( ' DEFAULT_UNIX_CHARSET ' , " UTF8 " , quote = True )