d6eadfd91b188f57483f960cf024c14bb7e49b49
[gd/samba-autobuild/.git] / packaging / Debian / debian / patches / krb5-vars.patch
1 --- samba_3_0/source/Makefile.in.orig   2003-07-15 12:26:55.000000000 -0400
2 +++ samba_3_0/source/Makefile.in        2003-07-15 12:26:57.000000000 -0400
3 @@ -32,7 +32,6 @@
4  ACLLIBS=@ACLLIBS@
5  PASSDBLIBS=@PASSDBLIBS@
6  IDMAP_LIBS=@IDMAP_LIBS@
7 -ADSLIBS=@ADSLIBS@
8  KRB5LIBS=@KRB5_LIBS@
9  LDAPLIBS=@LDAP_LIBS@
10  
11 @@ -735,12 +734,12 @@
12  
13  bin/smbd@EXEEXT@: $(SMBD_OBJ) @BUILD_POPT@ bin/.dummy
14         @echo Linking $@
15 -       @$(CC) $(FLAGS) -o $@ $(SMBD_OBJ) $(ADSLIBS) $(LDFLAGS) $(DYNEXP) $(PRINTLIBS) \
16 +       @$(CC) $(FLAGS) -o $@ $(SMBD_OBJ) $(KRB5LIBS) $(LDAPLIBS) $(LDFLAGS) $(DYNEXP) $(PRINTLIBS) \
17           $(AUTHLIBS) $(ACLLIBS) $(PASSDBLIBS) $(LIBS) @POPTLIBS@
18  
19  bin/nmbd@EXEEXT@: $(NMBD_OBJ) @BUILD_POPT@ bin/.dummy
20         @echo Linking $@
21 -       @$(CC) $(FLAGS) -o $@ $(NMBD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) @POPTLIBS@ $(ADSLIBS)
22 +       @$(CC) $(FLAGS) -o $@ $(NMBD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAPLIBS)
23  
24  bin/wrepld@EXEEXT@: $(WREPL_OBJ) @BUILD_POPT@ bin/.dummy
25         @echo Linking $@
26 @@ -749,19 +748,19 @@
27  bin/swat@EXEEXT@: $(SWAT_OBJ) @BUILD_POPT@ bin/.dummy
28         @echo Linking $@
29         @$(CC) $(FLAGS) -o $@ $(SWAT_OBJ) $(LDFLAGS) $(DYNEXP) $(PRINTLIBS) \
30 -         $(AUTHLIBS) $(LIBS) $(PASSDBLIBS) @POPTLIBS@ $(KRB5LIBS)
31 +         $(AUTHLIBS) $(LIBS) $(PASSDBLIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAPLIBS)
32  
33  bin/rpcclient@EXEEXT@: $(RPCCLIENT_OBJ) @BUILD_POPT@ bin/.dummy
34         @echo Linking $@
35 -       @$(CC) $(FLAGS) -o $@ $(PASSDBLIBS) $(RPCCLIENT_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ $(ADSLIBS)
36 +       @$(CC) $(FLAGS) -o $@ $(PASSDBLIBS) $(RPCCLIENT_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAPLIBS)
37  
38  bin/smbclient@EXEEXT@: $(CLIENT_OBJ) @BUILD_POPT@ bin/.dummy
39         @echo Linking $@
40 -       @$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ $(ADSLIBS)
41 +       @$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAPLIBS)
42  
43  bin/net@EXEEXT@: $(NET_OBJ) @BUILD_POPT@ bin/.dummy
44         @echo Linking $@
45 -       @$(CC) $(FLAGS) -o $@ $(NET_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) @POPTLIBS@ $(ADSLIBS) $(PASSDBLIBS)
46 +       @$(CC) $(FLAGS) -o $@ $(NET_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAPLIBS) $(PASSDBLIBS)
47  
48  bin/profiles@EXEEXT@: $(PROFILES_OBJ) @BUILD_POPT@ bin/.dummy
49         @echo Linking $@
50 @@ -809,7 +808,7 @@
51  
52  bin/smbpasswd@EXEEXT@: $(SMBPASSWD_OBJ) bin/.dummy
53         @echo Linking $@
54 -       @$(CC) $(FLAGS) -o $@ $(SMBPASSWD_OBJ) $(PASSDBLIBS) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS)
55 +       @$(CC) $(FLAGS) -o $@ $(SMBPASSWD_OBJ) $(PASSDBLIBS) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAPLIBS)
56  
57  bin/pdbedit@EXEEXT@: $(PDBEDIT_OBJ) @BUILD_POPT@ bin/.dummy
58         @echo Linking $@
59 @@ -881,7 +880,7 @@
60  
61  bin/smbw_sample@EXEEXT@: $(SMBW_OBJ) utils/smbw_sample.o bin/.dummy
62         @echo Linking $@
63 -       @$(CC) $(FLAGS) -o $@ $(SMBW_OBJ) utils/smbw_sample.o $(LDFLAGS) $(LIBS) $(KRB5LIBS)
64 +       @$(CC) $(FLAGS) -o $@ $(SMBW_OBJ) utils/smbw_sample.o $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAPLIBS)
65  
66  bin/smbsh@EXEEXT@: $(SMBSH_OBJ) bin/.dummy
67         @echo Linking $@
68 @@ -890,12 +889,14 @@
69  bin/smbwrapper.@SHLIBEXT@: $(PICOBJS) bin/.dummy
70         @echo Linking shared library $@
71         @$(SHLD) $(LDSHFLAGS) -o $@ $(PICOBJS) $(LIBS) \
72 -               @SONAMEFLAG@`basename $@` $(KRB5LIBS)
73 +               $(KRB5LIBS) $(LDAPLIBS) \
74 +               @SONAMEFLAG@`basename $@`
75  
76  bin/libsmbclient.@SHLIBEXT@: $(LIBSMBCLIENT_PICOBJS)
77         @echo Linking libsmbclient shared library $@
78         @$(SHLD) $(LDSHFLAGS) -o $@ $(LIBSMBCLIENT_PICOBJS) $(LDFLAGS) $(LIBS) \
79 -       $(KRB5LIBS) @SONAMEFLAG@`basename $@`.$(LIBSMBCLIENT_MAJOR)
80 +               $(KRB5LIBS) $(LDAPLIBS) \
81 +               @SONAMEFLAG@`basename $@`.$(LIBSMBCLIENT_MAJOR)
82  
83  bin/libsmbclient.a: $(LIBSMBCLIENT_PICOBJS)
84         @echo Linking libsmbclient non-shared library $@
85 @@ -905,7 +906,8 @@
86  bin/libbigballofmud.@SHLIBEXT@: $(LIBBIGBALLOFMUD_PICOBJS)
87         @echo Linking bigballofmud shared library $@
88         @$(SHLD) $(LDSHFLAGS) -o $@ $(LIBBIGBALLOFMUD_PICOBJS) $(LIBS) \
89 -               @SONAMEFLAG@`basename $@`.$(LIBBIGBALLOFMUD_MAJOR) $(PASSDBLIBS) $(IDMAP_LIBS) $(ADSLIBS)
90 +               $(PASSDBLIBS) $(IDMAP_LIBS) $(KRB5LIBS) $(LDAPLIBS) \
91 +               @SONAMEFLAG@`basename $@`.$(LIBBIGBALLOFMUD_MAJOR)
92         ln -snf libbigballofmud.so bin/libbigballofmud.so.0
93  
94  # It would be nice to build a static bigballofmud too, but when I try
95 diff -uNr samba-3.0.0beta2.orig/source/aclocal.m4 samba-3.0.0beta2/source/aclocal.m4
96 --- samba-3.0.0beta2.orig/source/aclocal.m4     2003-07-01 15:44:25.000000000 -0500
97 +++ samba-3.0.0beta2/source/aclocal.m4  2003-07-05 16:22:30.000000000 -0500
98 @@ -111,6 +111,113 @@
99    esac
100  ])
101  
102 +# AC_CHECK_LIB_EXT(LIBRARY, [EXT_LIBS], [FUNCTION],
103 +#              [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
104 +#              [ADD-ACTION-IF-FOUND],[OTHER-LIBRARIES])
105 +# ------------------------------------------------------
106 +#
107 +# Use a cache variable name containing both the library and function name,
108 +# because the test really is for library $1 defining function $3, not
109 +# just for library $1.  Separate tests with the same $1 and different $3s
110 +# may have different results.
111 +#
112 +# Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$3])
113 +# is asking for troubles, since AC_CHECK_LIB($lib, fun) would give
114 +# ac_cv_lib_$lib_fun, which is definitely not what was meant.  Hence
115 +# the AS_LITERAL_IF indirection.
116 +#
117 +# FIXME: This macro is extremely suspicious.  It DEFINEs unconditionnally,
118 +# whatever the FUNCTION, in addition to not being a *S macro.  Note
119 +# that the cache does depend upon the function we are looking for.
120 +#
121 +# It is on purpose we used `ac_check_lib_ext_save_LIBS' and not just
122 +# `ac_save_LIBS': there are many macros which don't want to see `LIBS'
123 +# changed but still want to use AC_CHECK_LIB_EXT, so they save `LIBS'.
124 +# And ``ac_save_LIBS' is too tempting a name, so let's leave them some
125 +# freedom.
126 +AC_DEFUN([AC_CHECK_LIB_EXT],
127 +[
128 +AH_CHECK_LIB_EXT([$1])
129 +ac_check_lib_ext_save_LIBS=$LIBS
130 +LIBS="-l$1 $$2 $7 $LIBS"
131 +AS_LITERAL_IF([$1],
132 +      [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1])],
133 +      [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1''])])dnl
134 +
135 +m4_ifval([$3],
136 + [
137 +    AH_CHECK_FUNC_EXT([$3])
138 +    AS_LITERAL_IF([$1],
139 +              [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1_$3])],
140 +              [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1''_$3])])dnl
141 +    AC_CACHE_CHECK([for $3 in -l$1], ac_Lib_func,
142 +       [AC_TRY_LINK_FUNC($3,
143 +                 [AS_VAR_SET(ac_Lib_func, yes);
144 +                 AS_VAR_SET(ac_Lib_ext, yes)],
145 +                 [AS_VAR_SET(ac_Lib_func, no);
146 +                 AS_VAR_SET(ac_Lib_ext, no)])
147 +       ])
148 +    AS_IF([test AS_VAR_GET(ac_Lib_func) = yes],
149 +        [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$3))])dnl
150 +    AS_VAR_POPDEF([ac_Lib_func])dnl
151 + ],[
152 +    AC_CACHE_CHECK([for -l$1], ac_Lib_ext,
153 +       [AC_TRY_LINK_FUNC([main],
154 +                 [AS_VAR_SET(ac_Lib_ext, yes)],
155 +                 [AS_VAR_SET(ac_Lib_ext, no)])
156 +       ])
157 + ])
158 +LIBS=$ac_check_lib_ext_save_LIBS
159 +
160 +AS_IF([test AS_VAR_GET(ac_Lib_ext) = yes],
161 +    [m4_default([$4], 
162 +        [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
163 +               case "$$2" in
164 +                   *-l$1*)
165 +                       ;;
166 +                   *)
167 +                       $2="$$2 -l$1"
168 +                       ;;
169 +               esac])
170 +               [$6]
171 +           ],
172 +           [$5])dnl
173 +AS_VAR_POPDEF([ac_Lib_ext])dnl
174 +])# AC_CHECK_LIB_EXT
175 +
176 +# AH_CHECK_LIB_EXT(LIBNAME)
177 +# ---------------------
178 +m4_define([AH_CHECK_LIB_EXT],
179 +[AH_TEMPLATE(AS_TR_CPP(HAVE_LIB$1),
180 +             [Define to 1 if you have the `]$1[' library (-l]$1[).])])
181 +
182 +# AC_CHECK_FUNCS_EXT(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
183 +# -----------------------------------------------------------------
184 +dnl check for a function in a $LIBS and $OTHER_LIBS libraries variable.
185 +dnl AC_CHECK_FUNC_EXT(func,OTHER_LIBS,IF-TRUE,IF-FALSE)
186 +AC_DEFUN([AC_CHECK_FUNC_EXT],
187 +[
188 +    AH_CHECK_FUNC_EXT($1)      
189 +    ac_check_func_ext_save_LIBS=$LIBS
190 +    LIBS="$2 $LIBS"
191 +    AS_VAR_PUSHDEF([ac_var], [ac_cv_func_ext_$1])dnl
192 +    AC_CACHE_CHECK([for $1], ac_var,
193 +       [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
194 +                [AS_VAR_SET(ac_var, yes)],
195 +                [AS_VAR_SET(ac_var, no)])])
196 +    LIBS=$ac_check_func_ext_save_LIBS
197 +    AS_IF([test AS_VAR_GET(ac_var) = yes], 
198 +           [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1])) $3], 
199 +           [$4])dnl
200 +AS_VAR_POPDEF([ac_var])dnl
201 +])# AC_CHECK_FUNC
202 +
203 +# AH_CHECK_FUNC_EXT(FUNCNAME)
204 +# ---------------------
205 +m4_define([AH_CHECK_FUNC_EXT],
206 +[AH_TEMPLATE(AS_TR_CPP(HAVE_$1),
207 +             [Define to 1 if you have the `]$1[' function.])])
208 +
209  dnl Define an AC_DEFINE with ifndef guard.
210  dnl AC_N_DEFINE(VARIABLE [, VALUE])
211  define(AC_N_DEFINE,
212 diff -uNr samba-3.0.0beta2.orig/source/configure.in samba-3.0.0beta2/source/configure.in
213 --- samba-3.0.0beta2.orig/source/configure.in   2003-07-05 16:22:00.000000000 -0500
214 +++ samba-3.0.0beta2/source/configure.in        2003-07-05 16:23:53.000000000 -0500
215 @@ -162,12 +162,10 @@
216  AC_SUBST(PRINTLIBS)
217  AC_SUBST(AUTHLIBS)
218  AC_SUBST(ACLLIBS)
219 -AC_SUBST(ADSLIBS)
220  AC_SUBST(PASSDBLIBS)
221  AC_SUBST(IDMAP_LIBS)
222  AC_SUBST(KRB5_LIBS)
223  AC_SUBST(LDAP_LIBS)
224 -AC_SUBST(LDAP_OBJ)
225  AC_SUBST(SHLIB_PROGS)
226  AC_SUBST(SMBWRAPPER)
227  AC_SUBST(EXTRA_BIN_PROGS)
228 @@ -2105,14 +2103,107 @@
229    AC_MSG_RESULT(no)
230  )
231  
232 +########################################################
233 +# Compile with LDAP support?
234 +
235 +with_ldap_support=auto
236 +AC_MSG_CHECKING([for LDAP support])
237 +
238 +AC_ARG_WITH(ldap,
239 +[  --with-ldap             LDAP support (default yes)],
240 +[ case "$withval" in
241 +    yes|no)
242 +       with_ldap_support=$withval
243 +       ;;
244 +  esac ])
245 +
246 +AC_MSG_RESULT($with_ldap_support)
247 +
248 +SMBLDAP=""
249 +SMBLDAP_PROTO=""
250 +AC_SUBST(SMBLDAP)
251 +AC_SUBST(SMBLDAP_PROTO)
252 +if test x"$with_ldap_support" != x"no"; then
253 +
254 +  ##################################################################
255 +  # first test for ldap.h and lber.h
256 +  # (ldap.h is required for this test)
257 +  AC_CHECK_HEADERS(ldap.h lber.h)
258 +  
259 +  if test x"$ac_cv_header_ldap_h" != x"yes"; then
260 +       if test x"$with_ldap_support" = x"yes"; then
261 +        AC_MSG_ERROR(ldap.h is needed for LDAP support)
262 +       else
263 +        AC_MSG_WARN(ldap.h is needed for LDAP support)
264 +       fi
265 +       
266 +       with_ldap_support=no
267 +  fi
268 +fi
269 +
270 +if test x"$with_ldap_support" != x"no"; then
271 +  ac_save_LIBS=$LIBS
272 +
273 +  ##################################################################
274 +  # we might need the lber lib on some systems. To avoid link errors
275 +  # this test must be before the libldap test
276 +  AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
277 +
278 +  ########################################################
279 +  # now see if we can find the ldap libs in standard paths
280 +  AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
281 +
282 +  AC_CHECK_FUNC_EXT(ldap_domain2hostlist,$LDAP_LIBS)
283 +  
284 +  ########################################################
285 +  # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
286 +  # Check found in pam_ldap 145.
287 +  AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
288 +
289 +  LIBS="$LIBS $LDAP_LIBS"
290 +  AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
291 +    AC_TRY_COMPILE([
292 +       #include <lber.h>
293 +       #include <ldap.h>], 
294 +       [ldap_set_rebind_proc(0, 0, 0);], 
295 +       [smb_ldap_cv_ldap_set_rebind_proc=3], 
296 +       [smb_ldap_cv_ldap_set_rebind_proc=2]
297 +    ) 
298 +  ])
299 +  
300 +  AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
301 +
302 +  AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)        
303 +  
304 +  if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes" -a x"$ac_cv_func_ext_ldap_domain2hostlist" = x"yes"; then
305 +    AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
306 +    default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
307 +    SMBLDAP="lib/smbldap.o"
308 +    with_ldap_support=yes
309 +    AC_MSG_CHECKING(whether LDAP support is used)
310 +    AC_MSG_RESULT(yes)
311 +  else
312 +    if test x"$with_ldap_support" = x"yes"; then
313 +       AC_MSG_ERROR(libldap is needed for LDAP support)
314 +    else
315 +       AC_MSG_WARN(libldap is needed for LDAP support)
316 +    fi
317 +    
318 +    LDAP_LIBS=""
319 +    with_ldap_support=no
320 +  fi
321 +  LIBS=$ac_save_LIBS
322 +fi
323 +
324 +
325  #################################################
326  # active directory support
327  
328  with_ads_support=auto
329 -AC_MSG_CHECKING([whether to use Active Directory])
330 +AC_MSG_CHECKING([for Active Directory and krb5 support])
331  
332  AC_ARG_WITH(ads,
333 -[  --with-ads              Active Directory support (default yes)],
334 +[  --with-ads              Active Directory support (default auto)],
335  [ case "$withval" in
336      yes|no)
337         with_ads_support="$withval"
338 @@ -2124,22 +2215,28 @@
339  FOUND_KRB5=no
340  KRB5_LIBS=""
341  
342 +if test x"$with_ldap_support" != x"yes"; then
343 +    if test x"$with_ads_support" = x"yes"; then
344 +       AC_MSG_ERROR(Active Directory Support requires LDAP support)
345 +    elif test x"$with_ads_support" != x"no"; then
346 +       AC_MSG_WARN(Active Directory Support requires LDAP support)
347 +    fi
348 +    with_ads_support=no
349 +fi
350 +
351  if test x"$with_ads_support" != x"no"; then
352  
353    # Do no harm to the values of CFLAGS and LIBS while testing for
354    # Kerberos support.
355  
356 -  ac_save_CFLAGS="$CFLAGS"
357 -  ac_save_LIBS="$LIBS"
358 -
359    #################################################
360    # check for krb5-config from recent MIT and Heimdal kerberos 5
361    AC_PATH_PROG(KRB5_CONFIG, krb5-config)
362    AC_MSG_CHECKING(for working krb5-config)
363    if test -x "$KRB5_CONFIG"; then
364 -    LIBS="$LIBS `$KRB5_CONFIG --libs`"
365 -    CFLAGS="$CFLAGS `$KRB5_CONFIG --cflags | sed s/@INCLUDE_des@//`" 
366 -    CPPFLAGS="$CPPFLAGS `$KRB5_CONFIG --cflags | sed s/@INCLUDE_des@//`"
367 +    KRB5_LIBS="`CFLAGS='' $KRB5_CONFIG --libs gssapi`"
368 +    KRB5_CFLAGS="`$KRB5_CONFIG --cflags | sed s/@INCLUDE_des@//`" 
369 +    KRB5_CPPFLAGS="`$KRB5_CONFIG --cflags | sed s/@INCLUDE_des@//`"
370      FOUND_KRB5=yes
371      AC_MSG_RESULT(yes)
372    else
373 @@ -2154,18 +2251,23 @@
374      [  --with-krb5=base-dir    Locate Kerberos 5 support (default=/usr)],
375      [ case "$withval" in
376        no)
377 -        AC_MSG_RESULT(no)
378 +        AC_MSG_RESULT(no krb5-path given)
379 +        ;;
380 +      yes)
381 +        AC_MSG_RESULT(/usr)
382 +        KRB5_LIBS="-lkrb5"
383 +        FOUND_KRB5=yes
384          ;;
385        *)
386 -        AC_MSG_RESULT(yes)
387 -        LIBS="$LIBS -lkrb5"
388 -        CFLAGS="$CFLAGS -I$withval/include"
389 -        CPPFLAGS="$CPPFLAGS -I$withval/include"
390 -        LDFLAGS="$LDFLAGS -L$withval/lib"
391 +        AC_MSG_RESULT($withval)
392 +        KRB5_LIBS="-lkrb5"
393 +        KRB5_CFLAGS="-I$withval/include"
394 +        KRB5_CPPFLAGS="-I$withval/include"
395 +        KRB5_LDFLAGS="-L$withval/lib"
396          FOUND_KRB5=yes
397          ;;
398        esac ],
399 -      AC_MSG_RESULT(no)
400 +      AC_MSG_RESULT(no krb5-path given)
401      )
402    fi
403  
404 @@ -2175,15 +2277,15 @@
405      AC_MSG_CHECKING(for /usr/include/heimdal)
406      if test -d /usr/include/heimdal; then
407        if test -f /usr/lib/heimdal/lib/libkrb5.a; then
408 -          LIBS="$LIBS -lkrb5"
409 -          CFLAGS="$CFLAGS -I/usr/include/heimdal"
410 -          CPPFLAGS="$CPPFLAGS -I/usr/include/heimdal"
411 -          LDFLAGS="$LDFLAGS -L/usr/lib/heimdal/lib"
412 +          KRB5_LIBS="-lkrb5"
413 +          KRB5_CFLAGS="-I/usr/include/heimdal"
414 +          KRB5_CPPFLAGS="-I/usr/include/heimdal"
415 +          KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
416            AC_MSG_RESULT(yes)
417        else
418 -          LIBS="$LIBS -lkrb5"
419 -          CFLAGS="$CFLAGS -I/usr/include/heimdal"
420 -          CPPFLAGS="$CPPFLAGS -I/usr/include/heimdal"
421 +          KRB5_LIBS="-lkrb5"
422 +          KRB5_CFLAGS="-I/usr/include/heimdal"
423 +          KRB5_CPPFLAGS="-I/usr/include/heimdal"
424            AC_MSG_RESULT(yes)
425        fi
426      else
427 @@ -2196,16 +2298,26 @@
428      # see if this box has the RedHat location for kerberos
429      AC_MSG_CHECKING(for /usr/kerberos)
430      if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
431 -      LIBS="$LIBS -lkrb5"
432 -      LDFLAGS="$LDFLAGS -L/usr/kerberos/lib"
433 -      CFLAGS="$CFLAGS -I/usr/kerberos/include"
434 -      CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
435 +      KRB5_LIBS="-lkrb5"
436 +      KRB5_LDFLAGS="-L/usr/kerberos/lib"
437 +      KRB5_CFLAGS="-I/usr/kerberos/include"
438 +      KRB5_CPPFLAGS="-I/usr/kerberos/include"
439        AC_MSG_RESULT(yes)
440      else
441        AC_MSG_RESULT(no)
442      fi
443    fi
444  
445 +  ac_save_CFLAGS=$CFLAGS
446 +  ac_save_CPPFLAGS=$CPPFLAGS
447 +  ac_save_LDFLAGS=$LDFLAGS
448 +
449 +  CFLAGS="$CFLAGS $KRB5_CFLAGS"
450 +  CPPFLAGS="$CPPFLAGS $KRB5_CPPFLAGS"
451 +  LDFLAGS="$LDFLAGS $KRB5_LDFLAGS"
452 +
453 +  KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
454 +
455    # now check for krb5.h. Some systems have the libraries without the headers!
456    # note that this check is done here to allow for different kerberos
457    # include paths
458 @@ -2225,24 +2337,17 @@
459      # Turn off AD support and restore CFLAGS and LIBS variables
460  
461      with_ads_support="no"
462 -
463 -    CFLAGS="$ac_save_CFLAGS"
464 -    LIBS="$ac_save_LIBS"
465 -
466 -  else
467 -
468 -    # Get rid of case where $with_ads_support=auto
469 -
470 -    with_ads_support="yes"
471 -
472 +    
473 +    CFLAGS=$ac_save_CFLAGS
474 +    CPPFLAGS=$ac_save_CPPFLAGS
475 +    LDFLAGS=$ac_save_LDFLAGS
476    fi
477  fi
478  
479  # Now we have determined whether we really want ADS support
480  
481 -if test x"$with_ads_support" = x"yes"; then
482 -
483 -  AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
484 +if test x"$with_ads_support" != x"no"; then
485 +  ac_save_LIBS=$LIBS
486  
487    # now check for gssapi headers.  This is also done here to allow for
488    # different kerberos include paths
489 @@ -2250,64 +2365,46 @@
490  
491    ##################################################################
492    # we might need the k5crypto and com_err libraries on some systems
493 -  AC_CHECK_LIB(com_err, _et_list)
494 -  AC_CHECK_LIB(k5crypto, krb5_encrypt_data)
495 +  AC_CHECK_LIB_EXT(com_err, KRB5_LIBS, _et_list)
496 +  AC_CHECK_LIB_EXT(k5crypto, KRB5_LIBS, krb5_encrypt_data)
497  
498    # Heimdal checks.
499 -  AC_CHECK_LIB(crypto, des_set_key)
500 -  AC_CHECK_LIB(asn1, copy_Authenticator)
501 -  AC_CHECK_LIB(roken, roken_getaddrinfo_hostspec)
502 +  AC_CHECK_LIB_EXT(crypto, KRB5_LIBS, des_set_key)
503 +  AC_CHECK_LIB_EXT(asn1, KRB5_LIBS, copy_Authenticator)
504 +  AC_CHECK_LIB_EXT(roken, KRB5_LIBS, roken_getaddrinfo_hostspec)
505  
506    # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
507 -  AC_CHECK_LIB(gssapi, gss_display_status, [LIBS="$LIBS -lgssapi -lkrb5";
508 +  AC_CHECK_LIB_EXT(gssapi, KRB5_LIBS, gss_display_status, [KRB5_LIBS="$KRB5_LIBS -lgssapi -lkrb5";
509                   AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available])])
510  
511 -  AC_CHECK_LIB(krb5, krb5_set_real_time, 
512 -                [AC_DEFINE(HAVE_KRB5_SET_REAL_TIME,1,
513 -                   [Whether krb5_set_real_time is available])])
514 -  AC_CHECK_LIB(krb5, krb5_set_default_in_tkt_etypes, 
515 -                 [AC_DEFINE(HAVE_KRB5_SET_DEFAULT_IN_TKT_ETYPES,1,
516 -                   [Whether krb5_set_default_in_tkt_etypes, is available])])
517 -  AC_CHECK_LIB(krb5, krb5_set_default_tgs_ktypes, 
518 -                 [AC_DEFINE(HAVE_KRB5_SET_DEFAULT_TGS_KTYPES,1,
519 -                   [Whether krb5_set_default_tgs_ktypes is available])])
520 -
521 -  AC_CHECK_LIB(krb5, krb5_principal2salt, 
522 -                [AC_DEFINE(HAVE_KRB5_PRINCIPAL2SALT,1,
523 -                   [Whether krb5_principal2salt is available])])
524 -  AC_CHECK_LIB(krb5, krb5_use_enctype, 
525 -                [AC_DEFINE(HAVE_KRB5_USE_ENCTYPE,1,
526 -                   [Whether krb5_use_enctype is available])])
527 -  AC_CHECK_LIB(krb5, krb5_string_to_key, 
528 -                [AC_DEFINE(HAVE_KRB5_STRING_TO_KEY,1,
529 -                   [Whether krb5_string_to_key is available])])
530 -  AC_CHECK_LIB(krb5, krb5_get_pw_salt, 
531 -                [AC_DEFINE(HAVE_KRB5_GET_PW_SALT,1,
532 -                   [Whether krb5_get_pw_salt is available])])
533 -  AC_CHECK_LIB(krb5, krb5_string_to_key_salt, 
534 -                [AC_DEFINE(HAVE_KRB5_STRING_TO_KEY_SALT,1,
535 -                   [Whether krb5_string_to_key_salt is available])])
536 -  AC_CHECK_LIB(krb5, krb5_auth_con_setkey, 
537 -                [AC_DEFINE(HAVE_KRB5_AUTH_CON_SETKEY,1,
538 -                   [Whether krb5_auth_con_setkey is available])])
539 -  AC_CHECK_LIB(krb5, krb5_auth_con_setuseruserkey, 
540 -                [AC_DEFINE(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY,1,
541 -                   [Whether krb5_auth_con_setuseruserkey is available])])
542 -  AC_CHECK_LIB(krb5, krb5_locate_kdc, 
543 -                [AC_DEFINE(HAVE_KRB5_LOCATE_KDC,1,
544 -                   [Whether krb5_locate_kdc is available])])
545 -  AC_CHECK_LIB(krb5, krb5_get_permitted_enctypes, 
546 -                [AC_DEFINE(HAVE_KRB5_GET_PERMITTED_ENCTYPES,1,
547 -                   [Whether krb5_get_permitted_enctypes is available])])
548 -  AC_CHECK_LIB(krb5, krb5_get_default_in_tkt_etypes, 
549 -                [AC_DEFINE(HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES,1,
550 -                   [Whether krb5_get_default_in_tkt_etypes is available])])
551 -  AC_CHECK_LIB(krb5, krb5_free_ktypes, 
552 -                [AC_DEFINE(HAVE_KRB5_FREE_KTYPES,1,
553 -                   [Whether krb5_free_ktypes is available])])
554 -  AC_CHECK_LIB(krb5, krb5_principal_get_comp_string, 
555 -                [AC_DEFINE(HAVE_KRB5_PRINCIPAL_GET_COMP_STRING,1,
556 -                   [Whether krb5_principal_get_comp_string is available])])
557 +  ########################################################
558 +  # now see if we can find the krb5 libs in standard paths
559 +  # or as specified above
560 +  AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
561 +
562 +  ########################################################
563 +  # now see if we can find the gssapi libs in standard paths
564 +  AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],
565 +          AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available]))
566 +
567 +  AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
568 +  AC_CHECK_FUNC_EXT(krb5_set_default_in_tkt_etypes, $KRB5_LIBS)
569 +  AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
570 +  AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
571 +  AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
572 +  AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS)
573 +  AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
574 +  AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS)
575 +  AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
576 +  AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS)
577 +  AC_CHECK_FUNC_EXT(krb5_locate_kdc, $KRB5_LIBS)
578 +  AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS)
579 +  AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS)
580 +  AC_CHECK_FUNC_EXT(krb5_free_ktypes, $KRB5_LIBS)
581 +  AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
582 +
583 +  LIBS="$LIBS $KRB5_LIBS"
584 +
585    AC_CACHE_CHECK([for the krb5_princ_component macro],
586                  samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
587      AC_TRY_LINK([#include <krb5.h>],
588 @@ -2380,87 +2468,21 @@
589                [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type is available])
590    fi
591  
592 -  ########################################################
593 -  # now see if we can find the krb5 libs in standard paths
594 -  # or as specified above
595 -  AC_CHECK_LIB(krb5, krb5_mk_req_extended, [KRB5_LIBS="$LIBS -lkrb5";
596 -              KRB5_CFLAGS="$CFLAGS";
597 -               AC_DEFINE(HAVE_KRB5,1,[Whether KRB5 is available])])
598 -
599 -  ########################################################
600 -  # now see if we can find the gssapi libs in standard paths
601 -  AC_CHECK_LIB(gssapi_krb5, gss_display_status, 
602 -               [KRB5_LIBS="$KRB5_LIBS -lgssapi_krb5";
603 -                AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available])])
604 -
605 -  CFLAGS="$ac_save_CFLAGS"
606 -  LIBS="$ac_save_LIBS"
607 -fi
608 -
609 -########################################################
610 -# Compile with LDAP support?
611 -
612 -LDAP_OBJ=""
613 -with_ldap_support=yes
614 -AC_MSG_CHECKING([whether to use LDAP])
615 -
616 -AC_ARG_WITH(ldap,
617 -[  --with-ldap             LDAP support (default yes)],
618 -[ case "$withval" in
619 -    no)
620 -       with_ldap_support=no
621 -       ;;
622 -  esac ])
623 -
624 -AC_MSG_RESULT($with_ldap_support)
625 -
626 -SMBLDAP=""
627 -if test x"$with_ldap_support" = x"yes"; then
628 -  ac_save_LIBS="$LIBS"
629 -  LIBS=""
630 -
631 -  ##################################################################
632 -  # we might need the lber lib on some systems. To avoid link errors
633 -  # this test must be before the libldap test
634 -  AC_CHECK_LIB(lber, ber_scanf)
635 -
636 -  ########################################################
637 -  # now see if we can find the ldap libs in standard paths
638 -  if test x$have_ldap != xyes; then
639 -        AC_CHECK_LIB(ldap, ldap_init, [
640 -           LIBS="$LIBS -lldap";
641 -           AC_CHECK_LIB(ldap, ldap_domain2hostlist, [
642 -             AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
643 -             AC_CHECK_HEADERS([ldap.h lber.h], 
644 -                 [default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
645 -                  SMBLDAP="lib/smbldap.o"])
646 -           ])
647 -        ])
648 -
649 -       ########################################################
650 -       # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
651 -       # Check found in pam_ldap 145.
652 -       AC_CHECK_FUNCS(ldap_set_rebind_proc)
653 -       AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, pam_ldap_cv_ldap_set_rebind_proc, [
654 -       AC_TRY_COMPILE([
655 -       #include <lber.h>
656 -       #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]) ])
657 -       AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $pam_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
658 -       AC_CHECK_FUNCS(ldap_initialize) 
659 -  fi
660 -  
661 -  AC_SUBST(SMBLDAP)
662 -  LDAP_LIBS="$LIBS";
663 -  LIBS="$ac_save_LIBS";
664 -else
665 -    # Can't have ADS support without LDAP
666 +  if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" = x"yes"; then
667 +    AC_DEFINE(HAVE_KRB5,1,[Whether to have KRB5 support])
668 +    AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
669 +    AC_MSG_CHECKING(whether Active Directory and krb5 support is used)
670 +    AC_MSG_RESULT(yes)
671 +  else
672      if test x"$with_ads_support" = x"yes"; then
673 -       AC_MSG_ERROR(Active directory support requires LDAP)
674 +       AC_MSG_ERROR(libkrb5 is needed for Active Directory support)
675 +    else
676 +       AC_MSG_WARN(libkrb5 is needed for Active Directory support)
677      fi
678 -fi
679 -
680 -if test x"$with_ads_support" = x"yes"; then
681 -       ADSLIBS="$LDAP_LIBS $KRB5_LIBS"
682 +    KRB5_LIBS=""
683 +    with_ads_support=no 
684 +  fi
685 +  LIBS="$ac_save_LIBS"
686  fi
687  
688  ########################################################