2 from waflib import Logs
4 conf.RECURSE('third_party/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=''):
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_FUNCS_IN(functions, name, headers=headers, empty_decl=False, set_target=True):
36 conf.define('USING_SYSTEM_%s' % name.upper(), 1)
39 check_system_heimdal_lib("com_err", "com_right_r com_err", "com_err.h")
41 # Make sure HAVE_CONFIG_H is unset, as the system Heimdal headers use it
42 # and include config.h if it is set, resulting in failure (since config.h
45 DEFINES = list(conf.env.DEFINES)
46 conf.undefine("HAVE_CONFIG_H")
47 while "HAVE_CONFIG_H=1" in conf.env.DEFINES:
48 conf.env.DEFINES.remove("HAVE_CONFIG_H=1")
50 check_system_heimdal_lib("asn1", "decode_Ticket", "krb5_asn1.h")
51 if check_system_heimdal_lib("krb5", "krb5_anyaddr", "krb5.h"):
52 conf.CHECK_FUNCS_IN('krb5_free_unparsed_name', 'krb5', headers="krb5.h")
53 check_system_heimdal_lib("gssapi", "gss_oid_to_name", "gssapi.h")
55 conf.env.DEFINES = DEFINES
57 # With the proper checks in place we should be able to build against the system libtommath.
58 #if conf.CHECK_BUNDLED_SYSTEM('tommath', checkfunctions='mp_init', headers='tommath.h'):
59 # conf.define('USING_SYSTEM_TOMMATH', 1)
61 conf.env.KRB5_VENDOR = 'heimdal'
62 conf.define('USING_SYSTEM_KRB5', 1)
63 conf.define('USING_SYSTEM_HEIMDAL', 1)