* aclocal.m4 (KRB5_AC_INET6): Drop enable/disable-ipv6 option; emit a warning for...
[krb5.git] / src / aclocal.m4
1 AC_PREREQ(2.52)
2 AC_COPYRIGHT([Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 Massachusetts Institute of Technology.
4 ])
5 dnl
6 dnl Figure out the top of the source and build trees.  We depend on localdir
7 dnl being a relative pathname; we could make it general later, but for now 
8 dnl this is good enough.
9 dnl
10 dnl esyscmd([test -r aclocal.m4 && echo YES])
11 define([fileexists],[dnl
12 pushdef([x],esyscmd([if test -r $1; then echo YES;else echo NO; fi]))dnl
13 dnl Strip out newline.
14 ifelse(x,[YES
15 ],[YES],x,[NO
16 ],[NO],UNKNOWN)[]popdef([x])])
17 define([K5_TOPDIR],dnl
18 ifelse(fileexists(./aclocal.m4),YES,[.],[dnl
19 ifelse(fileexists(../aclocal.m4),YES,[..],[dnl
20 ifelse(fileexists(../../aclocal.m4),YES,[../..],[dnl
21 ifelse(fileexists(../../../aclocal.m4),YES,[../../..],[dnl
22 ifelse(fileexists(../../../../aclocal.m4),YES,[../../../..],[dnl
23 errprint(__file__:__line__: Cannot find path to aclocal.m4[
24 ]) m4exit(1) dnl sometimes that does not work?
25 builtin(m4exit,1)UNKNOWN])])])])]))
26 dnl
27 AC_DEFUN(V5_SET_TOPDIR,[dnl
28 ac_reltopdir="K5_TOPDIR"
29 if test ! -r "$srcdir/K5_TOPDIR/aclocal.m4"; then
30   AC_MSG_ERROR([Configure could not determine the relative topdir])
31 fi
32 ac_topdir=$srcdir/$ac_reltopdir
33 ac_config_fragdir=$ac_reltopdir/config
34 krb5_pre_in=$ac_config_fragdir/pre.in
35 krb5_post_in=$ac_config_fragdir/post.in
36 # echo "Looking for $srcdir/$ac_config_fragdir"
37 if test -d "$srcdir/$ac_config_fragdir"; then
38   AC_CONFIG_AUX_DIR(K5_TOPDIR/config)
39 else
40   AC_MSG_ERROR([can not find config/ directory in $ac_reltopdir])
41 fi
42 ])dnl
43 dnl
44 dnl Version info.
45 dnl
46 pushdef([x],esyscmd([sed -n 's/#define \([A-Z0-9_]*\)[ \t]*\(.*\)/\1=\2/p' < ]K5_TOPDIR/patchlevel.h))
47 define([PL_KRB5_MAJOR_RELEASE],regexp(x,[KRB5_MAJOR_RELEASE=\(.*\)],[\1]))
48 ifelse(PL_KRB5_MAJOR_RELEASE,,[errprint([Can't determine KRB5_MAJOR_RELEASE value from patchlevel.h.
49 ]) m4exit(1) dnl sometimes that does not work?
50 builtin(m4exit,1)])
51 define([PL_KRB5_MINOR_RELEASE],regexp(x,[KRB5_MINOR_RELEASE=\(.*\)],[\1]))
52 ifelse(PL_KRB5_MINOR_RELEASE,,[errprint([Can't determine KRB5_MINOR_RELEASE value from patchlevel.h.
53 ]) m4exit(1) dnl sometimes that does not work?
54 builtin(m4exit,1)])
55 define([PL_KRB5_PATCHLEVEL],regexp(x,[KRB5_PATCHLEVEL=\(.*\)],[\1]))
56 ifelse(PL_KRB5_PATCHLEVEL,,[errprint([Can't determine KRB5_PATCHLEVEL value from patchlevel.h.
57 ]) m4exit(1) dnl sometimes that does not work?
58 builtin(m4exit,1)])
59 define([PL_KRB5_RELTAIL],regexp(x,[KRB5_RELTAIL="\(.*\)"],[\1]))
60 dnl RELTAIL is allowed to not be defined.
61 popdef([x])
62 define([K5_VERSION],PL_KRB5_MAJOR_RELEASE.PL_KRB5_MINOR_RELEASE[]ifelse(PL_KRB5_PATCHLEVEL,0,,.PL_KRB5_PATCHLEVEL)ifelse(PL_KRB5_RELTAIL,,,-PL_KRB5_RELTAIL))
63 define([K5_BUGADDR],krb5-bugs@mit.edu)
64 define([K5_AC_INIT],[AC_INIT(Kerberos 5, K5_VERSION, K5_BUGADDR, krb5)
65 AC_CONFIG_SRCDIR($1)])
66 dnl
67 dnl drop in standard rules for all configure files -- CONFIG_RULES
68 dnl
69 AC_DEFUN(CONFIG_RULES,[dnl
70 AC_REQUIRE([V5_SET_TOPDIR]) dnl
71 EXTRA_FILES=""
72 AC_SUBST(EXTRA_FILES)
73 WITH_CC dnl
74 AC_REQUIRE_CPP
75 if test -z "$LD" ; then LD=$CC; fi
76 AC_ARG_VAR(LD,[linker command [CC]])
77 AC_SUBST(LDFLAGS) dnl
78 WITH_KRB4 dnl
79 KRB5_AC_CHOOSE_ET dnl
80 KRB5_AC_CHOOSE_SS dnl
81 KRB5_AC_CHOOSE_DB dnl
82 dnl allow stuff in tree to access deprecated/private stuff for now
83 AC_DEFINE([KRB5_PRIVATE], 1, [Define only if building in-tree])
84 AC_DEFINE([KRB5_DEPRECATED], 1, [Define only if building in-tree])
85 AC_C_CONST dnl
86 WITH_NETLIB dnl
87 WITH_HESIOD dnl
88 KRB5_AC_MAINTAINER_MODE dnl
89 AC_ARG_PROGRAM dnl
90 dnl
91 dnl This identifies the top of the source tree relative to the directory 
92 dnl in which the configure file lives.
93 dnl
94 CONFIG_RELTOPDIR=$ac_reltopdir
95 AC_SUBST(CONFIG_RELTOPDIR)
96 AC_SUBST(subdirs)
97 lib_frag=$srcdir/$ac_config_fragdir/lib.in
98 AC_SUBST_FILE(lib_frag)
99 libobj_frag=$srcdir/$ac_config_fragdir/libobj.in
100 AC_SUBST_FILE(libobj_frag)
101 libnover_frag=$srcdir/$ac_config_fragdir/libnover.in
102 AC_SUBST_FILE(libnover_frag)
103 dnl
104 KRB5_AC_PRAGMA_WEAK_REF
105 KRB5_LIB_PARAMS
106 KRB5_AC_INITFINI
107 KRB5_AC_ENABLE_THREADS
108 KRB5_AC_FIND_DLOPEN
109 ])dnl
110
111 dnl Maintainer mode, akin to what automake provides, 'cept we don't
112 dnl want to use automake right now.
113 AC_DEFUN([KRB5_AC_MAINTAINER_MODE],
114 [AC_ARG_ENABLE([maintainer-mode],
115 AC_HELP_STRING([--enable-maintainer-mode],[enable rebuilding of source files, Makefiles, etc]),
116 USE_MAINTAINER_MODE=$enableval,
117 USE_MAINTAINER_MODE=no)
118 if test "$USE_MAINTAINER_MODE" = yes; then
119   MAINTAINER_MODE_TRUE=
120   MAINTAINER_MODE_FALSE='#'
121   AC_MSG_NOTICE(enabling maintainer mode)
122 else
123   MAINTAINER_MODE_TRUE='#'
124   MAINTAINER_MODE_FALSE=
125 fi
126 MAINT=$MAINTAINER_MODE_TRUE
127 AC_SUBST(MAINTAINER_MODE_TRUE)
128 AC_SUBST(MAINTAINER_MODE_FALSE)
129 AC_SUBST(MAINT)
130 ])
131
132 dnl
133 AC_DEFUN([KRB5_AC_INITFINI],[
134 dnl Do we want initialization at load time?
135 AC_ARG_ENABLE([delayed-initialization],
136 AC_HELP_STRING([--disable-delayed-initialization],initialize library code when loaded @<:@delay until first use@:>@), , enable_delayed_initialization=yes)
137 case "$enable_delayed_initialization" in
138   yes)
139     AC_DEFINE(DELAY_INITIALIZER,1,[Define if library initialization should be delayed until first use]) ;;
140   no) ;;
141   *)  AC_MSG_ERROR(invalid option $enable_delayed_initialization for delayed-initialization) ;;
142 esac
143 dnl We always want finalization at unload time.
144 dnl
145 dnl Can we do things through gcc?
146 KRB5_AC_GCC_ATTRS
147 dnl How about with the linker?
148 if test -z "$use_linker_init_option" ; then
149   AC_MSG_ERROR(ran INITFINI before checking shlib.conf?)
150 fi
151 if test "$use_linker_init_option" = yes; then
152   AC_DEFINE(USE_LINKER_INIT_OPTION,1,[Define if link-time options for library initialization will be used])
153 fi
154 if test "$use_linker_fini_option" = yes; then
155   AC_DEFINE(USE_LINKER_FINI_OPTION,1,[Define if link-time options for library finalization will be used])
156 fi
157 ])
158
159 dnl find dlopen
160 AC_DEFUN([KRB5_AC_FIND_DLOPEN],[
161 AC_CHECK_LIB(dl, dlopen, DL_LIB=-ldl)
162 AC_CHECK_LIB(ld, main, DL_LIB=-lld)
163 AC_SUBST(DL_LIB)
164 ])
165
166
167 dnl Hack for now.
168 AC_DEFUN([KRB5_AC_ENABLE_THREADS],[
169 AC_ARG_ENABLE([thread-support],
170 AC_HELP_STRING([--disable-thread-support],don't enable thread support @<:@enabled@:>@), , enable_thread_support=yes)
171 if test "$enable_thread_support" = yes ; then
172   AC_MSG_NOTICE(enabling thread support)
173   AC_DEFINE(ENABLE_THREADS,1,[Define if thread support enabled])
174 fi
175 dnl Maybe this should be inside the conditional above?  Doesn't cache....
176 if test "$enable_thread_support" = yes; then
177   ACX_PTHREAD(,[AC_MSG_ERROR([cannot determine options for enabling thread support; try --disable-thread-support])])
178   AC_MSG_NOTICE(PTHREAD_CC = $PTHREAD_CC)
179   AC_MSG_NOTICE(PTHREAD_CFLAGS = $PTHREAD_CFLAGS)
180   AC_MSG_NOTICE(PTHREAD_LIBS = $PTHREAD_LIBS)
181   dnl Not really needed -- if pthread.h isn't found, ACX_PTHREAD will fail.
182   dnl AC_CHECK_HEADERS(pthread.h)
183   # AIX and Tru64 don't support weak references, and don't have
184   # stub versions of the pthread code in libc.
185   case "${host_os}" in
186     aix* | osf*)
187       # On these platforms, we'll always pull in the thread support.
188       LIBS="$LIBS $PTHREAD_LIBS"
189       CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
190       # We don't need to sometimes add the flags we've just folded in...
191       PTHREAD_LIBS=
192       PTHREAD_CFLAGS=
193       ;;
194     hpux*)
195       # These are the flags that "gcc -pthread" adds.  But we don't
196       # want "-pthread" because that has link-time effects, and we
197       # don't exclude CFLAGS when linking.  *sigh*
198       PTHREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_C_SOURCE=199506L"
199       ;;
200     solaris*)
201       # On Solaris 10 with gcc 3.4.3, the autoconf archive macro doesn't
202       # get the right result.
203       if test "$GCC" = yes ; then
204         PTHREAD_CFLAGS="-D_REENTRANT -pthreads"
205       fi
206       ;;
207   esac
208   THREAD_SUPPORT=1
209 else
210   PTHREAD_CC="$CC"
211   PTHREAD_CFLAGS=""
212   PTHREAD_LIBS=""
213   THREAD_SUPPORT=0
214 fi
215 AC_SUBST(THREAD_SUPPORT)
216 dnl We want to know where these routines live, so on systems with weak
217 dnl reference support we can figure out whether or not the pthread library
218 dnl has been linked in.
219 dnl If we don't add any libraries for thread support, don't bother.
220 AC_CHECK_FUNCS(pthread_once pthread_mutexattr_setrobust_np pthread_rwlock_init)
221 old_CC="$CC"
222 test "$PTHREAD_CC" != "" && test "$ac_cv_c_compiler_gnu" = no && CC=$PTHREAD_CC
223 old_CFLAGS="$CFLAGS"
224 # On Solaris, -pthreads is added to CFLAGS, no extra explicit libraries.
225 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
226 AC_SUBST(PTHREAD_CFLAGS)
227 old_LIBS="$LIBS"
228 LIBS="$PTHREAD_LIBS $LIBS"
229 AC_MSG_NOTICE(rechecking with PTHREAD_... options)
230 AC_CHECK_LIB(c, pthread_mutexattr_setrobust_np,
231   [AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP_IN_THREAD_LIB,1,[Define if pthread_mutexattr_setrobust_np is provided in the thread library.])])
232 AC_CHECK_LIB(c, pthread_rwlock_init,
233   [AC_DEFINE(HAVE_PTHREAD_RWLOCK_INIT_IN_THREAD_LIB,1,[Define if pthread_rwlock_init is provided in the thread library.])])
234 LIBS="$old_LIBS"
235 CC="$old_CC"
236 CFLAGS="$old_CFLAGS"
237 ])
238
239 dnl This is somewhat gross and should go away when the build system
240 dnl is revamped. -- tlyu
241 dnl DECLARE_SYS_ERRLIST - check for sys_errlist in libc
242 dnl
243 AC_DEFUN([DECLARE_SYS_ERRLIST],
244 [AC_CACHE_CHECK([for sys_errlist declaration], krb5_cv_decl_sys_errlist,
245 [AC_TRY_COMPILE([#include <stdio.h>
246 #include <errno.h>], [1+sys_nerr;],
247 krb5_cv_decl_sys_errlist=yes, krb5_cv_decl_sys_errlist=no)])
248 # assume sys_nerr won't be declared w/o being in libc
249 if test $krb5_cv_decl_sys_errlist = yes; then
250   AC_DEFINE(SYS_ERRLIST_DECLARED,1,[Define if sys_errlist is defined in errno.h])
251   AC_DEFINE(HAVE_SYS_ERRLIST,1,[Define if sys_errlist in libc])
252 else
253   # This means that sys_errlist is not declared in errno.h, but may still
254   # be in libc.
255   AC_CACHE_CHECK([for sys_errlist in libc], krb5_cv_var_sys_errlist,
256   [AC_TRY_LINK([extern int sys_nerr;], [if (1+sys_nerr < 0) return 1;],
257   krb5_cv_var_sys_errlist=yes, krb5_cv_var_sys_errlist=no;)])
258   if test $krb5_cv_var_sys_errlist = yes; then
259     AC_DEFINE(HAVE_SYS_ERRLIST,1,[Define if sys_errlist in libc])
260     # Do this cruft for backwards compatibility for now.
261     AC_DEFINE(NEED_SYS_ERRLIST,1,[Define if need to declare sys_errlist])
262   else
263     AC_MSG_WARN([sys_errlist is neither in errno.h nor in libc])
264   fi
265 fi])
266
267 dnl
268 dnl check for sigmask/sigprocmask -- CHECK_SIGPROCMASK
269 dnl
270 AC_DEFUN(CHECK_SIGPROCMASK,[
271 AC_MSG_CHECKING([for use of sigprocmask])
272 AC_CACHE_VAL(krb5_cv_func_sigprocmask_use,
273 [AC_TRY_LINK([#include <signal.h>], [sigprocmask(SIG_SETMASK,0,0);],
274  krb5_cv_func_sigprocmask_use=yes,
275 AC_TRY_LINK([#include <signal.h>], [sigmask(1);], 
276  krb5_cv_func_sigprocmask_use=no, krb5_cv_func_sigprocmask_use=yes))])
277 AC_MSG_RESULT($krb5_cv_func_sigprocmask_use)
278 if test $krb5_cv_func_sigprocmask_use = yes; then
279  AC_DEFINE(USE_SIGPROCMASK)
280 fi
281 ])dnl
282 dnl
283 AC_DEFUN(AC_PROG_ARCHIVE, [AC_CHECK_PROG(ARCHIVE, ar, ar cqv, false)])dnl
284 AC_DEFUN(AC_PROG_ARCHIVE_ADD, [AC_CHECK_PROG(ARADD, ar, ar cruv, false)])dnl
285 dnl
286 dnl check for <dirent.h> -- CHECK_DIRENT
287 dnl (may need to be more complex later)
288 dnl
289 AC_DEFUN(CHECK_DIRENT,[
290 AC_CHECK_HEADER(dirent.h,AC_DEFINE(USE_DIRENT_H,1,[Define if you have dirent.h functionality]))])dnl
291 dnl
292 dnl check if union wait is defined, or if WAIT_USES_INT -- CHECK_WAIT_TYPE
293 dnl
294 AC_DEFUN(CHECK_WAIT_TYPE,[
295 AC_MSG_CHECKING([if argument to wait is int *])
296 AC_CACHE_VAL(krb5_cv_struct_wait,
297 dnl Test for prototype clash - if there is none - then assume int * works
298 [AC_TRY_COMPILE([#include <sys/types.h>
299 #include <sys/wait.h>
300 extern pid_t wait(int *);],[], krb5_cv_struct_wait=no,dnl
301 dnl Else fallback on old stuff
302 [AC_TRY_COMPILE(
303 [#include <sys/wait.h>], [union wait i;
304 #ifdef WEXITSTATUS
305   WEXITSTATUS (i);
306 #endif
307 ], 
308         krb5_cv_struct_wait=yes, krb5_cv_struct_wait=no)])])
309 AC_MSG_RESULT($krb5_cv_struct_wait)
310 if test $krb5_cv_struct_wait = no; then
311         AC_DEFINE(WAIT_USES_INT,1,[Define if wait takes int as a argument])
312 fi
313 ])dnl
314 dnl
315 dnl check for POSIX signal handling -- CHECK_SIGNALS
316 dnl
317 AC_DEFUN(CHECK_SIGNALS,[
318 AC_CHECK_FUNC(sigprocmask,
319 AC_MSG_CHECKING(for sigset_t and POSIX_SIGNALS)
320 AC_CACHE_VAL(krb5_cv_type_sigset_t,
321 [AC_TRY_COMPILE(
322 [#include <signal.h>],
323 [sigset_t x],
324 krb5_cv_type_sigset_t=yes, krb5_cv_type_sigset_t=no)])
325 AC_MSG_RESULT($krb5_cv_type_sigset_t)
326 if test $krb5_cv_type_sigset_t = yes; then
327   AC_DEFINE(POSIX_SIGNALS,1,[Define if POSIX signal handling is used])
328 fi
329 )])dnl
330 dnl
331 dnl check for signal type
332 dnl
333 dnl AC_RETSIGTYPE isn't quite right, but almost.
334 AC_DEFUN(KRB5_SIGTYPE,[
335 AC_MSG_CHECKING([POSIX signal handlers])
336 AC_CACHE_VAL(krb5_cv_has_posix_signals,
337 [AC_TRY_COMPILE(
338 [#include <sys/types.h>
339 #include <signal.h>
340 #ifdef signal
341 #undef signal
342 #endif
343 extern void (*signal ()) ();], [],
344 krb5_cv_has_posix_signals=yes, krb5_cv_has_posix_signals=no)])
345 AC_MSG_RESULT($krb5_cv_has_posix_signals)
346 if test $krb5_cv_has_posix_signals = yes; then
347    stype=void
348    AC_DEFINE(POSIX_SIGTYPE, 1, [Define if POSIX signal handlers are used])
349 else
350   if test $ac_cv_type_signal = void; then
351      stype=void
352   else
353      stype=int
354   fi
355 fi
356 AC_DEFINE_UNQUOTED(krb5_sigtype, $stype, [Define krb5_sigtype to type of signal handler])dnl
357 ])dnl
358 dnl
359 dnl check for POSIX setjmp/longjmp -- CHECK_SETJMP
360 dnl
361 AC_DEFUN(CHECK_SETJMP,[
362 AC_CHECK_FUNC(sigsetjmp,
363 AC_MSG_CHECKING(for sigjmp_buf)
364 AC_CACHE_VAL(krb5_cv_struct_sigjmp_buf,
365 [AC_TRY_COMPILE(
366 [#include <setjmp.h>],[sigjmp_buf x],
367 krb5_cv_struct_sigjmp_buf=yes,krb5_cv_struct_sigjmp_buf=no)])
368 AC_MSG_RESULT($krb5_cv_struct_sigjmp_buf)
369 if test $krb5_cv_struct_sigjmp_buf = yes; then
370   AC_DEFINE(POSIX_SETJMP)
371 fi
372 )])dnl
373 dnl
374 dnl Check for IPv6 compile-time support.
375 dnl
376 AC_DEFUN(KRB5_AC_INET6,[
377 AC_CHECK_HEADERS(sys/types.h sys/socket.h netinet/in.h netdb.h)
378 AC_CHECK_FUNCS(inet_ntop inet_pton getnameinfo)
379 dnl getaddrinfo test needs netdb.h, for proper compilation on alpha
380 dnl under OSF/1^H^H^H^H^HDigital^H^H^H^H^H^H^HTru64 UNIX, where it's
381 dnl a macro
382 AC_MSG_CHECKING(for getaddrinfo)
383 AC_CACHE_VAL(ac_cv_func_getaddrinfo,
384 [AC_TRY_LINK([#ifdef HAVE_NETDB_H
385 #include <netdb.h>
386 #endif],[
387 struct addrinfo *ai;
388 getaddrinfo("kerberos.mit.edu", "echo", 0, &ai);
389 ], ac_cv_func_getaddrinfo=yes, ac_cv_func_getaddrinfo=no)])
390 AC_MSG_RESULT($ac_cv_func_getaddrinfo)
391 if test $ac_cv_func_getaddrinfo = yes; then
392   AC_DEFINE(HAVE_GETADDRINFO,1,[Define if you have the getaddrinfo function])
393 fi
394 dnl
395 AC_REQUIRE([KRB5_SOCKADDR_SA_LEN])dnl
396 AC_ARG_ENABLE([ipv6], , AC_MSG_WARN(enable/disable-ipv6 option is deprecated))dnl
397 KRB5_AC_CHECK_INET6
398 ])dnl
399 dnl
400 AC_DEFUN(KRB5_AC_CHECK_TYPE_WITH_HEADERS,[
401 AC_MSG_CHECKING(for type $1)
402 changequote(<<,>>)dnl
403 varname=`echo $1 | sed 's,[ -],_,g'`
404 changequote([,])dnl
405 AC_CACHE_VAL(krb5_cv_$varname,[
406 AC_TRY_COMPILE([$2],[ $1 foo; ], eval krb5_cv_$varname=yes, eval krb5_cv_$varname=no)])
407 eval x="\$krb5_cv_$varname"
408 AC_MSG_RESULT($x)
409 if eval test "$x" = yes ; then
410   AC_DEFINE_UNQUOTED(HAVE_`echo $varname | tr [[[a-z]]] [[[A-Z]]]`)
411 fi])
412 dnl
413 dnl
414 AC_DEFUN(KRB5_AC_CHECK_SOCKADDR_STORAGE,[
415 KRB5_AC_CHECK_TYPE_WITH_HEADERS(struct sockaddr_storage, [
416 #ifdef HAVE_SYS_TYPES_H
417 #include <sys/types.h>
418 #endif
419 #include <sys/socket.h>
420 #include <netinet/in.h>
421 ])])dnl
422 dnl
423 dnl
424 AC_DEFUN(KRB5_AC_CHECK_INET6,[
425 AC_REQUIRE([KRB5_AC_CHECK_SOCKADDR_STORAGE])dnl
426 AC_MSG_CHECKING(for IPv6 compile-time support)
427 AC_CACHE_VAL(krb5_cv_inet6,[
428 if test "$ac_cv_func_inet_ntop" != "yes" ; then
429   krb5_cv_inet6=no
430 else
431 AC_TRY_COMPILE([
432 #ifdef HAVE_SYS_TYPES_H
433 #include <sys/types.h>
434 #endif
435 #include <sys/socket.h>
436 #include <netinet/in.h>
437 #include <netdb.h>
438 ],[
439   struct sockaddr_in6 in;
440   AF_INET6;
441   IN6_IS_ADDR_LINKLOCAL (&in.sin6_addr);
442 ],krb5_cv_inet6=yes,krb5_cv_inet6=no)])
443 fi
444 AC_MSG_RESULT($krb5_cv_inet6)
445 if test "$krb5_cv_inet6" = no && test "$ac_cv_func_inet_ntop" = yes; then
446 AC_MSG_CHECKING(for IPv6 compile-time support with -DINET6)
447 AC_CACHE_VAL(krb5_cv_inet6_with_dinet6,[
448 old_CC="$CC"
449 CC="$CC -DINET6"
450 AC_TRY_COMPILE([
451 #ifdef HAVE_SYS_TYPES_H
452 #include <sys/types.h>
453 #endif
454 #include <sys/socket.h>
455 #include <netinet/in.h>
456 #include <netdb.h>
457 ],[
458   struct sockaddr_in6 in;
459   AF_INET6;
460   IN6_IS_ADDR_LINKLOCAL (&in.sin6_addr);
461 ],krb5_cv_inet6_with_dinet6=yes,krb5_cv_inet6_with_dinet6=no)
462 CC="$old_CC"])
463 AC_MSG_RESULT($krb5_cv_inet6_with_dinet6)
464 fi
465 if test $krb5_cv_inet6 = yes || test "$krb5_cv_inet6_with_dinet6" = yes; then
466   if test "$krb5_cv_inet6_with_dinet6" = yes; then
467     AC_DEFINE(INET6,1,[May need to be defined to enable IPv6 support, for example on IRIX])
468   fi
469   AC_DEFINE(KRB5_USE_INET6,1,[Define if we should compile in IPv6 support (even if we can't use it at run time)])
470 fi
471 ])dnl
472 dnl
473 dnl Generic File existence tests
474 dnl 
475 dnl K5_AC_CHECK_FILE(FILE, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
476 dnl
477 AC_DEFUN(K5_AC_CHECK_FILE,
478 [AC_REQUIRE([AC_PROG_CC])dnl
479 dnl Do the transliteration at runtime so arg 1 can be a shell variable.
480 ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
481 AC_MSG_CHECKING([for $1])
482 AC_CACHE_VAL(ac_cv_file_$ac_safe,
483 [if test "$cross_compiling" = yes; then
484   errprint(__file__:__line__: warning: Cannot check for file existence when cross compiling
485 )dnl
486   AC_MSG_ERROR(Cannot check for file existence when cross compiling)
487 else
488   if test -r $1; then
489     eval "ac_cv_file_$ac_safe=yes"
490   else
491     eval "ac_cv_file_$ac_safe=no"
492   fi
493 fi])dnl
494 if eval "test \"`echo '$ac_cv_file_'$ac_safe`\" = yes"; then
495   AC_MSG_RESULT(yes)
496   ifelse([$2], , :, [$2])
497 else
498   AC_MSG_RESULT(no)
499 ifelse([$3], , , [$3
500 np])dnl
501 fi
502 ])
503 dnl
504 dnl K5_AC_CHECK_FILES(FILE... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
505 dnl
506 AC_DEFUN(K5_AC_CHECK_FILES,
507 [AC_REQUIRE([AC_PROG_CC])dnl
508 for ac_file in $1
509 do
510 K5_AC_CHECK_FILE($ac_file,
511 [changequote(, )dnl
512   ac_tr_file=HAVE`echo $ac_file | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
513 changequote([, ])dnl
514   AC_DEFINE_UNQUOTED($ac_tr_file) $2], $3)dnl
515 done
516 ])
517 dnl
518 dnl set $(KRB4) from --with-krb4=value -- WITH_KRB4
519 dnl
520 AC_DEFUN(WITH_KRB4,[
521 AC_ARG_WITH([krb4],
522 [  --without-krb4          don't include Kerberos V4 backwards compatibility
523   --with-krb4             use V4 libraries included with V5 (default)
524   --with-krb4=KRB4DIR     use preinstalled V4 libraries],
525 ,
526 withval=yes
527 )dnl
528 if test $withval = no; then
529         AC_MSG_NOTICE(no krb4 support)
530         KRB4_LIB=
531         KRB4_DEPLIB=
532         KRB4_INCLUDES=
533         KRB4_LIBPATH=
534         KRB_ERR_H_DEP=
535         krb5_cv_build_krb4_libs=no
536         krb5_cv_krb4_libdir=
537 else
538  AC_DEFINE([KRB5_KRB4_COMPAT], 1, [Define this if building with krb4 compat])
539  if test $withval = yes; then
540         AC_MSG_NOTICE(enabling built in krb4 support)
541         KRB4_DEPLIB='$(TOPLIBD)/libkrb4$(DEPLIBEXT)'
542         KRB4_LIB=-lkrb4
543         KRB4_INCLUDES='-I$(SRCTOP)/include/kerberosIV -I$(BUILDTOP)/include/kerberosIV'
544         KRB4_LIBPATH=
545         KRB_ERR_H_DEP='$(BUILDTOP)/include/kerberosIV/krb_err.h'
546         krb5_cv_build_krb4_libs=yes
547         krb5_cv_krb4_libdir=
548  else
549         AC_MSG_NOTICE(using preinstalled krb4 in $withval)
550         KRB4_LIB="-lkrb"
551 dnl     DEPKRB4_LIB="$withval/lib/libkrb.a"
552         KRB4_INCLUDES="-I$withval/include"
553         KRB4_LIBPATH="-L$withval/lib"
554         KRB_ERR_H_DEP=
555         krb5_cv_build_krb4_libs=no
556         krb5_cv_krb4_libdir="$withval/lib"
557  fi
558 fi
559 AC_SUBST(KRB4_INCLUDES)
560 AC_SUBST(KRB4_LIBPATH)
561 AC_SUBST(KRB4_LIB)
562 AC_SUBST(KRB4_DEPLIB)
563 AC_SUBST(KRB_ERR_H_DEP)
564 dnl We always compile the des425 library
565 DES425_DEPLIB='$(TOPLIBD)/libdes425$(DEPLIBEXT)'
566 DES425_LIB=-ldes425
567 AC_SUBST(DES425_DEPLIB)
568 AC_SUBST(DES425_LIB)
569 ])dnl
570 dnl
571 dnl
572 AC_DEFUN(KRB5_AC_CHECK_FOR_CFLAGS,[
573 AC_BEFORE([$0],[AC_PROG_CC])
574 krb5_ac_cflags_set=${CFLAGS+set}
575 ])
576 dnl
577 AC_DEFUN(WITH_CC,[dnl
578 AC_REQUIRE([KRB5_AC_CHECK_FOR_CFLAGS])dnl
579 AC_REQUIRE([AC_PROG_CC])dnl
580 krb5_cv_prog_gcc=$ac_cv_c_compiler_gnu
581 if test $ac_cv_c_compiler_gnu = yes ; then
582      HAVE_GCC=yes
583      else HAVE_GCC=
584 fi
585 AC_SUBST(HAVE_GCC)
586 AC_CACHE_CHECK([for GNU linker], krb5_cv_prog_gnu_ld,
587 [krb5_cv_prog_gnu_ld=no
588 if test "$GCC" = yes; then
589   if AC_TRY_COMMAND([$CC -Wl,-v 2>&1 dnl
590                         | grep "GNU ld" > /dev/null]); then
591     krb5_cv_prog_gnu_ld=yes
592   fi
593 fi])
594 # maybe add -Waggregate-return, or can we assume that actually works by now?
595 # -Wno-comment used to be used for SunOS system header <sys/stream.h>
596 # -Wno-long-long, if needed, for k5-platform.h without inttypes.h etc.
597 extra_gcc_warn_opts="-Wall -Wmissing-prototypes -Wcast-qual \
598  -Wcast-align -Wconversion -Wshadow"
599 if test "$GCC" = yes ; then
600   if test "x$krb5_ac_cflags_set" = xset ; then
601     AC_MSG_NOTICE(not adding extra gcc warning flags because CFLAGS was set)
602   else
603     AC_MSG_NOTICE(adding extra warning flags for gcc)
604     CFLAGS="$CFLAGS $extra_gcc_warn_opts"
605     if test "`uname -s`" = Darwin ; then
606       AC_MSG_NOTICE(skipping pedantic warnings on Darwin)
607     elif test "`uname -s`" = Linux ; then
608       AC_MSG_NOTICE(skipping pedantic warnings on Linux)
609     else
610       CFLAGS="$CFLAGS -pedantic"
611     fi
612   fi
613   if test "`uname -s`" = Darwin ; then
614     # Someday this should be a feature test.
615     # One current (Jaguar = OS 10.2) problem:
616     # Archive library with foo.o undef sym X and bar.o common sym X,
617     # if foo.o is pulled in at link time, bar.o may not be, causing
618     # the linker to complain.
619     # Dynamic library problems too?
620     case "$CC $CFLAGS" in
621     *-fcommon*) ;; # why someone would do this, I don't know
622     *-fno-common*) ;; # okay, they're already doing the right thing
623     *)
624       AC_MSG_NOTICE(disabling the use of common storage on Darwin)
625       CFLAGS="$CFLAGS -fno-common"
626       ;;
627     esac
628     case "$LD $LDFLAGS" in
629     *-Wl,-search_paths_first*) ;;
630     *) LDFLAGS="${LDFLAGS} -Wl,-search_paths_first" ;;
631     esac
632   fi
633 else
634   if test "`uname -s`" = AIX ; then
635     # Using AIX but not GCC, assume native compiler.
636     # The native compiler appears not to give a nonzero exit
637     # status for certain classes of errors, like missing arguments
638     # in function calls.  Let's try to fix that with -qhalt=e.
639     case "$CC $CFLAGS" in
640       *-qhalt=*) ;;
641       *)
642         CFLAGS="$CFLAGS -qhalt=e"
643         AC_MSG_NOTICE(adding -qhalt=e for better error reporting)
644         ;;
645     esac
646     # Also, the optimizer isn't turned on by default, which means
647     # the static inline functions get left in random object files,
648     # leading to references to pthread_mutex_lock from anything that
649     # includes k5-int.h whether it uses threads or not.
650     case "$CC $CFLAGS" in
651       *-O*) ;;
652       *)
653         CFLAGS="$CFLAGS -O"
654         AC_MSG_NOTICE(adding -O for inline thread-support function elimination)
655         ;;
656     esac
657   fi
658 fi
659 ])dnl
660 dnl
661 dnl
662 dnl check for yylineno -- HAVE_YYLINENO
663 dnl
664 AC_DEFUN(HAVE_YYLINENO,[dnl
665 AC_REQUIRE_CPP()AC_REQUIRE([AC_PROG_LEX])dnl
666 AC_MSG_CHECKING([for yylineno declaration])
667 AC_CACHE_VAL(krb5_cv_type_yylineno,
668 # some systems have yylineno, others don't...
669   echo '%%
670 %%' | ${LEX} -t > conftest.out
671   if egrep yylineno conftest.out >/dev/null 2>&1; then
672         krb5_cv_type_yylineno=yes
673   else
674         krb5_cv_type_yylineno=no
675   fi
676   rm -f conftest.out)
677   AC_MSG_RESULT($krb5_cv_type_yylineno)
678   if test $krb5_cv_type_yylineno = no; then
679         AC_DEFINE(NO_YYLINENO, 1, [Define if lex produes code with yylineno])
680   fi
681 ])dnl
682 dnl
683 dnl K5_GEN_MAKEFILE([dir, [frags]])
684 dnl
685 AC_DEFUN(K5_GEN_MAKEFILE,[dnl
686 ifelse($1, ,[_K5_GEN_MAKEFILE(.,$2)],[_K5_GEN_MAKEFILE($1,$2)])
687 ])
688 dnl
689 dnl _K5_GEN_MAKEFILE(dir, [frags])
690 dnl  dir must be present in this case
691 dnl  Note: Be careful in quoting. 
692 dnl        The ac_foreach generates the list of fragments to include
693 dnl        or "" if $2 is empty
694 AC_DEFUN(_K5_GEN_MAKEFILE,[dnl
695 AC_CONFIG_FILES([$1/Makefile:$krb5_pre_in:$1/Makefile.in:$krb5_post_in])
696 ])
697 dnl
698 dnl K5_GEN_FILE( <ac_output arguments> )
699 dnl
700 AC_DEFUN(K5_GEN_FILE,[AC_CONFIG_FILES($1)])dnl
701 dnl
702 dnl K5_AC_OUTPUT
703 dnl    Note: Adds the variables to config.status for individual 
704 dnl          Makefile generation from config.statsu
705 AC_DEFUN(K5_AC_OUTPUT,[dnl
706 AC_CONFIG_COMMANDS([krb5_config_prefix], [], dnl
707  [krb5_pre_in=$krb5_pre_in
708  ac_config_fragdir=$ac_config_fragdir
709  krb5_post_in=$krb5_post_in])
710 AC_OUTPUT])dnl
711 dnl
712 dnl V5_AC_OUTPUT_MAKEFILE
713 dnl
714 AC_DEFUN(V5_AC_OUTPUT_MAKEFILE,
715 [ifelse($1, , [_V5_AC_OUTPUT_MAKEFILE(.,$2)],[_V5_AC_OUTPUT_MAKEFILE($1,$2)])])
716 dnl
717 define(_V5_AC_OUTPUT_MAKEFILE,
718 [ifelse($2, , ,AC_CONFIG_FILES($2))
719 AC_FOREACH([DIR], [$1],dnl
720  [AC_CONFIG_FILES(DIR[/Makefile:$krb5_pre_in:]DIR[/Makefile.in:$krb5_post_in])])
721 K5_AC_OUTPUT])dnl
722 dnl
723 dnl
724 dnl KRB5_SOCKADDR_SA_LEN: define HAVE_SA_LEN if sockaddr contains the sa_len
725 dnl component
726 dnl
727 AC_DEFUN([KRB5_SOCKADDR_SA_LEN],[ dnl
728 AC_MSG_CHECKING(whether struct sockaddr contains sa_len)
729 AC_CACHE_VAL(krb5_cv_sockaddr_sa_len,
730 [AC_TRY_COMPILE([#include <sys/types.h>
731 #include <sys/socket.h>
732 ],
733 [struct sockaddr sa;
734 sa.sa_len;],
735 krb5_cv_sockaddr_sa_len=yes,krb5_cv_sockaddr_sa_len=no)])
736 AC_MSG_RESULT([$]krb5_cv_sockaddr_sa_len)
737 if test $krb5_cv_sockaddr_sa_len = yes; then
738    AC_DEFINE_UNQUOTED(HAVE_SA_LEN,1,[Define if struct sockaddr contains sa_len])
739    fi
740 ])
741 dnl
742 dnl
743 dnl CHECK_UTMP: check utmp structure and functions
744 dnl
745 AC_DEFUN(CHECK_UTMP,[
746 AC_MSG_CHECKING([ut_pid in struct utmp])
747 AC_CACHE_VAL(krb5_cv_struct_ut_pid,
748 [AC_TRY_COMPILE(
749 [#include <sys/types.h>
750 #include <utmp.h>],
751 [struct utmp ut; ut.ut_pid;],
752 krb5_cv_struct_ut_pid=yes, krb5_cv_struct_ut_pid=no)])
753 AC_MSG_RESULT($krb5_cv_struct_ut_pid)
754 if test $krb5_cv_struct_ut_pid = no; then
755   AC_DEFINE(NO_UT_PID)
756 fi
757 AC_MSG_CHECKING([ut_type in struct utmp])
758 AC_CACHE_VAL(krb5_cv_struct_ut_type,
759 [AC_TRY_COMPILE(
760 [#include <sys/types.h>
761 #include <utmp.h>],
762 [struct utmp ut; ut.ut_type;],
763 krb5_cv_struct_ut_type=yes, krb5_cv_struct_ut_type=no)])
764 AC_MSG_RESULT($krb5_cv_struct_ut_type)
765 if test $krb5_cv_struct_ut_type = no; then
766   AC_DEFINE(NO_UT_TYPE)
767 fi
768 AC_MSG_CHECKING([ut_host in struct utmp])
769 AC_CACHE_VAL(krb5_cv_struct_ut_host,
770 [AC_TRY_COMPILE(
771 [#include <sys/types.h>
772 #include <utmp.h>],
773 [struct utmp ut; ut.ut_host;],
774 krb5_cv_struct_ut_host=yes, krb5_cv_struct_ut_host=no)])
775 AC_MSG_RESULT($krb5_cv_struct_ut_host)
776 if test $krb5_cv_struct_ut_host = no; then
777   AC_DEFINE(NO_UT_HOST)
778 fi
779 AC_MSG_CHECKING([ut_exit in struct utmp])
780 AC_CACHE_VAL(krb5_cv_struct_ut_exit,
781 [AC_TRY_COMPILE(
782 [#include <sys/types.h>
783 #include <utmp.h>],
784 [struct utmp ut; ut.ut_exit;],
785 krb5_cv_struct_ut_exit=yes, krb5_cv_struct_ut_exit=no)])
786 AC_MSG_RESULT($krb5_cv_struct_ut_exit)
787 if test $krb5_cv_struct_ut_exit = no; then
788   AC_DEFINE(NO_UT_EXIT)
789 fi
790 AC_CHECK_FUNC(setutent,AC_DEFINE(HAVE_SETUTENT))
791 AC_CHECK_FUNC(setutxent,AC_DEFINE(HAVE_SETUTXENT))
792 AC_CHECK_FUNC(updwtmp,AC_DEFINE(HAVE_UPDWTMP))
793 AC_CHECK_FUNC(updwtmpx,AC_DEFINE(HAVE_UPDWTMPX))
794 ])dnl
795 dnl
796 dnl WITH_NETLIB
797 dnl 
798 dnl
799 AC_DEFUN(WITH_NETLIB,[
800 AC_ARG_WITH([netlib],
801 AC_HELP_STRING([--with-netlib=LIBS], use user defined resolver library),
802 [  if test "$withval" = yes -o "$withval" = no ; then
803         AC_MSG_RESULT("netlib will link with C library resolver only")
804   else
805         LIBS="$LIBS $withval"
806         AC_MSG_RESULT("netlib will use \'$withval\'")
807   fi
808 ],dnl
809 [AC_LIBRARY_NET]
810 )])dnl
811 dnl
812 dnl
813 AC_DEFUN(KRB5_AC_NEED_DAEMON, [
814 KRB5_NEED_PROTO([#ifdef HAVE_UNISTD_H
815 #include <unistd.h>
816 #endif],daemon,1)])dnl
817 dnl
818 dnl Check if stdarg or varargs is available *and compiles*; prefer stdarg.
819 dnl (This was sent to djm for incorporation into autoconf 3/12/1996.  KR)
820 dnl
821 AC_DEFUN(AC_HEADER_STDARG, [
822
823 AC_MSG_CHECKING([for stdarg.h])
824 AC_CACHE_VAL(ac_cv_header_stdarg_h,
825 [AC_TRY_COMPILE([#include <stdarg.h>], [
826   } /* ac_try_compile will have started a function body */
827   int aoeu (char *format, ...) {
828     va_list v;
829     int i;
830     va_start (v, format);
831     i = va_arg (v, int);
832     va_end (v);
833 ],ac_cv_header_stdarg_h=yes,ac_cv_header_stdarg_h=no)])dnl
834 AC_MSG_RESULT($ac_cv_header_stdarg_h)
835 if test $ac_cv_header_stdarg_h = yes; then
836   AC_DEFINE(HAVE_STDARG_H, 1, [Define if stdarg available and compiles])
837 else
838
839 AC_MSG_CHECKING([for varargs.h])
840 AC_CACHE_VAL(ac_cv_header_varargs_h,
841 [AC_TRY_COMPILE([#include <varargs.h>],[
842   } /* ac_try_compile will have started a function body */
843   int aoeu (va_alist) va_dcl {
844     va_list v;
845     int i;
846     va_start (v);
847     i = va_arg (v, int);
848     va_end (v);
849 ],ac_cv_header_varargs_h=yes,ac_cv_header_varargs_h=no)])dnl
850 AC_MSG_RESULT($ac_cv_header_varargs_h)
851 if test $ac_cv_header_varargs_h = yes; then
852   AC_DEFINE(HAVE_VARARGS_H, 1, [Define if varargs available and compiles])
853 else
854   AC_MSG_ERROR(Neither stdarg nor varargs compile?)
855 fi
856
857 fi dnl stdarg test failure
858
859 ])dnl
860
861 dnl
862 dnl KRB5_AC_NEED_LIBGEN --- check if libgen needs to be linked in for
863 dnl                             compile/step    
864 dnl
865 dnl
866 AC_DEFUN(KRB5_AC_NEED_LIBGEN,[
867 AC_REQUIRE([AC_PROG_CC])dnl
868 dnl
869 dnl regcomp is present but non-functional on Solaris 2.4
870 dnl
871 AC_MSG_CHECKING(for working regcomp)
872 AC_CACHE_VAL(ac_cv_func_regcomp,[
873 AC_TRY_RUN([
874 #include <sys/types.h>
875 #include <regex.h>
876 regex_t x; regmatch_t m;
877 int main() { return regcomp(&x,"pat.*",0) || regexec(&x,"pattern",1,&m,0); }
878 ], ac_cv_func_regcomp=yes, ac_cv_func_regcomp=no, AC_MSG_ERROR([Cannot test regcomp when cross compiling]))])
879 AC_MSG_RESULT($ac_cv_func_regcomp)
880 test $ac_cv_func_regcomp = yes && AC_DEFINE(HAVE_REGCOMP,1,[Define if regcomp exists and functions])
881 dnl
882 dnl Check for the compile and step functions - only if regcomp is not available
883 dnl
884 if test $ac_cv_func_regcomp = no; then
885  save_LIBS="$LIBS"
886  LIBS=-lgen
887 dnl this will fail if there's no compile/step in -lgen, or if there's
888 dnl no -lgen.  This is fine.
889  AC_CHECK_FUNCS(compile step)
890  LIBS="$save_LIBS"
891 dnl
892 dnl Set GEN_LIB if necessary 
893 dnl
894  AC_CHECK_LIB(gen, compile, GEN_LIB=-lgen, GEN_LIB=)
895  AC_SUBST(GEN_LIB)
896 fi
897 ])
898 dnl
899 dnl KRB5_AC_REGEX_FUNCS --- check for different regular expression 
900 dnl                             support functions
901 dnl
902 AC_DEFUN(KRB5_AC_REGEX_FUNCS,[
903 AC_CHECK_FUNCS(re_comp re_exec regexec)
904 AC_REQUIRE([KRB5_AC_NEED_LIBGEN])dnl
905 ])dnl
906 dnl
907 dnl AC_KRB5_TCL_FIND_CONFIG (uses tcl_dir)
908 dnl
909 AC_DEFUN(AC_KRB5_TCL_FIND_CONFIG,[
910 AC_REQUIRE([KRB5_LIB_AUX])dnl
911 AC_MSG_CHECKING(for tclConfig.sh)
912 if test -r "$tcl_dir/lib/tclConfig.sh" ; then
913   tcl_conf="$tcl_dir/lib/tclConfig.sh"
914 elif test -r "$tcl_dir/tclConfig.sh" ; then
915   tcl_conf="$tcl_dir/tclConfig.sh"
916 else
917   tcl_conf=
918   lib="$tcl_dir/lib"
919   changequote(<<,>>)dnl
920   for d in "$lib" "$lib"/tcl7.[0-9] "$lib"/tcl8.[0-9] ; do
921     if test -r "$d/tclConfig.sh" ; then
922       tcl_conf="$tcl_conf $d/tclConfig.sh"
923     fi
924   done
925   changequote([,])dnl
926 fi
927 if test -n "$tcl_conf" ; then
928   AC_MSG_RESULT($tcl_conf)
929 else
930   AC_MSG_RESULT(not found)
931 fi
932 tcl_ok_conf=
933 tcl_vers_maj=
934 tcl_vers_min=
935 old_CPPFLAGS=$CPPFLAGS
936 old_LIBS=$LIBS
937 old_LDFLAGS=$LDFLAGS
938 if test -n "$tcl_conf" ; then
939   for file in $tcl_conf ; do
940     TCL_MAJOR_VERSION=x ; TCL_MINOR_VERSION=x
941     AC_MSG_CHECKING(Tcl info in $file)
942     . $file
943     v=$TCL_MAJOR_VERSION.$TCL_MINOR_VERSION
944     if test -z "$tcl_vers_maj" \
945         || test "$tcl_vers_maj" -lt "$TCL_MAJOR_VERSION" \
946         || test "$tcl_vers_maj" = "$TCL_MAJOR_VERSION" -a "$tcl_vers_min" -lt "$TCL_MINOR_VERSION" ; then
947       for incdir in "$TCL_PREFIX/include/tcl$v" "$TCL_PREFIX/include" ; do
948         if test -r "$incdir/tcl.h" -o -r "$incdir/tcl/tcl.h" ; then
949           CPPFLAGS="$old_CPPFLAGS -I$incdir"
950           break
951         fi
952       done
953       LIBS="$old_LIBS `eval echo x $TCL_LIB_SPEC $TCL_LIBS | sed 's/^x//'`"
954       LDFLAGS="$old_LDFLAGS $TCL_LD_FLAGS"
955       AC_TRY_LINK( , [Tcl_CreateInterp ();],
956         tcl_ok_conf=$file
957         tcl_vers_maj=$TCL_MAJOR_VERSION
958         tcl_vers_min=$TCL_MINOR_VERSION
959         AC_MSG_RESULT($v - working),
960         AC_MSG_RESULT($v - compilation failed)
961       )
962     else
963       AC_MSG_RESULT(older version $v)
964     fi
965   done
966 fi
967 CPPFLAGS=$old_CPPFLAGS
968 LIBS=$old_LIBS
969 LDFLAGS=$old_LDFLAGS
970 tcl_header=no
971 tcl_lib=no
972 if test -n "$tcl_ok_conf" ; then
973   . $tcl_ok_conf
974   TCL_INCLUDES=
975   for incdir in "$TCL_PREFIX/include/tcl$v" "$TCL_PREFIX/include" ; do
976     if test -r "$incdir/tcl.h" -o -r "$incdir/tcl/tcl.h" ; then
977       if test "$incdir" != "/usr/include" ; then
978         TCL_INCLUDES=-I$incdir
979       fi
980       break
981     fi
982   done
983   # Need eval because the first-level expansion could reference
984   # variables like ${TCL_DBGX}.
985   eval TCL_LIBS='"'$TCL_LIB_SPEC $TCL_LIBS $TCL_DL_LIBS'"'
986   TCL_LIBPATH="-L$TCL_EXEC_PREFIX/lib"
987   TCL_RPATH=":$TCL_EXEC_PREFIX/lib"
988   if test "$DEPLIBEXT" != "$SHLIBEXT" && test -n "$RPATH_FLAG"; then
989     TCL_MAYBE_RPATH='$(RPATH_FLAG)'"$TCL_EXEC_PREFIX/lib$RPATH_TAIL"
990   else
991     TCL_MAYBE_RPATH=
992   fi
993   CPPFLAGS="$old_CPPFLAGS $TCL_INCLUDES"
994   AC_CHECK_HEADER(tcl.h,AC_DEFINE(HAVE_TCL_H,1,[Define if tcl.h is available]) tcl_header=yes)
995   if test $tcl_header=no; then
996      AC_CHECK_HEADER(tcl/tcl.h,AC_DEFINE(HAVE_TCL_TCL_H,1,[Define if tcl/tcl.h is available]) tcl_header=yes)
997   fi
998   CPPFLAGS="$old_CPPFLAGS"
999   tcl_lib=yes
1000 else
1001   # If we read a tclConfig.sh file, it probably set this.
1002   TCL_LIBS=
1003 fi  
1004 AC_SUBST(TCL_INCLUDES)
1005 AC_SUBST(TCL_LIBS)
1006 AC_SUBST(TCL_LIBPATH)
1007 AC_SUBST(TCL_RPATH)
1008 AC_SUBST(TCL_MAYBE_RPATH)
1009 ])dnl
1010 dnl
1011 dnl AC_KRB5_TCL_TRYOLD
1012 dnl attempt to use old search algorithm for locating tcl
1013 dnl
1014 AC_DEFUN(AC_KRB5_TCL_TRYOLD, [
1015 AC_REQUIRE([KRB5_AC_FIND_DLOPEN])
1016 AC_MSG_WARN([trying old tcl search code])
1017 if test "$with_tcl" != yes -a "$with_tcl" != no; then
1018         TCL_INCLUDES=-I$with_tcl/include
1019         TCL_LIBPATH=-L$with_tcl/lib
1020         TCL_RPATH=:$with_tcl/lib
1021 fi
1022 if test "$with_tcl" != no ; then
1023         krb5_save_CPPFLAGS="$CPPFLAGS"
1024         krb5_save_LDFLAGS="$LDFLAGS"
1025         CPPFLAGS="$CPPFLAGS $TCL_INCLUDES"
1026         LDFLAGS="$LDFLAGS $TCL_LIBPATH"
1027         tcl_header=no
1028         AC_CHECK_HEADER(tcl.h,AC_DEFINE(HAVE_TCL_H) tcl_header=yes)
1029         if test $tcl_header=no; then
1030            AC_CHECK_HEADER(tcl/tcl.h,AC_DEFINE(HAVE_TCL_TCL_H) tcl_header=yes)
1031         fi
1032
1033         if test $tcl_header = yes ; then
1034                 tcl_lib=no
1035
1036                 if test $tcl_lib = no; then
1037                         AC_CHECK_LIB(tcl8.0, Tcl_CreateCommand, 
1038                                 TCL_LIBS="$TCL_LIBS -ltcl8.0 -lm $DL_LIB" 
1039                                 tcl_lib=yes,,-lm $DL_LIB)
1040                 fi
1041                 if test $tcl_lib = no; then
1042                         AC_CHECK_LIB(tcl7.6, Tcl_CreateCommand, 
1043                                 TCL_LIBS="$TCL_LIBS -ltcl7.6 -lm $DL_LIB" 
1044                                 tcl_lib=yes,,-lm $DL_LIB)
1045                 fi
1046                 if test $tcl_lib = no; then
1047                         AC_CHECK_LIB(tcl7.5, Tcl_CreateCommand, 
1048                                 TCL_LIBS="$TCL_LIBS -ltcl7.5 -lm $DL_LIB"
1049                                 tcl_lib=yes,,-lm $DL_LIB)
1050
1051                 fi
1052                 if test $tcl_lib = no ; then
1053                         AC_CHECK_LIB(tcl, Tcl_CreateCommand, 
1054                                 TCL_LIBS="$TCL_LIBS -ltcl -lm $DL_LIB"
1055                                 tcl_lib=yes,,-lm $DL_LIB)
1056
1057                 fi
1058                 if test $tcl_lib = no ; then            
1059                         AC_MSG_WARN("tcl.h found but not library")
1060                 fi
1061         else
1062                 AC_MSG_WARN(Could not find Tcl which is needed for the kadm5 tests)
1063                 TCL_LIBS=
1064         fi
1065         CPPFLAGS="$krb5_save_CPPFLAGS"
1066         LDFLAGS="$krb5_save_LDFLAGS"
1067         AC_SUBST(TCL_INCLUDES)
1068         AC_SUBST(TCL_LIBS)
1069         AC_SUBST(TCL_LIBPATH)
1070         AC_SUBST(TCL_RPATH)
1071 else
1072         AC_MSG_RESULT("Not looking for Tcl library")
1073 fi
1074 ])dnl
1075 dnl
1076 dnl AC_KRB5_TCL - determine if the TCL library is present on system
1077 dnl
1078 AC_DEFUN(AC_KRB5_TCL,[
1079 TCL_INCLUDES=
1080 TCL_LIBPATH=
1081 TCL_RPATH=
1082 TCL_LIBS=
1083 TCL_WITH=
1084 tcl_dir=
1085 AC_ARG_WITH(tcl,
1086 [  --with-tcl=path         where Tcl resides], , with_tcl=try)
1087 if test "$with_tcl" = no ; then
1088   true
1089 elif test "$with_tcl" = yes -o "$with_tcl" = try ; then
1090   tcl_dir=/usr
1091   if test ! -r /usr/lib/tclConfig.sh; then
1092     cat >> conftest <<\EOF
1093 puts "tcl_dir=$tcl_library"
1094 EOF
1095     if tclsh conftest >conftest.out 2>/dev/null; then
1096       if grep tcl_dir= conftest.out >/dev/null 2>&1; then
1097         t=`sed s/tcl_dir=// conftest.out`
1098         tcl_dir=$t
1099       fi
1100     fi # tclsh ran script okay
1101   rm -f conftest conftest.out
1102   fi # no /usr/lib/tclConfig.sh
1103 else
1104   tcl_dir=$with_tcl
1105 fi
1106 if test "$with_tcl" != no ; then
1107   AC_KRB5_TCL_FIND_CONFIG
1108   if test $tcl_lib = no ; then
1109     if test "$with_tcl" != try ; then
1110       AC_KRB5_TCL_TRYOLD
1111     else
1112       AC_MSG_WARN(Could not find Tcl which is needed for some tests)
1113     fi
1114   fi
1115 fi
1116 # If "yes" or pathname, error out if not found.
1117 if test "$with_tcl" != no -a "$with_tcl" != try ; then
1118   if test "$tcl_header $tcl_lib" != "yes yes" ; then
1119     AC_MSG_ERROR(Could not find Tcl)
1120   fi
1121 fi
1122 ])dnl
1123
1124 dnl
1125 dnl WITH_HESIOD
1126 dnl
1127 AC_DEFUN(WITH_HESIOD,
1128 [AC_ARG_WITH(hesiod, AC_HELP_STRING(--with-hesiod[=path], compile with hesiod support @<:@omitted@:>@),
1129         hesiod=$with_hesiod, with_hesiod=no)
1130 if test "$with_hesiod" != "no"; then
1131         HESIOD_DEFS=-DHESIOD
1132         AC_CHECK_LIB(resolv, res_send, res_lib=-lresolv)
1133         if test "$hesiod" != "yes"; then
1134                 HESIOD_LIBS="-L${hesiod}/lib -lhesiod $res_lib"
1135         else
1136                 HESIOD_LIBS="-lhesiod $res_lib"
1137         fi
1138 else
1139         HESIOD_DEFS=
1140         HESIOD_LIBS=
1141 fi
1142 AC_SUBST(HESIOD_DEFS)
1143 AC_SUBST(HESIOD_LIBS)])
1144
1145
1146 dnl
1147 dnl KRB5_BUILD_LIBRARY
1148 dnl
1149 dnl Pull in the necessary stuff to create the libraries.
1150
1151 AC_DEFUN(KRB5_BUILD_LIBRARY,
1152 [KRB5_BUILD_LIBRARY_WITH_DEPS
1153 # null out SHLIB_EXPFLAGS because we lack any dependencies
1154 SHLIB_EXPFLAGS=])
1155
1156 dnl
1157 dnl KRB5_BUILD_LIBRARY_STATIC
1158 dnl
1159 dnl Force static library build.
1160
1161 AC_DEFUN(KRB5_AC_FORCE_STATIC,[dnl
1162 AC_BEFORE([$0],[KRB5_LIB_AUX])dnl
1163 krb5_force_static=yes])
1164 AC_DEFUN(KRB5_BUILD_LIBRARY_STATIC,
1165 dnl Use define rather than AC_DEFUN to avoid ordering problems.
1166 [AC_REQUIRE([KRB5_AC_FORCE_STATIC])dnl
1167 KRB5_BUILD_LIBRARY
1168 # If we're only building static libraries, they're for build-time use only,
1169 # so don't install.
1170 LIBINSTLIST=])
1171
1172 dnl
1173 dnl KRB5_BUILD_LIBRARY_WITH_DEPS
1174 dnl
1175 dnl Like KRB5_BUILD_LIBRARY, but adds in explicit dependencies in the
1176 dnl generated shared library.
1177
1178 AC_DEFUN(KRB5_BUILD_LIBRARY_WITH_DEPS,
1179 [AC_REQUIRE([KRB5_LIB_AUX])dnl
1180 AC_REQUIRE([AC_PROG_LN_S])dnl
1181 AC_REQUIRE([AC_PROG_RANLIB])dnl
1182 AC_REQUIRE([AC_PROG_ARCHIVE])dnl
1183 AC_REQUIRE([AC_PROG_ARCHIVE_ADD])dnl
1184 AC_REQUIRE([AC_PROG_INSTALL])dnl
1185 AC_CHECK_PROG(AR, ar, ar, false)
1186 AC_CHECK_PROG(PERL, perl, perl, false)
1187 if test "$ac_cv_prog_PERL" = "false"; then
1188   AC_MSG_ERROR(Perl is now required for Kerberos builds.)
1189 fi
1190 AC_SUBST(LIBLIST)
1191 AC_SUBST(LIBLINKS)
1192 AC_SUBST(MAKE_SHLIB_COMMAND)
1193 AC_SUBST(SHLIB_EXPFLAGS)
1194 AC_SUBST(SHLIB_EXPORT_FILE_DEP)
1195 AC_SUBST(INSTALL_SHLIB)
1196 AC_SUBST(STLIBEXT)
1197 AC_SUBST(SHLIBEXT)
1198 AC_SUBST(SHLIBVEXT)
1199 AC_SUBST(SHLIBSEXT)
1200 AC_SUBST(DEPLIBEXT)
1201 AC_SUBST(PFLIBEXT)
1202 AC_SUBST(LIBINSTLIST)
1203 AC_SUBST(DYNOBJEXT)
1204 AC_SUBST(MAKE_DYNOBJ_COMMAND)
1205 ])
1206
1207 dnl
1208 dnl KRB5_BUILD_LIBOBJS
1209 dnl
1210 dnl Pull in the necessary stuff to build library objects.
1211
1212 AC_DEFUN(KRB5_BUILD_LIBOBJS,
1213 [AC_REQUIRE([KRB5_LIB_AUX])dnl
1214 AC_SUBST(OBJLISTS)
1215 AC_SUBST(STOBJEXT)
1216 AC_SUBST(SHOBJEXT)
1217 AC_SUBST(PFOBJEXT)
1218 AC_SUBST(PICFLAGS)
1219 AC_SUBST(PROFFLAGS)])
1220
1221 dnl
1222 dnl KRB5_BUILD_PROGRAM
1223 dnl
1224 dnl Set variables to build a program.
1225
1226 AC_DEFUN(KRB5_BUILD_PROGRAM,
1227 [AC_REQUIRE([KRB5_LIB_AUX])dnl
1228 AC_REQUIRE([KRB5_AC_NEED_LIBGEN])dnl
1229 AC_SUBST(CC_LINK)
1230 AC_SUBST(RPATH_FLAG)
1231 AC_SUBST(DEPLIBEXT)])
1232
1233 dnl
1234 dnl KRB5_RUN_FLAGS
1235 dnl
1236 dnl Set up environment for running dynamic executables out of build tree
1237
1238 AC_DEFUN(KRB5_RUN_FLAGS,
1239 [AC_REQUIRE([KRB5_LIB_AUX])dnl
1240 KRB5_RUN_ENV="$RUN_ENV"
1241 AC_SUBST(KRB5_RUN_ENV)])
1242
1243 dnl
1244 dnl KRB5_LIB_AUX
1245 dnl
1246 dnl Parse configure options related to library building.
1247
1248 AC_DEFUN(KRB5_LIB_AUX,
1249 [AC_REQUIRE([KRB5_LIB_PARAMS])dnl
1250
1251 # Check whether to build static libraries.
1252 AC_ARG_ENABLE([static],
1253 AC_HELP_STRING([--enable-static],[build static libraries @<:@disabled for most platforms@:>@])
1254 AC_HELP_STRING([--disable-static],[don't build static libraries]), ,
1255 [enable_static=$default_static])
1256
1257 if test "$enable_static" = no && test "$krb5_force_static" != yes; then
1258         AC_MSG_NOTICE([disabling static libraries])
1259         LIBLINKS=
1260         LIBLIST=
1261         OBJLISTS=
1262 else
1263         LIBLIST='lib$(LIBBASE)$(STLIBEXT)'
1264         LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(STLIBEXT)'
1265         OBJLISTS=OBJS.ST
1266         LIBINSTLIST=install-static
1267         DEPLIBEXT=$STLIBEXT
1268 #       CFLAGS="$CFLAGS -D_KDB5_STATIC_LINK"
1269 fi
1270
1271 # Check whether to build shared libraries.
1272 AC_ARG_ENABLE([shared],
1273 AC_HELP_STRING([--enable-shared],[build shared libraries @<:@enabled for most platforms@:>@])
1274 AC_HELP_STRING([--disable-shared],[don't build shared libraries]), ,
1275 [enable_shared=$default_shared])
1276
1277 if test "$enable_shared" = yes; then
1278         case "$SHLIBEXT" in
1279         .so-nobuild)
1280                 AC_MSG_WARN([shared libraries not supported on this architecture])
1281                 RUN_ENV=
1282                 CC_LINK="$CC_LINK_STATIC"
1283                 ;;
1284         *)
1285                 # set this now because some logic below may reset SHLIBEXT
1286                 DEPLIBEXT=$SHLIBEXT
1287                 if test "$krb5_force_static" = "yes"; then
1288                         AC_MSG_RESULT([Forcing static libraries.])
1289                         # avoid duplicate rules generation for AIX and such
1290                         SHLIBEXT=.so-nobuild
1291                         SHLIBVEXT=.so.v-nobuild
1292                         SHLIBSEXT=.so.s-nobuild
1293                 else
1294                         AC_MSG_NOTICE([enabling shared libraries])
1295                         # Clear some stuff in case of AIX, etc.
1296                         if test "$STLIBEXT" = "$SHLIBEXT" ; then
1297                                 STLIBEXT=.a-nobuild
1298                                 LIBLIST=
1299                                 LIBLINKS=
1300                                 OBJLISTS=
1301                                 LIBINSTLIST=
1302                         fi
1303                         LIBLIST="$LIBLIST "'lib$(LIBBASE)$(SHLIBEXT)'
1304                         LIBLINKS="$LIBLINKS "'$(TOPLIBD)/lib$(LIBBASE)$(SHLIBEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBVEXT)'
1305                         case "$SHLIBSEXT" in
1306                         .so.s-nobuild)
1307                                 LIBINSTLIST="$LIBINSTLIST install-shared"
1308                                 ;;
1309                         *)
1310                                 LIBLIST="$LIBLIST "'lib$(LIBBASE)$(SHLIBSEXT)'
1311                                 LIBLINKS="$LIBLINKS "'$(TOPLIBD)/lib$(LIBBASE)$(SHLIBSEXT)'
1312                                 LIBINSTLIST="$LIBINSTLIST install-shlib-soname"
1313                                 ;;
1314                         esac
1315                         OBJLISTS="$OBJLISTS OBJS.SH"
1316                 fi
1317                 CC_LINK="$CC_LINK_SHARED"
1318                 ;;
1319         esac
1320 else
1321         RUN_ENV=
1322         CC_LINK="$CC_LINK_STATIC"
1323         SHLIBEXT=.so-nobuild
1324         SHLIBVEXT=.so.v-nobuild
1325         SHLIBSEXT=.so.s-nobuild
1326 fi
1327
1328 if test -z "$LIBLIST"; then
1329         AC_MSG_ERROR([must enable one of shared or static libraries])
1330 fi
1331
1332 # Check whether to build profiled libraries.
1333 AC_ARG_ENABLE([profiled],
1334 [  --enable-profiled       build profiled libraries @<:@disabled@:>@],
1335 [if test "$enableval" = yes; then
1336         case $PFLIBEXT in
1337         .po-nobuild)
1338                 AC_MSG_WARN([Profiled libraries not supported on this architecture.])
1339                 ;;
1340         *)
1341                 AC_MSG_NOTICE([enabling profiled libraries])
1342                 LIBLIST="$LIBLIST "'lib$(LIBBASE)$(PFLIBEXT)'
1343                 LIBLINKS="$LIBLINKS "'$(TOPLIBD)/lib$(LIBBASE)$(PFLIBEXT)'
1344                 OBJLISTS="$OBJLISTS OBJS.PF"
1345                 LIBINSTLIST="$LIBINSTLIST install-profiled"
1346                 ;;
1347         esac
1348 fi])])
1349
1350 dnl
1351 dnl KRB5_LIB_PARAMS
1352 dnl
1353 dnl Determine parameters related to libraries, e.g. various extensions.
1354
1355 AC_DEFUN(KRB5_LIB_PARAMS,
1356 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
1357 krb5_cv_host=$host
1358 AC_SUBST(krb5_cv_host)
1359 AC_REQUIRE([AC_PROG_CC])dnl
1360 AC_REQUIRE([V5_SET_TOPDIR])dnl
1361 . $ac_topdir/config/shlib.conf])
1362 dnl
1363 dnl The following was written by jhawk@mit.edu
1364 dnl
1365 dnl AC_LIBRARY_NET: Id: net.m4,v 1.4 1997/10/25 20:49:53 jhawk Exp 
1366 dnl
1367 dnl This test is for network applications that need socket() and
1368 dnl gethostbyname() -ish functions.  Under Solaris, those applications need to
1369 dnl link with "-lsocket -lnsl".  Under IRIX, they should *not* link with
1370 dnl "-lsocket" because libsocket.a breaks a number of things (for instance:
1371 dnl gethostbyname() under IRIX 5.2, and snoop sockets under most versions of
1372 dnl IRIX).
1373 dnl 
1374 dnl Unfortunately, many application developers are not aware of this, and
1375 dnl mistakenly write tests that cause -lsocket to be used under IRIX.  It is
1376 dnl also easy to write tests that cause -lnsl to be used under operating
1377 dnl systems where neither are necessary (or useful), such as SunOS 4.1.4, which
1378 dnl uses -lnsl for TLI.
1379 dnl 
1380 dnl This test exists so that every application developer does not test this in
1381 dnl a different, and subtly broken fashion.
1382 dnl 
1383 dnl It has been argued that this test should be broken up into two seperate
1384 dnl tests, one for the resolver libraries, and one for the libraries necessary
1385 dnl for using Sockets API. Unfortunately, the two are carefully intertwined and
1386 dnl allowing the autoconf user to use them independantly potentially results in
1387 dnl unfortunate ordering dependancies -- as such, such component macros would
1388 dnl have to carefully use indirection and be aware if the other components were
1389 dnl executed. Since other autoconf macros do not go to this trouble, and almost
1390 dnl no applications use sockets without the resolver, this complexity has not
1391 dnl been implemented.
1392 dnl
1393 dnl The check for libresolv is in case you are attempting to link statically
1394 dnl and happen to have a libresolv.a lying around (and no libnsl.a).
1395 dnl
1396 AC_DEFUN(AC_LIBRARY_NET, [
1397    # Most operating systems have gethostbyname() in the default searched
1398    # libraries (i.e. libc):
1399    AC_CHECK_FUNC(gethostbyname, , [
1400      # Some OSes (eg. Solaris) place it in libnsl:
1401      AC_CHECK_LIB(nsl, gethostbyname, , [
1402        # Some strange OSes (SINIX) have it in libsocket:
1403        AC_CHECK_LIB(socket, gethostbyname, , [
1404           # Unfortunately libsocket sometimes depends on libnsl.
1405           # AC_CHECK_LIB's API is essentially broken so the following
1406           # ugliness is necessary:
1407           AC_CHECK_LIB(socket, gethostbyname,
1408              LIBS="-lsocket -lnsl $LIBS",
1409                [AC_CHECK_LIB(resolv, gethostbyname,
1410                              LIBS="-lresolv $LIBS" )],
1411              -lnsl)
1412        ])
1413      ])
1414    ])
1415   AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
1416     AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl)))
1417   KRB5_AC_ENABLE_DNS
1418   if test "$enable_dns" = yes ; then
1419     # We assume that if libresolv exists we can link against it.
1420     # This may get us a gethostby* that doesn't respect nsswitch.
1421     AC_CHECK_LIB(resolv, main)
1422
1423 _KRB5_AC_CHECK_RES_FUNCS(res_ninit res_nclose res_ndestroy res_nsearch dnl
1424 ns_initparse ns_name_uncompress dn_skipname res_search)
1425     if test $krb5_cv_func_res_nsearch = no \
1426       && test $krb5_cv_func_res_search = no; then
1427         # Attempt to link with res_search(), in case it's not prototyped.
1428         AC_CHECK_FUNC(res_search,
1429           [AC_DEFINE(HAVE_RES_SEARCH, 1,
1430             [Define to 1 if you have the `res_search' function])],
1431           [AC_ERROR([cannot find res_nsearch or res_search])])
1432     fi
1433   fi
1434 ])
1435 AC_DEFUN([_KRB5_AC_CHECK_RES_FUNCS],
1436 [AC_FOREACH([AC_Func], [$1],
1437   [AH_TEMPLATE(AS_TR_CPP(HAVE_[]AC_Func),
1438                [Define to 1 if you have the `]AC_Func[' function.])])dnl
1439 for krb5_func in $1; do
1440 _KRB5_AC_CHECK_RES_FUNC($krb5_func)
1441 done
1442 ])
1443 AC_DEFUN([_KRB5_AC_CHECK_RES_FUNC], [
1444 # Solaris 9 prototypes ns_name_uncompress() in arpa/nameser.h, but
1445 # doesn't export it from libresolv.so, so we use extreme paranoia here
1446 # and check both for the declaration and that we can link against the
1447 # function.
1448 AC_CACHE_CHECK([for $1], [krb5_cv_func_$1], [AC_TRY_LINK(
1449 [#include <sys/types.h>
1450 #include <netinet/in.h>
1451 #include <arpa/nameser.h>
1452 @%:@include <resolv.h>],
1453 [/*
1454  * Use volatile, or else optimization can cause false positives.
1455  */
1456 void (* volatile p)() = (void (*)())$1;],
1457                              [AS_VAR_SET(krb5_cv_func_$1, yes)],
1458                              [AS_VAR_SET(krb5_cv_func_$1, no)])])
1459 AS_IF([test AS_VAR_GET(krb5_cv_func_$1) = yes],
1460       [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]), 1,
1461                           [Define to 1 if you have the `$1' function])])[]dnl
1462 ])
1463 dnl
1464 dnl
1465 dnl KRB5_AC_ENABLE_DNS
1466 dnl
1467 AC_DEFUN(KRB5_AC_ENABLE_DNS, [
1468 enable_dns=yes
1469 enable_dns_for_kdc=yes
1470 AC_DEFINE(KRB5_DNS_LOOKUP_KDC,1,[Define to enable DNS lookups of Kerberos KDCs])
1471
1472   AC_ARG_ENABLE([dns-for-realm],
1473 [  --enable-dns-for-realm  enable DNS lookups of Kerberos realm names], ,
1474 [enable_dns_for_realm=no])
1475   if test "$enable_dns_for_realm" = yes; then
1476     AC_DEFINE(KRB5_DNS_LOOKUP_REALM,1,[Define to enable DNS lookups of Kerberos realm names])
1477   fi
1478
1479 AC_DEFINE(KRB5_DNS_LOOKUP, 1,[Define for DNS support of locating realms and KDCs])
1480
1481 ])
1482 dnl
1483 dnl
1484 dnl Check if we need the prototype for a function - we give it a bogus 
1485 dnl prototype and if it complains - then a valid prototype exists on the 
1486 dnl system.
1487 dnl
1488 dnl KRB5_NEED_PROTO(includes, function, [bypass])
1489 dnl if $3 set, don't see if library defined. 
1490 dnl Useful for case where we will define in libkrb5 the function if need be
1491 dnl but want to know if a prototype exists in either case on system.
1492 dnl
1493 AC_DEFUN([KRB5_NEED_PROTO], [
1494 ifelse([$3], ,[if test "x$ac_cv_func_$2" = xyes; then])
1495 AC_CACHE_CHECK([if $2 needs a prototype provided], krb5_cv_func_$2_noproto,
1496 AC_TRY_COMPILE([$1],
1497 [struct k5foo {int foo; } xx;
1498 extern int $2 (struct k5foo*);
1499 $2(&xx);
1500 ],
1501 krb5_cv_func_$2_noproto=yes,krb5_cv_func_$2_noproto=no))
1502 if test $krb5_cv_func_$2_noproto = yes; then
1503         AC_DEFINE([NEED_]translit($2, [a-z], [A-Z])[_PROTO], 1, dnl
1504 [define if the system header files are missing prototype for $2()])
1505 fi
1506 ifelse([$3], ,[fi])
1507 ])
1508 dnl
1509 dnl =============================================================
1510 dnl Internal function for testing for getpeername prototype
1511 dnl
1512 AC_DEFUN([KRB5_GETPEERNAME_ARGS],[
1513 AC_DEFINE([GETPEERNAME_ARG2_TYPE],GETSOCKNAME_ARG2_TYPE,[Type of getpeername second argument.])
1514 AC_DEFINE([GETPEERNAME_ARG3_TYPE],GETSOCKNAME_ARG3_TYPE,[Type of getpeername second argument.])
1515 ])
1516 dnl
1517 dnl =============================================================
1518 dnl Internal function for testing for getsockname arguments
1519 dnl
1520 AC_DEFUN([TRY_GETSOCK_INT],[
1521 krb5_lib_var=`echo "$1 $2" | sed 'y% ./+-*%___p_p%'`
1522 AC_MSG_CHECKING([if getsockname() takes arguments $1 and $2])
1523 AC_CACHE_VAL(krb5_cv_getsockname_proto_$krb5_lib_var,
1524 [
1525 AC_TRY_COMPILE([#include <sys/types.h>
1526 #include <sys/socket.h>
1527 extern int getsockname(int, $1, $2);
1528 ],,eval "krb5_cv_getsockname_proto_$krb5_lib_var=yes",
1529     eval "krb5_cv_getsockname_proto_$krb5_lib_var=no")])
1530 if eval "test \"`echo '$krb5_cv_getsockname_proto_'$krb5_lib_var`\" = yes"; then
1531         AC_MSG_RESULT(yes)
1532         sock_set=yes; res1="$1"; res2="$2"
1533 else
1534         AC_MSG_RESULT(no)
1535 fi
1536 ])
1537 dnl
1538 dnl Determines the types of the second and third arguments to getsockname().
1539 dnl
1540 AC_DEFUN([KRB5_GETSOCKNAME_ARGS],[
1541 sock_set=no
1542 for sock_arg1 in "struct sockaddr *" "void *"
1543 do
1544   for sock_arg2 in "size_t *" "int *" "socklen_t *"
1545   do
1546         if test $sock_set = no; then
1547           TRY_GETSOCK_INT($sock_arg1, $sock_arg2)
1548         fi
1549   done 
1550 done
1551 if test "$sock_set" = no; then
1552   AC_MSG_NOTICE(assuming struct sockaddr and socklen_t for getsockname args)
1553   res1="struct sockaddr *"
1554   res2="socklen_t *"
1555 fi
1556 res1=`echo "$res1" | tr -d '*' | sed -e 's/ *$//'`
1557 res2=`echo "$res2" | tr -d '*' | sed -e 's/ *$//'`
1558 AC_DEFINE_UNQUOTED([GETSOCKNAME_ARG2_TYPE],$res1,[Type of pointer target for argument 2 to getsockname])
1559 AC_DEFINE_UNQUOTED([GETSOCKNAME_ARG3_TYPE],$res2,[Type of pointer target for argument 3 to getsockname])
1560 ])
1561 dnl
1562 dnl
1563 AC_DEFUN([KRB5_AC_CHOOSE_ET],[
1564 AC_ARG_WITH([system-et],
1565 AC_HELP_STRING(--with-system-et,use system compile_et and -lcom_err @<:@default: build and install a local version@:>@))
1566 AC_MSG_CHECKING(which version of com_err to use)
1567 if test "x$with_system_et" = xyes ; then
1568   COM_ERR_VERSION=sys
1569   AC_MSG_RESULT(system)
1570 else
1571   COM_ERR_VERSION=k5
1572   AC_MSG_RESULT(krb5)
1573 fi
1574 if test $COM_ERR_VERSION = sys; then
1575   # check for various functions we need
1576   AC_CHECK_LIB(com_err, add_error_table, :, AC_MSG_ERROR(cannot find add_error_table in com_err library))
1577   AC_CHECK_LIB(com_err, remove_error_table, :, AC_MSG_ERROR(cannot find remove_error_table in com_err library))
1578   # make sure compile_et provides "et_foo" name
1579   cat >> conf$$e.et <<EOF
1580 error_table foo
1581 error_code ERR_FOO, "foo"
1582 end
1583 EOF
1584   AC_CHECK_PROGS(compile_et,compile_et,false)
1585   if test "$compile_et" = false; then
1586     AC_MSG_ERROR(cannot find compile_et)
1587   fi
1588   AC_CACHE_CHECK(whether compile_et is useful,krb5_cv_compile_et_useful,[
1589   if compile_et conf$$e.et >/dev/null 2>&1 ; then true ; else
1590     AC_MSG_ERROR(execution failed)
1591   fi
1592   AC_TRY_COMPILE([#include "conf$$e.h"
1593                  ],[ et_foo_error_table; ],:,
1594                  [AC_MSG_ERROR(cannot use et_foo_error_table)])
1595   # Anything else we need to test for?
1596   rm -f conf$$e.et conf$$e.c conf$$e.h
1597   krb5_cv_compile_et_useful=yes
1598   ])
1599 fi
1600 AC_SUBST(COM_ERR_VERSION)
1601 ])
1602 AC_DEFUN([KRB5_AC_CHOOSE_SS],[
1603 AC_ARG_WITH(system-ss,
1604             AC_HELP_STRING(--with-system-ss,use system -lss and mk_cmds @<:@private version@:>@))
1605 AC_ARG_VAR(SS_LIB,[system libraries for 'ss' package [-lss]])
1606 AC_MSG_CHECKING(which version of subsystem package to use)
1607 if test "x$with_system_ss" = xyes ; then
1608   SS_VERSION=sys
1609   AC_MSG_RESULT(system)
1610   # todo: check for various libraries we might need
1611   # in the meantime...
1612   test "x${SS_LIB+set}" = xset || SS_LIB=-lss
1613   old_LIBS="$LIBS"
1614   LIBS="$LIBS $SS_LIB"
1615   AC_CACHE_CHECK(whether system ss package works, krb5_cv_system_ss_okay,[
1616   AC_TRY_RUN([
1617 #include <ss/ss.h>
1618 int main(int argc, char *argv[]) {
1619   if (argc == 42) {
1620     int i, err;
1621     i = ss_create_invocation("foo","foo","",0,&err);
1622     ss_listen(i);
1623   }
1624   return 0;
1625 }], krb5_cv_system_ss_okay=yes, AC_MSG_ERROR(cannot run test program),
1626   krb5_cv_system_ss_okay="assumed")])
1627   LIBS="$old_LIBS"
1628 else
1629   SS_VERSION=k5
1630   AC_MSG_RESULT(krb5)
1631 fi
1632 AC_SUBST(SS_LIB)
1633 AC_SUBST(SS_VERSION)
1634 ])
1635 dnl
1636 AC_DEFUN([KRB5_AC_CHOOSE_DB],[
1637 AC_ARG_WITH(system-db,
1638             AC_HELP_STRING(--with-system-db,use system Berkeley db @<:@private version@:>@))
1639 AC_ARG_VAR(DB_HEADER,[header file for system Berkeley db package [db.h]])
1640 AC_ARG_VAR(DB_LIB,[library for system Berkeley db package [-ldb]])
1641 if test "x$with_system_db" = xyes ; then
1642   DB_VERSION=sys
1643   # TODO: Do we have specific routines we should check for?
1644   # How about known, easily recognizable bugs?
1645   # We want to use bt_rseq in some cases, but no other version but
1646   # ours has it right now.
1647   #
1648   # Okay, check the variables.
1649   test "x${DB_HEADER+set}" = xset || DB_HEADER=db.h
1650   test "x${DB_LIB+set}" = xset || DB_LIB=-ldb
1651   #
1652   if test "x${DB_HEADER}" = xdb.h ; then
1653     DB_HEADER_VERSION=sys
1654   else
1655     DB_HEADER_VERSION=redirect
1656   fi
1657   KDB5_DB_LIB="$DB_LIB"
1658 else
1659   DB_VERSION=k5
1660   AC_DEFINE(HAVE_BT_RSEQ,1,[Define if bt_rseq is available, for recursive btree traversal.])
1661   DB_HEADER=db.h
1662   DB_HEADER_VERSION=k5
1663   # libdb gets sucked into libkdb
1664   KDB5_DB_LIB=
1665   # needed for a couple of things that need libdb for its own sake
1666   DB_LIB=-ldb
1667 fi
1668 AC_SUBST(DB_VERSION)
1669 AC_SUBST(DB_HEADER)
1670 AC_SUBST(DB_HEADER_VERSION)
1671 AC_SUBST(DB_LIB)
1672 AC_SUBST(KDB5_DB_LIB)
1673 ])
1674 dnl
1675 dnl KRB5_AC_PRIOCNTL_HACK
1676 dnl
1677 dnl
1678 AC_DEFUN([KRB5_AC_PRIOCNTL_HACK],
1679 [AC_REQUIRE([AC_PROG_AWK])dnl
1680 AC_REQUIRE([AC_LANG_COMPILER_REQUIRE])dnl
1681 AC_CACHE_CHECK([whether to use priocntl hack], [krb5_cv_priocntl_hack],
1682 [case $krb5_cv_host in
1683 *-*-solaris2.9*)
1684         if test "$cross_compiling" = yes; then
1685                 krb5_cv_priocntl_hack=yes
1686         else
1687                 # Solaris patch 117171-11 (sparc) or 117172-11 (x86)
1688                 # fixes the Solaris 9 bug where final pty output
1689                 # gets lost on close.
1690                 if showrev -p | $AWK 'BEGIN { e = 1 }
1691 /Patch: 11717[[12]]/ { x = index[]([$]2, "-");
1692 if (substr[]([$]2, x + 1, length([$]2) - x) >= 11)
1693 { e = 0 } else { e = 1 } }
1694 END { exit e; }'; then
1695                         krb5_cv_priocntl_hack=no
1696                 else
1697                         krb5_cv_priocntl_hack=yes
1698                 fi
1699         fi
1700         ;;
1701 *)
1702         krb5_cv_priocntl_hack=no
1703         ;;
1704 esac])
1705 if test "$krb5_cv_priocntl_hack" = yes; then
1706         PRIOCNTL_HACK=1
1707 else
1708         PRIOCNTL_HACK=0
1709 fi
1710 AC_SUBST(PRIOCNTL_HACK)])
1711 dnl
1712 dnl
1713 dnl KRB5_AC_GCC_ATTRS
1714 AC_DEFUN([KRB5_AC_GCC_ATTRS],
1715 [AC_CACHE_CHECK([for constructor/destructor attribute support],krb5_cv_attr_constructor_destructor,
1716 [rm -f conftest.1 conftest.2
1717 if test -r conftest.1 || test -r conftest.2 ; then
1718   AC_MSG_ERROR(write error in local file system?)
1719 fi
1720 true > conftest.1
1721 true > conftest.2
1722 if test -r conftest.1 && test -r conftest.2 ; then true ; else
1723   AC_MSG_ERROR(write error in local file system?)
1724 fi
1725 a=no
1726 b=no
1727 # blindly assume we have 'unlink'...
1728 AC_TRY_RUN([void foo1() __attribute__((constructor));
1729 void foo1() { unlink("conftest.1"); }
1730 void foo2() __attribute__((destructor));
1731 void foo2() { unlink("conftest.2"); }
1732 int main () { return 0; }],
1733 [test -r conftest.1 || a=yes
1734 test -r conftest.2 || b=yes], , AC_MSG_ERROR(Cannot test for constructor/destructor support when cross compiling))
1735 case $krb5_cv_host in
1736 *-*-aix4.*)
1737         # Under AIX 4.3.3, at least, shared library destructor functions
1738         # appear to get executed in reverse link order (right to left),
1739         # so that a library's destructor function may run after that of
1740         # libraries it depends on, and may still have to access in the
1741         # destructor.
1742         #
1743         # That counts as "not working", for me, but it's a much more
1744         # complicated test case to set up.
1745         b=no
1746         ;;
1747 esac
1748 krb5_cv_attr_constructor_destructor="$a,$b"
1749 ])
1750 # Okay, krb5_cv_... should be set now.
1751 case $krb5_cv_attr_constructor_destructor in
1752   yes,*)
1753     AC_DEFINE(CONSTRUCTOR_ATTR_WORKS,1,[Define if __attribute__((constructor)) works]) ;;
1754 esac
1755 case $krb5_cv_attr_constructor_destructor in
1756   *,yes)
1757     AC_DEFINE(DESTRUCTOR_ATTR_WORKS,1,[Define if __attribute__((destructor)) works]) ;;
1758 esac
1759 dnl End of attributes we care about right now.
1760 ])
1761 dnl
1762 dnl
1763 dnl KRB5_AC_PRAGMA_WEAK_REF
1764 AC_DEFUN([KRB5_AC_PRAGMA_WEAK_REF],
1765 [AC_CACHE_CHECK([whether pragma weak references are supported],
1766 krb5_cv_pragma_weak_ref,
1767 [AC_TRY_LINK([#pragma weak flurbl
1768 extern int flurbl(void);],[if (&flurbl != 0) return flurbl();],
1769 krb5_cv_pragma_weak_ref=yes,krb5_cv_pragma_weak_ref=no)])
1770 if test $krb5_cv_pragma_weak_ref = yes ; then
1771   AC_DEFINE(HAVE_PRAGMA_WEAK_REF,1,[Define if #pragma weak references work])
1772 fi])
1773 dnl
1774 dnl
1775 m4_include(config/ac-archive/acx_pthread.m4)
1776 #
1777 # KRB5_AC_LIBUTIL
1778 #
1779 # Check for libutil, for NetBSD, et al.; needed for openpty() and
1780 # logwtmp() on some platforms.
1781 #
1782 AC_DEFUN([KRB5_AC_LIBUTIL],
1783         [AC_CHECK_LIB(util, main,
1784                 [AC_DEFINE(HAVE_LIBUTIL)
1785   UTIL_LIB=-lutil])dnl
1786 AC_SUBST(UTIL_LIB)
1787 ])