2 from waflib import Logs
4 conf.RECURSE('source4/heimdal_build')
6 heimdal_includedirs = []
8 krb5_config = conf.find_program("krb5-config.heimdal", var="HEIMDAL_KRB5_CONFIG")
10 krb5_config = conf.find_program("krb5-config", var="HEIMDAL_KRB5_CONFIG")
12 # Not ideal, but seems like the best way to get at these paths:
13 f = open(krb5_config[0], 'r')
16 if l.startswith("libdir="):
17 heimdal_libdirs.append(l.strip()[len("libdir="):])
18 elif l.startswith("includedir="):
19 include_path = l.strip()[len("includedir="):]
20 heimdal_includedirs.append(include_path)
21 conf.ADD_EXTRA_INCLUDES(include_path)
22 conf.define('HEIMDAL_KRB5_TYPES_PATH',
23 include_path + "/krb5-types.h")
27 def check_system_heimdal_lib(name, functions='', headers='', onlyif=None):
28 # Only use system library if the user requested the bundled one not be
30 if conf.LIB_MAY_BE_BUNDLED(name):
32 setattr(conf.env, "CPPPATH_%s" % name.upper(), heimdal_includedirs)
33 setattr(conf.env, "LIBPATH_%s" % name.upper(), heimdal_libdirs)
34 if not conf.CHECK_BUNDLED_SYSTEM(name, checkfunctions=functions, headers=headers,
37 conf.define('USING_SYSTEM_%s' % name.upper(), 1)
40 def check_system_heimdal_binary(name):
41 if conf.LIB_MAY_BE_BUNDLED(name):
43 if not conf.find_program(name, var=name.upper()):
45 conf.define('USING_SYSTEM_%s' % name.upper(), 1)
48 check_system_heimdal_lib("com_err", "com_right_r com_err", "com_err.h")
50 if check_system_heimdal_lib("roken", "rk_socket_set_reuseaddr", "roken.h"):
51 conf.env.CPPPATH_ROKEN_HOSTCC = conf.env.CPPPATH_ROKEN
52 conf.env.LIBPATH_ROKEN_HOSTCC = conf.env.LIBPATH_ROKEN
53 conf.env.LIB_ROKEN_HOSTCC = "roken"
54 conf.SET_TARGET_TYPE("ROKEN_HOSTCC", 'SYSLIB')
56 # Make sure HAVE_CONFIG_H is unset, as the system Heimdal headers use it
57 # and include config.h if it is set, resulting in failure (since config.h
60 DEFINES = list(conf.env.DEFINES)
61 conf.undefine("HAVE_CONFIG_H")
62 while "HAVE_CONFIG_H=1" in conf.env.DEFINES:
63 conf.env.DEFINES.remove("HAVE_CONFIG_H=1")
65 check_system_heimdal_lib("wind", "wind_stringprep", "wind.h", onlyif="roken")
66 check_system_heimdal_lib("hx509", "hx509_bitstring_print", "hx509.h", onlyif="roken wind")
67 check_system_heimdal_lib("asn1", "initialize_asn1_error_table", "asn1_err.h", onlyif="roken com_err")
68 check_system_heimdal_lib("heimbase", "heim_cmp", "heimbase.h", onlyif="roken")
69 check_system_heimdal_lib("hcrypto", "MD4_Init", "hcrypto/md4.h",
70 onlyif="asn1 roken com_err")
71 if check_system_heimdal_lib("krb5", "krb5_anyaddr", "krb5.h",
72 onlyif="roken wind asn1 hx509 hcrypto com_err heimbase"):
73 conf.CHECK_FUNCS_IN('krb5_free_unparsed_name', 'krb5', headers="krb5.h")
74 check_system_heimdal_lib("gssapi", "gss_oid_to_name", "gssapi.h",
75 onlyif="hcrypto asn1 roken krb5 com_err wind")
76 check_system_heimdal_lib("heimntlm", "heim_ntlm_ntlmv2_key", "heimntlm.h",
77 onlyif="roken hcrypto krb5")
78 if check_system_heimdal_lib("hdb", "hdb_db_dir", "krb5.h hdb.h",
79 onlyif="roken krb5 hcrypto com_err wind"):
82 int main(void) { hdb_enctype2key(NULL, NULL, NULL, 0, NULL); }
84 define='HDB_ENCTYPE2KEY_TAKES_KEYSET',
87 msg='Checking whether hdb_enctype2key takes a keyset argument',
90 check_system_heimdal_lib("kdc", "kdc_log", "kdc.h",
91 onlyif="roken krb5 hdb asn1 heimntlm hcrypto com_err wind heimbase")
93 conf.env.DEFINES = DEFINES
95 # With the proper checks in place we should be able to build against the system libtommath.
96 #if conf.CHECK_BUNDLED_SYSTEM('tommath', checkfunctions='mp_init', headers='tommath.h'):
97 # conf.define('USING_SYSTEM_TOMMATH', 1)
99 check_system_heimdal_binary("compile_et")
100 check_system_heimdal_binary("asn1_compile")
102 conf.env.KRB5_VENDOR = 'heimdal'
103 conf.define('USING_SYSTEM_KRB5', 1)
104 conf.define('USING_SYSTEM_HEIMDAL', 1)