ctdb-daemon: Use ctdb_connection_to_buf() to simplify
[Samba.git] / wscript_configure_system_heimdal
blob5dbb5e4b3f737ccb2f1467e2142cbe9b7087fde2
1 import sys
2 from waflib import Logs
4 conf.RECURSE('third_party/heimdal_build')
6 heimdal_includedirs = []
7 heimdal_libdirs = []
8 krb5_config = conf.find_program("krb5-config.heimdal", var="HEIMDAL_KRB5_CONFIG")
9 if not krb5_config:
10     krb5_config = conf.find_program("krb5-config", var="HEIMDAL_KRB5_CONFIG")
11 if krb5_config:
12     # Not ideal, but seems like the best way to get at these paths:
13     f = open(krb5_config[0], 'r')
14     try:
15         for l in f:
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")
24     finally:
25         f.close()
27 def check_system_heimdal_lib(name, functions='', headers=''):
28     # Only use system library if the user requested the bundled one not be
29     # used.
30     if conf.LIB_MAY_BE_BUNDLED(name):
31         return False
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):
35         return False
36     conf.define('USING_SYSTEM_%s' % name.upper(), 1)
37     return True
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
43 # doesn't yet exist)
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")
49 try:
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")
54 finally:
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)