PEP8: fix E225: missing whitespace around operator
[garming/samba-autobuild/.git] / source3 / build / charset.py
1 # tests for charsets for Samba3
2
3 from Configure import conf
4
5 @conf
6 def CHECK_SAMBA3_CHARSET(conf, crossbuild=False):
7     '''Check for default charsets for Samba3
8     '''
9     if conf.CHECK_ICONV(define='HAVE_NATIVE_ICONV'):
10         default_dos_charset = False
11         default_unix_charset = False
12
13         # check for default dos charset name
14         for charset in ['CP850', 'IBM850']:
15             if conf.CHECK_CHARSET_EXISTS(charset, headers='iconv.h'):
16                 default_dos_charset = charset
17                 break
18
19         # check for default unix charset name
20         for charset in ['UTF-8', 'UTF8']:
21             if conf.CHECK_CHARSET_EXISTS(charset, headers='iconv.h'):
22                 default_unix_charset = charset
23                 break
24
25         # At this point, we have a libiconv candidate. We know that
26         # we have the right headers and libraries, but we don't know
27         # whether it does the conversions we want. We can't test this
28         # because we are cross-compiling. This is not necessarily a big
29         # deal, since we can't guarantee that the results we get now will
30         # match the results we get at runtime anyway.
31         if crossbuild:
32             default_dos_charset = "CP850"
33             default_unix_charset = "UTF-8"
34             # TODO: this used to warn about the set charset on cross builds
35
36         if default_dos_charset is False or default_unix_charset is False:
37             # we found iconv, but it failed to convert anything (e.g. on AIX)
38             conf.undefine('HAVE_NATIVE_ICONV');
39             default_dos_charset = "ASCII"
40             default_unix_charset = "UTF-8"
41
42         conf.DEFINE('DEFAULT_DOS_CHARSET', default_dos_charset, quote=True)
43         conf.DEFINE('DEFAULT_UNIX_CHARSET', default_unix_charset, quote=True)
44
45     else:
46         conf.DEFINE('DEFAULT_DOS_CHARSET', "ASCII", quote=True)
47         conf.DEFINE('DEFAULT_UNIX_CHARSET', "UTF8", quote=True)
48