script/autobuild.py: rm unused mime type text/plain in tasks
[Samba.git] / wscript_configure_system_heimdal
blob0ff6dad2f55e946ae0f14c46fc8393b41cc00dfe
1 import sys
2 from waflib import Logs
4 conf.RECURSE('source4/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.define('HEIMDAL_KRB5_TYPES_PATH',
22                             include_path + "/krb5-types.h")
23     finally:
24         f.close()
26 def check_system_heimdal_lib(name, functions='', headers='', onlyif=None):
27     # Only use system library if the user requested the bundled one not be
28     # used.
29     if conf.LIB_MAY_BE_BUNDLED(name):
30         return False
31     setattr(conf.env, "CPPPATH_%s" % name.upper(), heimdal_includedirs)
32     setattr(conf.env, "LIBPATH_%s" % name.upper(), heimdal_libdirs)
33     if not conf.CHECK_BUNDLED_SYSTEM(name, checkfunctions=functions, headers=headers,
34                                      onlyif=onlyif):
35         return False
36     conf.define('USING_SYSTEM_%s' % name.upper(), 1)
37     return True
39 def check_system_heimdal_binary(name):
40     if conf.LIB_MAY_BE_BUNDLED(name):
41         return False
42     if not conf.find_program(name, var=name.upper()):
43         return False
44     conf.define('USING_SYSTEM_%s' % name.upper(), 1)
45     return True
47 check_system_heimdal_lib("com_err", "com_right_r com_err", "com_err.h")
49 if check_system_heimdal_lib("roken", "rk_socket_set_reuseaddr", "roken.h"):
50     conf.env.CPPPATH_ROKEN_HOSTCC = conf.env.CPPPATH_ROKEN
51     conf.env.LIBPATH_ROKEN_HOSTCC = conf.env.LIBPATH_ROKEN
52     conf.env.LIB_ROKEN_HOSTCC = "roken"
53     conf.SET_TARGET_TYPE("ROKEN_HOSTCC", 'SYSLIB')
55 # Make sure HAVE_CONFIG_H is unset, as the system Heimdal headers use it
56 # and include config.h if it is set, resulting in failure (since config.h
57 # doesn't yet exist)
59 DEFINES = list(conf.env.DEFINES)
60 conf.undefine("HAVE_CONFIG_H")
61 while "HAVE_CONFIG_H=1" in conf.env.DEFINES:
62     conf.env.DEFINES.remove("HAVE_CONFIG_H=1")
63 try:
64     check_system_heimdal_lib("wind", "wind_stringprep", "wind.h", onlyif="roken")
65     check_system_heimdal_lib("hx509", "hx509_bitstring_print", "hx509.h", onlyif="roken wind")
66     check_system_heimdal_lib("asn1", "initialize_asn1_error_table", "asn1_err.h", onlyif="roken com_err")
67     check_system_heimdal_lib("heimbase", "heim_cmp", "heimbase.h", onlyif="roken")
68     check_system_heimdal_lib("hcrypto", "MD4_Init", "hcrypto/md4.h",
69         onlyif="asn1 roken com_err")
70     if check_system_heimdal_lib("krb5", "krb5_anyaddr", "krb5.h",
71         onlyif="roken wind asn1 hx509 hcrypto com_err heimbase"):
72         conf.CHECK_FUNCS_IN('krb5_free_unparsed_name', 'krb5', headers="krb5.h")
73     check_system_heimdal_lib("gssapi", "gss_oid_to_name", "gssapi.h",
74         onlyif="hcrypto asn1 roken krb5 com_err wind")
75     check_system_heimdal_lib("heimntlm", "heim_ntlm_ntlmv2_key", "heimntlm.h",
76         onlyif="roken hcrypto krb5")
77     if check_system_heimdal_lib("hdb", "hdb_db_dir", "krb5.h hdb.h",
78         onlyif="roken krb5 hcrypto com_err wind"):
79         conf.CHECK_CODE('''
80             #include <hdb.h>
81             int main(void) { hdb_enctype2key(NULL, NULL, NULL, 0, NULL); }
82             ''',
83             define='HDB_ENCTYPE2KEY_TAKES_KEYSET',
84             addmain=False,
85             lib='hdb',
86             msg='Checking whether hdb_enctype2key takes a keyset argument',
87             local_include=False)
89     check_system_heimdal_lib("kdc", "kdc_log", "kdc.h",
90         onlyif="roken krb5 hdb asn1 heimntlm hcrypto com_err wind heimbase")
91 finally:
92     conf.env.DEFINES = DEFINES
94 # With the proper checks in place we should be able to build against the system libtommath.
95 #if conf.CHECK_BUNDLED_SYSTEM('tommath', checkfunctions='mp_init', headers='tommath.h'):
96 #    conf.define('USING_SYSTEM_TOMMATH', 1)
98 check_system_heimdal_binary("compile_et")
99 check_system_heimdal_binary("asn1_compile")