Initial step at cleaning and splitting up configure.in.
[ira/wip.git] / source / libads / config.m4
1 #################################################
2 # active directory support
3
4 with_ads_support=yes
5 AC_MSG_CHECKING([whether to use Active Directory])
6
7 AC_ARG_WITH(ads,
8 [   --with-ads  Active Directory support (default yes)],
9 [ case "$withval" in
10     no)
11         with_ads_support=no
12         ;;
13   esac ])
14
15 if test x"$with_ads_support" = x"yes"; then
16    AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
17 fi
18
19 AC_MSG_RESULT($with_ads_support)
20
21 FOUND_KRB5=no
22 if test x"$with_ads_support" = x"yes"; then
23
24   #################################################
25   # check for krb5-config from recent MIT and Heimdal kerberos 5
26   AC_PATH_PROG(KRB5_CONFIG, krb5-config)
27   AC_MSG_CHECKING(for working krb5-config)
28   if test -x "$KRB5_CONFIG"; then
29     LIBS="$LIBS `$KRB5_CONFIG --libs`"
30     CFLAGS="$CFLAGS `$KRB5_CONFIG --cflags`" 
31     CPPFLAGS="$CPPFLAGS `$KRB5_CONFIG --cflags`"
32     FOUND_KRB5=yes
33     AC_MSG_RESULT(yes)
34   else
35     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
36   fi
37   
38   if test x$FOUND_KRB5 = x"no"; then
39   #################################################
40   # check for location of Kerberos 5 install
41   AC_MSG_CHECKING(for kerberos 5 install path)
42   AC_ARG_WITH(krb5,
43   [  --with-krb5=base-dir    Locate Kerberos 5 support (default=/usr)],
44   [ case "$withval" in
45     no)
46       AC_MSG_RESULT(no)
47       ;;
48     *)
49       AC_MSG_RESULT(yes)
50       LIBS="$LIBS -lkrb5"
51       CFLAGS="$CFLAGS -I$withval/include"
52       CPPFLAGS="$CPPFLAGS -I$withval/include"
53       LDFLAGS="$LDFLAGS -L$withval/lib"
54       FOUND_KRB5=yes
55       ;;
56     esac ],
57     AC_MSG_RESULT(no)
58   )
59   fi
60
61 if test x$FOUND_KRB5 = x"no"; then
62 #################################################
63 # see if this box has the SuSE location for the heimdal kerberos implementation
64 AC_MSG_CHECKING(for /usr/include/heimdal)
65 if test -d /usr/include/heimdal; then
66     if test -f /usr/lib/heimdal/lib/libkrb5.a; then
67         LIBS="$LIBS -lkrb5"
68         CFLAGS="$CFLAGS -I/usr/include/heimdal"
69         CPPFLAGS="$CPPFLAGS -I/usr/include/heimdal"
70         LDFLAGS="$LDFLAGS -L/usr/lib/heimdal/lib"
71         AC_MSG_RESULT(yes)
72     else
73         LIBS="$LIBS -lkrb5"
74         CFLAGS="$CFLAGS -I/usr/include/heimdal"
75         CPPFLAGS="$CPPFLAGS -I/usr/include/heimdal"
76         AC_MSG_RESULT(yes)
77  
78     fi
79 else
80     AC_MSG_RESULT(no)
81 fi
82 fi
83
84
85 if test x$FOUND_KRB5 = x"no"; then
86 #################################################
87 # see if this box has the RedHat location for kerberos
88 AC_MSG_CHECKING(for /usr/kerberos)
89 if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
90     LIBS="$LIBS -lkrb5"
91     LDFLAGS="$LDFLAGS -L/usr/kerberos/lib"
92     CFLAGS="$CFLAGS -I/usr/kerberos/include"
93     CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
94     AC_MSG_RESULT(yes)
95 else
96     AC_MSG_RESULT(no)
97 fi
98 fi
99
100   # now check for krb5.h. Some systems have the libraries without the headers!
101   # note that this check is done here to allow for different kerberos
102   # include paths
103   AC_CHECK_HEADERS(krb5.h)
104
105   # now check for gssapi headers.  This is also done here to allow for
106   # different kerberos include paths
107   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h)
108
109   ##################################################################
110   # we might need the k5crypto and com_err libraries on some systems
111   AC_CHECK_LIB(com_err, _et_list, [LIBS="$LIBS -lcom_err"])
112   AC_CHECK_LIB(k5crypto, krb5_encrypt_data, [LIBS="$LIBS -lk5crypto"])
113   # Heimdal checks.
114   AC_CHECK_LIB(crypto, des_set_key, [LIBS="$LIBS -lcrypto"])
115   AC_CHECK_LIB(asn1, copy_Authenticator, [LIBS="$LIBS -lasn1 -lroken"])
116   # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
117   AC_CHECK_LIB(gssapi, gss_display_status, [LIBS="$LIBS -lgssapi -lkrb5 -lasn1";
118         AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available])])
119
120   AC_CHECK_LIB(krb5, krb5_set_real_time, [AC_DEFINE(HAVE_KRB5_SET_REAL_TIME,1,[Whether krb5_set_real_time is available])])
121   AC_CHECK_LIB(krb5, krb5_set_default_in_tkt_etypes, [AC_DEFINE(HAVE_KRB5_SET_DEFAULT_IN_TKT_ETYPES,1,[Whether krb5_set_default_in_tkt_etypes, is available])])
122   AC_CHECK_LIB(krb5, krb5_set_default_tgs_ktypes, [AC_DEFINE(HAVE_KRB5_SET_DEFAULT_TGS_KTYPES,1,[Whether krb5_set_default_tgs_ktypes is available])])
123
124   AC_CHECK_LIB(krb5, krb5_principal2salt, [AC_DEFINE(HAVE_KRB5_PRINCIPAL2SALT,1,[Whether krb5_principal2salt is available])])
125   AC_CHECK_LIB(krb5, krb5_use_enctype, [AC_DEFINE(HAVE_KRB5_USE_ENCTYPE,1,[Whether krb5_use_enctype is available])])
126   AC_CHECK_LIB(krb5, krb5_string_to_key, [AC_DEFINE(HAVE_KRB5_STRING_TO_KEY,1,[Whether krb5_string_to_key is available])])
127   AC_CHECK_LIB(krb5, krb5_get_pw_salt, [AC_DEFINE(HAVE_KRB5_GET_PW_SALT,1,[Whether krb5_get_pw_salt is available])])
128   AC_CHECK_LIB(krb5, krb5_string_to_key_salt, [AC_DEFINE(HAVE_KRB5_STRING_TO_KEY_SALT,1,[Whether krb5_string_to_key_salt is available])])
129   AC_CHECK_LIB(krb5, krb5_auth_con_setkey, [AC_DEFINE(HAVE_KRB5_AUTH_CON_SETKEY,1,[Whether krb5_auth_con_setkey is available])])
130   AC_CHECK_LIB(krb5, krb5_auth_con_setuseruserkey, [AC_DEFINE(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY,1,[Whether krb5_auth_con_setuseruserkey is available])])
131   AC_CHECK_LIB(krb5, krb5_locate_kdc, [AC_DEFINE(HAVE_KRB5_LOCATE_KDC,1,[Whether krb5_locate_kdc is available])])
132   AC_CHECK_LIB(krb5, krb5_get_permitted_enctypes, [AC_DEFINE(HAVE_KRB5_GET_PERMITTED_ENCTYPES,1,[Whether krb5_get_permitted_enctypes is available])])
133   AC_CHECK_LIB(krb5, krb5_get_default_in_tkt_etypes, [AC_DEFINE(HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES,1,[Whether krb5_get_default_in_tkt_etypes is available])])
134   AC_CHECK_LIB(krb5, krb5_free_ktypes, [AC_DEFINE(HAVE_KRB5_FREE_KTYPES,1,[Whether krb5_free_ktypes is available])])
135
136 AC_CACHE_CHECK([for addrtype in krb5_address],samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
137 AC_TRY_COMPILE([#include <krb5.h>],
138 [krb5_address kaddr; kaddr.addrtype = ADDRTYPE_INET;],
139 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=yes,samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=no)])
140 if test x"$samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS" = x"yes"; then
141     AC_DEFINE(HAVE_ADDRTYPE_IN_KRB5_ADDRESS,1,[Whether the krb5_address struct has a addrtype property])
142 fi
143
144 AC_CACHE_CHECK([for addr_type in krb5_address],samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,[
145 AC_TRY_COMPILE([#include <krb5.h>],
146 [krb5_address kaddr; kaddr.addr_type = KRB5_ADDRESS_INET;],
147 samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=yes,samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=no)])
148 if test x"$samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS" = x"yes"; then
149     AC_DEFINE(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,1,[Whether the krb5_address struct has a addr_type property])
150 fi
151
152 AC_CACHE_CHECK([for enc_part2 in krb5_ticket],samba_cv_HAVE_KRB5_TKT_ENC_PART2,[
153 AC_TRY_COMPILE([#include <krb5.h>],
154 [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
155 samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
156 if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
157     AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,[Whether the krb5_ticket struct has a enc_part2 property])
158 fi
159
160 AC_CACHE_CHECK([for keyvalue in krb5_keyblock],samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
161 AC_TRY_COMPILE([#include <krb5.h>],
162 [krb5_keyblock key; key.keyvalue.data = NULL;],
163 samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=yes,samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=no)])
164 if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE" = x"yes"; then
165     AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,[Whether the krb5_keyblock struct has a keyvalue property])
166 fi
167
168 AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
169 AC_TRY_COMPILE([#include <krb5.h>],
170 [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC_MD5;],
171 samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=yes,samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=no)])
172 if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes"; then
173     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,[Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type is available])
174 fi
175
176   ########################################################
177   # now see if we can find the krb5 libs in standard paths
178   # or as specified above
179   AC_CHECK_LIB(krb5, krb5_mk_req_extended, [LIBS="$LIBS -lkrb5";
180         AC_DEFINE(HAVE_KRB5,1,[Whether KRB5 is available])])
181
182   ########################################################
183   # now see if we can find the gssapi libs in standard paths
184   AC_CHECK_LIB(gssapi_krb5, gss_display_status, [LIBS="$LIBS -lgssapi_krb5";
185         AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available])])
186
187 fi
188
189 ########################################################
190 # Compile with LDAP support?
191
192 with_ldap_support=yes
193 AC_MSG_CHECKING([whether to use LDAP])
194
195 AC_ARG_WITH(ldap,
196 [   --with-ldap  LDAP support (default yes)],
197 [ case "$withval" in
198     no)
199         with_ldap_support=no
200         ;;
201   esac ])
202
203 AC_MSG_RESULT($with_ldap_support)
204
205 if test x"$with_ldap_support" = x"yes"; then
206
207   ##################################################################
208   # we might need the lber lib on some systems. To avoid link errors
209   # this test must be before the libldap test
210   AC_CHECK_LIB(lber, ber_scanf, [LIBS="$LIBS -llber"])
211
212   ########################################################
213   # now see if we can find the ldap libs in standard paths
214   if test x$have_ldap != xyes; then
215   AC_CHECK_LIB(ldap, ldap_domain2hostlist, [LIBS="$LIBS -lldap";
216         AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])])
217
218         ########################################################
219         # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
220         # Check found in pam_ldap 145.
221         AC_CHECK_FUNCS(ldap_set_rebind_proc)
222         AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, pam_ldap_cv_ldap_set_rebind_proc, [
223         AC_TRY_COMPILE([
224         #include <lber.h>
225         #include <ldap.h>], [ldap_set_rebind_proc(0, 0, 0);], [pam_ldap_cv_ldap_set_rebind_proc=3], [pam_ldap_cv_ldap_set_rebind_proc=2]) ])
226         AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $pam_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
227   fi
228 fi
229
230  check for a PAM clear-text auth, accounts, password and session support
231 with_pam_for_crypt=no
232 AC_MSG_CHECKING(whether to use PAM)
233 AC_ARG_WITH(pam,
234 [  --with-pam              Include PAM support (default=no)],
235 [ case "$withval" in
236   yes)
237     AC_MSG_RESULT(yes)
238     AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
239     AUTHLIBS="$AUTHLIBS -lpam"
240     with_pam_for_crypt=yes
241     ;;
242   *)
243     AC_MSG_RESULT(no)
244     ;;
245   esac ],
246   AC_MSG_RESULT(no)
247 )