"Fossies" - the Fresh Open Source Software Archive

Member "krb5-1.18/src/aclocal.m4" (12 Feb 2020, 54988 Bytes) of package /linux/misc/krb5-1.18.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "aclocal.m4": 1.17.1_vs_1.18.

    1 AC_PREREQ(2.63)
    2 AC_COPYRIGHT([Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
    3 Massachusetts Institute of Technology.
    4 ])
    5 dnl
    6 define([K5_TOPDIR],[.])dnl
    7 dnl
    8 AC_DEFUN(V5_SET_TOPDIR,[dnl
    9 ac_reltopdir="K5_TOPDIR"
   10 if test ! -r "$srcdir/K5_TOPDIR/aclocal.m4"; then
   11   AC_MSG_ERROR([Configure could not determine the relative topdir])
   12 fi
   13 ac_topdir=$srcdir/$ac_reltopdir
   14 ac_config_fragdir=$ac_reltopdir/config
   15 # echo "Looking for $srcdir/$ac_config_fragdir"
   16 if test -d "$srcdir/$ac_config_fragdir"; then
   17   AC_CONFIG_AUX_DIR(K5_TOPDIR/config)
   18 else
   19   AC_MSG_ERROR([can not find config/ directory in $ac_reltopdir])
   20 fi
   21 ])dnl
   22 dnl
   23 dnl Version info.
   24 dnl
   25 pushdef([x],esyscmd([sed -n 's/#define \([A-Z0-9_]*\)[ \t]*\(.*\)/\1=\2/p' < ]K5_TOPDIR/patchlevel.h))
   26 define([PL_KRB5_MAJOR_RELEASE],regexp(x,[KRB5_MAJOR_RELEASE=\(.*\)],[\1]))
   27 ifelse(PL_KRB5_MAJOR_RELEASE,,[errprint([Can't determine KRB5_MAJOR_RELEASE value from patchlevel.h.
   28 ]) m4exit(1) dnl sometimes that does not work?
   29 builtin(m4exit,1)])
   30 define([PL_KRB5_MINOR_RELEASE],regexp(x,[KRB5_MINOR_RELEASE=\(.*\)],[\1]))
   31 ifelse(PL_KRB5_MINOR_RELEASE,,[errprint([Can't determine KRB5_MINOR_RELEASE value from patchlevel.h.
   32 ]) m4exit(1) dnl sometimes that does not work?
   33 builtin(m4exit,1)])
   34 define([PL_KRB5_PATCHLEVEL],regexp(x,[KRB5_PATCHLEVEL=\(.*\)],[\1]))
   35 ifelse(PL_KRB5_PATCHLEVEL,,[errprint([Can't determine KRB5_PATCHLEVEL value from patchlevel.h.
   36 ]) m4exit(1) dnl sometimes that does not work?
   37 builtin(m4exit,1)])
   38 define([PL_KRB5_RELTAIL],regexp(x,[KRB5_RELTAIL="\(.*\)"],[\1]))
   39 dnl RELTAIL is allowed to not be defined.
   40 popdef([x])
   41 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))
   42 define([K5_BUGADDR],krb5-bugs@mit.edu)
   43 define([K5_AC_INIT],[AC_INIT(Kerberos 5, K5_VERSION, K5_BUGADDR, krb5)
   44 AC_CONFIG_SRCDIR($1)
   45 build_dynobj=no])
   46 dnl
   47 dnl drop in standard rules for all configure files -- CONFIG_RULES
   48 dnl
   49 AC_DEFUN(CONFIG_RULES,[dnl
   50 AC_REQUIRE([V5_SET_TOPDIR]) dnl
   51 EXTRA_FILES=""
   52 AC_SUBST(EXTRA_FILES)
   53 dnl Consider using AC_USE_SYSTEM_EXTENSIONS when we require autoconf
   54 dnl 2.59c or later, but be sure to test on Solaris first.
   55 AC_DEFINE([_GNU_SOURCE], 1, [Define to enable extensions in glibc])
   56 AC_DEFINE([__STDC_WANT_LIB_EXT1__], 1, [Define to enable C11 extensions])
   57 
   58 WITH_CC dnl
   59 AC_REQUIRE_CPP
   60 if test -z "$LD" ; then LD=$CC; fi
   61 AC_ARG_VAR(LD,[linker command [CC]])
   62 AC_SUBST(LDFLAGS) dnl
   63 KRB5_AC_CHOOSE_ET dnl
   64 KRB5_AC_CHOOSE_SS dnl
   65 KRB5_AC_CHOOSE_DB dnl
   66 dnl allow stuff in tree to access deprecated stuff for now
   67 dnl AC_DEFINE([KRB5_DEPRECATED], 1, [Define only if building in-tree])
   68 AC_C_CONST dnl
   69 WITH_NETLIB dnl
   70 WITH_HESIOD dnl
   71 KRB5_AC_MAINTAINER_MODE dnl
   72 AC_ARG_PROGRAM dnl
   73 dnl
   74 dnl This identifies the top of the source tree relative to the directory 
   75 dnl in which the configure file lives.
   76 dnl
   77 CONFIG_RELTOPDIR=$ac_reltopdir
   78 AC_SUBST(CONFIG_RELTOPDIR)
   79 lib_frag=$srcdir/$ac_config_fragdir/lib.in
   80 AC_SUBST_FILE(lib_frag)
   81 libobj_frag=$srcdir/$ac_config_fragdir/libobj.in
   82 AC_SUBST_FILE(libobj_frag)
   83 libnover_frag=$srcdir/$ac_config_fragdir/libnover.in
   84 AC_SUBST_FILE(libnover_frag)
   85 libpriv_frag=$srcdir/$ac_config_fragdir/libpriv.in
   86 AC_SUBST_FILE(libpriv_frag)
   87 libnodeps_frag=$srcdir/$ac_config_fragdir/libnodeps.in
   88 AC_SUBST_FILE(libnodeps_frag)
   89 dnl
   90 KRB5_AC_PRAGMA_WEAK_REF
   91 WITH_LDAP
   92 KRB5_LIB_PARAMS
   93 KRB5_AC_INITFINI
   94 KRB5_AC_ENABLE_THREADS
   95 KRB5_AC_FIND_DLOPEN
   96 ])dnl
   97 
   98 dnl Maintainer mode, akin to what automake provides, 'cept we don't
   99 dnl want to use automake right now.
  100 AC_DEFUN([KRB5_AC_MAINTAINER_MODE],
  101 [AC_ARG_ENABLE([maintainer-mode],
  102 AC_HELP_STRING([--enable-maintainer-mode],[enable rebuilding of source files, Makefiles, etc]),
  103 USE_MAINTAINER_MODE=$enableval,
  104 USE_MAINTAINER_MODE=no)
  105 if test "$USE_MAINTAINER_MODE" = yes; then
  106   MAINTAINER_MODE_TRUE=
  107   MAINTAINER_MODE_FALSE='#'
  108   AC_MSG_NOTICE(enabling maintainer mode)
  109 else
  110   MAINTAINER_MODE_TRUE='#'
  111   MAINTAINER_MODE_FALSE=
  112 fi
  113 MAINT=$MAINTAINER_MODE_TRUE
  114 AC_SUBST(MAINTAINER_MODE_TRUE)
  115 AC_SUBST(MAINTAINER_MODE_FALSE)
  116 AC_SUBST(MAINT)
  117 ])
  118 
  119 dnl
  120 AC_DEFUN([KRB5_AC_INITFINI],[
  121 dnl Do we want initialization at load time?
  122 AC_ARG_ENABLE([delayed-initialization],
  123 AC_HELP_STRING([--disable-delayed-initialization],initialize library code when loaded @<:@delay until first use@:>@), , enable_delayed_initialization=yes)
  124 case "$enable_delayed_initialization" in
  125   yes)
  126     AC_DEFINE(DELAY_INITIALIZER,1,[Define if library initialization should be delayed until first use]) ;;
  127   no) ;;
  128   *)  AC_MSG_ERROR(invalid option $enable_delayed_initialization for delayed-initialization) ;;
  129 esac
  130 dnl We always want finalization at unload time.
  131 dnl
  132 dnl Can we do things through gcc?
  133 KRB5_AC_GCC_ATTRS
  134 dnl How about with the linker?
  135 if test -z "$use_linker_init_option" ; then
  136   AC_MSG_ERROR(ran INITFINI before checking shlib.conf?)
  137 fi
  138 if test "$use_linker_init_option" = yes; then
  139   AC_DEFINE(USE_LINKER_INIT_OPTION,1,[Define if link-time options for library initialization will be used])
  140 fi
  141 if test "$use_linker_fini_option" = yes; then
  142   AC_DEFINE(USE_LINKER_FINI_OPTION,1,[Define if link-time options for library finalization will be used])
  143 fi
  144 ])
  145 
  146 dnl find dlopen
  147 AC_DEFUN([KRB5_AC_FIND_DLOPEN],[
  148 old_LIBS="$LIBS"
  149 DL_LIB=
  150 AC_SEARCH_LIBS(dlopen, dl, [
  151 if test "$ac_cv_search_dlopen" != "none required"; then
  152   DL_LIB=$ac_cv_search_dlopen
  153 fi
  154 LIBS="$old_LIBS"
  155 AC_DEFINE(USE_DLOPEN,1,[Define if dlopen should be used])])
  156 AC_SUBST(DL_LIB)
  157 ])
  158 
  159 
  160 dnl Hack for now.
  161 AC_DEFUN([KRB5_AC_ENABLE_THREADS],[
  162 AC_ARG_ENABLE([thread-support],
  163 AC_HELP_STRING([--disable-thread-support],don't enable thread support @<:@enabled@:>@), , enable_thread_support=yes)
  164 if test "$enable_thread_support" = yes ; then
  165   AC_MSG_NOTICE(enabling thread support)
  166   AC_DEFINE(ENABLE_THREADS,1,[Define if thread support enabled])
  167 fi
  168 dnl Maybe this should be inside the conditional above?  Doesn't cache....
  169 if test "$enable_thread_support" = yes; then
  170   AX_PTHREAD(,[AC_MSG_ERROR([cannot determine options for enabling thread support; try --disable-thread-support])])
  171   AC_MSG_NOTICE(PTHREAD_CC = $PTHREAD_CC)
  172   AC_MSG_NOTICE(PTHREAD_CFLAGS = $PTHREAD_CFLAGS)
  173   AC_MSG_NOTICE(PTHREAD_LIBS = $PTHREAD_LIBS)
  174   dnl Not really needed -- if pthread.h isn't found, ACX_PTHREAD will fail.
  175   dnl AC_CHECK_HEADERS(pthread.h)
  176   # AIX and Tru64 don't support weak references, and don't have
  177   # stub versions of the pthread code in libc.
  178   case "${host_os}" in
  179     aix* | osf*)
  180       # On these platforms, we'll always pull in the thread support.
  181       LIBS="$LIBS $PTHREAD_LIBS"
  182       CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  183       # We don't need to sometimes add the flags we've just folded in...
  184       PTHREAD_LIBS=
  185       PTHREAD_CFLAGS=
  186       ;;
  187     hpux*)
  188       # These are the flags that "gcc -pthread" adds.  But we don't
  189       # want "-pthread" because that has link-time effects, and we
  190       # don't exclude CFLAGS when linking.  *sigh*
  191       PTHREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_C_SOURCE=199506L"
  192       ;;
  193     solaris2.[[1-9]])
  194       # On Solaris 10 with gcc 3.4.3, the autoconf archive macro doesn't
  195       # get the right result.   XXX What about Solaris 9 and earlier?
  196       if test "$GCC" = yes ; then
  197         PTHREAD_CFLAGS="-D_REENTRANT -pthreads"
  198       fi
  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       # On Solaris 10, the thread support is always available in libc.
  207       AC_DEFINE(NO_WEAK_PTHREADS,1,[Define if references to pthread routines should be non-weak.])
  208       ;;
  209   esac
  210   THREAD_SUPPORT=1
  211 else
  212   PTHREAD_CC="$CC"
  213   PTHREAD_CFLAGS=""
  214   PTHREAD_LIBS=""
  215   THREAD_SUPPORT=0
  216 fi
  217 AC_SUBST(THREAD_SUPPORT)
  218 dnl We want to know where these routines live, so on systems with weak
  219 dnl reference support we can figure out whether or not the pthread library
  220 dnl has been linked in.
  221 dnl If we don't add any libraries for thread support, don't bother.
  222 AC_CHECK_FUNCS(pthread_once pthread_rwlock_init)
  223 old_CC="$CC"
  224 test "$PTHREAD_CC" != "" && test "$ac_cv_c_compiler_gnu" = no && CC=$PTHREAD_CC
  225 old_CFLAGS="$CFLAGS"
  226 # On Solaris, -pthreads is added to CFLAGS, no extra explicit libraries.
  227 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  228 AC_SUBST(PTHREAD_CFLAGS)
  229 old_LIBS="$LIBS"
  230 LIBS="$PTHREAD_LIBS $LIBS"
  231 AC_MSG_NOTICE(rechecking with PTHREAD_... options)
  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,1,[Define if sigprocmask should be used])
  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,1,[Define if setjmp indicates POSIX interface])
  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_MSG_CHECKING(for IPv6 compile-time support without -DINET6)
  397 AC_CACHE_VAL(krb5_cv_inet6,[
  398 if test "$ac_cv_func_inet_ntop" != "yes" ; then
  399   krb5_cv_inet6=no
  400 else
  401 AC_TRY_COMPILE([
  402 #ifdef HAVE_SYS_TYPES_H
  403 #include <sys/types.h>
  404 #endif
  405 #include <sys/socket.h>
  406 #include <netinet/in.h>
  407 #include <netdb.h>
  408 ],[
  409   struct sockaddr_in6 in;
  410   AF_INET6;
  411   IN6_IS_ADDR_LINKLOCAL (&in.sin6_addr);
  412 ],krb5_cv_inet6=yes,krb5_cv_inet6=no)])
  413 fi
  414 AC_MSG_RESULT($krb5_cv_inet6)
  415 if test "$krb5_cv_inet6" = no && test "$ac_cv_func_inet_ntop" = yes; then
  416 AC_MSG_CHECKING(for IPv6 compile-time support with -DINET6)
  417 AC_CACHE_VAL(krb5_cv_inet6_with_dinet6,[
  418 old_CC="$CC"
  419 CC="$CC -DINET6"
  420 AC_TRY_COMPILE([
  421 #ifdef HAVE_SYS_TYPES_H
  422 #include <sys/types.h>
  423 #endif
  424 #include <sys/socket.h>
  425 #include <netinet/in.h>
  426 #include <netdb.h>
  427 ],[
  428   struct sockaddr_in6 in;
  429   AF_INET6;
  430   IN6_IS_ADDR_LINKLOCAL (&in.sin6_addr);
  431 ],krb5_cv_inet6_with_dinet6=yes,krb5_cv_inet6_with_dinet6=no)
  432 CC="$old_CC"])
  433 AC_MSG_RESULT($krb5_cv_inet6_with_dinet6)
  434 fi
  435 if test $krb5_cv_inet6 = yes || test "$krb5_cv_inet6_with_dinet6" = yes; then
  436   if test "$krb5_cv_inet6_with_dinet6" = yes; then
  437     AC_DEFINE(INET6,1,[May need to be defined to enable IPv6 support, for example on IRIX])
  438   fi
  439 fi
  440 ])dnl
  441 dnl
  442 AC_DEFUN(KRB5_AC_CHECK_FOR_CFLAGS,[
  443 AC_BEFORE([$0],[AC_PROG_CC])
  444 AC_BEFORE([$0],[AC_PROG_CXX])
  445 krb5_ac_cflags_set=${CFLAGS+set}
  446 krb5_ac_cxxflags_set=${CXXFLAGS+set}
  447 krb5_ac_warn_cflags_set=${WARN_CFLAGS+set}
  448 krb5_ac_warn_cxxflags_set=${WARN_CXXFLAGS+set}
  449 ])
  450 dnl
  451 AC_DEFUN(TRY_WARN_CC_FLAG_1,[dnl
  452   cachevar=`echo "krb5_cv_cc_flag_$1" | sed -e s/=/_eq_/g -e s/-/_dash_/g -e s/[[^a-zA-Z0-9_]]/_/g`
  453   AC_CACHE_CHECK([if C compiler supports $1], [$cachevar],
  454   [# first try without, then with
  455   AC_TRY_COMPILE([], 1;,
  456     [old_cflags="$CFLAGS"
  457      CFLAGS="$CFLAGS $cflags_warning_test_flags $1"
  458      AC_TRY_COMPILE([], 1;, eval $cachevar=yes, eval $cachevar=no)
  459      CFLAGS="$old_cflags"],
  460     [AC_MSG_ERROR(compiling simple test program with $CFLAGS failed)])])
  461   if eval test '"${'$cachevar'}"' = yes; then
  462     WARN_CFLAGS="$WARN_CFLAGS $1"
  463   fi
  464   eval flag_supported='${'$cachevar'}'
  465 ])dnl
  466 dnl
  467 dnl Are additional flags needed to make unsupported warning options
  468 dnl get reported as errors?
  469 AC_DEFUN(CHECK_CC_WARNING_TEST_FLAGS,[dnl
  470   cflags_warning_test_flags=
  471   TRY_WARN_CC_FLAG_1(-Werror=unknown-warning-option)
  472   if test $flag_supported = yes; then
  473     cflags_warning_test_flags=-Werror=unknown-warning-option
  474   fi
  475 ])dnl
  476 dnl
  477 AC_DEFUN(TRY_WARN_CC_FLAG,[dnl
  478 AC_REQUIRE([CHECK_CC_WARNING_TEST_FLAGS])dnl
  479 TRY_WARN_CC_FLAG_1($1)dnl
  480 ])dnl
  481 dnl
  482 AC_DEFUN(WITH_CC,[dnl
  483 AC_REQUIRE([KRB5_AC_CHECK_FOR_CFLAGS])dnl
  484 AC_REQUIRE([AC_PROG_CC])dnl
  485 AC_REQUIRE([AC_PROG_CXX])dnl
  486 if test $ac_cv_c_compiler_gnu = yes ; then
  487      HAVE_GCC=yes
  488      else HAVE_GCC=
  489 fi
  490 AC_SUBST(HAVE_GCC)
  491 AC_CACHE_CHECK([for GNU linker], krb5_cv_prog_gnu_ld,
  492 [krb5_cv_prog_gnu_ld=no
  493 if test "$GCC" = yes; then
  494   if AC_TRY_COMMAND([$CC -Wl,-v 2>&1 dnl
  495 			| grep "GNU ld" > /dev/null]); then
  496     krb5_cv_prog_gnu_ld=yes
  497   fi
  498 fi])
  499 AC_ARG_WITH([size-optimizations],
  500 [  --with-size-optimizations enable a few optimizations to reduce code size
  501                           possibly at some run-time cost],
  502 ,
  503 withval=no)
  504 if test "$withval" = yes; then
  505   AC_DEFINE(CONFIG_SMALL,1,[Define to reduce code size even if it means more cpu usage])
  506 fi
  507 # -Wno-long-long, if needed, for k5-platform.h without inttypes.h etc.
  508 extra_gcc_warn_opts="-Wall -Wcast-align -Wshadow"
  509 # -Wmissing-prototypes
  510 if test "$GCC" = yes ; then
  511   # Putting this here means we get -Os after -O2, which works.
  512   if test "$with_size_optimizations" = yes && test "x$krb5_ac_cflags_set" != xset; then
  513     AC_MSG_NOTICE(adding -Os optimization option)
  514     case "$CFLAGS" in
  515       "-g -O2") CFLAGS="-g -Os" ;;
  516       "-O2")    CFLAGS="-Os" ;;
  517       *)        CFLAGS="$CFLAGS -Os" ;;
  518     esac
  519   fi
  520   if test "x$krb5_ac_warn_cflags_set" = xset ; then
  521     AC_MSG_NOTICE(not adding extra gcc warning flags because WARN_CFLAGS was set)
  522   else
  523     AC_MSG_NOTICE(adding extra warning flags for gcc)
  524     WARN_CFLAGS="$WARN_CFLAGS $extra_gcc_warn_opts -Wmissing-prototypes"
  525     if test "`uname -s`" = Darwin ; then
  526       AC_MSG_NOTICE(skipping pedantic warnings on Darwin)
  527     elif test "`uname -s`" = Linux ; then
  528       AC_MSG_NOTICE(skipping pedantic warnings on Linux)
  529     else
  530       WARN_CFLAGS="$WARN_CFLAGS -pedantic"
  531     fi
  532     if test "$ac_cv_cxx_compiler_gnu" = yes; then
  533       if test "x$krb5_ac_warn_cxxflags_set" = xset ; then
  534         AC_MSG_NOTICE(not adding extra g++ warnings because WARN_CXXFLAGS was set)
  535       else
  536         AC_MSG_NOTICE(adding extra warning flags for g++)
  537         WARN_CXXFLAGS="$WARN_CXXFLAGS $extra_gcc_warn_opts"
  538       fi
  539     fi
  540     # Currently, G++ does not support -Wno-format-zero-length.
  541     TRY_WARN_CC_FLAG(-Wno-format-zero-length)
  542     # Other flags here may not be supported on some versions of
  543     # gcc that people want to use.
  544     for flag in overflow strict-overflow missing-format-attribute missing-prototypes return-type missing-braces parentheses switch unused-function unused-label unused-variable unused-value unknown-pragmas sign-compare newline-eof error=uninitialized no-maybe-uninitialized error=pointer-arith error=int-conversion error=incompatible-pointer-types error=discarded-qualifiers error=implicit-int ; do
  545       TRY_WARN_CC_FLAG(-W$flag)
  546     done
  547     #  old-style-definition? generates many, many warnings
  548     #
  549     # Warnings that we'd like to turn into errors on versions of gcc
  550     # that support promoting only specific warnings to errors, but
  551     # we'll take as warnings on older compilers.  (If such a warning
  552     # is added after the -Werror=foo feature, you can just put
  553     # error=foo in the above list, and skip the test for the
  554     # warning-only form.)  At least in some versions, -Werror= doesn't
  555     # seem to make the conditions actual errors, but still issues
  556     # warnings; I guess we'll take what we can get.
  557     #
  558     # We're currently targeting C89+, not C99, so disallow some
  559     # constructs.
  560     for flag in declaration-after-statement ; do
  561       TRY_WARN_CC_FLAG(-Werror=$flag)
  562       if test "$flag_supported" = no; then
  563         TRY_WARN_CC_FLAG(-W$flag)
  564       fi
  565     done
  566     # We require function declarations now.
  567     #
  568     # In some compiler versions -- e.g., "gcc version 4.2.1 (Apple
  569     # Inc. build 5664)" -- the -Werror- option works, but the -Werror=
  570     # version doesn't cause implicitly declared functions to be
  571     # flagged as errors.  If neither works, -Wall implies
  572     # -Wimplicit-function-declaration so don't bother.
  573     TRY_WARN_CC_FLAG(-Werror-implicit-function-declaration)
  574     if test "implicit-function-declaration_supported" = no; then
  575       TRY_WARN_CC_FLAG(-Werror=implicit-function-declaration)
  576     fi
  577     #
  578   fi
  579   if test "`uname -s`" = Darwin ; then
  580     # Someday this should be a feature test.
  581     # One current (Jaguar = OS 10.2) problem:
  582     # Archive library with foo.o undef sym X and bar.o common sym X,
  583     # if foo.o is pulled in at link time, bar.o may not be, causing
  584     # the linker to complain.
  585     # Dynamic library problems too?
  586     case "$CC $CFLAGS" in
  587     *-fcommon*) ;; # why someone would do this, I don't know
  588     *-fno-common*) ;; # okay, they're already doing the right thing
  589     *)
  590       AC_MSG_NOTICE(disabling the use of common storage on Darwin)
  591       CFLAGS="$CFLAGS -fno-common"
  592       ;;
  593     esac
  594     case "$LD $LDFLAGS" in
  595     *-Wl,-search_paths_first*) ;;
  596     *) LDFLAGS="${LDFLAGS} -Wl,-search_paths_first" ;;
  597     esac
  598   fi
  599 else
  600   if test "`uname -s`" = AIX ; then
  601     # Using AIX but not GCC, assume native compiler.
  602     # The native compiler appears not to give a nonzero exit
  603     # status for certain classes of errors, like missing arguments
  604     # in function calls.  Let's try to fix that with -qhalt=e.
  605     case "$CC $CFLAGS" in
  606       *-qhalt=*) ;;
  607       *)
  608 	CFLAGS="$CFLAGS -qhalt=e"
  609 	AC_MSG_NOTICE(adding -qhalt=e for better error reporting)
  610 	;;
  611     esac
  612     # Also, the optimizer isn't turned on by default, which means
  613     # the static inline functions get left in random object files,
  614     # leading to references to pthread_mutex_lock from anything that
  615     # includes k5-int.h whether it uses threads or not.
  616     case "$CC $CFLAGS" in
  617       *-O*) ;;
  618       *)
  619 	CFLAGS="$CFLAGS -O"
  620 	AC_MSG_NOTICE(adding -O for inline thread-support function elimination)
  621 	;;
  622     esac
  623   fi
  624   if test "`uname -s`" = SunOS ; then
  625     # Using Solaris but not GCC, assume Sunsoft compiler.
  626     # We have some error-out-on-warning options available.
  627     # Sunsoft 12 compiler defaults to -xc99=all, it appears, so "inline"
  628     # works, but it also means that declaration-in-code warnings won't
  629     # be issued.
  630     # -v -fd -errwarn=E_DECLARATION_IN_CODE ...
  631     if test "x$krb5_ac_warn_cflags_set" = xset ; then
  632       AC_MSG_NOTICE(not adding extra warning flags because WARN_CFLAGS was set)
  633     else
  634       WARN_CFLAGS="-errtags=yes -errwarn=E_BAD_PTR_INT_COMBINATION,E_BAD_PTR_INT_COMB_ARG,E_PTR_TO_VOID_IN_ARITHMETIC,E_NO_IMPLICIT_DECL_ALLOWED,E_ATTRIBUTE_PARAM_UNDEFINED"
  635     fi
  636     if test "x$krb5_ac_warn_cxxflags_set" = xset ; then
  637       AC_MSG_NOTICE(not adding extra warning flags because WARN_CXXFLAGS was set)
  638     else
  639       WARN_CXXFLAGS="-errtags=yes +w +w2 -xport64"
  640     fi
  641   fi
  642 fi
  643 AC_SUBST(WARN_CFLAGS)
  644 AC_SUBST(WARN_CXXFLAGS)
  645 ])dnl
  646 dnl
  647 dnl
  648 dnl check for yylineno -- HAVE_YYLINENO
  649 dnl
  650 AC_DEFUN(HAVE_YYLINENO,[dnl
  651 AC_REQUIRE_CPP()AC_REQUIRE([AC_PROG_LEX])dnl
  652 AC_MSG_CHECKING([for yylineno declaration])
  653 AC_CACHE_VAL(krb5_cv_type_yylineno,
  654 # some systems have yylineno, others don't...
  655   echo '%%
  656 %%' | ${LEX} -t > conftest.out
  657   if egrep yylineno conftest.out >/dev/null 2>&1; then
  658 	krb5_cv_type_yylineno=yes
  659   else
  660 	krb5_cv_type_yylineno=no
  661   fi
  662   rm -f conftest.out)
  663   AC_MSG_RESULT($krb5_cv_type_yylineno)
  664   if test $krb5_cv_type_yylineno = no; then
  665 	AC_DEFINE(NO_YYLINENO, 1, [Define if lex produes code with yylineno])
  666   fi
  667 ])dnl
  668 dnl
  669 dnl K5_GEN_MAKEFILE([dir, [frags]])
  670 dnl
  671 AC_DEFUN(K5_GEN_MAKEFILE,[dnl
  672 ifelse($1, ,[_K5_GEN_MAKEFILE(.,$2)],[_K5_GEN_MAKEFILE($1,$2)])
  673 ])
  674 dnl
  675 dnl _K5_GEN_MAKEFILE(dir, [frags])
  676 dnl  dir must be present in this case
  677 dnl  Note: Be careful in quoting. 
  678 dnl        The ac_foreach generates the list of fragments to include
  679 dnl        or "" if $2 is empty
  680 AC_DEFUN(_K5_GEN_MAKEFILE,[dnl
  681 AC_CONFIG_FILES([$1/Makefile:$srcdir/]K5_TOPDIR[/config/pre.in:$1/Makefile.in:$1/deps:$srcdir/]K5_TOPDIR[/config/post.in])
  682 ])
  683 dnl
  684 dnl K5_GEN_FILE( <ac_output arguments> )
  685 dnl
  686 AC_DEFUN(K5_GEN_FILE,[AC_CONFIG_FILES($1)])dnl
  687 dnl
  688 dnl K5_AC_OUTPUT
  689 dnl    Note: Adds the variables to config.status for individual 
  690 dnl          Makefile generation from config.status
  691 AC_DEFUN(K5_AC_OUTPUT,[AC_OUTPUT])dnl
  692 dnl
  693 dnl V5_AC_OUTPUT_MAKEFILE
  694 dnl
  695 AC_DEFUN(V5_AC_OUTPUT_MAKEFILE,
  696 [ifelse($1, , [_V5_AC_OUTPUT_MAKEFILE(.,$2)],[_V5_AC_OUTPUT_MAKEFILE($1,$2)])])
  697 dnl
  698 define(_V5_AC_OUTPUT_MAKEFILE,
  699 [ifelse($2, , ,AC_CONFIG_FILES($2))
  700 AC_FOREACH([DIR], [$1],dnl
  701  [AC_CONFIG_FILES(DIR[/Makefile:$srcdir/]K5_TOPDIR[/config/pre.in:]DIR[/Makefile.in:]DIR[/deps:$srcdir/]K5_TOPDIR[/config/post.in])])
  702 K5_AC_OUTPUT])dnl
  703 dnl
  704 dnl
  705 dnl KRB5_SOCKADDR_SA_LEN: define HAVE_SA_LEN if sockaddr contains the sa_len
  706 dnl component
  707 dnl
  708 AC_DEFUN([KRB5_SOCKADDR_SA_LEN],[ dnl
  709 AC_CHECK_MEMBER(struct sockaddr.sa_len,
  710   AC_DEFINE(HAVE_SA_LEN,1,[Define if struct sockaddr contains sa_len])
  711 ,,[#include <sys/types.h>
  712 #include <sys/socket.h>])])
  713 dnl
  714 dnl WITH_NETLIB
  715 dnl 
  716 dnl
  717 AC_DEFUN(WITH_NETLIB,[
  718 AC_ARG_WITH([netlib],
  719 AC_HELP_STRING([--with-netlib=LIBS], use user defined resolver library),
  720 [  if test "$withval" = yes -o "$withval" = no ; then
  721 	AC_MSG_RESULT("netlib will link with C library resolver only")
  722   else
  723 	LIBS="$LIBS $withval"
  724 	AC_MSG_RESULT("netlib will use \'$withval\'")
  725   fi
  726 ],dnl
  727 [AC_LIBRARY_NET]
  728 )])dnl
  729 dnl
  730 dnl
  731 AC_DEFUN(KRB5_AC_NEED_DAEMON, [
  732 KRB5_NEED_PROTO([#ifdef HAVE_UNISTD_H
  733 #include <unistd.h>
  734 #endif],daemon,1)])dnl
  735 
  736 dnl
  737 dnl KRB5_AC_NEED_LIBGEN --- check if libgen needs to be linked in for
  738 dnl 				compile/step	
  739 dnl
  740 dnl
  741 AC_DEFUN(KRB5_AC_NEED_LIBGEN,[
  742 AC_REQUIRE([AC_PROG_CC])dnl
  743 dnl
  744 dnl regcomp is present but non-functional on Solaris 2.4
  745 dnl
  746 AC_MSG_CHECKING(for working regcomp)
  747 AC_CACHE_VAL(ac_cv_func_regcomp,[
  748 AC_TRY_RUN([
  749 #include <sys/types.h>
  750 #include <regex.h>
  751 regex_t x; regmatch_t m;
  752 int main() { return regcomp(&x,"pat.*",0) || regexec(&x,"pattern",1,&m,0); }
  753 ], ac_cv_func_regcomp=yes, ac_cv_func_regcomp=no, AC_MSG_ERROR([Cannot test regcomp when cross compiling]))])
  754 AC_MSG_RESULT($ac_cv_func_regcomp)
  755 test $ac_cv_func_regcomp = yes && AC_DEFINE(HAVE_REGCOMP,1,[Define if regcomp exists and functions])
  756 dnl
  757 dnl Check for the compile and step functions - only if regcomp is not available
  758 dnl
  759 if test $ac_cv_func_regcomp = no; then
  760  save_LIBS="$LIBS"
  761  LIBS=-lgen
  762 dnl this will fail if there's no compile/step in -lgen, or if there's
  763 dnl no -lgen.  This is fine.
  764  AC_CHECK_FUNCS(compile step)
  765  LIBS="$save_LIBS"
  766 dnl
  767 dnl Set GEN_LIB if necessary 
  768 dnl
  769  AC_CHECK_LIB(gen, compile, GEN_LIB=-lgen, GEN_LIB=)
  770  AC_SUBST(GEN_LIB)
  771 fi
  772 ])
  773 dnl
  774 dnl KRB5_AC_REGEX_FUNCS --- check for different regular expression 
  775 dnl				support functions
  776 dnl
  777 AC_DEFUN(KRB5_AC_REGEX_FUNCS,[
  778 AC_CHECK_FUNCS(re_comp re_exec regexec)
  779 AC_REQUIRE([KRB5_AC_NEED_LIBGEN])dnl
  780 ])dnl
  781 dnl
  782 dnl AC_KRB5_TCL_FIND_CONFIG (uses tcl_dir)
  783 dnl
  784 AC_DEFUN(AC_KRB5_TCL_FIND_CONFIG,[
  785 AC_REQUIRE([KRB5_LIB_AUX])dnl
  786 AC_MSG_CHECKING(for tclConfig.sh)
  787 dnl On Debian, we might be given --with-tcl=/usr, or tclsh might
  788 dnl point us to /usr/lib/tcl8.4; either way, we need to find
  789 dnl /usr/lib/tcl8.4/tclConfig.sh.
  790 dnl On NetBSD, we might be given --with-tcl=/usr/pkg, or tclsh
  791 dnl might point us to /usr/pkg/lib/tcl8.4; we need to find
  792 dnl /usr/pkg/lib/tclConfig.sh.
  793 if test -r "$tcl_dir/lib/tclConfig.sh" ; then
  794   tcl_conf="$tcl_dir/lib/tclConfig.sh"
  795 elif test -r "$tcl_dir/tclConfig.sh" ; then
  796   tcl_conf="$tcl_dir/tclConfig.sh"
  797 elif test -r "$tcl_dir/../tclConfig.sh" ; then
  798   tcl_conf="$tcl_dir/../tclConfig.sh"
  799 else
  800   tcl_conf=
  801   lib="$tcl_dir/lib"
  802   changequote(<<,>>)dnl
  803   for d in "$lib" "$lib"/tcl7.[0-9] "$lib"/tcl8.[0-9] ; do
  804     if test -r "$d/tclConfig.sh" ; then
  805       tcl_conf="$tcl_conf $d/tclConfig.sh"
  806     fi
  807   done
  808   changequote([,])dnl
  809 fi
  810 if test -n "$tcl_conf" ; then
  811   AC_MSG_RESULT($tcl_conf)
  812 else
  813   AC_MSG_RESULT(not found)
  814 fi
  815 tcl_ok_conf=
  816 tcl_vers_maj=
  817 tcl_vers_min=
  818 old_CPPFLAGS=$CPPFLAGS
  819 old_LIBS=$LIBS
  820 old_LDFLAGS=$LDFLAGS
  821 if test -n "$tcl_conf" ; then
  822   for file in $tcl_conf ; do
  823     TCL_MAJOR_VERSION=x ; TCL_MINOR_VERSION=x
  824     AC_MSG_CHECKING(Tcl info in $file)
  825     . $file
  826     v=$TCL_MAJOR_VERSION.$TCL_MINOR_VERSION
  827     if test -z "$tcl_vers_maj" \
  828 	|| test "$tcl_vers_maj" -lt "$TCL_MAJOR_VERSION" \
  829 	|| test "$tcl_vers_maj" = "$TCL_MAJOR_VERSION" -a "$tcl_vers_min" -lt "$TCL_MINOR_VERSION" ; then
  830       for incdir in "$TCL_PREFIX/include/tcl$v" "$TCL_PREFIX/include" ; do
  831 	if test -r "$incdir/tcl.h" -o -r "$incdir/tcl/tcl.h" ; then
  832 	  CPPFLAGS="$old_CPPFLAGS -I$incdir"
  833 	  break
  834 	fi
  835       done
  836       LIBS="$old_LIBS `eval echo x $TCL_LIB_SPEC $TCL_LIBS | sed 's/^x//'`"
  837       LDFLAGS="$old_LDFLAGS $TCL_LD_FLAGS"
  838       AC_TRY_LINK( , [Tcl_CreateInterp ();],
  839 	tcl_ok_conf=$file
  840 	tcl_vers_maj=$TCL_MAJOR_VERSION
  841 	tcl_vers_min=$TCL_MINOR_VERSION
  842 	AC_MSG_RESULT($v - working),
  843 	AC_MSG_RESULT($v - compilation failed)
  844       )
  845     else
  846       AC_MSG_RESULT(older version $v)
  847     fi
  848   done
  849 fi
  850 CPPFLAGS=$old_CPPFLAGS
  851 LIBS=$old_LIBS
  852 LDFLAGS=$old_LDFLAGS
  853 tcl_header=no
  854 tcl_lib=no
  855 if test -n "$tcl_ok_conf" ; then
  856   . $tcl_ok_conf
  857   TCL_INCLUDES=
  858   for incdir in "$TCL_PREFIX/include/tcl$v" "$TCL_PREFIX/include" ; do
  859     if test -r "$incdir/tcl.h" -o -r "$incdir/tcl/tcl.h" ; then
  860       if test "$incdir" != "/usr/include" ; then
  861         TCL_INCLUDES=-I$incdir
  862       fi
  863       break
  864     fi
  865   done
  866   # Need eval because the first-level expansion could reference
  867   # variables like ${TCL_DBGX}.
  868   eval TCL_LIBS='"'$TCL_LIB_SPEC $TCL_LIBS $TCL_DL_LIBS'"'
  869   TCL_LIBPATH="-L$TCL_EXEC_PREFIX/lib"
  870   TCL_RPATH=":$TCL_EXEC_PREFIX/lib"
  871   if test "$DEPLIBEXT" != "$SHLIBEXT" && test -n "$RPATH_FLAG"; then
  872     TCL_MAYBE_RPATH='$(RPATH_FLAG)'"$TCL_EXEC_PREFIX/lib$RPATH_TAIL"
  873   else
  874     TCL_MAYBE_RPATH=
  875   fi
  876   CPPFLAGS="$old_CPPFLAGS $TCL_INCLUDES"
  877   AC_CHECK_HEADER(tcl.h,AC_DEFINE(HAVE_TCL_H,1,[Define if tcl.h is available]) tcl_header=yes)
  878   if test $tcl_header=no; then
  879      AC_CHECK_HEADER(tcl/tcl.h,AC_DEFINE(HAVE_TCL_TCL_H,1,[Define if tcl/tcl.h is available]) tcl_header=yes)
  880   fi
  881   CPPFLAGS="$old_CPPFLAGS"
  882   tcl_lib=yes
  883 else
  884   # If we read a tclConfig.sh file, it probably set this.
  885   TCL_LIBS=
  886 fi  
  887 AC_SUBST(TCL_INCLUDES)
  888 AC_SUBST(TCL_LIBS)
  889 AC_SUBST(TCL_LIBPATH)
  890 AC_SUBST(TCL_RPATH)
  891 AC_SUBST(TCL_MAYBE_RPATH)
  892 ])dnl
  893 dnl
  894 dnl AC_KRB5_TCL_TRYOLD
  895 dnl attempt to use old search algorithm for locating tcl
  896 dnl
  897 AC_DEFUN(AC_KRB5_TCL_TRYOLD, [
  898 AC_REQUIRE([KRB5_AC_FIND_DLOPEN])
  899 AC_MSG_WARN([trying old tcl search code])
  900 if test "$with_tcl" != yes -a "$with_tcl" != no; then
  901 	TCL_INCLUDES=-I$with_tcl/include
  902 	TCL_LIBPATH=-L$with_tcl/lib
  903 	TCL_RPATH=:$with_tcl/lib
  904 fi
  905 if test "$with_tcl" != no ; then
  906 	krb5_save_CPPFLAGS="$CPPFLAGS"
  907 	krb5_save_LDFLAGS="$LDFLAGS"
  908 	CPPFLAGS="$CPPFLAGS $TCL_INCLUDES"
  909 	LDFLAGS="$LDFLAGS $TCL_LIBPATH"
  910 	tcl_header=no
  911 	AC_CHECK_HEADER(tcl.h,AC_DEFINE(HAVE_TCL_H,1,[Define if tcl.h found]) tcl_header=yes)
  912 	if test $tcl_header=no; then
  913 	   AC_CHECK_HEADER(tcl/tcl.h,AC_DEFINE(HAVE_TCL_TCL_H,1,[Define if tcl/tcl.h found]) tcl_header=yes)
  914 	fi
  915 
  916 	if test $tcl_header = yes ; then
  917 		tcl_lib=no
  918 
  919 		if test $tcl_lib = no; then
  920 			AC_CHECK_LIB(tcl8.0, Tcl_CreateCommand, 
  921 				TCL_LIBS="$TCL_LIBS -ltcl8.0 -lm $DL_LIB $LIBS"
  922 				tcl_lib=yes,,-lm $DL_LIB)
  923 		fi
  924 		if test $tcl_lib = no; then
  925 			AC_CHECK_LIB(tcl7.6, Tcl_CreateCommand, 
  926 				TCL_LIBS="$TCL_LIBS -ltcl7.6 -lm $DL_LIB $LIBS"
  927 				tcl_lib=yes,,-lm $DL_LIB)
  928 		fi
  929 		if test $tcl_lib = no; then
  930 			AC_CHECK_LIB(tcl7.5, Tcl_CreateCommand, 
  931 				TCL_LIBS="$TCL_LIBS -ltcl7.5 -lm $DL_LIB $LIBS"
  932 				tcl_lib=yes,,-lm $DL_LIB)
  933 
  934 		fi
  935 		if test $tcl_lib = no ; then
  936 			AC_CHECK_LIB(tcl, Tcl_CreateCommand, 
  937 				TCL_LIBS="$TCL_LIBS -ltcl -lm $DL_LIB $LIBS"
  938 				tcl_lib=yes,,-lm $DL_LIB)
  939 
  940 		fi
  941 		if test $tcl_lib = no ; then		
  942 			AC_MSG_WARN("tcl.h found but not library")
  943 		fi
  944 	else
  945 		AC_MSG_WARN(Could not find Tcl which is needed for the kadm5 tests)
  946 		TCL_LIBS=
  947 	fi
  948 	CPPFLAGS="$krb5_save_CPPFLAGS"
  949 	LDFLAGS="$krb5_save_LDFLAGS"
  950 	AC_SUBST(TCL_INCLUDES)
  951 	AC_SUBST(TCL_LIBS)
  952 	AC_SUBST(TCL_LIBPATH)
  953 	AC_SUBST(TCL_RPATH)
  954 else
  955 	AC_MSG_RESULT("Not looking for Tcl library")
  956 fi
  957 ])dnl
  958 dnl
  959 dnl AC_KRB5_TCL - determine if the TCL library is present on system
  960 dnl
  961 AC_DEFUN(AC_KRB5_TCL,[
  962 TCL_INCLUDES=
  963 TCL_LIBPATH=
  964 TCL_RPATH=
  965 TCL_LIBS=
  966 TCL_WITH=
  967 tcl_dir=
  968 AC_ARG_WITH(tcl,
  969 [  --with-tcl=path         where Tcl resides], , with_tcl=try)
  970 if test "$with_tcl" = no ; then
  971   true
  972 elif test "$with_tcl" = yes -o "$with_tcl" = try ; then
  973   tcl_dir=/usr
  974   if test ! -r /usr/lib/tclConfig.sh; then
  975     cat >> conftest <<\EOF
  976 puts "tcl_dir=$tcl_library"
  977 EOF
  978     if tclsh conftest >conftest.out 2>/dev/null; then
  979       if grep tcl_dir= conftest.out >/dev/null 2>&1; then
  980         t=`sed s/tcl_dir=// conftest.out`
  981         tcl_dir=$t
  982       fi
  983     fi # tclsh ran script okay
  984   rm -f conftest conftest.out
  985   fi # no /usr/lib/tclConfig.sh
  986 else
  987   tcl_dir=$with_tcl
  988 fi
  989 if test "$with_tcl" != no ; then
  990   AC_KRB5_TCL_FIND_CONFIG
  991   if test $tcl_lib = no ; then
  992     if test "$with_tcl" != try ; then
  993       AC_KRB5_TCL_TRYOLD
  994     else
  995       AC_MSG_WARN(Could not find Tcl which is needed for some tests)
  996     fi
  997   fi
  998 fi
  999 # If "yes" or pathname, error out if not found.
 1000 if test "$with_tcl" != no -a "$with_tcl" != try ; then
 1001   if test "$tcl_header $tcl_lib" != "yes yes" ; then
 1002     AC_MSG_ERROR(Could not find Tcl)
 1003   fi
 1004 fi
 1005 ])dnl
 1006 
 1007 dnl
 1008 dnl WITH_HESIOD
 1009 dnl
 1010 AC_DEFUN(WITH_HESIOD,
 1011 [AC_ARG_WITH(hesiod, AC_HELP_STRING(--with-hesiod[=path], compile with hesiod support @<:@omitted@:>@),
 1012 	hesiod=$with_hesiod, with_hesiod=no)
 1013 if test "$with_hesiod" != "no"; then
 1014 	HESIOD_DEFS=-DHESIOD
 1015 	AC_CHECK_LIB(resolv, res_send, res_lib=-lresolv)
 1016 	if test "$hesiod" != "yes"; then
 1017 		HESIOD_LIBS="-L${hesiod}/lib -lhesiod $res_lib"
 1018 	else
 1019 		HESIOD_LIBS="-lhesiod $res_lib"
 1020 	fi
 1021 else
 1022 	HESIOD_DEFS=
 1023 	HESIOD_LIBS=
 1024 fi
 1025 AC_SUBST(HESIOD_DEFS)
 1026 AC_SUBST(HESIOD_LIBS)])
 1027 
 1028 
 1029 dnl
 1030 dnl KRB5_BUILD_LIBRARY
 1031 dnl
 1032 dnl Pull in the necessary stuff to create the libraries.
 1033 
 1034 AC_DEFUN(KRB5_BUILD_LIBRARY,
 1035 [AC_REQUIRE([KRB5_LIB_AUX])dnl
 1036 AC_REQUIRE([AC_PROG_LN_S])dnl
 1037 AC_REQUIRE([AC_PROG_RANLIB])dnl
 1038 AC_REQUIRE([AC_PROG_ARCHIVE])dnl
 1039 AC_REQUIRE([AC_PROG_ARCHIVE_ADD])dnl
 1040 AC_REQUIRE([AC_PROG_INSTALL])dnl
 1041 AC_CHECK_PROG(AR, ar, ar, false)
 1042 if test "$AR" = "false"; then
 1043   AC_MSG_ERROR([ar not found in PATH])
 1044 fi
 1045 AC_CHECK_PROG(PERL, perl, perl, false)
 1046 if test "$ac_cv_prog_PERL" = "false"; then
 1047   AC_MSG_ERROR(Perl is now required for Kerberos builds.)
 1048 fi
 1049 AC_SUBST(LIBLIST)
 1050 AC_SUBST(LIBLINKS)
 1051 AC_SUBST(PLUGIN)
 1052 AC_SUBST(PLUGINLINK)
 1053 AC_SUBST(PLUGININST)
 1054 AC_SUBST(KDB5_PLUGIN_DEPLIBS)
 1055 AC_SUBST(KDB5_PLUGIN_LIBS)
 1056 AC_SUBST(MAKE_SHLIB_COMMAND)
 1057 AC_SUBST(SHLIB_RPATH_FLAGS)
 1058 AC_SUBST(SHLIB_EXPFLAGS)
 1059 AC_SUBST(SHLIB_EXPORT_FILE_DEP)
 1060 AC_SUBST(DYNOBJ_EXPDEPS)
 1061 AC_SUBST(DYNOBJ_EXPFLAGS)
 1062 AC_SUBST(INSTALL_SHLIB)
 1063 AC_SUBST(STLIBEXT)
 1064 AC_SUBST(SHLIBEXT)
 1065 AC_SUBST(SHLIBVEXT)
 1066 AC_SUBST(SHLIBSEXT)
 1067 AC_SUBST(DEPLIBEXT)
 1068 AC_SUBST(PFLIBEXT)
 1069 AC_SUBST(LIBINSTLIST)
 1070 AC_SUBST(DYNOBJEXT)
 1071 AC_SUBST(MAKE_DYNOBJ_COMMAND)
 1072 AC_SUBST(UNDEF_CHECK)
 1073 ])
 1074 
 1075 dnl
 1076 dnl KRB5_BUILD_LIBOBJS
 1077 dnl
 1078 dnl Pull in the necessary stuff to build library objects.
 1079 
 1080 AC_DEFUN(KRB5_BUILD_LIBOBJS,
 1081 [AC_REQUIRE([KRB5_LIB_AUX])dnl
 1082 AC_SUBST(OBJLISTS)
 1083 AC_SUBST(STOBJEXT)
 1084 AC_SUBST(SHOBJEXT)
 1085 AC_SUBST(PFOBJEXT)
 1086 AC_SUBST(PICFLAGS)
 1087 AC_SUBST(PROFFLAGS)])
 1088 
 1089 dnl
 1090 dnl KRB5_BUILD_PROGRAM
 1091 dnl
 1092 dnl Set variables to build a program.
 1093 
 1094 AC_DEFUN(KRB5_BUILD_PROGRAM,
 1095 [AC_REQUIRE([KRB5_LIB_AUX])dnl
 1096 AC_REQUIRE([KRB5_AC_NEED_LIBGEN])dnl
 1097 AC_SUBST(CC_LINK)
 1098 AC_SUBST(CXX_LINK)
 1099 AC_SUBST(RPATH_FLAG)
 1100 AC_SUBST(PROG_RPATH_FLAGS)
 1101 AC_SUBST(DEPLIBEXT)])
 1102 
 1103 dnl
 1104 dnl KRB5_RUN_FLAGS
 1105 dnl
 1106 dnl Set up environment for running dynamic executables out of build tree
 1107 
 1108 AC_DEFUN(KRB5_RUN_FLAGS,
 1109 [AC_REQUIRE([KRB5_LIB_AUX])dnl
 1110 KRB5_RUN_ENV="$RUN_ENV"
 1111 KRB5_RUN_VARS="$RUN_VARS"
 1112 AC_SUBST(KRB5_RUN_ENV)
 1113 AC_SUBST(KRB5_RUN_VARS)])
 1114 
 1115 dnl
 1116 dnl KRB5_LIB_AUX
 1117 dnl
 1118 dnl Parse configure options related to library building.
 1119 
 1120 AC_DEFUN(KRB5_LIB_AUX,
 1121 [AC_REQUIRE([KRB5_LIB_PARAMS])dnl
 1122 
 1123 AC_ARG_ENABLE([static],,, [enable_static=no])
 1124 AC_ARG_ENABLE([shared],,, [enable_shared=yes])
 1125 
 1126 if test "x$enable_static" = "x$enable_shared"; then
 1127   AC_MSG_ERROR([--enable-static must be specified with --disable-shared])
 1128 fi
 1129 
 1130 AC_ARG_ENABLE([rpath],
 1131 AC_HELP_STRING([--disable-rpath],[suppress run path flags in link lines]),,
 1132 [enable_rpath=yes])
 1133 
 1134 if test "x$enable_rpath" != xyes ; then
 1135 	# Unset the rpath flag values set by shlib.conf
 1136 	SHLIB_RPATH_FLAGS=
 1137 	RPATH_FLAG=
 1138 	PROG_RPATH_FLAGS=
 1139 fi
 1140 
 1141 if test "$SHLIBEXT" = ".so-nobuild"; then
 1142    AC_MSG_ERROR([Shared libraries are not yet supported on this platform.])
 1143 fi
 1144 
 1145 DEPLIBEXT=$SHLIBEXT
 1146 
 1147 if test "x$enable_static" = xyes; then
 1148 	AC_MSG_NOTICE([using static libraries])
 1149 	LIBLIST='lib$(LIBBASE)$(STLIBEXT)'
 1150 	LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(STLIBEXT)'
 1151 	PLUGIN='libkrb5_$(LIBBASE)$(STLIBEXT)'
 1152 	PLUGINLINK='$(TOPLIBD)/libkrb5_$(LIBBASE)$(STLIBEXT)'
 1153 	PLUGININST=install-static
 1154 	OBJLISTS=OBJS.ST
 1155 	LIBINSTLIST=install-static
 1156 	DEPLIBEXT=$STLIBEXT
 1157 	AC_DEFINE([STATIC_PLUGINS], 1, [Define for static plugin linkage])
 1158 
 1159 	KDB5_PLUGIN_DEPLIBS='$(TOPLIBD)/libkrb5_db2$(DEPLIBEXT)'
 1160 	KDB5_PLUGIN_LIBS='-lkrb5_db2'
 1161 	if test "x$OPENLDAP_PLUGIN" = xyes; then
 1162 		KDB5_PLUGIN_DEBLIBS=$KDB5_PLUGIN_DEPLIBS' $(TOPLIBD)/libkrb5_ldap$(DEPLIBEXT) $(TOPLIBD)/libkdb_ldap$(DEPLIBEXT)'
 1163 		KDB5_PLUGIN_LIBS=$KDB5_PLUGIN_LIBS' -lkrb5_kldap -lkdb_ldap $(LDAP_LIBS)'
 1164 	fi
 1165 	# kadm5srv_mit normally comes before kdb on the link line.  Add it
 1166 	# again after the KDB plugins, since they depend on it for XDR stuff.
 1167 	KDB5_PLUGIN_DEPLIBS=$KDB5_PLUGIN_DEPLIBS' $(TOPLIBD)/libkadm5srv_mit$(DEPLIBEXT)'
 1168 	KDB5_PLUGIN_LIBS=$KDB5_PLUGIN_LIBS' -lkadm5srv_mit'
 1169 
 1170 	# avoid duplicate rules generation for AIX and such
 1171 	SHLIBEXT=.so-nobuild
 1172 	SHLIBVEXT=.so.v-nobuild
 1173 	SHLIBSEXT=.so.s-nobuild
 1174 else
 1175 	AC_MSG_NOTICE([using shared libraries])
 1176 
 1177 	# Clear some stuff in case of AIX, etc.
 1178 	if test "$STLIBEXT" = "$SHLIBEXT" ; then
 1179 		STLIBEXT=.a-nobuild
 1180 	fi
 1181 	case "$SHLIBSEXT" in
 1182 	.so.s-nobuild)
 1183 		LIBLIST='lib$(LIBBASE)$(SHLIBEXT)'
 1184 		LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(SHLIBEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBVEXT)'
 1185 		LIBINSTLIST="install-shared"
 1186 		;;
 1187 	*)
 1188 		LIBLIST='lib$(LIBBASE)$(SHLIBEXT) lib$(LIBBASE)$(SHLIBSEXT)'
 1189 		LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(SHLIBEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBVEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBSEXT)'
 1190 		LIBINSTLIST="install-shlib-soname"
 1191 		;;
 1192 	esac
 1193 	OBJLISTS="OBJS.SH"
 1194 	PLUGIN='$(LIBBASE)$(DYNOBJEXT)'
 1195 	PLUGINLINK='../$(PLUGIN)'
 1196 	PLUGININST=install-plugin
 1197 	KDB5_PLUGIN_DEPLIBS=
 1198 	KDB5_PLUGIN_LIBS=
 1199 fi
 1200 CC_LINK="$CC_LINK_SHARED"
 1201 CXX_LINK="$CXX_LINK_SHARED"
 1202 
 1203 if test -z "$LIBLIST"; then
 1204 	AC_MSG_ERROR([must enable one of shared or static libraries])
 1205 fi
 1206 
 1207 # Check whether to build profiled libraries.
 1208 AC_ARG_ENABLE([profiled],
 1209 dnl [  --enable-profiled       build profiled libraries @<:@disabled@:>@]
 1210 ,
 1211 [if test "$enableval" = yes; then
 1212   AC_MSG_ERROR([Sorry, profiled libraries do not work in this release.])
 1213 fi])])
 1214 
 1215 dnl
 1216 dnl KRB5_LIB_PARAMS
 1217 dnl
 1218 dnl Determine parameters related to libraries, e.g. various extensions.
 1219 
 1220 AC_DEFUN(KRB5_LIB_PARAMS,
 1221 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
 1222 krb5_cv_host=$host
 1223 AC_SUBST(krb5_cv_host)
 1224 AC_REQUIRE([AC_PROG_CC])dnl
 1225 AC_REQUIRE([V5_SET_TOPDIR])dnl
 1226 . $ac_topdir/config/shlib.conf])
 1227 dnl
 1228 dnl The following was written by jhawk@mit.edu
 1229 dnl
 1230 dnl AC_LIBRARY_NET: Id: net.m4,v 1.4 1997/10/25 20:49:53 jhawk Exp 
 1231 dnl
 1232 dnl This test is for network applications that need socket() and
 1233 dnl gethostbyname() -ish functions.  Under Solaris, those applications need to
 1234 dnl link with "-lsocket -lnsl".  Under IRIX, they should *not* link with
 1235 dnl "-lsocket" because libsocket.a breaks a number of things (for instance:
 1236 dnl gethostbyname() under IRIX 5.2, and snoop sockets under most versions of
 1237 dnl IRIX).
 1238 dnl 
 1239 dnl Unfortunately, many application developers are not aware of this, and
 1240 dnl mistakenly write tests that cause -lsocket to be used under IRIX.  It is
 1241 dnl also easy to write tests that cause -lnsl to be used under operating
 1242 dnl systems where neither are necessary (or useful), such as SunOS 4.1.4, which
 1243 dnl uses -lnsl for TLI.
 1244 dnl 
 1245 dnl This test exists so that every application developer does not test this in
 1246 dnl a different, and subtly broken fashion.
 1247 dnl 
 1248 dnl It has been argued that this test should be broken up into two separate
 1249 dnl tests, one for the resolver libraries, and one for the libraries necessary
 1250 dnl for using Sockets API. Unfortunately, the two are carefully intertwined and
 1251 dnl allowing the autoconf user to use them independantly potentially results in
 1252 dnl unfortunate ordering dependencies -- as such, such component macros would
 1253 dnl have to carefully use indirection and be aware if the other components were
 1254 dnl executed. Since other autoconf macros do not go to this trouble, and almost
 1255 dnl no applications use sockets without the resolver, this complexity has not
 1256 dnl been implemented.
 1257 dnl
 1258 dnl The check for libresolv is in case you are attempting to link statically
 1259 dnl and happen to have a libresolv.a lying around (and no libnsl.a).
 1260 dnl
 1261 AC_DEFUN(AC_LIBRARY_NET, [
 1262    # Most operating systems have gethostbyname() in the default searched
 1263    # libraries (i.e. libc):
 1264    AC_CHECK_FUNC(gethostbyname, , [
 1265      # Some OSes (eg. Solaris) place it in libnsl:
 1266      AC_CHECK_LIB(nsl, gethostbyname, , [
 1267        # Some strange OSes (SINIX) have it in libsocket:
 1268        AC_CHECK_LIB(socket, gethostbyname, , [
 1269           # Unfortunately libsocket sometimes depends on libnsl.
 1270           # AC_CHECK_LIB's API is essentially broken so the following
 1271           # ugliness is necessary:
 1272           AC_CHECK_LIB(socket, gethostbyname,
 1273              LIBS="-lsocket -lnsl $LIBS",
 1274                [AC_CHECK_LIB(resolv, gethostbyname,
 1275 			     LIBS="-lresolv $LIBS" )],
 1276              -lnsl)
 1277        ])
 1278      ])
 1279    ])
 1280   AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
 1281     AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl)))
 1282   KRB5_AC_ENABLE_DNS
 1283   if test "$enable_dns" = yes ; then
 1284     # We assume that if libresolv exists we can link against it.
 1285     # This may get us a gethostby* that doesn't respect nsswitch.
 1286     AC_CHECK_LIB(resolv, main)
 1287 
 1288 _KRB5_AC_CHECK_RES_FUNCS(res_ninit res_nclose res_ndestroy res_nsearch dnl
 1289 ns_initparse ns_name_uncompress dn_skipname res_search)
 1290     if test $krb5_cv_func_res_nsearch = no \
 1291       && test $krb5_cv_func_res_search = no; then
 1292 	# Attempt to link with res_search(), in case it's not prototyped.
 1293 	AC_CHECK_FUNC(res_search,
 1294 	  [AC_DEFINE(HAVE_RES_SEARCH, 1,
 1295 	    [Define to 1 if you have the `res_search' function])],
 1296 	  [AC_ERROR([cannot find res_nsearch or res_search])])
 1297     fi
 1298   fi
 1299 ])
 1300 AC_DEFUN([_KRB5_AC_CHECK_RES_FUNCS],
 1301 [AC_FOREACH([AC_Func], [$1],
 1302   [AH_TEMPLATE(AS_TR_CPP(HAVE_[]AC_Func),
 1303                [Define to 1 if you have the `]AC_Func[' function.])])dnl
 1304 for krb5_func in $1; do
 1305 _KRB5_AC_CHECK_RES_FUNC($krb5_func)
 1306 done
 1307 ])
 1308 AC_DEFUN([_KRB5_AC_CHECK_RES_FUNC], [
 1309 # Solaris 9 prototypes ns_name_uncompress() in arpa/nameser.h, but
 1310 # doesn't export it from libresolv.so, so we use extreme paranoia here
 1311 # and check both for the declaration and that we can link against the
 1312 # function.
 1313 AC_CACHE_CHECK([for $1], [krb5_cv_func_$1], [AC_TRY_LINK(
 1314 [#include <sys/types.h>
 1315 #include <netinet/in.h>
 1316 #include <arpa/nameser.h>
 1317 @%:@include <resolv.h>],
 1318 [/*
 1319  * Use volatile, or else optimization can cause false positives.
 1320  */
 1321 void (* volatile p)() = (void (*)())$1;],
 1322 			     [AS_VAR_SET(krb5_cv_func_$1, yes)],
 1323 			     [AS_VAR_SET(krb5_cv_func_$1, no)])])
 1324 AS_IF([test AS_VAR_GET(krb5_cv_func_$1) = yes],
 1325       [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]), 1,
 1326 			  [Define to 1 if you have the `$1' function])])[]dnl
 1327 ])
 1328 dnl
 1329 dnl
 1330 dnl KRB5_AC_ENABLE_DNS
 1331 dnl
 1332 AC_DEFUN(KRB5_AC_ENABLE_DNS, [
 1333 enable_dns=yes
 1334   AC_ARG_ENABLE([dns-for-realm],
 1335 [  --enable-dns-for-realm  enable DNS lookups of Kerberos realm names], ,
 1336 [enable_dns_for_realm=no])
 1337   if test "$enable_dns_for_realm" = yes; then
 1338     AC_DEFINE(KRB5_DNS_LOOKUP_REALM,1,[Define to enable DNS lookups of Kerberos realm names])
 1339   fi
 1340 
 1341 AC_DEFINE(KRB5_DNS_LOOKUP, 1,[Define for DNS support of locating realms and KDCs])
 1342 
 1343 ])
 1344 dnl
 1345 dnl
 1346 dnl Check if we need the prototype for a function - we give it a bogus 
 1347 dnl prototype and if it complains - then a valid prototype exists on the 
 1348 dnl system.
 1349 dnl
 1350 dnl KRB5_NEED_PROTO(includes, function, [bypass])
 1351 dnl if $3 set, don't see if library defined. 
 1352 dnl Useful for case where we will define in libkrb5 the function if need be
 1353 dnl but want to know if a prototype exists in either case on system.
 1354 dnl
 1355 AC_DEFUN([KRB5_NEED_PROTO], [
 1356 ifelse([$3], ,[if test "x$ac_cv_func_$2" = xyes; then])
 1357 AC_CACHE_CHECK([if $2 needs a prototype provided], krb5_cv_func_$2_noproto,
 1358 AC_TRY_COMPILE([$1],
 1359 [#undef $2
 1360 struct k5foo {int foo; } xx;
 1361 extern int $2 (struct k5foo*);
 1362 $2(&xx);
 1363 ],
 1364 krb5_cv_func_$2_noproto=yes,krb5_cv_func_$2_noproto=no))
 1365 if test $krb5_cv_func_$2_noproto = yes; then
 1366 	AC_DEFINE([NEED_]translit($2, [a-z], [A-Z])[_PROTO], 1, dnl
 1367 [define if the system header files are missing prototype for $2()])
 1368 fi
 1369 ifelse([$3], ,[fi])
 1370 ])
 1371 dnl
 1372 dnl =============================================================
 1373 dnl Internal function for testing for getpeername prototype
 1374 dnl
 1375 AC_DEFUN([KRB5_GETPEERNAME_ARGS],[
 1376 AC_DEFINE([GETPEERNAME_ARG3_TYPE],GETSOCKNAME_ARG3_TYPE,[Type of getpeername second argument.])
 1377 ])
 1378 dnl
 1379 dnl =============================================================
 1380 dnl Internal function for testing for getsockname arguments
 1381 dnl
 1382 AC_DEFUN([TRY_GETSOCK_INT],[
 1383 krb5_lib_var=`echo "$1 $2" | sed 'y% ./+-*%___p_p%'`
 1384 AC_MSG_CHECKING([if getsockname() takes arguments $1 and $2])
 1385 AC_CACHE_VAL(krb5_cv_getsockname_proto_$krb5_lib_var,
 1386 [
 1387 AC_TRY_COMPILE([#include <sys/types.h>
 1388 #include <sys/socket.h>
 1389 extern int getsockname(int, $1, $2);
 1390 ],,eval "krb5_cv_getsockname_proto_$krb5_lib_var=yes",
 1391     eval "krb5_cv_getsockname_proto_$krb5_lib_var=no")])
 1392 if eval "test \"`echo '$krb5_cv_getsockname_proto_'$krb5_lib_var`\" = yes"; then
 1393 	AC_MSG_RESULT(yes)
 1394 	sock_set=yes; res1="$1"; res2="$2"
 1395 else
 1396 	AC_MSG_RESULT(no)
 1397 fi
 1398 ])
 1399 dnl
 1400 dnl Determines the types of the second and third arguments to getsockname().
 1401 dnl
 1402 AC_DEFUN([KRB5_GETSOCKNAME_ARGS],[
 1403 sock_set=no
 1404 for sock_arg1 in "struct sockaddr *" "void *"
 1405 do
 1406   for sock_arg2 in "size_t *" "int *" "socklen_t *"
 1407   do
 1408 	if test $sock_set = no; then
 1409 	  TRY_GETSOCK_INT($sock_arg1, $sock_arg2)
 1410 	fi
 1411   done 
 1412 done
 1413 if test "$sock_set" = no; then
 1414   AC_MSG_NOTICE(assuming struct sockaddr and socklen_t for getsockname args)
 1415   res1="struct sockaddr *"
 1416   res2="socklen_t *"
 1417 fi
 1418 res1=`echo "$res1" | tr -d '*' | sed -e 's/ *$//'`
 1419 res2=`echo "$res2" | tr -d '*' | sed -e 's/ *$//'`
 1420 AC_DEFINE_UNQUOTED([GETSOCKNAME_ARG3_TYPE],$res2,[Type of pointer target for argument 3 to getsockname])
 1421 ])
 1422 dnl
 1423 dnl
 1424 AC_DEFUN([KRB5_AC_CHOOSE_ET],[
 1425 AC_ARG_WITH([system-et],
 1426 AC_HELP_STRING(--with-system-et,use system compile_et and -lcom_err @<:@default: build and install a local version@:>@))
 1427 AC_MSG_CHECKING(which version of com_err to use)
 1428 if test "x$with_system_et" = xyes ; then
 1429   # This will be changed to "intlsys" if textdomain support is present.
 1430   COM_ERR_VERSION=sys
 1431   AC_MSG_RESULT(system)
 1432 else
 1433   COM_ERR_VERSION=k5
 1434   AC_MSG_RESULT(krb5)
 1435 fi
 1436 if test $COM_ERR_VERSION = sys; then
 1437   # check for various functions we need
 1438   AC_CHECK_LIB(com_err, add_error_table, :, AC_MSG_ERROR(cannot find add_error_table in com_err library))
 1439   AC_CHECK_LIB(com_err, remove_error_table, :, AC_MSG_ERROR(cannot find remove_error_table in com_err library))
 1440   # make sure compile_et provides "et_foo" name
 1441   cat >> conf$$e.et <<EOF
 1442 error_table foo
 1443 error_code ERR_FOO, "foo"
 1444 end
 1445 EOF
 1446   AC_CHECK_PROGS(compile_et,compile_et,false)
 1447   if test "$compile_et" = false; then
 1448     AC_MSG_ERROR(cannot find compile_et)
 1449   fi
 1450   AC_CACHE_CHECK(whether compile_et is useful,krb5_cv_compile_et_useful,[
 1451   if compile_et conf$$e.et >/dev/null 2>&1 ; then true ; else
 1452     AC_MSG_ERROR(execution failed)
 1453   fi
 1454   AC_TRY_COMPILE([#include "conf$$e.h"
 1455       		 ],[ &et_foo_error_table; ],:,
 1456 		 [AC_MSG_ERROR(cannot use et_foo_error_table)])
 1457   # Anything else we need to test for?
 1458   rm -f conf$$e.c conf$$e.h
 1459   krb5_cv_compile_et_useful=yes
 1460   ])
 1461   AC_CACHE_CHECK(whether compile_et supports --textdomain,
 1462                  krb5_cv_compile_et_textdomain,[
 1463   krb5_cv_compile_et_textdomain=no
 1464   if compile_et --textdomain=xyzw conf$$e.et >/dev/null 2>&1 ; then
 1465     if grep -q xyzw conf$$e.c; then
 1466       krb5_cv_compile_et_textdomain=yes
 1467     fi
 1468   fi
 1469   rm -f conf$$e.c conf$$e.h
 1470   ])
 1471   if test "$krb5_cv_compile_et_textdomain" = yes; then
 1472     COM_ERR_VERSION=intlsys
 1473   fi
 1474   rm -f conf$$e.et
 1475 fi
 1476 AC_SUBST(COM_ERR_VERSION)
 1477 if test "$COM_ERR_VERSION" = k5 -o "$COM_ERR_VERSION" = intlsys; then
 1478   AC_DEFINE(HAVE_COM_ERR_INTL,1,
 1479             [Define if com_err has compatible gettext support])
 1480 fi
 1481 ])
 1482 AC_DEFUN([KRB5_AC_CHOOSE_SS],[
 1483 AC_ARG_WITH(system-ss,
 1484 	    AC_HELP_STRING(--with-system-ss,use system -lss and mk_cmds @<:@private version@:>@))
 1485 AC_ARG_VAR(SS_LIB,[system libraries for 'ss' package [-lss]])
 1486 AC_MSG_CHECKING(which version of subsystem package to use)
 1487 if test "x$with_system_ss" = xyes ; then
 1488   SS_VERSION=sys
 1489   AC_MSG_RESULT(system)
 1490   # todo: check for various libraries we might need
 1491   # in the meantime...
 1492   test "x${SS_LIB+set}" = xset || SS_LIB=-lss
 1493   old_LIBS="$LIBS"
 1494   LIBS="$LIBS $SS_LIB"
 1495   AC_CACHE_CHECK(whether system ss package works, krb5_cv_system_ss_okay,[
 1496   AC_TRY_RUN([
 1497 #include <ss/ss.h>
 1498 int main(int argc, char *argv[]) {
 1499   if (argc == 42) {
 1500     int i, err;
 1501     i = ss_create_invocation("foo","foo","",0,&err);
 1502     ss_listen(i);
 1503   }
 1504   return 0;
 1505 }], krb5_cv_system_ss_okay=yes, AC_MSG_ERROR(cannot run test program),
 1506   krb5_cv_system_ss_okay="assumed")])
 1507   LIBS="$old_LIBS"
 1508   KRB5_NEED_PROTO([#include <ss/ss.h>],ss_execute_command,1)
 1509 else
 1510   SS_VERSION=k5
 1511   AC_MSG_RESULT(krb5)
 1512 fi
 1513 AC_SUBST(SS_LIB)
 1514 AC_SUBST(SS_VERSION)
 1515 ])
 1516 dnl
 1517 AC_DEFUN([KRB5_AC_CHOOSE_DB],[
 1518 AC_ARG_WITH(system-db,
 1519 	    AC_HELP_STRING(--with-system-db,use system Berkeley db @<:@private version@:>@))
 1520 AC_ARG_VAR(DB_HEADER,[header file for system Berkeley db package [db.h]])
 1521 AC_ARG_VAR(DB_LIB,[library for system Berkeley db package [-ldb]])
 1522 if test "x$with_system_db" = xyes ; then
 1523   DB_VERSION=sys
 1524   # TODO: Do we have specific routines we should check for?
 1525   # How about known, easily recognizable bugs?
 1526   # We want to use bt_rseq in some cases, but no other version but
 1527   # ours has it right now.
 1528   #
 1529   # Okay, check the variables.
 1530   test "x${DB_HEADER+set}" = xset || DB_HEADER=db.h
 1531   test "x${DB_LIB+set}" = xset || DB_LIB=-ldb
 1532   #
 1533   if test "x${DB_HEADER}" = xdb.h ; then
 1534     DB_HEADER_VERSION=sys
 1535   else
 1536     DB_HEADER_VERSION=redirect
 1537   fi
 1538   KDB5_DB_LIB="$DB_LIB"
 1539 else
 1540   DB_VERSION=k5
 1541   AC_DEFINE(HAVE_BT_RSEQ,1,[Define if bt_rseq is available, for recursive btree traversal.])
 1542   DB_HEADER=db.h
 1543   DB_HEADER_VERSION=k5
 1544   # libdb gets sucked into libkdb
 1545   KDB5_DB_LIB=
 1546   # needed for a couple of things that need libdb for its own sake
 1547   DB_LIB=-ldb
 1548 fi
 1549 AC_SUBST(DB_VERSION)
 1550 AC_SUBST(DB_HEADER)
 1551 AC_SUBST(DB_HEADER_VERSION)
 1552 AC_SUBST(DB_LIB)
 1553 AC_SUBST(KDB5_DB_LIB)
 1554 ])
 1555 dnl
 1556 dnl KRB5_AC_PRIOCNTL_HACK
 1557 dnl
 1558 dnl
 1559 AC_DEFUN([KRB5_AC_PRIOCNTL_HACK],
 1560 [AC_REQUIRE([AC_PROG_AWK])dnl
 1561 AC_REQUIRE([AC_LANG_COMPILER_REQUIRE])dnl
 1562 AC_CACHE_CHECK([whether to use priocntl hack], [krb5_cv_priocntl_hack],
 1563 [case $krb5_cv_host in
 1564 *-*-solaris2.9*)
 1565 	if test "$cross_compiling" = yes; then
 1566 		krb5_cv_priocntl_hack=yes
 1567 	else
 1568 		# Solaris patch 117171-11 (sparc) or 117172-11 (x86)
 1569 		# fixes the Solaris 9 bug where final pty output
 1570 		# gets lost on close.
 1571 		if showrev -p | $AWK 'BEGIN { e = 1 }
 1572 /Patch: 11717[[12]]/ { x = index[]([$]2, "-");
 1573 if (substr[]([$]2, x + 1, length([$]2) - x) >= 11)
 1574 { e = 0 } else { e = 1 } }
 1575 END { exit e; }'; then
 1576 			krb5_cv_priocntl_hack=no
 1577 		else
 1578 			krb5_cv_priocntl_hack=yes
 1579 		fi
 1580 	fi
 1581 	;;
 1582 *)
 1583 	krb5_cv_priocntl_hack=no
 1584 	;;
 1585 esac])
 1586 if test "$krb5_cv_priocntl_hack" = yes; then
 1587 	PRIOCNTL_HACK=1
 1588 else
 1589 	PRIOCNTL_HACK=0
 1590 fi
 1591 AC_SUBST(PRIOCNTL_HACK)])
 1592 dnl
 1593 dnl
 1594 dnl KRB5_AC_GCC_ATTRS
 1595 AC_DEFUN([KRB5_AC_GCC_ATTRS],
 1596 [AC_CACHE_CHECK([for constructor/destructor attribute support],krb5_cv_attr_constructor_destructor,
 1597 [rm -f conftest.1 conftest.2
 1598 if test -r conftest.1 || test -r conftest.2 ; then
 1599   AC_MSG_ERROR(write error in local file system?)
 1600 fi
 1601 true > conftest.1
 1602 true > conftest.2
 1603 if test -r conftest.1 && test -r conftest.2 ; then true ; else
 1604   AC_MSG_ERROR(write error in local file system?)
 1605 fi
 1606 a=no
 1607 b=no
 1608 # blindly assume we have 'unlink'...
 1609 AC_TRY_RUN([void foo1() __attribute__((constructor));
 1610 void foo1() { unlink("conftest.1"); }
 1611 void foo2() __attribute__((destructor));
 1612 void foo2() { unlink("conftest.2"); }
 1613 int main () { return 0; }],
 1614 [test -r conftest.1 || a=yes
 1615 test -r conftest.2 || b=yes], , AC_MSG_ERROR(Cannot test for constructor/destructor support when cross compiling))
 1616 case $krb5_cv_host in
 1617 *-*-aix4.*)
 1618 	# Under AIX 4.3.3, at least, shared library destructor functions
 1619 	# appear to get executed in reverse link order (right to left),
 1620 	# so that a library's destructor function may run after that of
 1621 	# libraries it depends on, and may still have to access in the
 1622 	# destructor.
 1623 	#
 1624 	# That counts as "not working", for me, but it's a much more
 1625 	# complicated test case to set up.
 1626 	b=no
 1627 	;;
 1628 esac
 1629 krb5_cv_attr_constructor_destructor="$a,$b"
 1630 ])
 1631 # Okay, krb5_cv_... should be set now.
 1632 case $krb5_cv_attr_constructor_destructor in
 1633   yes,*)
 1634     AC_DEFINE(CONSTRUCTOR_ATTR_WORKS,1,[Define if __attribute__((constructor)) works]) ;;
 1635 esac
 1636 case $krb5_cv_attr_constructor_destructor in
 1637   *,yes)
 1638     AC_DEFINE(DESTRUCTOR_ATTR_WORKS,1,[Define if __attribute__((destructor)) works]) ;;
 1639 esac
 1640 dnl End of attributes we care about right now.
 1641 ])
 1642 dnl
 1643 dnl
 1644 dnl KRB5_AC_PRAGMA_WEAK_REF
 1645 AC_DEFUN([KRB5_AC_PRAGMA_WEAK_REF],
 1646 [AC_CACHE_CHECK([whether pragma weak references are supported],
 1647 krb5_cv_pragma_weak_ref,
 1648 [AC_TRY_LINK([#pragma weak flurbl
 1649 extern int flurbl(void);],[if (&flurbl != 0) return flurbl();],
 1650 krb5_cv_pragma_weak_ref=yes,krb5_cv_pragma_weak_ref=no)])
 1651 if test $krb5_cv_pragma_weak_ref = yes ; then
 1652   AC_DEFINE(HAVE_PRAGMA_WEAK_REF,1,[Define if #pragma weak references work])
 1653 fi])
 1654 dnl
 1655 dnl
 1656 m4_include(config/ac-archive/ax_pthread.m4)
 1657 m4_include(config/ac-archive/ax_recursive_eval.m4)
 1658 m4_include(config/pkg.m4)
 1659 dnl
 1660 dnl
 1661 dnl
 1662 dnl --with-ldap=value
 1663 dnl
 1664 AC_DEFUN(WITH_LDAP,[
 1665 AC_ARG_WITH([ldap],
 1666 [  --with-ldap             compile OpenLDAP database backend module],
 1667 [case "$withval" in
 1668     OPENLDAP) with_ldap=yes ;;
 1669     yes | no) ;;
 1670     *)  AC_MSG_ERROR(Invalid option value --with-ldap="$withval") ;;
 1671 esac], with_ldap=no)dnl
 1672 
 1673 if test "$with_ldap" = yes; then
 1674   AC_MSG_NOTICE(enabling OpenLDAP database backend module support)
 1675   OPENLDAP_PLUGIN=yes
 1676 fi
 1677 ])dnl