heimdal_build: Fix detection of system roken library.
[sfrench/samba-autobuild/.git] / source4 / heimdal_build / wscript_configure
1 #!/usr/bin/env python
2
3 import Logs, sys
4
5 conf.CHECK_TYPE('u_char', 'uint8_t')
6 conf.CHECK_TYPE('u_int32_t', 'uint32_t')
7
8 conf.CHECK_HEADERS('err.h')
9
10 conf.CHECK_HEADERS('ifaddrs.h')
11 conf.CHECK_HEADERS('''crypt.h errno.h inttypes.h netdb.h signal.h sys/bswap.h
12                   sys/file.h sys/stropts.h sys/timeb.h sys/times.h sys/uio.h sys/un.h
13               sys/utsname.h time.h timezone.h ttyname.h netinet/in.h
14               netinet/in6.h netinet6/in6.h libintl.h''')
15
16 conf.CHECK_HEADERS('curses.h term.h termcap.h', together=True)
17
18 conf.CHECK_FUNCS('''atexit cgetent getprogname setprogname gethostname
19                     putenv rcmd readv sendmsg setitimer strlwr strncasecmp
20             strptime strsep strsep_copy    strtok_r strupr swab umask uname unsetenv
21             closefrom err warn errx warnx flock writev''')
22
23 conf.CHECK_FUNCS_IN('hstrerror', 'resolv socket nsl', checklibc=True)
24 conf.CHECK_FUNCS_IN('''getnameinfo sendmsg socket getipnodebyname gethostent gethostent_r
25                        sethostent endhostent getipnodebyaddr freehostent gethostbyname
26                        gethostbyname_r gethostbyaddr''',
27                     'socket nsl',
28                     checklibc=True)
29
30 conf.CHECK_FUNCS_IN('dgettext gettext', 'intl', headers='libintl.h')
31
32 conf.CHECK_FUNCS('iruserok')
33
34 conf.CHECK_FUNCS('bswap16')
35 conf.CHECK_FUNCS('bswap32')
36
37 conf.CHECK_TYPE('struct winsize', define='HAVE_STRUCT_WINSIZE', headers='sys/termios.h sys/ioctl.h')
38 conf.CHECK_STRUCTURE_MEMBER('struct winsize', 'ws_xpixel',
39                     define='HAVE_WS_XPIXEL', headers='sys/termios.h sys/ioctl.h')
40 conf.CHECK_STRUCTURE_MEMBER('struct winsize', 'ws_ypixel',
41                     define='HAVE_WS_YPIXEL', headers='sys/termios.h sys/ioctl.h')
42 conf.DEFINE('HAVE_KRB_STRUCT_WINSIZE', 1)
43 conf.DEFINE('VOID_RETSIGTYPE', 1)
44
45 conf.CHECK_VARIABLE('h_errno', headers='netdb.h')
46
47 # strangely enough, we need it with another define too
48 conf.CHECK_DECLS('h_errno', headers='netdb.h')
49
50 conf.CHECK_FUNCS_IN('res_search res_nsearch res_ndestroy dns_search dn_expand', 'resolv',
51                     checklibc=True, headers='netinet/in.h arpa/nameser.h resolv.h dns.h')
52 conf.CHECK_VARIABLE('_res', headers='netinet/in.h arpa/nameser.h resolv.h')
53 conf.CHECK_DECLS('_res', headers='netinet/in.h arpa/nameser.h resolv.h')
54 conf.CHECK_FUNCS_IN('openpty', 'util', checklibc=True, headers='pty.h util.h libutil.h')
55
56 conf.DEFINE('HAVE_KRB5',1)
57 conf.DEFINE('HAVE_GSSAPI',1)
58
59 conf.CHECK_FUNCS('dirfd', headers='dirent.h')
60 conf.CHECK_DECLS('dirfd', reverse=True, headers='dirent.h')
61 conf.CHECK_STRUCTURE_MEMBER('DIR', 'dd_fd', define='HAVE_DIR_DD_FD',  headers='dirent.h')
62
63 conf.DEFINE('SAMBA4_INTERNAL_HEIMDAL', 1)
64
65 if conf.CHECK_BUNDLED_SYSTEM('com_err', checkfunctions='com_right_r com_err', headers='com_err.h'):
66     conf.define('USING_SYSTEM_COM_ERR', 1)
67
68 def check_system_heimdal_lib(name, functions='', headers='', onlyif=None):
69     # Only use system library if the user requested the bundled one not be used.
70     if conf.LIB_MAY_BE_BUNDLED(name):
71         return False
72     setattr(conf.env, "CPPPATH_%s" % name.upper(), ["/usr/include/heimdal"])
73     setattr(conf.env, "LIBPATH_%s" % name.upper(), ["/usr/lib/heimdal"])
74     conf.CHECK_BUNDLED_SYSTEM(name, checkfunctions=functions, headers=headers,
75         onlyif=onlyif)
76     conf.define('USING_SYSTEM_%s' % name.upper(), 1)
77     return True
78
79 if check_system_heimdal_lib("roken", "rk_socket_set_reuseaddr", "roken.h"):
80     conf.env.CPPPATH_ROKEN_HOSTCC = conf.env.CPPPATH_ROKEN
81     conf.env.LIBPATH_ROKEN_HOSTCC = conf.env.LIBPATH_ROKEN
82     conf.env.LIB_ROKEN_HOSTCC = "roken"
83     conf.SET_TARGET_TYPE("ROKEN_HOSTCC", 'SYSLIB')
84 check_system_heimdal_lib("wind", "wind_stringprep", "wind.h", onlyif="roken")
85 check_system_heimdal_lib("hx509", "hx509_bitstring_print", "hx509.h", onlyif="roken wind")
86 check_system_heimdal_lib("asn1", "initialize_asn1_error_table", "asn1_err.h", onlyif="roken com_err")
87
88 # With the proper checks in place we should be able to build against the system libtommath.
89 # conf.CHECK_BUNDLED_SYSTEM('tommath', checkfunctions='mp_init', headers='tommath.h')
90 # conf.define('USING_SYSTEM_TOMMATH', 1)
91
92 # disable trying to use an external compile_et until we have a configure
93 # test that checks that the system one actually works. On some systems it
94 # results in missing symbols (eg. OpenSUSE 10.2 'opi' in the build farm)
95 #if conf.find_program('compile_et', var='COMPILE_ET'):
96 #    conf.define('USING_SYSTEM_COMPILE_ET', 1)