s3-waf: split out LIBCLI_WINREG_INTERNAL as LIBCLI_WINREG was pulling in rpc server...
[Samba.git] / source4 / heimdal_build / wscript_configure
blob29def8bcaa594cb8e139753ae7c777bae571d664
1 #!/usr/bin/env python
2 # Waf build script for Samba 4's bundled Heimdal.
4 # Unless explicitly requested by the user (e.g.
5 # "./configure --bundled-libraries=!asn1_compile") this will always use the
6 # bundled Heimdal, even if a system heimdal was found. The reason
7 # for this is that our checks for the system heimdal are not accurate
8 # enough yet to know if it is usable (some bug fix might be missing,
9 # compile_et might not generate the expected code, etc).
11 import Logs, sys
13 conf.CHECK_TYPE('u_char', 'uint8_t')
14 conf.CHECK_TYPE('u_int32_t', 'uint32_t')
16 conf.CHECK_HEADERS('err.h')
18 conf.CHECK_HEADERS('ifaddrs.h')
19 conf.CHECK_HEADERS('''crypt.h errno.h inttypes.h netdb.h signal.h sys/bswap.h
20 sys/file.h sys/stropts.h sys/timeb.h sys/times.h sys/uio.h sys/un.h
21 sys/utsname.h time.h timezone.h ttyname.h netinet/in.h
22 netinet/in6.h netinet6/in6.h libintl.h''')
24 conf.CHECK_HEADERS('curses.h term.h termcap.h', together=True)
26 conf.CHECK_FUNCS('''atexit cgetent getprogname setprogname gethostname
27 putenv rcmd readv sendmsg setitimer strlwr strncasecmp
28 strptime strsep strsep_copy strtok_r strupr swab umask uname unsetenv
29 closefrom err warn errx warnx flock writev''')
31 conf.CHECK_FUNCS_IN('hstrerror', 'resolv socket nsl', checklibc=True)
32 conf.CHECK_FUNCS_IN('''getnameinfo sendmsg socket getipnodebyname gethostent gethostent_r
33 sethostent endhostent getipnodebyaddr freehostent gethostbyname
34 gethostbyname_r gethostbyaddr''',
35 'socket nsl',
36 checklibc=True)
38 conf.CHECK_FUNCS_IN('dgettext gettext', 'intl', headers='libintl.h')
40 conf.CHECK_FUNCS('iruserok')
42 conf.CHECK_FUNCS('bswap16')
43 conf.CHECK_FUNCS('bswap32')
45 conf.CHECK_TYPE('struct winsize', define='HAVE_STRUCT_WINSIZE', headers='sys/termios.h sys/ioctl.h')
46 conf.CHECK_STRUCTURE_MEMBER('struct winsize', 'ws_xpixel',
47 define='HAVE_WS_XPIXEL', headers='sys/termios.h sys/ioctl.h')
48 conf.CHECK_STRUCTURE_MEMBER('struct winsize', 'ws_ypixel',
49 define='HAVE_WS_YPIXEL', headers='sys/termios.h sys/ioctl.h')
50 conf.DEFINE('HAVE_KRB_STRUCT_WINSIZE', 1)
51 conf.DEFINE('VOID_RETSIGTYPE', 1)
53 conf.CHECK_VARIABLE('h_errno', headers='netdb.h')
55 # strangely enough, we need it with another define too
56 conf.CHECK_DECLS('h_errno', headers='netdb.h')
58 conf.CHECK_FUNCS_IN('res_search res_nsearch res_ndestroy dns_search dn_expand', 'resolv',
59 checklibc=True, headers='netinet/in.h arpa/nameser.h resolv.h dns.h')
60 conf.CHECK_VARIABLE('_res', headers='netinet/in.h arpa/nameser.h resolv.h')
61 conf.CHECK_DECLS('_res', headers='netinet/in.h arpa/nameser.h resolv.h')
62 conf.CHECK_FUNCS_IN('openpty', 'util', checklibc=True, headers='pty.h util.h libutil.h')
64 conf.DEFINE('HAVE_KRB5',1)
65 conf.DEFINE('HAVE_GSSAPI',1)
67 conf.CHECK_FUNCS('dirfd', headers='dirent.h')
68 conf.CHECK_DECLS('dirfd', reverse=True, headers='dirent.h')
69 conf.CHECK_STRUCTURE_MEMBER('DIR', 'dd_fd', define='HAVE_DIR_DD_FD', headers='dirent.h')
71 conf.DEFINE('SAMBA4_INTERNAL_HEIMDAL', 1)
73 if conf.CHECK_BUNDLED_SYSTEM('com_err', checkfunctions='com_right_r com_err', headers='com_err.h'):
74 conf.define('USING_SYSTEM_COM_ERR', 1)
76 def check_system_heimdal_lib(name, functions='', headers='', onlyif=None):
77 # Only use system library if the user requested the bundled one not be
78 # used.
79 if conf.LIB_MAY_BE_BUNDLED(name):
80 return False
81 setattr(conf.env, "CPPPATH_%s" % name.upper(), ["/usr/include/heimdal"])
82 setattr(conf.env, "LIBPATH_%s" % name.upper(), ["/usr/lib/heimdal"])
83 conf.CHECK_BUNDLED_SYSTEM(name, checkfunctions=functions, headers=headers,
84 onlyif=onlyif)
85 conf.define('USING_SYSTEM_%s' % name.upper(), 1)
86 return True
88 def check_system_heimdal_binary(name):
89 if conf.LIB_MAY_BE_BUNDLED(name):
90 return False
91 if not conf.find_program(name, var=name.upper()):
92 return False
93 conf.define('USING_SYSTEM_%s' % name.upper(), 1)
94 return True
96 if check_system_heimdal_lib("roken", "rk_socket_set_reuseaddr", "roken.h"):
97 conf.env.CPPPATH_ROKEN_HOSTCC = conf.env.CPPPATH_ROKEN
98 conf.env.LIBPATH_ROKEN_HOSTCC = conf.env.LIBPATH_ROKEN
99 conf.env.LIB_ROKEN_HOSTCC = "roken"
100 conf.SET_TARGET_TYPE("ROKEN_HOSTCC", 'SYSLIB')
101 check_system_heimdal_lib("wind", "wind_stringprep", "wind.h", onlyif="roken")
102 check_system_heimdal_lib("hx509", "hx509_bitstring_print", "hx509.h", onlyif="roken wind")
103 check_system_heimdal_lib("asn1", "initialize_asn1_error_table", "asn1_err.h", onlyif="roken com_err")
104 check_system_heimdal_lib("heimbase", "heim_cmp", "heimbase.h", onlyif="roken")
105 check_system_heimdal_lib("hcrypto", "MD4_Init", "hcrypto/md4.h",
106 onlyif="asn1 roken com_err")
107 check_system_heimdal_lib("krb5", "krb5_anyaddr", "krb5.h",
108 onlyif="roken wind asn1 hx509 hcrypto com_err heimbase")
109 check_system_heimdal_lib("gssapi", "gss_oid_to_name", "gssapi.h",
110 onlyif="hcrypto asn1 roken krb5 com_err wind")
111 check_system_heimdal_lib("heimntlm", "heim_ntlm_ntlmv2_key", "heimntlm.h",
112 onlyif="roken hcrypto krb5")
113 check_system_heimdal_lib("hdb", "hdb_db_dir", "krb5.h hdb.h",
114 onlyif="roken krb5 hcrypto com_err wind")
115 check_system_heimdal_lib("kdc", "kdc_log", "kdc.h",
116 onlyif="roken krb5 hdb asn1 heimntlm hcrypto com_err wind heimbase")
119 # With the proper checks in place we should be able to build against the system libtommath.
120 # conf.CHECK_BUNDLED_SYSTEM('tommath', checkfunctions='mp_init', headers='tommath.h')
121 # conf.define('USING_SYSTEM_TOMMATH', 1)
123 check_system_heimdal_binary("compile_et")
124 check_system_heimdal_binary("asn1_compile")