2022-01-19 15:15:45 +03:00
conf.RECURSE('third_party/heimdal_build')
2019-01-24 04:31:10 +03:00
heimdal_includedirs = []
heimdal_libdirs = []
krb5_config = conf.find_program("krb5-config.heimdal", var="HEIMDAL_KRB5_CONFIG")
if not krb5_config:
krb5_config = conf.find_program("krb5-config", var="HEIMDAL_KRB5_CONFIG")
if krb5_config:
# Not ideal, but seems like the best way to get at these paths:
f = open(krb5_config[0], 'r')
try:
for l in f:
if l.startswith("libdir="):
heimdal_libdirs.append(l.strip()[len("libdir="):])
elif l.startswith("includedir="):
include_path = l.strip()[len("includedir="):]
heimdal_includedirs.append(include_path)
2019-10-30 23:15:48 +03:00
conf.ADD_EXTRA_INCLUDES(include_path)
2019-01-24 04:31:10 +03:00
conf.define('HEIMDAL_KRB5_TYPES_PATH',
include_path + "/krb5-types.h")
finally:
f.close()
2022-11-03 07:35:35 +03:00
def check_system_heimdal_lib(name, functions='', headers=''):
2019-01-24 04:31:10 +03:00
# Only use system library if the user requested the bundled one not be
# used.
if conf.LIB_MAY_BE_BUNDLED(name):
return False
setattr(conf.env, "CPPPATH_%s" % name.upper(), heimdal_includedirs)
setattr(conf.env, "LIBPATH_%s" % name.upper(), heimdal_libdirs)
2022-11-03 07:35:35 +03:00
if not conf.CHECK_FUNCS_IN(functions, name, headers=headers, empty_decl=False, set_target=True):
2019-01-24 04:31:10 +03:00
return False
conf.define('USING_SYSTEM_%s' % name.upper(), 1)
return True
check_system_heimdal_lib("com_err", "com_right_r com_err", "com_err.h")
# Make sure HAVE_CONFIG_H is unset, as the system Heimdal headers use it
# and include config.h if it is set, resulting in failure (since config.h
# doesn't yet exist)
DEFINES = list(conf.env.DEFINES)
conf.undefine("HAVE_CONFIG_H")
while "HAVE_CONFIG_H=1" in conf.env.DEFINES:
conf.env.DEFINES.remove("HAVE_CONFIG_H=1")
try:
2022-11-03 07:35:35 +03:00
check_system_heimdal_lib("asn1", "decode_Ticket", "krb5_asn1.h")
if check_system_heimdal_lib("krb5", "krb5_anyaddr", "krb5.h"):
2019-01-24 04:31:10 +03:00
conf.CHECK_FUNCS_IN('krb5_free_unparsed_name', 'krb5', headers="krb5.h")
2022-11-03 07:35:35 +03:00
check_system_heimdal_lib("gssapi", "gss_oid_to_name", "gssapi.h")
2019-01-24 04:31:10 +03:00
finally:
conf.env.DEFINES = DEFINES
# With the proper checks in place we should be able to build against the system libtommath.
#if conf.CHECK_BUNDLED_SYSTEM('tommath', checkfunctions='mp_init', headers='tommath.h'):
# conf.define('USING_SYSTEM_TOMMATH', 1)
2020-04-02 10:31:33 +03:00
conf.env.KRB5_VENDOR = 'heimdal'
2019-10-30 23:15:48 +03:00
conf.define('USING_SYSTEM_KRB5', 1)
2020-04-02 10:31:33 +03:00
conf.define('USING_SYSTEM_HEIMDAL', 1)