2 AC_COPYRIGHT([Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
3 Massachusetts Institute of Technology.
6 define([K5_TOPDIR],[.])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])
13 ac_topdir=$srcdir/$ac_reltopdir
14 ac_config_fragdir=$ac_reltopdir/config
15 # echo "Looking for $srcdir/$ac_config_fragdir"
16 AC_CONFIG_AUX_DIR(K5_TOPDIR/config)
21 pushdef([x],esyscmd([sed -n 's/#define \([A-Z0-9_]*\)[ \t]*\(.*\)/\1=\2/p' < ]K5_TOPDIR/patchlevel.h))
22 define([PL_KRB5_MAJOR_RELEASE],regexp(x,[KRB5_MAJOR_RELEASE=\(.*\)],[\1]))
23 ifelse(PL_KRB5_MAJOR_RELEASE,,[errprint([Can't determine KRB5_MAJOR_RELEASE value from patchlevel.h.
24 ]) m4exit(1) dnl sometimes that does not work?
26 define([PL_KRB5_MINOR_RELEASE],regexp(x,[KRB5_MINOR_RELEASE=\(.*\)],[\1]))
27 ifelse(PL_KRB5_MINOR_RELEASE,,[errprint([Can't determine KRB5_MINOR_RELEASE value from patchlevel.h.
28 ]) m4exit(1) dnl sometimes that does not work?
30 define([PL_KRB5_PATCHLEVEL],regexp(x,[KRB5_PATCHLEVEL=\(.*\)],[\1]))
31 ifelse(PL_KRB5_PATCHLEVEL,,[errprint([Can't determine KRB5_PATCHLEVEL value from patchlevel.h.
32 ]) m4exit(1) dnl sometimes that does not work?
34 define([PL_KRB5_RELTAIL],regexp(x,[KRB5_RELTAIL="\(.*\)"],[\1]))
35 dnl RELTAIL is allowed to not be defined.
37 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))
38 define([K5_BUGADDR],krb5-bugs@mit.edu)
39 define([K5_AC_INIT],[AC_INIT(Kerberos 5, K5_VERSION, K5_BUGADDR, krb5)
43 dnl drop in standard rules for all configure files -- CONFIG_RULES
45 AC_DEFUN(CONFIG_RULES,[dnl
46 AC_REQUIRE([V5_SET_TOPDIR]) dnl
49 dnl Consider using AC_USE_SYSTEM_EXTENSIONS when we require autoconf
50 dnl 2.59c or later, but be sure to test on Solaris first.
51 AC_DEFINE([_GNU_SOURCE], 1, [Define to enable extensions in glibc])
52 AC_DEFINE([__STDC_WANT_LIB_EXT1__], 1, [Define to enable C11 extensions])
56 if test -z "$LD" ; then LD=$CC; fi
57 AC_ARG_VAR(LD,[linker command [CC]])
62 dnl allow stuff in tree to access deprecated stuff for now
63 dnl AC_DEFINE([KRB5_DEPRECATED], 1, [Define only if building in-tree])
67 KRB5_AC_MAINTAINER_MODE dnl
70 dnl This identifies the top of the source tree relative to the directory
71 dnl in which the configure file lives.
73 CONFIG_RELTOPDIR=$ac_reltopdir
74 AC_SUBST(CONFIG_RELTOPDIR)
75 lib_frag=$srcdir/$ac_config_fragdir/lib.in
76 AC_SUBST_FILE(lib_frag)
77 libobj_frag=$srcdir/$ac_config_fragdir/libobj.in
78 AC_SUBST_FILE(libobj_frag)
79 libnover_frag=$srcdir/$ac_config_fragdir/libnover.in
80 AC_SUBST_FILE(libnover_frag)
81 libpriv_frag=$srcdir/$ac_config_fragdir/libpriv.in
82 AC_SUBST_FILE(libpriv_frag)
83 libnodeps_frag=$srcdir/$ac_config_fragdir/libnodeps.in
84 AC_SUBST_FILE(libnodeps_frag)
86 KRB5_AC_PRAGMA_WEAK_REF
90 KRB5_AC_ENABLE_THREADS
92 KRB5_AC_KEYRING_CCACHE
93 KRB5_AC_PERSISTENT_KEYRING
96 dnl Maintainer mode, akin to what automake provides, 'cept we don't
97 dnl want to use automake right now.
98 AC_DEFUN([KRB5_AC_MAINTAINER_MODE],
99 [AC_ARG_ENABLE([maintainer-mode],
100 AC_HELP_STRING([--enable-maintainer-mode],[enable rebuilding of source files, Makefiles, etc]),
101 USE_MAINTAINER_MODE=$enableval,
102 USE_MAINTAINER_MODE=no)
103 if test "$USE_MAINTAINER_MODE" = yes; then
104 MAINTAINER_MODE_TRUE=
105 MAINTAINER_MODE_FALSE='#'
106 AC_MSG_NOTICE(enabling maintainer mode)
108 MAINTAINER_MODE_TRUE='#'
109 MAINTAINER_MODE_FALSE=
111 MAINT=$MAINTAINER_MODE_TRUE
112 AC_SUBST(MAINTAINER_MODE_TRUE)
113 AC_SUBST(MAINTAINER_MODE_FALSE)
118 AC_DEFUN([KRB5_AC_INITFINI],[
119 dnl Do we want initialization at load time?
120 AC_ARG_ENABLE([delayed-initialization],
121 AC_HELP_STRING([--disable-delayed-initialization],initialize library code when loaded @<:@delay until first use@:>@), , enable_delayed_initialization=yes)
122 case "$enable_delayed_initialization" in
124 AC_DEFINE(DELAY_INITIALIZER,1,[Define if library initialization should be delayed until first use]) ;;
126 *) AC_MSG_ERROR(invalid option $enable_delayed_initialization for delayed-initialization) ;;
128 dnl We always want finalization at unload time.
130 dnl Can we do things through gcc?
132 dnl How about with the linker?
133 if test -z "$use_linker_init_option" ; then
134 AC_MSG_ERROR(ran INITFINI before checking shlib.conf?)
136 if test "$use_linker_init_option" = yes; then
137 AC_DEFINE(USE_LINKER_INIT_OPTION,1,[Define if link-time options for library initialization will be used])
139 if test "$use_linker_fini_option" = yes; then
140 AC_DEFINE(USE_LINKER_FINI_OPTION,1,[Define if link-time options for library finalization will be used])
145 AC_DEFUN([KRB5_AC_FIND_DLOPEN],[
148 AC_SEARCH_LIBS(dlopen, dl, [
149 if test "$ac_cv_search_dlopen" != "none required"; then
150 DL_LIB=$ac_cv_search_dlopen
153 AC_DEFINE(USE_DLOPEN,1,[Define if dlopen should be used])])
159 AC_DEFUN([KRB5_AC_ENABLE_THREADS],[
160 AC_ARG_ENABLE([thread-support],
161 AC_HELP_STRING([--disable-thread-support],don't enable thread support @<:@enabled@:>@), , enable_thread_support=yes)
162 if test "$enable_thread_support" = yes ; then
163 AC_MSG_NOTICE(enabling thread support)
164 AC_DEFINE(ENABLE_THREADS,1,[Define if thread support enabled])
166 dnl Maybe this should be inside the conditional above? Doesn't cache....
167 if test "$enable_thread_support" = yes; then
168 AX_PTHREAD(,[AC_MSG_ERROR([cannot determine options for enabling thread support; try --disable-thread-support])])
169 AC_MSG_NOTICE(PTHREAD_CC = $PTHREAD_CC)
170 AC_MSG_NOTICE(PTHREAD_CFLAGS = $PTHREAD_CFLAGS)
171 AC_MSG_NOTICE(PTHREAD_LIBS = $PTHREAD_LIBS)
172 dnl Not really needed -- if pthread.h isn't found, ACX_PTHREAD will fail.
173 dnl AC_CHECK_HEADERS(pthread.h)
174 # AIX and Tru64 don't support weak references, and don't have
175 # stub versions of the pthread code in libc.
178 # On these platforms, we'll always pull in the thread support.
179 LIBS="$LIBS $PTHREAD_LIBS"
180 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
181 # We don't need to sometimes add the flags we've just folded in...
186 # These are the flags that "gcc -pthread" adds. But we don't
187 # want "-pthread" because that has link-time effects, and we
188 # don't exclude CFLAGS when linking. *sigh*
189 PTHREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_C_SOURCE=199506L"
192 # On Solaris 10 with gcc 3.4.3, the autoconf archive macro doesn't
193 # get the right result. XXX What about Solaris 9 and earlier?
194 if test "$GCC" = yes ; then
195 PTHREAD_CFLAGS="-D_REENTRANT -pthreads"
199 # On Solaris 10 with gcc 3.4.3, the autoconf archive macro doesn't
200 # get the right result.
201 if test "$GCC" = yes ; then
202 PTHREAD_CFLAGS="-D_REENTRANT -pthreads"
204 # On Solaris 10, the thread support is always available in libc.
205 AC_DEFINE(NO_WEAK_PTHREADS,1,[Define if references to pthread routines should be non-weak.])
215 AC_SUBST(THREAD_SUPPORT)
216 dnl We want to know where these routines live, so on systems with weak
217 dnl reference support we can figure out whether or not the pthread library
218 dnl has been linked in.
219 dnl If we don't add any libraries for thread support, don't bother.
220 AC_CHECK_FUNCS(pthread_once pthread_rwlock_init)
222 test "$PTHREAD_CC" != "" && test "$ac_cv_c_compiler_gnu" = no && CC=$PTHREAD_CC
224 # On Solaris, -pthreads is added to CFLAGS, no extra explicit libraries.
225 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
226 AC_SUBST(PTHREAD_CFLAGS)
228 LIBS="$PTHREAD_LIBS $LIBS"
229 AC_MSG_NOTICE(rechecking with PTHREAD_... options)
230 AC_CHECK_LIB(c, pthread_rwlock_init,
231 [AC_DEFINE(HAVE_PTHREAD_RWLOCK_INIT_IN_THREAD_LIB,1,[Define if pthread_rwlock_init is provided in the thread library.])])
237 dnl This is somewhat gross and should go away when the build system
238 dnl is revamped. -- tlyu
239 dnl DECLARE_SYS_ERRLIST - check for sys_errlist in libc
241 AC_DEFUN([DECLARE_SYS_ERRLIST],
242 [AC_CACHE_CHECK([for sys_errlist declaration], krb5_cv_decl_sys_errlist,
243 [AC_TRY_COMPILE([#include <stdio.h>
244 #include <errno.h>], [1+sys_nerr;],
245 krb5_cv_decl_sys_errlist=yes, krb5_cv_decl_sys_errlist=no)])
246 # assume sys_nerr won't be declared w/o being in libc
247 if test $krb5_cv_decl_sys_errlist = yes; then
248 AC_DEFINE(SYS_ERRLIST_DECLARED,1,[Define if sys_errlist is defined in errno.h])
249 AC_DEFINE(HAVE_SYS_ERRLIST,1,[Define if sys_errlist in libc])
251 # This means that sys_errlist is not declared in errno.h, but may still
253 AC_CACHE_CHECK([for sys_errlist in libc], krb5_cv_var_sys_errlist,
254 [AC_TRY_LINK([extern int sys_nerr;], [if (1+sys_nerr < 0) return 1;],
255 krb5_cv_var_sys_errlist=yes, krb5_cv_var_sys_errlist=no;)])
256 if test $krb5_cv_var_sys_errlist = yes; then
257 AC_DEFINE(HAVE_SYS_ERRLIST,1,[Define if sys_errlist in libc])
258 # Do this cruft for backwards compatibility for now.
259 AC_DEFINE(NEED_SYS_ERRLIST,1,[Define if need to declare sys_errlist])
261 AC_MSG_WARN([sys_errlist is neither in errno.h nor in libc])
266 dnl check for sigmask/sigprocmask -- CHECK_SIGPROCMASK
268 AC_DEFUN(CHECK_SIGPROCMASK,[
269 AC_MSG_CHECKING([for use of sigprocmask])
270 AC_CACHE_VAL(krb5_cv_func_sigprocmask_use,
271 [AC_TRY_LINK([#include <signal.h>], [sigprocmask(SIG_SETMASK,0,0);],
272 krb5_cv_func_sigprocmask_use=yes,
273 AC_TRY_LINK([#include <signal.h>], [sigmask(1);],
274 krb5_cv_func_sigprocmask_use=no, krb5_cv_func_sigprocmask_use=yes))])
275 AC_MSG_RESULT($krb5_cv_func_sigprocmask_use)
276 if test $krb5_cv_func_sigprocmask_use = yes; then
277 AC_DEFINE(USE_SIGPROCMASK,1,[Define if sigprocmask should be used])
281 AC_DEFUN(AC_PROG_ARCHIVE, [AC_CHECK_PROG(ARCHIVE, ar, ar cqv, false)])dnl
282 AC_DEFUN(AC_PROG_ARCHIVE_ADD, [AC_CHECK_PROG(ARADD, ar, ar cruv, false)])dnl
284 dnl check for <dirent.h> -- CHECK_DIRENT
285 dnl (may need to be more complex later)
287 AC_DEFUN(CHECK_DIRENT,[
288 AC_CHECK_HEADER(dirent.h,AC_DEFINE(USE_DIRENT_H,1,[Define if you have dirent.h functionality]))])dnl
290 dnl check if union wait is defined, or if WAIT_USES_INT -- CHECK_WAIT_TYPE
292 AC_DEFUN(CHECK_WAIT_TYPE,[
293 AC_MSG_CHECKING([if argument to wait is int *])
294 AC_CACHE_VAL(krb5_cv_struct_wait,
295 dnl Test for prototype clash - if there is none - then assume int * works
296 [AC_TRY_COMPILE([#include <sys/types.h>
297 #include <sys/wait.h>
298 extern pid_t wait(int *);],[], krb5_cv_struct_wait=no,dnl
299 dnl Else fallback on old stuff
301 [#include <sys/wait.h>], [union wait i;
306 krb5_cv_struct_wait=yes, krb5_cv_struct_wait=no)])])
307 AC_MSG_RESULT($krb5_cv_struct_wait)
308 if test $krb5_cv_struct_wait = no; then
309 AC_DEFINE(WAIT_USES_INT,1,[Define if wait takes int as a argument])
313 dnl check for POSIX signal handling -- CHECK_SIGNALS
315 AC_DEFUN(CHECK_SIGNALS,[
316 AC_CHECK_FUNC(sigprocmask,
317 AC_MSG_CHECKING(for sigset_t and POSIX_SIGNALS)
318 AC_CACHE_VAL(krb5_cv_type_sigset_t,
320 [#include <signal.h>],
322 krb5_cv_type_sigset_t=yes, krb5_cv_type_sigset_t=no)])
323 AC_MSG_RESULT($krb5_cv_type_sigset_t)
324 if test $krb5_cv_type_sigset_t = yes; then
325 AC_DEFINE(POSIX_SIGNALS,1,[Define if POSIX signal handling is used])
329 dnl check for signal type
331 dnl AC_RETSIGTYPE isn't quite right, but almost.
332 AC_DEFUN(KRB5_SIGTYPE,[
333 AC_MSG_CHECKING([POSIX signal handlers])
334 AC_CACHE_VAL(krb5_cv_has_posix_signals,
336 [#include <sys/types.h>
341 extern void (*signal ()) ();], [],
342 krb5_cv_has_posix_signals=yes, krb5_cv_has_posix_signals=no)])
343 AC_MSG_RESULT($krb5_cv_has_posix_signals)
344 if test $krb5_cv_has_posix_signals = yes; then
346 AC_DEFINE(POSIX_SIGTYPE, 1, [Define if POSIX signal handlers are used])
348 if test $ac_cv_type_signal = void; then
354 AC_DEFINE_UNQUOTED(krb5_sigtype, $stype, [Define krb5_sigtype to type of signal handler])dnl
357 dnl check for POSIX setjmp/longjmp -- CHECK_SETJMP
359 AC_DEFUN(CHECK_SETJMP,[
360 AC_CHECK_FUNC(sigsetjmp,
361 AC_MSG_CHECKING(for sigjmp_buf)
362 AC_CACHE_VAL(krb5_cv_struct_sigjmp_buf,
364 [#include <setjmp.h>],[sigjmp_buf x],
365 krb5_cv_struct_sigjmp_buf=yes,krb5_cv_struct_sigjmp_buf=no)])
366 AC_MSG_RESULT($krb5_cv_struct_sigjmp_buf)
367 if test $krb5_cv_struct_sigjmp_buf = yes; then
368 AC_DEFINE(POSIX_SETJMP,1,[Define if setjmp indicates POSIX interface])
372 dnl Check for IPv6 compile-time support.
374 AC_DEFUN(KRB5_AC_INET6,[
375 AC_CHECK_HEADERS(sys/types.h sys/socket.h netinet/in.h netdb.h)
376 AC_CHECK_FUNCS(inet_ntop inet_pton getnameinfo)
377 dnl getaddrinfo test needs netdb.h, for proper compilation on alpha
378 dnl under OSF/1^H^H^H^H^HDigital^H^H^H^H^H^H^HTru64 UNIX, where it's
380 AC_MSG_CHECKING(for getaddrinfo)
381 AC_CACHE_VAL(ac_cv_func_getaddrinfo,
382 [AC_TRY_LINK([#ifdef HAVE_NETDB_H
386 getaddrinfo("kerberos.mit.edu", "echo", 0, &ai);
387 ], ac_cv_func_getaddrinfo=yes, ac_cv_func_getaddrinfo=no)])
388 AC_MSG_RESULT($ac_cv_func_getaddrinfo)
389 if test $ac_cv_func_getaddrinfo = yes; then
390 AC_DEFINE(HAVE_GETADDRINFO,1,[Define if you have the getaddrinfo function])
393 AC_REQUIRE([KRB5_SOCKADDR_SA_LEN])dnl
394 AC_MSG_CHECKING(for IPv6 compile-time support without -DINET6)
395 AC_CACHE_VAL(krb5_cv_inet6,[
396 if test "$ac_cv_func_inet_ntop" != "yes" ; then
400 #ifdef HAVE_SYS_TYPES_H
401 #include <sys/types.h>
403 #include <sys/socket.h>
404 #include <netinet/in.h>
407 struct sockaddr_in6 in;
409 IN6_IS_ADDR_LINKLOCAL (&in.sin6_addr);
410 ],krb5_cv_inet6=yes,krb5_cv_inet6=no)])
412 AC_MSG_RESULT($krb5_cv_inet6)
413 if test "$krb5_cv_inet6" = no && test "$ac_cv_func_inet_ntop" = yes; then
414 AC_MSG_CHECKING(for IPv6 compile-time support with -DINET6)
415 AC_CACHE_VAL(krb5_cv_inet6_with_dinet6,[
419 #ifdef HAVE_SYS_TYPES_H
420 #include <sys/types.h>
422 #include <sys/socket.h>
423 #include <netinet/in.h>
426 struct sockaddr_in6 in;
428 IN6_IS_ADDR_LINKLOCAL (&in.sin6_addr);
429 ],krb5_cv_inet6_with_dinet6=yes,krb5_cv_inet6_with_dinet6=no)
431 AC_MSG_RESULT($krb5_cv_inet6_with_dinet6)
433 if test $krb5_cv_inet6 = yes || test "$krb5_cv_inet6_with_dinet6" = yes; then
434 if test "$krb5_cv_inet6_with_dinet6" = yes; then
435 AC_DEFINE(INET6,1,[May need to be defined to enable IPv6 support, for example on IRIX])
440 AC_DEFUN(KRB5_AC_CHECK_FOR_CFLAGS,[
441 AC_BEFORE([$0],[AC_PROG_CC])
442 AC_BEFORE([$0],[AC_PROG_CXX])
443 krb5_ac_cflags_set=${CFLAGS+set}
444 krb5_ac_cxxflags_set=${CXXFLAGS+set}
445 krb5_ac_warn_cflags_set=${WARN_CFLAGS+set}
446 krb5_ac_warn_cxxflags_set=${WARN_CXXFLAGS+set}
449 AC_DEFUN(TRY_WARN_CC_FLAG_1,[dnl
450 cachevar=`echo "krb5_cv_cc_flag_$1" | sed -e s/=/_eq_/g -e s/-/_dash_/g -e s/[[^a-zA-Z0-9_]]/_/g`
451 AC_CACHE_CHECK([if C compiler supports $1], [$cachevar],
452 [# first try without, then with
453 AC_TRY_COMPILE([], 1;,
454 [old_cflags="$CFLAGS"
455 CFLAGS="$CFLAGS $cflags_warning_test_flags $1"
456 AC_TRY_COMPILE([], 1;, eval $cachevar=yes, eval $cachevar=no)
457 CFLAGS="$old_cflags"],
458 [AC_MSG_ERROR(compiling simple test program with $CFLAGS failed)])])
459 if eval test '"${'$cachevar'}"' = yes; then
460 WARN_CFLAGS="$WARN_CFLAGS $1"
462 eval flag_supported='${'$cachevar'}'
465 dnl Are additional flags needed to make unsupported warning options
466 dnl get reported as errors?
467 AC_DEFUN(CHECK_CC_WARNING_TEST_FLAGS,[dnl
468 cflags_warning_test_flags=
469 TRY_WARN_CC_FLAG_1(-Werror=unknown-warning-option)
470 if test $flag_supported = yes; then
471 cflags_warning_test_flags=-Werror=unknown-warning-option
475 AC_DEFUN(TRY_WARN_CC_FLAG,[dnl
476 AC_REQUIRE([CHECK_CC_WARNING_TEST_FLAGS])dnl
477 TRY_WARN_CC_FLAG_1($1)dnl
480 AC_DEFUN(WITH_CC,[dnl
481 AC_REQUIRE([KRB5_AC_CHECK_FOR_CFLAGS])dnl
482 AC_REQUIRE([AC_PROG_CC])dnl
483 AC_REQUIRE([AC_PROG_CXX])dnl
484 if test $ac_cv_c_compiler_gnu = yes ; then
489 AC_CACHE_CHECK([for GNU linker], krb5_cv_prog_gnu_ld,
490 [krb5_cv_prog_gnu_ld=no
491 if test "$GCC" = yes; then
492 if AC_TRY_COMMAND([$CC -Wl,-v 2>&1 dnl
493 | grep "GNU ld" > /dev/null]); then
494 krb5_cv_prog_gnu_ld=yes
497 AC_ARG_WITH([size-optimizations],
498 [ --with-size-optimizations enable a few optimizations to reduce code size
499 possibly at some run-time cost],
502 if test "$withval" = yes; then
503 AC_DEFINE(CONFIG_SMALL,1,[Define to reduce code size even if it means more cpu usage])
505 # -Wno-long-long, if needed, for k5-platform.h without inttypes.h etc.
506 extra_gcc_warn_opts="-Wall -Wcast-align -Wshadow"
507 # -Wmissing-prototypes
508 if test "$GCC" = yes ; then
509 # Putting this here means we get -Os after -O2, which works.
510 if test "$with_size_optimizations" = yes && test "x$krb5_ac_cflags_set" != xset; then
511 AC_MSG_NOTICE(adding -Os optimization option)
513 "-g -O2") CFLAGS="-g -Os" ;;
514 "-O2") CFLAGS="-Os" ;;
515 *) CFLAGS="$CFLAGS -Os" ;;
518 if test "x$krb5_ac_warn_cflags_set" = xset ; then
519 AC_MSG_NOTICE(not adding extra gcc warning flags because WARN_CFLAGS was set)
521 AC_MSG_NOTICE(adding extra warning flags for gcc)
522 WARN_CFLAGS="$WARN_CFLAGS $extra_gcc_warn_opts -Wmissing-prototypes"
523 if test "`uname -s`" = Darwin ; then
524 AC_MSG_NOTICE(skipping pedantic warnings on Darwin)
525 elif test "`uname -s`" = Linux ; then
526 AC_MSG_NOTICE(skipping pedantic warnings on Linux)
528 WARN_CFLAGS="$WARN_CFLAGS -pedantic"
530 if test "$ac_cv_cxx_compiler_gnu" = yes; then
531 if test "x$krb5_ac_warn_cxxflags_set" = xset ; then
532 AC_MSG_NOTICE(not adding extra g++ warnings because WARN_CXXFLAGS was set)
534 AC_MSG_NOTICE(adding extra warning flags for g++)
535 WARN_CXXFLAGS="$WARN_CXXFLAGS $extra_gcc_warn_opts"
538 # Currently, G++ does not support -Wno-format-zero-length.
539 TRY_WARN_CC_FLAG(-Wno-format-zero-length)
540 # Other flags here may not be supported on some versions of
541 # gcc that people want to use.
542 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
543 TRY_WARN_CC_FLAG(-W$flag)
545 # old-style-definition? generates many, many warnings
547 # Warnings that we'd like to turn into errors on versions of gcc
548 # that support promoting only specific warnings to errors, but
549 # we'll take as warnings on older compilers. (If such a warning
550 # is added after the -Werror=foo feature, you can just put
551 # error=foo in the above list, and skip the test for the
552 # warning-only form.) At least in some versions, -Werror= doesn't
553 # seem to make the conditions actual errors, but still issues
554 # warnings; I guess we'll take what we can get.
556 # We're currently targeting C89+, not C99, so disallow some
558 for flag in declaration-after-statement ; do
559 TRY_WARN_CC_FLAG(-Werror=$flag)
560 if test "$flag_supported" = no; then
561 TRY_WARN_CC_FLAG(-W$flag)
564 # We require function declarations now.
566 # In some compiler versions -- e.g., "gcc version 4.2.1 (Apple
567 # Inc. build 5664)" -- the -Werror- option works, but the -Werror=
568 # version doesn't cause implicitly declared functions to be
569 # flagged as errors. If neither works, -Wall implies
570 # -Wimplicit-function-declaration so don't bother.
571 TRY_WARN_CC_FLAG(-Werror-implicit-function-declaration)
572 if test "implicit-function-declaration_supported" = no; then
573 TRY_WARN_CC_FLAG(-Werror=implicit-function-declaration)
577 if test "`uname -s`" = Darwin ; then
578 # Someday this should be a feature test.
579 # One current (Jaguar = OS 10.2) problem:
580 # Archive library with foo.o undef sym X and bar.o common sym X,
581 # if foo.o is pulled in at link time, bar.o may not be, causing
582 # the linker to complain.
583 # Dynamic library problems too?
584 case "$CC $CFLAGS" in
585 *-fcommon*) ;; # why someone would do this, I don't know
586 *-fno-common*) ;; # okay, they're already doing the right thing
588 AC_MSG_NOTICE(disabling the use of common storage on Darwin)
589 CFLAGS="$CFLAGS -fno-common"
592 case "$LD $LDFLAGS" in
593 *-Wl,-search_paths_first*) ;;
594 *) LDFLAGS="${LDFLAGS} -Wl,-search_paths_first" ;;
598 if test "`uname -s`" = AIX ; then
599 # Using AIX but not GCC, assume native compiler.
600 # The native compiler appears not to give a nonzero exit
601 # status for certain classes of errors, like missing arguments
602 # in function calls. Let's try to fix that with -qhalt=e.
603 case "$CC $CFLAGS" in
606 CFLAGS="$CFLAGS -qhalt=e"
607 AC_MSG_NOTICE(adding -qhalt=e for better error reporting)
610 # Also, the optimizer isn't turned on by default, which means
611 # the static inline functions get left in random object files,
612 # leading to references to pthread_mutex_lock from anything that
613 # includes k5-int.h whether it uses threads or not.
614 case "$CC $CFLAGS" in
618 AC_MSG_NOTICE(adding -O for inline thread-support function elimination)
622 if test "`uname -s`" = SunOS ; then
623 # Using Solaris but not GCC, assume Sunsoft compiler.
624 # We have some error-out-on-warning options available.
625 # Sunsoft 12 compiler defaults to -xc99=all, it appears, so "inline"
626 # works, but it also means that declaration-in-code warnings won't
628 # -v -fd -errwarn=E_DECLARATION_IN_CODE ...
629 if test "x$krb5_ac_warn_cflags_set" = xset ; then
630 AC_MSG_NOTICE(not adding extra warning flags because WARN_CFLAGS was set)
632 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"
634 if test "x$krb5_ac_warn_cxxflags_set" = xset ; then
635 AC_MSG_NOTICE(not adding extra warning flags because WARN_CXXFLAGS was set)
637 WARN_CXXFLAGS="-errtags=yes +w +w2 -xport64"
641 AC_SUBST(WARN_CFLAGS)
642 AC_SUBST(WARN_CXXFLAGS)
646 dnl check for yylineno -- HAVE_YYLINENO
648 AC_DEFUN(HAVE_YYLINENO,[dnl
649 AC_REQUIRE_CPP()AC_REQUIRE([AC_PROG_LEX])dnl
650 AC_MSG_CHECKING([for yylineno declaration])
651 AC_CACHE_VAL(krb5_cv_type_yylineno,
652 # some systems have yylineno, others don't...
654 %%' | ${LEX} -t > conftest.out
655 if egrep yylineno conftest.out >/dev/null 2>&1; then
656 krb5_cv_type_yylineno=yes
658 krb5_cv_type_yylineno=no
661 AC_MSG_RESULT($krb5_cv_type_yylineno)
662 if test $krb5_cv_type_yylineno = no; then
663 AC_DEFINE(NO_YYLINENO, 1, [Define if lex produes code with yylineno])
667 dnl K5_GEN_MAKEFILE([dir, [frags]])
669 AC_DEFUN(K5_GEN_MAKEFILE,[dnl
670 ifelse($1, ,[_K5_GEN_MAKEFILE(.,$2)],[_K5_GEN_MAKEFILE($1,$2)])
673 dnl _K5_GEN_MAKEFILE(dir, [frags])
674 dnl dir must be present in this case
675 dnl Note: Be careful in quoting.
676 dnl The ac_foreach generates the list of fragments to include
677 dnl or "" if $2 is empty
678 AC_DEFUN(_K5_GEN_MAKEFILE,[dnl
679 AC_CONFIG_FILES([$1/Makefile:$srcdir/]K5_TOPDIR[/config/pre.in:$1/Makefile.in:$1/deps:$srcdir/]K5_TOPDIR[/config/post.in])
682 dnl K5_GEN_FILE( <ac_output arguments> )
684 AC_DEFUN(K5_GEN_FILE,[AC_CONFIG_FILES($1)])dnl
687 dnl Note: Adds the variables to config.status for individual
688 dnl Makefile generation from config.status
689 AC_DEFUN(K5_AC_OUTPUT,[AC_OUTPUT])dnl
691 dnl V5_AC_OUTPUT_MAKEFILE
693 AC_DEFUN(V5_AC_OUTPUT_MAKEFILE,
694 [ifelse($1, , [_V5_AC_OUTPUT_MAKEFILE(.,$2)],[_V5_AC_OUTPUT_MAKEFILE($1,$2)])])
696 define(_V5_AC_OUTPUT_MAKEFILE,
697 [ifelse($2, , ,AC_CONFIG_FILES($2))
698 AC_FOREACH([DIR], [$1],dnl
699 [AC_CONFIG_FILES(DIR[/Makefile:$srcdir/]K5_TOPDIR[/config/pre.in:]DIR[/Makefile.in:]DIR[/deps:$srcdir/]K5_TOPDIR[/config/post.in])])
703 dnl KRB5_SOCKADDR_SA_LEN: define HAVE_SA_LEN if sockaddr contains the sa_len
706 AC_DEFUN([KRB5_SOCKADDR_SA_LEN],[ dnl
707 AC_CHECK_MEMBER(struct sockaddr.sa_len,
708 AC_DEFINE(HAVE_SA_LEN,1,[Define if struct sockaddr contains sa_len])
709 ,,[#include <sys/types.h>
710 #include <sys/socket.h>])])
715 AC_DEFUN(WITH_NETLIB,[
716 AC_ARG_WITH([netlib],
717 AC_HELP_STRING([--with-netlib=LIBS], use user defined resolver library),
718 [ if test "$withval" = yes -o "$withval" = no ; then
719 AC_MSG_RESULT("netlib will link with C library resolver only")
721 LIBS="$LIBS $withval"
722 AC_MSG_RESULT("netlib will use \'$withval\'")
729 AC_DEFUN(KRB5_AC_NEED_DAEMON, [
730 KRB5_NEED_PROTO([#ifdef HAVE_UNISTD_H
732 #endif],daemon,1)])dnl
735 dnl KRB5_AC_NEED_LIBGEN --- check if libgen needs to be linked in for
739 AC_DEFUN(KRB5_AC_NEED_LIBGEN,[
740 AC_REQUIRE([AC_PROG_CC])dnl
742 dnl regcomp is present but non-functional on Solaris 2.4
744 AC_MSG_CHECKING(for working regcomp)
745 AC_CACHE_VAL(ac_cv_func_regcomp,[
747 #include <sys/types.h>
749 regex_t x; regmatch_t m;
750 int main() { return regcomp(&x,"pat.*",0) || regexec(&x,"pattern",1,&m,0); }
751 ], ac_cv_func_regcomp=yes, ac_cv_func_regcomp=no, AC_MSG_ERROR([Cannot test regcomp when cross compiling]))])
752 AC_MSG_RESULT($ac_cv_func_regcomp)
753 test $ac_cv_func_regcomp = yes && AC_DEFINE(HAVE_REGCOMP,1,[Define if regcomp exists and functions])
755 dnl Check for the compile and step functions - only if regcomp is not available
757 if test $ac_cv_func_regcomp = no; then
760 dnl this will fail if there's no compile/step in -lgen, or if there's
761 dnl no -lgen. This is fine.
762 AC_CHECK_FUNCS(compile step)
765 dnl Set GEN_LIB if necessary
767 AC_CHECK_LIB(gen, compile, GEN_LIB=-lgen, GEN_LIB=)
772 dnl KRB5_AC_REGEX_FUNCS --- check for different regular expression
773 dnl support functions
775 AC_DEFUN(KRB5_AC_REGEX_FUNCS,[
776 AC_CHECK_FUNCS(re_comp re_exec regexec)
777 AC_REQUIRE([KRB5_AC_NEED_LIBGEN])dnl
780 dnl AC_KRB5_TCL_FIND_CONFIG (uses tcl_dir)
782 AC_DEFUN(AC_KRB5_TCL_FIND_CONFIG,[
783 AC_REQUIRE([KRB5_LIB_AUX])dnl
784 AC_MSG_CHECKING(for tclConfig.sh)
785 dnl On Debian, we might be given --with-tcl=/usr, or tclsh might
786 dnl point us to /usr/lib/tcl8.4; either way, we need to find
787 dnl /usr/lib/tcl8.4/tclConfig.sh.
788 dnl On NetBSD, we might be given --with-tcl=/usr/pkg, or tclsh
789 dnl might point us to /usr/pkg/lib/tcl8.4; we need to find
790 dnl /usr/pkg/lib/tclConfig.sh.
791 if test -r "$tcl_dir/lib/tclConfig.sh" ; then
792 tcl_conf="$tcl_dir/lib/tclConfig.sh"
793 elif test -r "$tcl_dir/tclConfig.sh" ; then
794 tcl_conf="$tcl_dir/tclConfig.sh"
795 elif test -r "$tcl_dir/../tclConfig.sh" ; then
796 tcl_conf="$tcl_dir/../tclConfig.sh"
800 changequote(<<,>>)dnl
801 for d in "$lib" "$lib"/tcl7.[0-9] "$lib"/tcl8.[0-9] ; do
802 if test -r "$d/tclConfig.sh" ; then
803 tcl_conf="$tcl_conf $d/tclConfig.sh"
808 if test -n "$tcl_conf" ; then
809 AC_MSG_RESULT($tcl_conf)
811 AC_MSG_RESULT(not found)
816 old_CPPFLAGS=$CPPFLAGS
819 if test -n "$tcl_conf" ; then
820 for file in $tcl_conf ; do
821 TCL_MAJOR_VERSION=x ; TCL_MINOR_VERSION=x
822 AC_MSG_CHECKING(Tcl info in $file)
824 v=$TCL_MAJOR_VERSION.$TCL_MINOR_VERSION
825 if test -z "$tcl_vers_maj" \
826 || test "$tcl_vers_maj" -lt "$TCL_MAJOR_VERSION" \
827 || test "$tcl_vers_maj" = "$TCL_MAJOR_VERSION" -a "$tcl_vers_min" -lt "$TCL_MINOR_VERSION" ; then
828 for incdir in "$TCL_PREFIX/include/tcl$v" "$TCL_PREFIX/include" ; do
829 if test -r "$incdir/tcl.h" -o -r "$incdir/tcl/tcl.h" ; then
830 CPPFLAGS="$old_CPPFLAGS -I$incdir"
834 LIBS="$old_LIBS `eval echo x $TCL_LIB_SPEC $TCL_LIBS | sed 's/^x//'`"
835 LDFLAGS="$old_LDFLAGS $TCL_LD_FLAGS"
836 AC_TRY_LINK( , [Tcl_CreateInterp ();],
838 tcl_vers_maj=$TCL_MAJOR_VERSION
839 tcl_vers_min=$TCL_MINOR_VERSION
840 AC_MSG_RESULT($v - working),
841 AC_MSG_RESULT($v - compilation failed)
844 AC_MSG_RESULT(older version $v)
848 CPPFLAGS=$old_CPPFLAGS
853 if test -n "$tcl_ok_conf" ; then
856 for incdir in "$TCL_PREFIX/include/tcl$v" "$TCL_PREFIX/include" ; do
857 if test -r "$incdir/tcl.h" -o -r "$incdir/tcl/tcl.h" ; then
858 if test "$incdir" != "/usr/include" ; then
859 TCL_INCLUDES=-I$incdir
864 # Need eval because the first-level expansion could reference
865 # variables like ${TCL_DBGX}.
866 eval TCL_LIBS='"'$TCL_LIB_SPEC $TCL_LIBS $TCL_DL_LIBS'"'
867 TCL_LIBPATH="-L$TCL_EXEC_PREFIX/lib"
868 TCL_RPATH=":$TCL_EXEC_PREFIX/lib"
869 if test "$DEPLIBEXT" != "$SHLIBEXT" && test -n "$RPATH_FLAG"; then
870 TCL_MAYBE_RPATH='$(RPATH_FLAG)'"$TCL_EXEC_PREFIX/lib$RPATH_TAIL"
874 CPPFLAGS="$old_CPPFLAGS $TCL_INCLUDES"
875 AC_CHECK_HEADER(tcl.h,AC_DEFINE(HAVE_TCL_H,1,[Define if tcl.h is available]) tcl_header=yes)
876 if test $tcl_header=no; then
877 AC_CHECK_HEADER(tcl/tcl.h,AC_DEFINE(HAVE_TCL_TCL_H,1,[Define if tcl/tcl.h is available]) tcl_header=yes)
879 CPPFLAGS="$old_CPPFLAGS"
882 # If we read a tclConfig.sh file, it probably set this.
885 AC_SUBST(TCL_INCLUDES)
887 AC_SUBST(TCL_LIBPATH)
889 AC_SUBST(TCL_MAYBE_RPATH)
892 dnl AC_KRB5_TCL_TRYOLD
893 dnl attempt to use old search algorithm for locating tcl
895 AC_DEFUN(AC_KRB5_TCL_TRYOLD, [
896 AC_REQUIRE([KRB5_AC_FIND_DLOPEN])
897 AC_MSG_WARN([trying old tcl search code])
898 if test "$with_tcl" != yes -a "$with_tcl" != no; then
899 TCL_INCLUDES=-I$with_tcl/include
900 TCL_LIBPATH=-L$with_tcl/lib
901 TCL_RPATH=:$with_tcl/lib
903 if test "$with_tcl" != no ; then
904 krb5_save_CPPFLAGS="$CPPFLAGS"
905 krb5_save_LDFLAGS="$LDFLAGS"
906 CPPFLAGS="$CPPFLAGS $TCL_INCLUDES"
907 LDFLAGS="$LDFLAGS $TCL_LIBPATH"
909 AC_CHECK_HEADER(tcl.h,AC_DEFINE(HAVE_TCL_H,1,[Define if tcl.h found]) tcl_header=yes)
910 if test $tcl_header=no; then
911 AC_CHECK_HEADER(tcl/tcl.h,AC_DEFINE(HAVE_TCL_TCL_H,1,[Define if tcl/tcl.h found]) tcl_header=yes)
914 if test $tcl_header = yes ; then
917 if test $tcl_lib = no; then
918 AC_CHECK_LIB(tcl8.0, Tcl_CreateCommand,
919 TCL_LIBS="$TCL_LIBS -ltcl8.0 -lm $DL_LIB $LIBS"
920 tcl_lib=yes,,-lm $DL_LIB)
922 if test $tcl_lib = no; then
923 AC_CHECK_LIB(tcl7.6, Tcl_CreateCommand,
924 TCL_LIBS="$TCL_LIBS -ltcl7.6 -lm $DL_LIB $LIBS"
925 tcl_lib=yes,,-lm $DL_LIB)
927 if test $tcl_lib = no; then
928 AC_CHECK_LIB(tcl7.5, Tcl_CreateCommand,
929 TCL_LIBS="$TCL_LIBS -ltcl7.5 -lm $DL_LIB $LIBS"
930 tcl_lib=yes,,-lm $DL_LIB)
933 if test $tcl_lib = no ; then
934 AC_CHECK_LIB(tcl, Tcl_CreateCommand,
935 TCL_LIBS="$TCL_LIBS -ltcl -lm $DL_LIB $LIBS"
936 tcl_lib=yes,,-lm $DL_LIB)
939 if test $tcl_lib = no ; then
940 AC_MSG_WARN("tcl.h found but not library")
943 AC_MSG_WARN(Could not find Tcl which is needed for the kadm5 tests)
946 CPPFLAGS="$krb5_save_CPPFLAGS"
947 LDFLAGS="$krb5_save_LDFLAGS"
948 AC_SUBST(TCL_INCLUDES)
950 AC_SUBST(TCL_LIBPATH)
953 AC_MSG_RESULT("Not looking for Tcl library")
957 dnl AC_KRB5_TCL - determine if the TCL library is present on system
959 AC_DEFUN(AC_KRB5_TCL,[
967 [ --with-tcl=path where Tcl resides], , with_tcl=try)
968 if test "$with_tcl" = no ; then
970 elif test "$with_tcl" = yes -o "$with_tcl" = try ; then
972 if test ! -r /usr/lib/tclConfig.sh; then
973 cat >> conftest <<\EOF
974 puts "tcl_dir=$tcl_library"
976 if tclsh conftest >conftest.out 2>/dev/null; then
977 if grep tcl_dir= conftest.out >/dev/null 2>&1; then
978 t=`sed s/tcl_dir=// conftest.out`
981 fi # tclsh ran script okay
982 rm -f conftest conftest.out
983 fi # no /usr/lib/tclConfig.sh
987 if test "$with_tcl" != no ; then
988 AC_KRB5_TCL_FIND_CONFIG
989 if test $tcl_lib = no ; then
990 if test "$with_tcl" != try ; then
993 AC_MSG_WARN(Could not find Tcl which is needed for some tests)
997 # If "yes" or pathname, error out if not found.
998 if test "$with_tcl" != no -a "$with_tcl" != try ; then
999 if test "$tcl_header $tcl_lib" != "yes yes" ; then
1000 AC_MSG_ERROR(Could not find Tcl)
1008 AC_DEFUN(WITH_HESIOD,
1009 [AC_ARG_WITH(hesiod, AC_HELP_STRING(--with-hesiod[=path], compile with hesiod support @<:@omitted@:>@),
1010 hesiod=$with_hesiod, with_hesiod=no)
1011 if test "$with_hesiod" != "no"; then
1012 HESIOD_DEFS=-DHESIOD
1013 AC_CHECK_LIB(resolv, res_send, res_lib=-lresolv)
1014 if test "$hesiod" != "yes"; then
1015 HESIOD_LIBS="-L${hesiod}/lib -lhesiod $res_lib"
1017 HESIOD_LIBS="-lhesiod $res_lib"
1023 AC_SUBST(HESIOD_DEFS)
1024 AC_SUBST(HESIOD_LIBS)])
1028 dnl KRB5_BUILD_LIBRARY
1030 dnl Pull in the necessary stuff to create the libraries.
1032 AC_DEFUN(KRB5_BUILD_LIBRARY,
1033 [AC_REQUIRE([KRB5_LIB_AUX])dnl
1034 AC_REQUIRE([AC_PROG_LN_S])dnl
1035 AC_REQUIRE([AC_PROG_RANLIB])dnl
1036 AC_REQUIRE([AC_PROG_ARCHIVE])dnl
1037 AC_REQUIRE([AC_PROG_ARCHIVE_ADD])dnl
1038 AC_REQUIRE([AC_PROG_INSTALL])dnl
1039 AC_CHECK_PROG(AR, ar, ar, false)
1040 if test "$AR" = "false"; then
1041 AC_MSG_ERROR([ar not found in PATH])
1043 AC_CHECK_PROG(PERL, perl, perl, false)
1044 if test "$ac_cv_prog_PERL" = "false"; then
1045 AC_MSG_ERROR(Perl is now required for Kerberos builds.)
1050 AC_SUBST(PLUGINLINK)
1051 AC_SUBST(PLUGININST)
1052 AC_SUBST(KDB5_PLUGIN_DEPLIBS)
1053 AC_SUBST(KDB5_PLUGIN_LIBS)
1054 AC_SUBST(MAKE_SHLIB_COMMAND)
1055 AC_SUBST(SHLIB_RPATH_FLAGS)
1056 AC_SUBST(SHLIB_EXPFLAGS)
1057 AC_SUBST(SHLIB_EXPORT_FILE_DEP)
1058 AC_SUBST(DYNOBJ_EXPDEPS)
1059 AC_SUBST(DYNOBJ_EXPFLAGS)
1060 AC_SUBST(INSTALL_SHLIB)
1067 AC_SUBST(LIBINSTLIST)
1069 AC_SUBST(MAKE_DYNOBJ_COMMAND)
1070 AC_SUBST(UNDEF_CHECK)
1074 dnl KRB5_BUILD_LIBOBJS
1076 dnl Pull in the necessary stuff to build library objects.
1078 AC_DEFUN(KRB5_BUILD_LIBOBJS,
1079 [AC_REQUIRE([KRB5_LIB_AUX])dnl
1085 AC_SUBST(PROFFLAGS)])
1088 dnl KRB5_BUILD_PROGRAM
1090 dnl Set variables to build a program.
1092 AC_DEFUN(KRB5_BUILD_PROGRAM,
1093 [AC_REQUIRE([KRB5_LIB_AUX])dnl
1094 AC_REQUIRE([KRB5_AC_NEED_LIBGEN])dnl
1097 AC_SUBST(RPATH_FLAG)
1098 AC_SUBST(PROG_RPATH_FLAGS)
1099 AC_SUBST(DEPLIBEXT)])
1104 dnl Set up environment for running dynamic executables out of build tree
1106 AC_DEFUN(KRB5_RUN_FLAGS,
1107 [AC_REQUIRE([KRB5_LIB_AUX])dnl
1108 KRB5_RUN_ENV="$RUN_ENV"
1109 KRB5_RUN_VARS="$RUN_VARS"
1110 AC_SUBST(KRB5_RUN_ENV)
1111 AC_SUBST(KRB5_RUN_VARS)])
1116 dnl Parse configure options related to library building.
1118 AC_DEFUN(KRB5_LIB_AUX,
1119 [AC_REQUIRE([KRB5_LIB_PARAMS])dnl
1121 AC_ARG_ENABLE([static],,, [enable_static=no])
1122 AC_ARG_ENABLE([shared],,, [enable_shared=yes])
1124 if test "x$enable_static" = "x$enable_shared"; then
1125 AC_MSG_ERROR([--enable-static must be specified with --disable-shared])
1128 AC_ARG_ENABLE([rpath],
1129 AC_HELP_STRING([--disable-rpath],[suppress run path flags in link lines]),,
1132 if test "x$enable_rpath" != xyes ; then
1133 # Unset the rpath flag values set by shlib.conf
1139 if test "$SHLIBEXT" = ".so-nobuild"; then
1140 AC_MSG_ERROR([Shared libraries are not yet supported on this platform.])
1145 if test "x$enable_static" = xyes; then
1146 AC_MSG_NOTICE([using static libraries])
1147 LIBLIST='lib$(LIBBASE)$(STLIBEXT)'
1148 LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(STLIBEXT)'
1149 PLUGIN='libkrb5_$(LIBBASE)$(STLIBEXT)'
1150 PLUGINLINK='$(TOPLIBD)/libkrb5_$(LIBBASE)$(STLIBEXT)'
1151 PLUGININST=install-static
1153 LIBINSTLIST=install-static
1155 AC_DEFINE([STATIC_PLUGINS], 1, [Define for static plugin linkage])
1157 KDB5_PLUGIN_DEPLIBS='$(TOPLIBD)/libkrb5_db2$(DEPLIBEXT)'
1158 KDB5_PLUGIN_LIBS='-lkrb5_db2'
1159 if test "x$OPENLDAP_PLUGIN" = xyes; then
1160 KDB5_PLUGIN_DEBLIBS=$KDB5_PLUGIN_DEPLIBS' $(TOPLIBD)/libkrb5_ldap$(DEPLIBEXT) $(TOPLIBD)/libkdb_ldap$(DEPLIBEXT)'
1161 KDB5_PLUGIN_LIBS=$KDB5_PLUGIN_LIBS' -lkrb5_kldap -lkdb_ldap $(LDAP_LIBS)'
1163 # kadm5srv_mit normally comes before kdb on the link line. Add it
1164 # again after the KDB plugins, since they depend on it for XDR stuff.
1165 KDB5_PLUGIN_DEPLIBS=$KDB5_PLUGIN_DEPLIBS' $(TOPLIBD)/libkadm5srv_mit$(DEPLIBEXT)'
1166 KDB5_PLUGIN_LIBS=$KDB5_PLUGIN_LIBS' -lkadm5srv_mit'
1168 # avoid duplicate rules generation for AIX and such
1169 SHLIBEXT=.so-nobuild
1170 SHLIBVEXT=.so.v-nobuild
1171 SHLIBSEXT=.so.s-nobuild
1173 AC_MSG_NOTICE([using shared libraries])
1175 # Clear some stuff in case of AIX, etc.
1176 if test "$STLIBEXT" = "$SHLIBEXT" ; then
1179 case "$SHLIBSEXT" in
1181 LIBLIST='lib$(LIBBASE)$(SHLIBEXT)'
1182 LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(SHLIBEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBVEXT)'
1183 LIBINSTLIST="install-shared"
1186 LIBLIST='lib$(LIBBASE)$(SHLIBEXT) lib$(LIBBASE)$(SHLIBSEXT)'
1187 LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(SHLIBEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBVEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBSEXT)'
1188 LIBINSTLIST="install-shlib-soname"
1192 PLUGIN='$(LIBBASE)$(DYNOBJEXT)'
1193 PLUGINLINK='../$(PLUGIN)'
1194 PLUGININST=install-plugin
1195 KDB5_PLUGIN_DEPLIBS=
1198 CC_LINK="$CC_LINK_SHARED"
1199 CXX_LINK="$CXX_LINK_SHARED"
1201 if test -z "$LIBLIST"; then
1202 AC_MSG_ERROR([must enable one of shared or static libraries])
1205 # Check whether to build profiled libraries.
1206 AC_ARG_ENABLE([profiled],
1207 dnl [ --enable-profiled build profiled libraries @<:@disabled@:>@]
1209 [if test "$enableval" = yes; then
1210 AC_MSG_ERROR([Sorry, profiled libraries do not work in this release.])
1216 dnl Determine parameters related to libraries, e.g. various extensions.
1218 AC_DEFUN(KRB5_LIB_PARAMS,
1219 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
1221 AC_SUBST(krb5_cv_host)
1222 AC_REQUIRE([AC_PROG_CC])dnl
1223 AC_REQUIRE([V5_SET_TOPDIR])dnl
1224 . $ac_topdir/config/shlib.conf])
1226 dnl The following was written by jhawk@mit.edu
1228 dnl AC_LIBRARY_NET: Id: net.m4,v 1.4 1997/10/25 20:49:53 jhawk Exp
1230 dnl This test is for network applications that need socket() and
1231 dnl gethostbyname() -ish functions. Under Solaris, those applications need to
1232 dnl link with "-lsocket -lnsl". Under IRIX, they should *not* link with
1233 dnl "-lsocket" because libsocket.a breaks a number of things (for instance:
1234 dnl gethostbyname() under IRIX 5.2, and snoop sockets under most versions of
1237 dnl Unfortunately, many application developers are not aware of this, and
1238 dnl mistakenly write tests that cause -lsocket to be used under IRIX. It is
1239 dnl also easy to write tests that cause -lnsl to be used under operating
1240 dnl systems where neither are necessary (or useful), such as SunOS 4.1.4, which
1241 dnl uses -lnsl for TLI.
1243 dnl This test exists so that every application developer does not test this in
1244 dnl a different, and subtly broken fashion.
1246 dnl It has been argued that this test should be broken up into two seperate
1247 dnl tests, one for the resolver libraries, and one for the libraries necessary
1248 dnl for using Sockets API. Unfortunately, the two are carefully intertwined and
1249 dnl allowing the autoconf user to use them independantly potentially results in
1250 dnl unfortunate ordering dependancies -- as such, such component macros would
1251 dnl have to carefully use indirection and be aware if the other components were
1252 dnl executed. Since other autoconf macros do not go to this trouble, and almost
1253 dnl no applications use sockets without the resolver, this complexity has not
1254 dnl been implemented.
1256 dnl The check for libresolv is in case you are attempting to link statically
1257 dnl and happen to have a libresolv.a lying around (and no libnsl.a).
1259 AC_DEFUN(AC_LIBRARY_NET, [
1260 # Most operating systems have gethostbyname() in the default searched
1261 # libraries (i.e. libc):
1262 AC_CHECK_FUNC(gethostbyname, , [
1263 # Some OSes (eg. Solaris) place it in libnsl:
1264 AC_CHECK_LIB(nsl, gethostbyname, , [
1265 # Some strange OSes (SINIX) have it in libsocket:
1266 AC_CHECK_LIB(socket, gethostbyname, , [
1267 # Unfortunately libsocket sometimes depends on libnsl.
1268 # AC_CHECK_LIB's API is essentially broken so the following
1269 # ugliness is necessary:
1270 AC_CHECK_LIB(socket, gethostbyname,
1271 LIBS="-lsocket -lnsl $LIBS",
1272 [AC_CHECK_LIB(resolv, gethostbyname,
1273 LIBS="-lresolv $LIBS" )],
1278 AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
1279 AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl)))
1281 if test "$enable_dns" = yes ; then
1282 # We assume that if libresolv exists we can link against it.
1283 # This may get us a gethostby* that doesn't respect nsswitch.
1284 AC_CHECK_LIB(resolv, main)
1286 _KRB5_AC_CHECK_RES_FUNCS(res_ninit res_nclose res_ndestroy res_nsearch dnl
1287 ns_initparse ns_name_uncompress dn_skipname res_search)
1288 if test $krb5_cv_func_res_nsearch = no \
1289 && test $krb5_cv_func_res_search = no; then
1290 # Attempt to link with res_search(), in case it's not prototyped.
1291 AC_CHECK_FUNC(res_search,
1292 [AC_DEFINE(HAVE_RES_SEARCH, 1,
1293 [Define to 1 if you have the `res_search' function])],
1294 [AC_ERROR([cannot find res_nsearch or res_search])])
1298 AC_DEFUN([_KRB5_AC_CHECK_RES_FUNCS],
1299 [AC_FOREACH([AC_Func], [$1],
1300 [AH_TEMPLATE(AS_TR_CPP(HAVE_[]AC_Func),
1301 [Define to 1 if you have the `]AC_Func[' function.])])dnl
1302 for krb5_func in $1; do
1303 _KRB5_AC_CHECK_RES_FUNC($krb5_func)
1306 AC_DEFUN([_KRB5_AC_CHECK_RES_FUNC], [
1307 # Solaris 9 prototypes ns_name_uncompress() in arpa/nameser.h, but
1308 # doesn't export it from libresolv.so, so we use extreme paranoia here
1309 # and check both for the declaration and that we can link against the
1311 AC_CACHE_CHECK([for $1], [krb5_cv_func_$1], [AC_TRY_LINK(
1312 [#include <sys/types.h>
1313 #include <netinet/in.h>
1314 #include <arpa/nameser.h>
1315 @%:@include <resolv.h>],
1317 * Use volatile, or else optimization can cause false positives.
1319 void (* volatile p)() = (void (*)())$1;],
1320 [AS_VAR_SET(krb5_cv_func_$1, yes)],
1321 [AS_VAR_SET(krb5_cv_func_$1, no)])])
1322 AS_IF([test AS_VAR_GET(krb5_cv_func_$1) = yes],
1323 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]), 1,
1324 [Define to 1 if you have the `$1' function])])[]dnl
1328 dnl KRB5_AC_ENABLE_DNS
1330 AC_DEFUN(KRB5_AC_ENABLE_DNS, [
1332 AC_ARG_ENABLE([dns-for-realm],
1333 [ --enable-dns-for-realm enable DNS lookups of Kerberos realm names], ,
1334 [enable_dns_for_realm=no])
1335 if test "$enable_dns_for_realm" = yes; then
1336 AC_DEFINE(KRB5_DNS_LOOKUP_REALM,1,[Define to enable DNS lookups of Kerberos realm names])
1339 AC_DEFINE(KRB5_DNS_LOOKUP, 1,[Define for DNS support of locating realms and KDCs])
1344 dnl Check if we need the prototype for a function - we give it a bogus
1345 dnl prototype and if it complains - then a valid prototype exists on the
1348 dnl KRB5_NEED_PROTO(includes, function, [bypass])
1349 dnl if $3 set, don't see if library defined.
1350 dnl Useful for case where we will define in libkrb5 the function if need be
1351 dnl but want to know if a prototype exists in either case on system.
1353 AC_DEFUN([KRB5_NEED_PROTO], [
1354 ifelse([$3], ,[if test "x$ac_cv_func_$2" = xyes; then])
1355 AC_CACHE_CHECK([if $2 needs a prototype provided], krb5_cv_func_$2_noproto,
1356 AC_TRY_COMPILE([$1],
1358 struct k5foo {int foo; } xx;
1359 extern int $2 (struct k5foo*);
1362 krb5_cv_func_$2_noproto=yes,krb5_cv_func_$2_noproto=no))
1363 if test $krb5_cv_func_$2_noproto = yes; then
1364 AC_DEFINE([NEED_]translit($2, [a-z], [A-Z])[_PROTO], 1, dnl
1365 [define if the system header files are missing prototype for $2()])
1370 dnl =============================================================
1371 dnl Internal function for testing for getpeername prototype
1373 AC_DEFUN([KRB5_GETPEERNAME_ARGS],[
1374 AC_DEFINE([GETPEERNAME_ARG3_TYPE],GETSOCKNAME_ARG3_TYPE,[Type of getpeername second argument.])
1377 dnl =============================================================
1378 dnl Internal function for testing for getsockname arguments
1380 AC_DEFUN([TRY_GETSOCK_INT],[
1381 krb5_lib_var=`echo "$1 $2" | sed 'y% ./+-*%___p_p%'`
1382 AC_MSG_CHECKING([if getsockname() takes arguments $1 and $2])
1383 AC_CACHE_VAL(krb5_cv_getsockname_proto_$krb5_lib_var,
1385 AC_TRY_COMPILE([#include <sys/types.h>
1386 #include <sys/socket.h>
1387 extern int getsockname(int, $1, $2);
1388 ],,eval "krb5_cv_getsockname_proto_$krb5_lib_var=yes",
1389 eval "krb5_cv_getsockname_proto_$krb5_lib_var=no")])
1390 if eval "test \"`echo '$krb5_cv_getsockname_proto_'$krb5_lib_var`\" = yes"; then
1392 sock_set=yes; res1="$1"; res2="$2"
1398 dnl Determines the types of the second and third arguments to getsockname().
1400 AC_DEFUN([KRB5_GETSOCKNAME_ARGS],[
1402 for sock_arg1 in "struct sockaddr *" "void *"
1404 for sock_arg2 in "size_t *" "int *" "socklen_t *"
1406 if test $sock_set = no; then
1407 TRY_GETSOCK_INT($sock_arg1, $sock_arg2)
1411 if test "$sock_set" = no; then
1412 AC_MSG_NOTICE(assuming struct sockaddr and socklen_t for getsockname args)
1413 res1="struct sockaddr *"
1416 res1=`echo "$res1" | tr -d '*' | sed -e 's/ *$//'`
1417 res2=`echo "$res2" | tr -d '*' | sed -e 's/ *$//'`
1418 AC_DEFINE_UNQUOTED([GETSOCKNAME_ARG3_TYPE],$res2,[Type of pointer target for argument 3 to getsockname])
1422 AC_DEFUN([KRB5_AC_CHOOSE_ET],[
1423 AC_ARG_WITH([system-et],
1424 AC_HELP_STRING(--with-system-et,use system compile_et and -lcom_err @<:@default: build and install a local version@:>@))
1425 AC_MSG_CHECKING(which version of com_err to use)
1426 if test "x$with_system_et" = xyes ; then
1427 # This will be changed to "intlsys" if textdomain support is present.
1429 AC_MSG_RESULT(system)
1434 if test $COM_ERR_VERSION = sys; then
1435 # check for various functions we need
1436 AC_CHECK_LIB(com_err, add_error_table, :, AC_MSG_ERROR(cannot find add_error_table in com_err library))
1437 AC_CHECK_LIB(com_err, remove_error_table, :, AC_MSG_ERROR(cannot find remove_error_table in com_err library))
1438 # make sure compile_et provides "et_foo" name
1439 cat >> conf$$e.et <<EOF
1441 error_code ERR_FOO, "foo"
1444 AC_CHECK_PROGS(compile_et,compile_et,false)
1445 if test "$compile_et" = false; then
1446 AC_MSG_ERROR(cannot find compile_et)
1448 AC_CACHE_CHECK(whether compile_et is useful,krb5_cv_compile_et_useful,[
1449 if compile_et conf$$e.et >/dev/null 2>&1 ; then true ; else
1450 AC_MSG_ERROR(execution failed)
1452 AC_TRY_COMPILE([#include "conf$$e.h"
1453 ],[ &et_foo_error_table; ],:,
1454 [AC_MSG_ERROR(cannot use et_foo_error_table)])
1455 # Anything else we need to test for?
1456 rm -f conf$$e.c conf$$e.h
1457 krb5_cv_compile_et_useful=yes
1459 AC_CACHE_CHECK(whether compile_et supports --textdomain,
1460 krb5_cv_compile_et_textdomain,[
1461 krb5_cv_compile_et_textdomain=no
1462 if compile_et --textdomain=xyzw conf$$e.et >/dev/null 2>&1 ; then
1463 if grep -q xyzw conf$$e.c; then
1464 krb5_cv_compile_et_textdomain=yes
1467 rm -f conf$$e.c conf$$e.h
1469 if test "$krb5_cv_compile_et_textdomain" = yes; then
1470 COM_ERR_VERSION=intlsys
1474 AC_SUBST(COM_ERR_VERSION)
1475 if test "$COM_ERR_VERSION" = k5 -o "$COM_ERR_VERSION" = intlsys; then
1476 AC_DEFINE(HAVE_COM_ERR_INTL,1,
1477 [Define if com_err has compatible gettext support])
1480 AC_DEFUN([KRB5_AC_CHOOSE_SS],[
1481 AC_ARG_WITH(system-ss,
1482 AC_HELP_STRING(--with-system-ss,use system -lss and mk_cmds @<:@private version@:>@))
1483 AC_ARG_VAR(SS_LIB,[system libraries for 'ss' package [-lss]])
1484 AC_MSG_CHECKING(which version of subsystem package to use)
1485 if test "x$with_system_ss" = xyes ; then
1487 AC_MSG_RESULT(system)
1488 # todo: check for various libraries we might need
1489 # in the meantime...
1490 test "x${SS_LIB+set}" = xset || SS_LIB=-lss
1492 LIBS="$LIBS $SS_LIB"
1493 AC_CACHE_CHECK(whether system ss package works, krb5_cv_system_ss_okay,[
1496 int main(int argc, char *argv[]) {
1499 i = ss_create_invocation("foo","foo","",0,&err);
1503 }], krb5_cv_system_ss_okay=yes, AC_MSG_ERROR(cannot run test program),
1504 krb5_cv_system_ss_okay="assumed")])
1506 KRB5_NEED_PROTO([#include <ss/ss.h>],ss_execute_command,1)
1512 AC_SUBST(SS_VERSION)
1515 AC_DEFUN([KRB5_AC_CHOOSE_DB],[
1516 AC_ARG_WITH(system-db,
1517 AC_HELP_STRING(--with-system-db,use system Berkeley db @<:@private version@:>@))
1518 AC_ARG_VAR(DB_HEADER,[header file for system Berkeley db package [db.h]])
1519 AC_ARG_VAR(DB_LIB,[library for system Berkeley db package [-ldb]])
1520 if test "x$with_system_db" = xyes ; then
1522 # TODO: Do we have specific routines we should check for?
1523 # How about known, easily recognizable bugs?
1524 # We want to use bt_rseq in some cases, but no other version but
1525 # ours has it right now.
1527 # Okay, check the variables.
1528 test "x${DB_HEADER+set}" = xset || DB_HEADER=db.h
1529 test "x${DB_LIB+set}" = xset || DB_LIB=-ldb
1531 if test "x${DB_HEADER}" = xdb.h ; then
1532 DB_HEADER_VERSION=sys
1534 DB_HEADER_VERSION=redirect
1536 KDB5_DB_LIB="$DB_LIB"
1539 AC_DEFINE(HAVE_BT_RSEQ,1,[Define if bt_rseq is available, for recursive btree traversal.])
1541 DB_HEADER_VERSION=k5
1542 # libdb gets sucked into libkdb
1544 # needed for a couple of things that need libdb for its own sake
1547 AC_SUBST(DB_VERSION)
1549 AC_SUBST(DB_HEADER_VERSION)
1551 AC_SUBST(KDB5_DB_LIB)
1554 dnl KRB5_AC_PRIOCNTL_HACK
1557 AC_DEFUN([KRB5_AC_PRIOCNTL_HACK],
1558 [AC_REQUIRE([AC_PROG_AWK])dnl
1559 AC_REQUIRE([AC_LANG_COMPILER_REQUIRE])dnl
1560 AC_CACHE_CHECK([whether to use priocntl hack], [krb5_cv_priocntl_hack],
1561 [case $krb5_cv_host in
1563 if test "$cross_compiling" = yes; then
1564 krb5_cv_priocntl_hack=yes
1566 # Solaris patch 117171-11 (sparc) or 117172-11 (x86)
1567 # fixes the Solaris 9 bug where final pty output
1568 # gets lost on close.
1569 if showrev -p | $AWK 'BEGIN { e = 1 }
1570 /Patch: 11717[[12]]/ { x = index[]([$]2, "-");
1571 if (substr[]([$]2, x + 1, length([$]2) - x) >= 11)
1572 { e = 0 } else { e = 1 } }
1573 END { exit e; }'; then
1574 krb5_cv_priocntl_hack=no
1576 krb5_cv_priocntl_hack=yes
1581 krb5_cv_priocntl_hack=no
1584 if test "$krb5_cv_priocntl_hack" = yes; then
1589 AC_SUBST(PRIOCNTL_HACK)])
1592 dnl KRB5_AC_GCC_ATTRS
1593 AC_DEFUN([KRB5_AC_GCC_ATTRS],
1594 [AC_CACHE_CHECK([for constructor/destructor attribute support],krb5_cv_attr_constructor_destructor,
1595 [rm -f conftest.1 conftest.2
1596 if test -r conftest.1 || test -r conftest.2 ; then
1597 AC_MSG_ERROR(write error in local file system?)
1601 if test -r conftest.1 && test -r conftest.2 ; then true ; else
1602 AC_MSG_ERROR(write error in local file system?)
1606 # blindly assume we have 'unlink'...
1607 AC_TRY_RUN([void foo1() __attribute__((constructor));
1608 void foo1() { unlink("conftest.1"); }
1609 void foo2() __attribute__((destructor));
1610 void foo2() { unlink("conftest.2"); }
1611 int main () { return 0; }],
1612 [test -r conftest.1 || a=yes
1613 test -r conftest.2 || b=yes], , AC_MSG_ERROR(Cannot test for constructor/destructor support when cross compiling))
1614 case $krb5_cv_host in
1616 # Under AIX 4.3.3, at least, shared library destructor functions
1617 # appear to get executed in reverse link order (right to left),
1618 # so that a library's destructor function may run after that of
1619 # libraries it depends on, and may still have to access in the
1622 # That counts as "not working", for me, but it's a much more
1623 # complicated test case to set up.
1627 krb5_cv_attr_constructor_destructor="$a,$b"
1629 # Okay, krb5_cv_... should be set now.
1630 case $krb5_cv_attr_constructor_destructor in
1632 AC_DEFINE(CONSTRUCTOR_ATTR_WORKS,1,[Define if __attribute__((constructor)) works]) ;;
1634 case $krb5_cv_attr_constructor_destructor in
1636 AC_DEFINE(DESTRUCTOR_ATTR_WORKS,1,[Define if __attribute__((destructor)) works]) ;;
1638 dnl End of attributes we care about right now.
1642 dnl KRB5_AC_PRAGMA_WEAK_REF
1643 AC_DEFUN([KRB5_AC_PRAGMA_WEAK_REF],
1644 [AC_CACHE_CHECK([whether pragma weak references are supported],
1645 krb5_cv_pragma_weak_ref,
1646 [AC_TRY_LINK([#pragma weak flurbl
1647 extern int flurbl(void);],[if (&flurbl != 0) return flurbl();],
1648 krb5_cv_pragma_weak_ref=yes,krb5_cv_pragma_weak_ref=no)])
1649 if test $krb5_cv_pragma_weak_ref = yes ; then
1650 AC_DEFINE(HAVE_PRAGMA_WEAK_REF,1,[Define if #pragma weak references work])
1654 m4_include(config/ac-archive/ax_pthread.m4)
1655 m4_include(config/ac-archive/ax_recursive_eval.m4)
1656 m4_include(config/pkg.m4)
1660 dnl --with-ldap=value
1662 AC_DEFUN(WITH_LDAP,[
1664 [ --with-ldap compile OpenLDAP database backend module],
1666 OPENLDAP) with_ldap=yes ;;
1668 *) AC_MSG_ERROR(Invalid option value --with-ldap="$withval") ;;
1669 esac], with_ldap=no)dnl
1671 if test "$with_ldap" = yes; then
1672 AC_MSG_NOTICE(enabling OpenLDAP database backend module support)
1677 dnl If libkeyutils exists (on Linux) include it and use keyring ccache
1678 AC_DEFUN(KRB5_AC_KEYRING_CCACHE,[
1679 AC_CHECK_HEADERS([keyutils.h],
1680 AC_CHECK_LIB(keyutils, add_key,
1681 [dnl Pre-reqs were found
1682 AC_DEFINE(USE_KEYRING_CCACHE, 1, [Define if the keyring ccache should be enabled])
1683 LIBS="-lkeyutils $LIBS"
1687 dnl If libkeyutils supports persistent keyrings, use them
1688 AC_DEFUN(KRB5_AC_PERSISTENT_KEYRING,[
1689 AC_CHECK_HEADERS([keyutils.h],
1690 AC_CHECK_LIB(keyutils, keyctl_get_persistent,
1691 [AC_DEFINE(HAVE_PERSISTENT_KEYRING, 1,
1692 [Define if persistent keyrings are supported])