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