r5601: add a gsskrb5 backend that uses lorikeet-heimdal's new gssapi with
[Samba/gebeck_regimport.git] / source4 / libads / config.m4
blob57416113b35684c99ae200aaa9f35a6c408186ea
1 ########################################################
2 # Compile with LDAP support?
4 LDAP_LIBS=""
5 with_ldap_support=auto
6 AC_MSG_CHECKING([for LDAP support])
8 AC_ARG_WITH(ldap,
9 [  --with-ldap             LDAP support (default yes)],
10 [ case "$withval" in
11     yes|no)
12         with_ldap_support=$withval
13         ;;
14   esac ])
16 AC_MSG_RESULT($with_ldap_support)
18 if test x"$with_ldap_support" != x"no"; then
20   ##################################################################
21   # first test for ldap.h and lber.h
22   # (ldap.h is required for this test)
23   AC_CHECK_HEADERS(ldap.h lber.h)
24   
25   if test x"$ac_cv_header_ldap_h" != x"yes"; then
26         if test x"$with_ldap_support" = x"yes"; then
27          AC_MSG_ERROR(ldap.h is needed for LDAP support)
28         else
29          AC_MSG_WARN(ldap.h is needed for LDAP support)
30         fi
31         
32         with_ldap_support=no
33   fi
36 if test x"$with_ldap_support" != x"no"; then
37   ac_save_LIBS=$LIBS
39   ##################################################################
40   # we might need the lber lib on some systems. To avoid link errors
41   # this test must be before the libldap test
42   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
44   ########################################################
45   # now see if we can find the ldap libs in standard paths
46   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
48   AC_CHECK_FUNC_EXT(ldap_domain2hostlist,$LDAP_LIBS)
49   
50   ########################################################
51   # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
52   # Check found in pam_ldap 145.
53   AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
55   LIBS="$LIBS $LDAP_LIBS"
56   AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
57     AC_TRY_COMPILE([
58         #include <lber.h>
59         #include <ldap.h>], 
60         [ldap_set_rebind_proc(0, 0, 0);], 
61         [smb_ldap_cv_ldap_set_rebind_proc=3], 
62         [smb_ldap_cv_ldap_set_rebind_proc=2]
63     ) 
64   ])
65   
66   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
68   AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS) 
69   
70   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes" -a x"$ac_cv_func_ext_ldap_domain2hostlist" = x"yes"; then
71     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
72     with_ldap_support=yes
73     AC_MSG_CHECKING(whether LDAP support is used)
74     AC_MSG_RESULT(yes)
75     SMB_EXT_LIB_ENABLE(LDAP,YES)
76   else
77     if test x"$with_ldap_support" = x"yes"; then
78         AC_MSG_ERROR(libldap is needed for LDAP support)
79     else
80         AC_MSG_WARN(libldap is needed for LDAP support)
81     fi
82     
83     LDAP_LIBS=""
84     with_ldap_support=no
85   fi
86   LIBS=$ac_save_LIBS
89 #################################################
90 # KRB5 support
91 KRB5_CFLAGS=""
92 KRB5_CPPFLAGS=""
93 KRB5_LDFLAGS=""
94 KRB5_LIBS=""
95 with_krb5_support=auto
96 krb5_withval=auto
97 AC_MSG_CHECKING([for KRB5 support])
99 # Do no harm to the values of CFLAGS and LIBS while testing for
100 # Kerberos support.
101 AC_ARG_WITH(krb5,
102 [  --with-krb5=base-dir    Locate Kerberos 5 support (default=auto)],
103         [ case "$withval" in
104                 no)
105                         with_krb5_support=no
106                         AC_MSG_RESULT(no)
107                         krb5_withval=no
108                         ;;
109                 yes)
110                         with_krb5_support=yes
111                         AC_MSG_RESULT(yes)
112                         krb5_withval=yes
113                         ;;
114                 auto)
115                         with_krb5_support=auto
116                         AC_MSG_RESULT(auto)
117                         krb5_withval=auto
118                         ;;
119                 *)
120                         with_krb5_support=yes
121                         AC_MSG_RESULT(yes)
122                         krb5_withval=$withval
123                         KRB5CONFIG="$krb5_withval/bin/krb5-config"
124                         ;;
125         esac ],
126         AC_MSG_RESULT($with_krb5_support)
129 if test x$with_krb5_support != x"no"; then
130         FOUND_KRB5=no
131         FOUND_KRB5_VIA_CONFIG=no
133         #################################################
134         # check for krb5-config from recent MIT and Heimdal kerberos 5
135         AC_MSG_CHECKING(for working specified location for krb5-config)
136         if test x$KRB5CONFIG != "x"; then
137                 if test -x "$KRB5CONFIG"; then
138                         ac_save_CFLAGS=$CFLAGS
139                         CFLAGS="";export CFLAGS
140                         ac_save_LDFLAGS=$LDFLAGS
141                         LDFLAGS="";export LDFLAGS
142                         KRB5_LIBS="`$KRB5CONFIG --libs gssapi`"
143                         KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`" 
144                         KRB5_CPPFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
145                         CFLAGS=$ac_save_CFLAGS;export CFLAGS
146                         LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
147                         FOUND_KRB5=yes
148                         FOUND_KRB5_VIA_CONFIG=yes
149                         AC_MSG_RESULT(yes. Found $KRB5CONFIG)
150                 else 
151                         AC_MSG_RESULT(no. Fallback to specified directory)
152                 fi
153         else
154                 AC_MSG_RESULT(no. Fallback to finding krb5-config in path)
155                 #################################################
156                 # check for krb5-config from recent MIT and Heimdal kerberos 5
157                 AC_PATH_PROG(KRB5CONFIG, krb5-config)
158                 AC_MSG_CHECKING(for working krb5-config in path)
159                 if test -x "$KRB5CONFIG"; then
160                         ac_save_CFLAGS=$CFLAGS
161                         CFLAGS="";export CFLAGS
162                         ac_save_LDFLAGS=$LDFLAGS
163                         LDFLAGS="";export LDFLAGS
164                         KRB5_LIBS="`$KRB5CONFIG --libs gssapi`"
165                         KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`" 
166                         KRB5_CPPFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
167                         CFLAGS=$ac_save_CFLAGS;export CFLAGS
168                         LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
169                         FOUND_KRB5=yes
170                         FOUND_KRB5_VIA_CONFIG=yes
171                         AC_MSG_RESULT(yes. Found $KRB5CONFIG)
172                 else
173                         AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
174                 fi
175         fi
176   
177         if test x$FOUND_KRB5 != x"yes"; then
178                 #################################################
179                 # check for location of Kerberos 5 install
180                 AC_MSG_CHECKING(for kerberos 5 install path)
181                 case "$krb5_withval" in
182                         no)
183                                 AC_MSG_RESULT(no krb5-path given)
184                                 ;;
185                         yes)
186                                 AC_MSG_RESULT(/usr)
187                                 FOUND_KRB5=yes
188                                 ;;
189                         *)
190                                 AC_MSG_RESULT($krb5_withval)
191                                 KRB5_CFLAGS="-I$krb5_withval/include"
192                                 KRB5_CPPFLAGS="-I$krb5_withval/include"
193                                 KRB5_LDFLAGS="-L$krb5_withval/lib"
194                                 FOUND_KRB5=yes
195                                 ;;
196                 esac
197         fi
199         if test x$FOUND_KRB5 != x"yes"; then
200                 #################################################
201                 # see if this box has the SuSE location for the heimdal krb implementation
202                 AC_MSG_CHECKING(for /usr/include/heimdal)
203                 if test -d /usr/include/heimdal; then
204                         if test -f /usr/lib/heimdal/lib/libkrb5.a; then
205                                 KRB5_CFLAGS="-I/usr/include/heimdal"
206                                 KRB5_CPPFLAGS="-I/usr/include/heimdal"
207                                 KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
208                                 AC_MSG_RESULT(yes)
209                         else
210                                 KRB5_CFLAGS="-I/usr/include/heimdal"
211                                 KRB5_CPPFLAGS="-I/usr/include/heimdal"
212                                 AC_MSG_RESULT(yes)
213                         fi
214                 else
215                         AC_MSG_RESULT(no)
216                 fi
217         fi
219         if test x$FOUND_KRB5 != x"yes"; then
220                 #################################################
221                 # see if this box has the RedHat location for kerberos
222                 AC_MSG_CHECKING(for /usr/kerberos)
223                 if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
224                         KRB5_LDFLAGS="-L/usr/kerberos/lib"
225                         KRB5_CFLAGS="-I/usr/kerberos/include"
226                         KRB5_CPPFLAGS="-I/usr/kerberos/include"
227                         AC_MSG_RESULT(yes)
228                 else
229                         AC_MSG_RESULT(no)
230                 fi
231         fi
233         ac_save_CFLAGS=$CFLAGS
234         ac_save_CPPFLAGS=$CPPFLAGS
235         ac_save_LDFLAGS=$LDFLAGS
237         #MIT needs this, to let us see 'internal' parts of the headers we use
238         KRB5_CFLAGS="${KRB5_CFLAGS} -DKRB5_PRIVATE -DKRB5_DEPRECATED"
240         #Heimdal needs this
241         #TODO: we need to parse KRB5_LIBS for -L path
242         #      and set -Wl,-rpath -Wl,path
244         CFLAGS="$CFLAGS $KRB5_CFLAGS"
245         CPPFLAGS="$CPPFLAGS $KRB5_CPPFLAGS"
246         LDFLAGS="$LDFLAGS $KRB5_LDFLAGS"
248         KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
250         # now check for krb5.h. Some systems have the libraries without the headers!
251         # note that this check is done here to allow for different kerberos
252         # include paths
253         AC_CHECK_HEADERS(krb5.h)
255         if test x"$ac_cv_header_krb5_h" = x"no"; then
256                 # Give a warning if KRB5 support was not explicitly requested,
257                 # i.e with_krb5_support = auto, otherwise die with an error.
258                 if test x"$with_krb5_support" = x"yes"; then
259                         AC_MSG_ERROR([KRB5 cannot be supported without krb5.h])
260                 else
261                         AC_MSG_WARN([KRB5 cannot be supported without krb5.h])
262                 fi
263                 # Turn off AD support and restore CFLAGS and LIBS variables
264                 with_krb5_support="no"
265         fi
267         CFLAGS=$ac_save_CFLAGS
268         CPPFLAGS=$ac_save_CPPFLAGS
269         LDFLAGS=$ac_save_LDFLAGS
272 # Now we have determined whether we really want KRB5 support
274 if test x"$with_krb5_support" != x"no"; then
275         ac_save_CFLAGS=$CFLAGS
276         ac_save_CPPFLAGS=$CPPFLAGS
277         ac_save_LDFLAGS=$LDFLAGS
278         ac_save_LIBS=$LIBS
280         CFLAGS="$CFLAGS $KRB5_CFLAGS"
281         CPPFLAGS="$CPPFLAGS $KRB5_CPPFLAGS"
282         LDFLAGS="$LDFLAGS $KRB5_LDFLAGS"
284         # now check for gssapi headers.  This is also done here to allow for
285         # different kerberos include paths
286         AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h)
288         ##################################################################
289         # we might need the k5crypto and com_err libraries on some systems
290         AC_CHECK_LIB_EXT(com_err, KRB5_LIBS, _et_list)
291         AC_CHECK_LIB_EXT(k5crypto, KRB5_LIBS, krb5_encrypt_data)
293         # Heimdal checks.
294         # But only if we didn't have a krb5-config to tell us this already
295         if test x"$FOUND_KRB5_VIA_CONFIG" != x"yes"; then
296                 AC_CHECK_LIB_EXT(crypto, KRB5_LIBS, des_set_key)
297                 AC_CHECK_LIB_EXT(asn1, KRB5_LIBS, copy_Authenticator)
298                 AC_CHECK_LIB_EXT(roken, KRB5_LIBS, roken_getaddrinfo_hostspec)
299         fi
301         # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
302         AC_CHECK_LIB_EXT(gssapi, KRB5_LIBS, gss_display_status,[],[],
303                                 AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available]))
305         ########################################################
306         # now see if we can find the krb5 libs in standard paths
307         # or as specified above
308         AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
309         AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_kt_compare)
311         ########################################################
312         # now see if we can find the gssapi libs in standard paths
313         if test x"$ac_cv_lib_ext_gssapi_gss_display_status" != x"yes"; then
314            AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],
315                 AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available]))
316         fi
318         AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
319         AC_CHECK_FUNC_EXT(krb5_set_default_in_tkt_etypes, $KRB5_LIBS)
320         AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
321         AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
322         AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
323         AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS) 
324         AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
325         AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS) 
326         AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
327         AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS) 
328         AC_CHECK_FUNC_EXT(krb5_locate_kdc, $KRB5_LIBS)
329         AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS) 
330         AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS) 
331         AC_CHECK_FUNC_EXT(krb5_free_ktypes, $KRB5_LIBS)
332         AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
333         AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
334         AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
335         AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
336         AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
337         AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
338         AC_CHECK_FUNC_EXT(krb5_verify_checksum, $KRB5_LIBS)
339         AC_CHECK_FUNC_EXT(krb5_c_verify_checksum, $KRB5_LIBS)
340         AC_CHECK_FUNC_EXT(krb5_ticket_get_authorization_data_type, $KRB5_LIBS)
341         AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
342         AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
343         AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
345         LIBS="$LIBS $KRB5_LIBS"
346   
347         AC_CACHE_CHECK([for krb5_encrypt_block type],
348                 samba_cv_HAVE_KRB5_ENCRYPT_BLOCK,[
349         AC_TRY_COMPILE([#include <krb5.h>],
350                 [krb5_encrypt_block block;],
351                 samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=yes,
352                 samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=no)])
354         if test x"$samba_cv_HAVE_KRB5_ENCRYPT_BLOCK" = x"yes"; then
355                 AC_DEFINE(HAVE_KRB5_ENCRYPT_BLOCK,1,
356                 [Whether the type krb5_encrypt_block exists])
357         fi
359         AC_CACHE_CHECK([for addrtype in krb5_address],
360                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
361                 AC_TRY_COMPILE([#include <krb5.h>],
362                 [krb5_address kaddr; kaddr.addrtype = ADDRTYPE_INET;],
363                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=yes,
364                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=no)])
365         if test x"$samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS" = x"yes"; then
366                 AC_DEFINE(HAVE_ADDRTYPE_IN_KRB5_ADDRESS,1,
367                 [Whether the krb5_address struct has a addrtype property])
368         fi
370         AC_CACHE_CHECK([for addr_type in krb5_address],
371                 samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,[
372                 AC_TRY_COMPILE([#include <krb5.h>],
373                 [krb5_address kaddr; kaddr.addr_type = KRB5_ADDRESS_INET;],
374                 samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=yes,
375                 samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=no)])
376         if test x"$samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS" = x"yes"; then
377                 AC_DEFINE(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,1,
378                 [Whether the krb5_address struct has a addr_type property])
379         fi
381         AC_CACHE_CHECK([for enc_part2 in krb5_ticket], 
382                 samba_cv_HAVE_KRB5_TKT_ENC_PART2,[
383                 AC_TRY_COMPILE([#include <krb5.h>],
384                 [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
385                 samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,
386                 samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
387         if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
388                 AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,
389                 [Whether the krb5_ticket struct has a enc_part2 property])
390         fi
392         AC_CACHE_CHECK([for keyblock in krb5_creds],
393                  samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
394         AC_TRY_COMPILE([#include <krb5.h>],
395                 [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
396                 samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
397                 samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
399         if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
400                 AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
401                 [Whether the krb5_creds struct has a keyblock property])
402         fi
404         AC_CACHE_CHECK([for session in krb5_creds],
405                  samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
406         AC_TRY_COMPILE([#include <krb5.h>],
407                 [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
408                 samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
409                 samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
411         if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
412                 AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
413                 [Whether the krb5_creds struct has a session property])
414         fi
416         AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
417                 samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
418                 AC_TRY_COMPILE([#include <krb5.h>],
419                 [krb5_keyblock key; key.keyvalue.data = NULL;],
420                 samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=yes,
421                 samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=no)])
422         if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE" = x"yes"; then
423                 AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,
424                 [Whether the krb5_keyblock struct has a keyvalue property])
425         fi
427         AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],
428                 samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
429                 AC_TRY_COMPILE([#include <krb5.h>],
430                 [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC_MD5;],
431                 samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=yes,
432                 samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=no)])
433         AC_CACHE_CHECK([for KEYTYPE_ARCFOUR_56],
434                  samba_cv_HAVE_KEYTYPE_ARCFOUR_56,[
435                 AC_TRY_COMPILE([#include <krb5.h>],
436                 [krb5_keytype keytype; keytype = KEYTYPE_ARCFOUR_56;],
437                 samba_cv_HAVE_KEYTYPE_ARCFOUR_56=yes,
438                 samba_cv_HAVE_KEYTYPE_ARCFOUR_56=no)])
439         # Heimdals with KEYTYPE_ARCFOUR but not KEYTYPE_ARCFOUR_56 are broken
440         # w.r.t. arcfour and windows, so we must not enable it here
441         if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes" -a\
442            x"$samba_cv_HAVE_KEYTYPE_ARCFOUR_56" = x"yes"; then
443                 AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,
444                 [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type is available])
445         fi
447         AC_CACHE_CHECK([for AP_OPTS_USE_SUBKEY],
448                 samba_cv_HAVE_AP_OPTS_USE_SUBKEY,[
449                 AC_TRY_COMPILE([#include <krb5.h>],
450                 [krb5_flags ap_options; ap_options = AP_OPTS_USE_SUBKEY;],
451                 samba_cv_HAVE_AP_OPTS_USE_SUBKEY=yes,
452                 samba_cv_HAVE_AP_OPTS_USE_SUBKEY=no)])
453         if test x"$samba_cv_HAVE_AP_OPTS_USE_SUBKEY" = x"yes"; then
454                 AC_DEFINE(HAVE_AP_OPTS_USE_SUBKEY,1,
455                 [Whether the AP_OPTS_USE_SUBKEY ap option is available])
456         fi
458         AC_CACHE_CHECK([for KV5M_KEYTAB],
459                 samba_cv_HAVE_KV5M_KEYTAB,[
460                 AC_TRY_COMPILE([#include <krb5.h>],
461                 [krb5_keytab_entry entry; entry.magic = KV5M_KEYTAB;],
462                 samba_cv_HAVE_KV5M_KEYTAB=yes,
463                 samba_cv_HAVE_KV5M_KEYTAB=no)])
464         if test x"$samba_cv_HAVE_KV5M_KEYTAB" = x"yes"; then
465                 AC_DEFINE(HAVE_KV5M_KEYTAB,1,
466                 [Whether the KV5M_KEYTAB option is available])
467         fi
469         AC_CACHE_CHECK([for the krb5_princ_component macro],
470                 samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
471                 AC_TRY_LINK([#include <krb5.h>],
472                 [const krb5_data *pkdata; krb5_context context; krb5_principal principal; 
473                         pkdata = krb5_princ_component(context, principal, 0);],
474                 samba_cv_HAVE_KRB5_PRINC_COMPONENT=yes,
475                 samba_cv_HAVE_KRB5_PRINC_COMPONENT=no)])
476         if test x"$samba_cv_HAVE_KRB5_PRINC_COMPONENT" = x"yes"; then
477                 AC_DEFINE(HAVE_KRB5_PRINC_COMPONENT,1,
478                [Whether krb5_princ_component is available])
479         fi
481         AC_CACHE_CHECK([for key in krb5_keytab_entry],
482                 samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY,[
483                 AC_TRY_COMPILE([#include <krb5.h>],
484                 [krb5_keytab_entry entry; krb5_keyblock e; entry.key = e;],
485                 samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=yes,
486                 samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=no)])
487         if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY" = x"yes"; then
488                 AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEY,1,
489                 [Whether krb5_keytab_entry has key member])
490         fi
492         AC_CACHE_CHECK([for keyblock in krb5_keytab_entry],
493                 samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,[
494                 AC_TRY_COMPILE([#include <krb5.h>],
495                 [krb5_keytab_entry entry; entry.keyblock.keytype = 0;],
496                 samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=yes,
497                 samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=no)])
498         if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK" = x"yes"; then
499                 AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,1,
500                 [Whether krb5_keytab_entry has keyblock member])
501         fi
503         AC_CACHE_CHECK([for WRFILE: keytab support],
504                 samba_cv_HAVE_WRFILE_KEYTAB,[
505                 AC_TRY_RUN([
506                 #include<krb5.h>
507                 main()
508                 {
509                         krb5_context context;
510                         krb5_keytab keytab;
511                         krb5_init_context(&context);
512                         return krb5_kt_resolve(context, "WRFILE:api", &keytab);
513                 }],
514                 samba_cv_HAVE_WRFILE_KEYTAB=yes,
515                 samba_cv_HAVE_WRFILE_KEYTAB=no)])
516         if test x"$samba_cv_HAVE_WRFILE_KEYTAB" = x"yes"; then
517                 AC_DEFINE(HAVE_WRFILE_KEYTAB,1,
518                 [Whether the WRFILE:-keytab is supported])
519         fi
521         AC_CACHE_CHECK([for krb5_princ_realm returns krb5_realm or krb5_data],
522                 samba_cv_KRB5_PRINC_REALM_RETURNS_REALM,[
523                 AC_TRY_COMPILE([#include <krb5.h>],
524                 [krb5_context context;krb5_principal principal;krb5_realm realm;
525                         realm = *krb5_princ_realm(context, principal);],
526                 samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=yes,
527                 samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=no)])
528         if test x"$samba_cv_KRB5_PRINC_REALM_RETURNS_REALM" = x"yes"; then
529                 AC_DEFINE(KRB5_PRINC_REALM_RETURNS_REALM,1,
530                 [Whether krb5_princ_realm returns krb5_realm or krb5_data])
531         fi
533         # TODO: check all gssapi headers for this
534         AC_CACHE_CHECK([for GSS_C_DCE_STYLE in gssapi.h],
535                 samba_cv_GSS_C_DCE_STYLE,[
536                 AC_TRY_COMPILE([#include <gssapi.h>],
537                 [int flags = GSS_C_DCE_STYLE;],
538                 samba_cv_GSS_C_DCE_STYLE=yes,
539                 samba_cv_GSS_C_DCE_STYLE=no)])
541         if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" = x"yes"; then
542                 AC_DEFINE(HAVE_KRB5,1,[Whether to have KRB5 support])
543                 AC_MSG_CHECKING(whether KRB5 support is used)
544                 SMB_EXT_LIB_ENABLE(KRB5,YES)
545                 AC_MSG_RESULT(yes)
546                 echo "KRB5_CFLAGS:   ${KRB5_CFLAGS}"
547                 echo "KRB5_CPPFLAGS: ${KRB5_CPPFLAGS}"
548                 echo "KRB5_LDFLAGS:  ${KRB5_LDFLAGS}"
549                 echo "KRB5_LIBS:     ${KRB5_LIBS}"
550         else
551                 if test x"$with_krb5_support" = x"yes"; then
552                         AC_MSG_ERROR(a working krb5 library is needed for KRB5 support)
553                 else
554                         AC_MSG_WARN(a working krb5 library is needed for KRB5 support)
555                 fi
556                 KRB5_CFLAGS=""
557                 KRB5_CPPFLAGS=""
558                 KRB5_LDFLAGS=""
559                 KRB5_LIBS=""
560                 with_krb5_support=no 
561         fi
563         CFLAGS=$ac_save_CFLAGS
564         CPPFLAGS=$ac_save_CPPFLAGS
565         LDFLAGS=$ac_save_LDFLAGS
566         LIBS="$ac_save_LIBS"
568         # as a nasty hack add the krb5 stuff to the global vars,
569         # at some point this should not be needed anymore when the build system
570         # can handle that alone
571         CFLAGS="$CFLAGS $KRB5_CFLAGS"
572         CPPFLAGS="$CPPFLAGS $KRB5_CPPFLAGS"
573         LDFLAGS="$LDFLAGS $KRB5_LDFLAGS"
576 SMB_EXT_LIB(LDAP,[${LDAP_LIBS}],[${LDAP_CFLAGS}],[${LDAP_CPPFLAGS}],[${LDAP_LDFLAGS}])
577 SMB_EXT_LIB(KRB5,[${KRB5_LIBS}],[${KRB5_CFLAGS}],[${KRB5_CPPFLAGS}],[${KRB5_LDFLAGS}])