summaryrefslogtreecommitdiff
path: root/source4/lib/charset/SConscript
blob: 15ee49909cc13b88b124d191b9a9d81f0147a8d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
# tastes like -*- python -*-


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 <stdlib.h>
#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 <iconv.h>
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.Library('charset',['iconv.c','charcnv.c',iconv])
Export('charset')