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