ctdb-tcp: Consolidate failure code
[samba4-gss.git] / wscript_configure_system_heimdal
blobb6ca9e98c7e8cc0087000711b9dd90fc2535c4a0
1 conf.RECURSE('third_party/heimdal_build')
3 heimdal_includedirs = []
4 heimdal_libdirs = []
5 krb5_config = conf.find_program("krb5-config.heimdal", var="HEIMDAL_KRB5_CONFIG")
6 if not krb5_config:
7     krb5_config = conf.find_program("krb5-config", var="HEIMDAL_KRB5_CONFIG")
8 if krb5_config:
9     # Not ideal, but seems like the best way to get at these paths:
10     f = open(krb5_config[0], 'r')
11     try:
12         for l in f:
13             if l.startswith("libdir="):
14                 heimdal_libdirs.append(l.strip()[len("libdir="):])
15             elif l.startswith("includedir="):
16                 include_path = l.strip()[len("includedir="):]
17                 heimdal_includedirs.append(include_path)
18                 conf.ADD_EXTRA_INCLUDES(include_path)
19                 conf.define('HEIMDAL_KRB5_TYPES_PATH',
20                             include_path + "/krb5-types.h")
21     finally:
22         f.close()
24 def check_system_heimdal_lib(name, functions='', headers=''):
25     # Only use system library if the user requested the bundled one not be
26     # used.
27     if conf.LIB_MAY_BE_BUNDLED(name):
28         return False
29     setattr(conf.env, "CPPPATH_%s" % name.upper(), heimdal_includedirs)
30     setattr(conf.env, "LIBPATH_%s" % name.upper(), heimdal_libdirs)
31     if not conf.CHECK_FUNCS_IN(functions, name, headers=headers, empty_decl=False, set_target=True):
32         return False
33     conf.define('USING_SYSTEM_%s' % name.upper(), 1)
34     return True
36 check_system_heimdal_lib("com_err", "com_right_r com_err", "com_err.h")
38 # Make sure HAVE_CONFIG_H is unset, as the system Heimdal headers use it
39 # and include config.h if it is set, resulting in failure (since config.h
40 # doesn't yet exist)
42 DEFINES = list(conf.env.DEFINES)
43 conf.undefine("HAVE_CONFIG_H")
44 while "HAVE_CONFIG_H=1" in conf.env.DEFINES:
45     conf.env.DEFINES.remove("HAVE_CONFIG_H=1")
46 try:
47     check_system_heimdal_lib("asn1", "decode_Ticket", "krb5_asn1.h")
48     if check_system_heimdal_lib("krb5", "krb5_anyaddr", "krb5.h"):
49         conf.CHECK_FUNCS_IN('krb5_free_unparsed_name', 'krb5', headers="krb5.h")
50     check_system_heimdal_lib("gssapi", "gss_oid_to_name", "gssapi.h")
51 finally:
52     conf.env.DEFINES = DEFINES
54 # With the proper checks in place we should be able to build against the system libtommath.
55 #if conf.CHECK_BUNDLED_SYSTEM('tommath', checkfunctions='mp_init', headers='tommath.h'):
56 #    conf.define('USING_SYSTEM_TOMMATH', 1)
58 conf.env.KRB5_VENDOR = 'heimdal'
59 conf.define('USING_SYSTEM_KRB5', 1)
60 conf.define('USING_SYSTEM_HEIMDAL', 1)
62 conf.CHECK_FUNCS('''
63        krb5_get_init_creds_opt_set_fast_ccache
64        krb5_get_init_creds_opt_set_fast_flags
65        ''',
66      lib='krb5',
67      headers='krb5.h')