1AC_PREREQ(2.63) 2AC_COPYRIGHT([Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 3Massachusetts Institute of Technology. 4]) 5dnl 6define([K5_TOPDIR],[.])dnl 7dnl 8AC_DEFUN(V5_SET_TOPDIR,[dnl 9ac_reltopdir="K5_TOPDIR" 10if test ! -r "$srcdir/K5_TOPDIR/aclocal.m4"; then 11 AC_MSG_ERROR([Configure could not determine the relative topdir]) 12fi 13ac_topdir=$srcdir/$ac_reltopdir 14ac_config_fragdir=$ac_reltopdir/config 15# echo "Looking for $srcdir/$ac_config_fragdir" 16AC_CONFIG_AUX_DIR(K5_TOPDIR/config) 17])dnl 18dnl 19dnl Version info. 20dnl 21pushdef([x],esyscmd([sed -n 's/#define \([A-Z0-9_]*\)[ \t]*\(.*\)/\1=\2/p' < ]K5_TOPDIR/patchlevel.h)) 22define([PL_KRB5_MAJOR_RELEASE],regexp(x,[KRB5_MAJOR_RELEASE=\(.*\)],[\1])) 23ifelse(PL_KRB5_MAJOR_RELEASE,,[errprint([Can't determine KRB5_MAJOR_RELEASE value from patchlevel.h. 24]) m4exit(1) dnl sometimes that does not work? 25builtin(m4exit,1)]) 26define([PL_KRB5_MINOR_RELEASE],regexp(x,[KRB5_MINOR_RELEASE=\(.*\)],[\1])) 27ifelse(PL_KRB5_MINOR_RELEASE,,[errprint([Can't determine KRB5_MINOR_RELEASE value from patchlevel.h. 28]) m4exit(1) dnl sometimes that does not work? 29builtin(m4exit,1)]) 30define([PL_KRB5_PATCHLEVEL],regexp(x,[KRB5_PATCHLEVEL=\(.*\)],[\1])) 31ifelse(PL_KRB5_PATCHLEVEL,,[errprint([Can't determine KRB5_PATCHLEVEL value from patchlevel.h. 32]) m4exit(1) dnl sometimes that does not work? 33builtin(m4exit,1)]) 34define([PL_KRB5_RELTAIL],regexp(x,[KRB5_RELTAIL="\(.*\)"],[\1])) 35dnl RELTAIL is allowed to not be defined. 36popdef([x]) 37define([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)) 38define([K5_BUGADDR],krb5-bugs@mit.edu) 39define([K5_AC_INIT],[AC_INIT(Kerberos 5, K5_VERSION, K5_BUGADDR, krb5) 40AC_CONFIG_SRCDIR($1) 41build_dynobj=no]) 42dnl 43dnl drop in standard rules for all configure files -- CONFIG_RULES 44dnl 45AC_DEFUN(CONFIG_RULES,[dnl 46AC_REQUIRE([V5_SET_TOPDIR]) dnl 47EXTRA_FILES="" 48AC_SUBST(EXTRA_FILES) 49dnl Consider using AC_USE_SYSTEM_EXTENSIONS when we require autoconf 50dnl 2.59c or later, but be sure to test on Solaris first. 51AC_DEFINE([_GNU_SOURCE], 1, [Define to enable extensions in glibc]) 52AC_DEFINE([__STDC_WANT_LIB_EXT1__], 1, [Define to enable C11 extensions]) 53 54WITH_CC dnl 55AC_REQUIRE_CPP 56if test -z "$LD" ; then LD=$CC; fi 57AC_ARG_VAR(LD,[linker command [CC]]) 58AC_SUBST(LDFLAGS) dnl 59KRB5_AC_CHOOSE_ET dnl 60KRB5_AC_CHOOSE_SS dnl 61KRB5_AC_CHOOSE_DB dnl 62dnl allow stuff in tree to access deprecated stuff for now 63dnl AC_DEFINE([KRB5_DEPRECATED], 1, [Define only if building in-tree]) 64AC_C_CONST dnl 65WITH_NETLIB dnl 66WITH_HESIOD dnl 67KRB5_AC_MAINTAINER_MODE dnl 68AC_ARG_PROGRAM dnl 69dnl 70dnl This identifies the top of the source tree relative to the directory 71dnl in which the configure file lives. 72dnl 73CONFIG_RELTOPDIR=$ac_reltopdir 74AC_SUBST(CONFIG_RELTOPDIR) 75lib_frag=$srcdir/$ac_config_fragdir/lib.in 76AC_SUBST_FILE(lib_frag) 77libobj_frag=$srcdir/$ac_config_fragdir/libobj.in 78AC_SUBST_FILE(libobj_frag) 79libnover_frag=$srcdir/$ac_config_fragdir/libnover.in 80AC_SUBST_FILE(libnover_frag) 81libpriv_frag=$srcdir/$ac_config_fragdir/libpriv.in 82AC_SUBST_FILE(libpriv_frag) 83libnodeps_frag=$srcdir/$ac_config_fragdir/libnodeps.in 84AC_SUBST_FILE(libnodeps_frag) 85dnl 86KRB5_AC_PRAGMA_WEAK_REF 87WITH_LDAP 88KRB5_LIB_PARAMS 89KRB5_AC_INITFINI 90KRB5_AC_ENABLE_THREADS 91KRB5_AC_FIND_DLOPEN 92])dnl 93 94dnl Maintainer mode, akin to what automake provides, 'cept we don't 95dnl want to use automake right now. 96AC_DEFUN([KRB5_AC_MAINTAINER_MODE], 97[AC_ARG_ENABLE([maintainer-mode], 98 [AS_HELP_STRING([--enable-maintainer-mode], 99 [enable rebuilding of source files, Makefiles, etc])], 100 [USE_MAINTAINER_MODE=$enableval], [USE_MAINTAINER_MODE=no]) 101if test "$USE_MAINTAINER_MODE" = yes; then 102 MAINTAINER_MODE_TRUE= 103 MAINTAINER_MODE_FALSE='#' 104 AC_MSG_NOTICE(enabling maintainer mode) 105else 106 MAINTAINER_MODE_TRUE='#' 107 MAINTAINER_MODE_FALSE= 108fi 109MAINT=$MAINTAINER_MODE_TRUE 110AC_SUBST(MAINTAINER_MODE_TRUE) 111AC_SUBST(MAINTAINER_MODE_FALSE) 112AC_SUBST(MAINT) 113]) 114 115dnl 116AC_DEFUN([KRB5_AC_INITFINI],[ 117dnl Do we want initialization at load time? 118AC_ARG_ENABLE([delayed-initialization], 119 [AS_HELP_STRING([--disable-delayed-initialization], 120 [initialize library code when loaded @<:@delay until first use@:>@])], 121 [], [enable_delayed_initialization=yes]) 122case "$enable_delayed_initialization" in 123 yes) 124 AC_DEFINE(DELAY_INITIALIZER,1,[Define if library initialization should be delayed until first use]) ;; 125 no) ;; 126 *) AC_MSG_ERROR(invalid option $enable_delayed_initialization for delayed-initialization) ;; 127esac 128dnl We always want finalization at unload time. 129dnl 130dnl Can we do things through gcc? 131KRB5_AC_GCC_ATTRS 132dnl How about with the linker? 133if test -z "$use_linker_init_option" ; then 134 AC_MSG_ERROR(ran INITFINI before checking shlib.conf?) 135fi 136if 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]) 138fi 139if 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]) 141fi 142]) 143 144dnl find dlopen 145AC_DEFUN([KRB5_AC_FIND_DLOPEN],[ 146old_LIBS="$LIBS" 147DL_LIB= 148AC_SEARCH_LIBS(dlopen, dl, [ 149if test "$ac_cv_search_dlopen" != "none required"; then 150 DL_LIB=$ac_cv_search_dlopen 151fi 152LIBS="$old_LIBS" 153AC_DEFINE(USE_DLOPEN,1,[Define if dlopen should be used])]) 154AC_SUBST(DL_LIB) 155]) 156 157 158dnl Hack for now. 159AC_DEFUN([KRB5_AC_ENABLE_THREADS],[ 160AC_ARG_ENABLE([thread-support], 161 [AS_HELP_STRING([--disable-thread-support], 162 [don't enable thread support @<:@enabled@:>@])], 163 [], [enable_thread_support=yes]) 164if test "$enable_thread_support" = yes ; then 165 AC_MSG_NOTICE(enabling thread support) 166 AC_DEFINE(ENABLE_THREADS,1,[Define if thread support enabled]) 167fi 168dnl Maybe this should be inside the conditional above? Doesn't cache.... 169if 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 211else 212 PTHREAD_CC="$CC" 213 PTHREAD_CFLAGS="" 214 PTHREAD_LIBS="" 215 THREAD_SUPPORT=0 216fi 217AC_SUBST(THREAD_SUPPORT) 218dnl We want to know where these routines live, so on systems with weak 219dnl reference support we can figure out whether or not the pthread library 220dnl has been linked in. 221dnl If we don't add any libraries for thread support, don't bother. 222AC_CHECK_FUNCS(pthread_once pthread_rwlock_init) 223old_CC="$CC" 224test "$PTHREAD_CC" != "" && test "$ac_cv_c_compiler_gnu" = no && CC=$PTHREAD_CC 225old_CFLAGS="$CFLAGS" 226# On Solaris, -pthreads is added to CFLAGS, no extra explicit libraries. 227CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 228AC_SUBST(PTHREAD_CFLAGS) 229old_LIBS="$LIBS" 230LIBS="$PTHREAD_LIBS $LIBS" 231AC_MSG_NOTICE(rechecking with PTHREAD_... options) 232AC_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.])]) 234LIBS="$old_LIBS" 235CC="$old_CC" 236CFLAGS="$old_CFLAGS" 237]) 238 239dnl This is somewhat gross and should go away when the build system 240dnl is revamped. -- tlyu 241dnl DECLARE_SYS_ERRLIST - check for sys_errlist in libc 242dnl 243AC_DEFUN([DECLARE_SYS_ERRLIST], 244[AC_CACHE_CHECK([for sys_errlist declaration], krb5_cv_decl_sys_errlist, 245[AC_COMPILE_IFELSE( 246 [AC_LANG_PROGRAM( 247 [[#include <stdio.h> 248 #include <errno.h> 249 ]], 250 [[1+sys_nerr;]])], 251 [krb5_cv_decl_sys_errlist=yes], [krb5_cv_decl_sys_errlist=no])]) 252# assume sys_nerr won't be declared w/o being in libc 253if test $krb5_cv_decl_sys_errlist = yes; then 254 AC_DEFINE(SYS_ERRLIST_DECLARED,1,[Define if sys_errlist is defined in errno.h]) 255 AC_DEFINE(HAVE_SYS_ERRLIST,1,[Define if sys_errlist in libc]) 256else 257 # This means that sys_errlist is not declared in errno.h, but may still 258 # be in libc. 259 AC_CACHE_CHECK([for sys_errlist in libc], krb5_cv_var_sys_errlist, 260 [AC_LINK_IFELSE( 261 [AC_LANG_PROGRAM( 262 [[extern int sys_nerr;]], 263 [[if (1+sys_nerr < 0) return 1;]])], 264 [krb5_cv_var_sys_errlist=yes], [krb5_cv_var_sys_errlist=no])]) 265 if test $krb5_cv_var_sys_errlist = yes; then 266 AC_DEFINE(HAVE_SYS_ERRLIST,1,[Define if sys_errlist in libc]) 267 # Do this cruft for backwards compatibility for now. 268 AC_DEFINE(NEED_SYS_ERRLIST,1,[Define if need to declare sys_errlist]) 269 else 270 AC_MSG_WARN([sys_errlist is neither in errno.h nor in libc]) 271 fi 272fi]) 273 274dnl 275dnl check for sigmask/sigprocmask -- CHECK_SIGPROCMASK 276dnl 277AC_DEFUN(CHECK_SIGPROCMASK,[ 278AC_MSG_CHECKING([for use of sigprocmask]) 279AC_CACHE_VAL(krb5_cv_func_sigprocmask_use, 280[AC_LINK_IFELSE( 281 [AC_LANG_PROGRAM( 282 [[#include <signal.h> 283 ]], 284 [[sigprocmask(SIG_SETMASK, 0, 0);]])], 285 [krb5_cv_func_sigprocmask_use=yes], 286 [AC_LINK_IFELSE( 287 [AC_LANG_PROGRAM( 288 [[#include <signal.h> 289 ]], 290 [[sigmask(1);]])], 291 [krb5_cv_func_sigprocmask_use=no], [krb5_cv_func_sigprocmask_use=yes])])]) 292AC_MSG_RESULT($krb5_cv_func_sigprocmask_use) 293if test $krb5_cv_func_sigprocmask_use = yes; then 294 AC_DEFINE(USE_SIGPROCMASK,1,[Define if sigprocmask should be used]) 295fi 296])dnl 297dnl 298dnl 299dnl check for <dirent.h> -- CHECK_DIRENT 300dnl (may need to be more complex later) 301dnl 302AC_DEFUN(CHECK_DIRENT,[ 303AC_CHECK_HEADER(dirent.h,AC_DEFINE(USE_DIRENT_H,1,[Define if you have dirent.h functionality]))])dnl 304dnl 305dnl check if union wait is defined, or if WAIT_USES_INT -- CHECK_WAIT_TYPE 306dnl 307AC_DEFUN(CHECK_WAIT_TYPE,[ 308AC_MSG_CHECKING([if argument to wait is int *]) 309AC_CACHE_VAL(krb5_cv_struct_wait, 310dnl Test for prototype clash - if there is none - then assume int * works 311[AC_COMPILE_IFELSE( 312 [AC_LANG_SOURCE( 313 [[#include <sys/types.h> 314 #include <sys/wait.h> 315 extern pid_t wait(int *);]])], 316 [krb5_cv_struct_wait=no], 317 dnl Else fallback on old stuff 318 [AC_COMPILE_IFELSE( 319 [AC_LANG_PROGRAM( 320 [[#include <sys/wait.h> 321 ]], 322 [[union wait i; 323 #ifdef WEXITSTATUS 324 WEXITSTATUS (i); 325 #endif 326 ]])], 327 [krb5_cv_struct_wait=yes], [krb5_cv_struct_wait=no])])]) 328AC_MSG_RESULT($krb5_cv_struct_wait) 329if test $krb5_cv_struct_wait = no; then 330 AC_DEFINE(WAIT_USES_INT,1,[Define if wait takes int as a argument]) 331fi 332])dnl 333dnl 334dnl check for POSIX signal handling -- CHECK_SIGNALS 335dnl 336AC_DEFUN(CHECK_SIGNALS,[ 337AC_CHECK_FUNC(sigprocmask, 338AC_MSG_CHECKING(for sigset_t and POSIX_SIGNALS) 339AC_CACHE_VAL(krb5_cv_type_sigset_t, 340[AC_COMPILE_IFELSE( 341 [AC_LANG_PROGRAM( 342 [[#include <signal.h> 343 ]], 344 [[sigset_t x]])], 345 [krb5_cv_type_sigset_t=yes], [krb5_cv_type_sigset_t=no])]) 346AC_MSG_RESULT($krb5_cv_type_sigset_t) 347if test $krb5_cv_type_sigset_t = yes; then 348 AC_DEFINE(POSIX_SIGNALS,1,[Define if POSIX signal handling is used]) 349fi 350)])dnl 351dnl 352dnl check for POSIX setjmp/longjmp -- CHECK_SETJMP 353dnl 354AC_DEFUN(CHECK_SETJMP,[ 355AC_CHECK_FUNC(sigsetjmp, 356AC_MSG_CHECKING(for sigjmp_buf) 357AC_CACHE_VAL(krb5_cv_struct_sigjmp_buf, 358[AC_COMPILE_IFELSE( 359 [AC_LANG_PROGRAM( 360 [[#include <setjmp.h> 361 ]], 362 [[sigjmp_buf x]])], 363 [krb5_cv_struct_sigjmp_buf=yes], [krb5_cv_struct_sigjmp_buf=no])]) 364AC_MSG_RESULT($krb5_cv_struct_sigjmp_buf) 365if test $krb5_cv_struct_sigjmp_buf = yes; then 366 AC_DEFINE(POSIX_SETJMP,1,[Define if setjmp indicates POSIX interface]) 367fi 368)])dnl 369dnl 370dnl Check for IPv6 compile-time support. 371dnl 372AC_DEFUN(KRB5_AC_INET6,[ 373AC_CHECK_HEADERS(sys/types.h sys/socket.h netinet/in.h netdb.h) 374AC_CHECK_FUNCS(inet_ntop inet_pton getnameinfo) 375dnl getaddrinfo test needs netdb.h, for proper compilation on alpha 376dnl under OSF/1^H^H^H^H^HDigital^H^H^H^H^H^H^HTru64 UNIX, where it's 377dnl a macro 378AC_MSG_CHECKING(for getaddrinfo) 379AC_CACHE_VAL(ac_cv_func_getaddrinfo, 380[AC_LINK_IFELSE( 381 [AC_LANG_PROGRAM( 382 [[#ifdef HAVE_NETDB_H 383 #include <netdb.h> 384 #endif 385 ]], 386 [[struct addrinfo *ai; 387 getaddrinfo("kerberos.mit.edu", "echo", 0, &ai);]])], 388 [ac_cv_func_getaddrinfo=yes], [ac_cv_func_getaddrinfo=no])]) 389AC_MSG_RESULT($ac_cv_func_getaddrinfo) 390if test $ac_cv_func_getaddrinfo = yes; then 391 AC_DEFINE(HAVE_GETADDRINFO,1,[Define if you have the getaddrinfo function]) 392fi 393dnl 394AC_REQUIRE([KRB5_SOCKADDR_SA_LEN])dnl 395AC_MSG_CHECKING(for IPv6 compile-time support without -DINET6) 396AC_CACHE_VAL(krb5_cv_inet6,[ 397if test "$ac_cv_func_inet_ntop" != "yes" ; then 398 krb5_cv_inet6=no 399else 400 AC_COMPILE_IFELSE( 401 [AC_LANG_PROGRAM( 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]) 413fi]) 414AC_MSG_RESULT($krb5_cv_inet6) 415if test "$krb5_cv_inet6" = no && test "$ac_cv_func_inet_ntop" = yes; then 416AC_MSG_CHECKING(for IPv6 compile-time support with -DINET6) 417AC_CACHE_VAL(krb5_cv_inet6_with_dinet6,[ 418old_CC="$CC" 419CC="$CC -DINET6" 420AC_COMPILE_IFELSE( 421 [AC_LANG_PROGRAM( 422 [[#ifdef HAVE_SYS_TYPES_H 423 #include <sys/types.h> 424 #endif 425 #include <sys/socket.h> 426 #include <netinet/in.h> 427 #include <netdb.h> 428 ]], 429 [[struct sockaddr_in6 in; 430 AF_INET6; 431 IN6_IS_ADDR_LINKLOCAL (&in.sin6_addr);]])], 432 [krb5_cv_inet6_with_dinet6=yes], [krb5_cv_inet6_with_dinet6=no]) 433CC="$old_CC"]) 434AC_MSG_RESULT($krb5_cv_inet6_with_dinet6) 435fi 436if test $krb5_cv_inet6 = yes || test "$krb5_cv_inet6_with_dinet6" = yes; then 437 if test "$krb5_cv_inet6_with_dinet6" = yes; then 438 AC_DEFINE(INET6,1,[May need to be defined to enable IPv6 support, for example on IRIX]) 439 fi 440fi 441])dnl 442dnl 443AC_DEFUN(KRB5_AC_CHECK_FOR_CFLAGS,[ 444AC_BEFORE([$0],[AC_PROG_CC]) 445AC_BEFORE([$0],[AC_PROG_CXX]) 446krb5_ac_cflags_set=${CFLAGS+set} 447krb5_ac_cxxflags_set=${CXXFLAGS+set} 448krb5_ac_warn_cflags_set=${WARN_CFLAGS+set} 449krb5_ac_warn_cxxflags_set=${WARN_CXXFLAGS+set} 450]) 451dnl 452AC_DEFUN(TRY_WARN_CC_FLAG_1,[dnl 453 cachevar=`echo "krb5_cv_cc_flag_$1" | sed -e s/=/_eq_/g -e s/-/_dash_/g -e s/[[^a-zA-Z0-9_]]/_/g` 454 AC_CACHE_CHECK([if C compiler supports $1], [$cachevar], 455 [# first try without, then with 456 AC_COMPILE_IFELSE( 457 [AC_LANG_PROGRAM([], [1;])], 458 [old_cflags="$CFLAGS" 459 CFLAGS="$CFLAGS $cflags_warning_test_flags $1" 460 AC_COMPILE_IFELSE( 461 [AC_LANG_PROGRAM([], [1;])], 462 [eval $cachevar=yes], [eval $cachevar=no]) 463 CFLAGS="$old_cflags"], 464 [AC_MSG_ERROR(compiling simple test program with $CFLAGS failed)])]) 465 if eval test '"${'$cachevar'}"' = yes; then 466 WARN_CFLAGS="$WARN_CFLAGS $1" 467 fi 468 eval flag_supported='${'$cachevar'}' 469])dnl 470dnl 471dnl Are additional flags needed to make unsupported warning options 472dnl get reported as errors? 473AC_DEFUN(CHECK_CC_WARNING_TEST_FLAGS,[dnl 474 cflags_warning_test_flags= 475 TRY_WARN_CC_FLAG_1(-Werror=unknown-warning-option) 476 if test $flag_supported = yes; then 477 cflags_warning_test_flags=-Werror=unknown-warning-option 478 fi 479])dnl 480dnl 481AC_DEFUN(TRY_WARN_CC_FLAG,[dnl 482AC_REQUIRE([CHECK_CC_WARNING_TEST_FLAGS])dnl 483TRY_WARN_CC_FLAG_1($1)dnl 484])dnl 485dnl 486AC_DEFUN(WITH_CC,[dnl 487AC_REQUIRE([KRB5_AC_CHECK_FOR_CFLAGS])dnl 488AC_REQUIRE([AC_PROG_CC])dnl 489AC_REQUIRE([AC_PROG_CXX])dnl 490if test $ac_cv_c_compiler_gnu = yes ; then 491 HAVE_GCC=yes 492 else HAVE_GCC= 493fi 494AC_SUBST(HAVE_GCC) 495AC_CACHE_CHECK([for GNU linker], krb5_cv_prog_gnu_ld, 496[krb5_cv_prog_gnu_ld=no 497if test "$GCC" = yes; then 498 if AC_TRY_COMMAND([$CC -Wl,-v 2>&1 dnl 499 | grep "GNU ld" > /dev/null]); then 500 krb5_cv_prog_gnu_ld=yes 501 fi 502fi]) 503AC_ARG_WITH([size-optimizations], 504[ --with-size-optimizations enable a few optimizations to reduce code size 505 possibly at some run-time cost], 506, 507withval=no) 508if test "$withval" = yes; then 509 AC_DEFINE(CONFIG_SMALL,1,[Define to reduce code size even if it means more cpu usage]) 510fi 511# -Wno-long-long, if needed, for k5-platform.h without inttypes.h etc. 512extra_gcc_warn_opts="-Wall -Wcast-align -Wshadow" 513# -Wmissing-prototypes 514if test "$GCC" = yes ; then 515 # Putting this here means we get -Os after -O2, which works. 516 if test "$with_size_optimizations" = yes && test "x$krb5_ac_cflags_set" != xset; then 517 AC_MSG_NOTICE(adding -Os optimization option) 518 case "$CFLAGS" in 519 "-g -O2") CFLAGS="-g -Os" ;; 520 "-O2") CFLAGS="-Os" ;; 521 *) CFLAGS="$CFLAGS -Os" ;; 522 esac 523 fi 524 if test "x$krb5_ac_warn_cflags_set" = xset ; then 525 AC_MSG_NOTICE(not adding extra gcc warning flags because WARN_CFLAGS was set) 526 else 527 AC_MSG_NOTICE(adding extra warning flags for gcc) 528 WARN_CFLAGS="$WARN_CFLAGS $extra_gcc_warn_opts -Wmissing-prototypes" 529 if test "`uname -s`" = Darwin ; then 530 AC_MSG_NOTICE(skipping pedantic warnings on Darwin) 531 elif test "`uname -s`" = Linux ; then 532 AC_MSG_NOTICE(skipping pedantic warnings on Linux) 533 else 534 WARN_CFLAGS="$WARN_CFLAGS -pedantic" 535 fi 536 if test "$ac_cv_cxx_compiler_gnu" = yes; then 537 if test "x$krb5_ac_warn_cxxflags_set" = xset ; then 538 AC_MSG_NOTICE(not adding extra g++ warnings because WARN_CXXFLAGS was set) 539 else 540 AC_MSG_NOTICE(adding extra warning flags for g++) 541 WARN_CXXFLAGS="$WARN_CXXFLAGS $extra_gcc_warn_opts" 542 fi 543 fi 544 # Currently, G++ does not support -Wno-format-zero-length. 545 TRY_WARN_CC_FLAG(-Wno-format-zero-length) 546 # Other flags here may not be supported on some versions of 547 # gcc that people want to use. 548 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 549 TRY_WARN_CC_FLAG(-W$flag) 550 done 551 # old-style-definition? generates many, many warnings 552 # 553 # Warnings that we'd like to turn into errors on versions of gcc 554 # that support promoting only specific warnings to errors, but 555 # we'll take as warnings on older compilers. (If such a warning 556 # is added after the -Werror=foo feature, you can just put 557 # error=foo in the above list, and skip the test for the 558 # warning-only form.) At least in some versions, -Werror= doesn't 559 # seem to make the conditions actual errors, but still issues 560 # warnings; I guess we'll take what we can get. 561 # 562 # We're currently targeting C89+, not C99, so disallow some 563 # constructs. 564 for flag in declaration-after-statement ; do 565 TRY_WARN_CC_FLAG(-Werror=$flag) 566 if test "$flag_supported" = no; then 567 TRY_WARN_CC_FLAG(-W$flag) 568 fi 569 done 570 # We require function declarations now. 571 # 572 # In some compiler versions -- e.g., "gcc version 4.2.1 (Apple 573 # Inc. build 5664)" -- the -Werror- option works, but the -Werror= 574 # version doesn't cause implicitly declared functions to be 575 # flagged as errors. If neither works, -Wall implies 576 # -Wimplicit-function-declaration so don't bother. 577 TRY_WARN_CC_FLAG(-Werror-implicit-function-declaration) 578 if test "implicit-function-declaration_supported" = no; then 579 TRY_WARN_CC_FLAG(-Werror=implicit-function-declaration) 580 fi 581 # 582 fi 583 if test "`uname -s`" = Darwin ; then 584 # Someday this should be a feature test. 585 # One current (Jaguar = OS 10.2) problem: 586 # Archive library with foo.o undef sym X and bar.o common sym X, 587 # if foo.o is pulled in at link time, bar.o may not be, causing 588 # the linker to complain. 589 # Dynamic library problems too? 590 case "$CC $CFLAGS" in 591 *-fcommon*) ;; # why someone would do this, I don't know 592 *-fno-common*) ;; # okay, they're already doing the right thing 593 *) 594 AC_MSG_NOTICE(disabling the use of common storage on Darwin) 595 CFLAGS="$CFLAGS -fno-common" 596 ;; 597 esac 598 fi 599else 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 642fi 643AC_SUBST(WARN_CFLAGS) 644AC_SUBST(WARN_CXXFLAGS) 645])dnl 646dnl 647dnl K5_GEN_MAKEFILE([dir, [frags]]) 648dnl 649AC_DEFUN(K5_GEN_MAKEFILE,[dnl 650ifelse($1, ,[_K5_GEN_MAKEFILE(.,$2)],[_K5_GEN_MAKEFILE($1,$2)]) 651]) 652dnl 653dnl _K5_GEN_MAKEFILE(dir, [frags]) 654dnl dir must be present in this case 655dnl Note: Be careful in quoting. 656dnl The m4_foreach_w generates the list of fragments to include 657dnl or "" if $2 is empty 658AC_DEFUN(_K5_GEN_MAKEFILE,[dnl 659AC_CONFIG_FILES([$1/Makefile:$srcdir/]K5_TOPDIR[/config/pre.in:$1/Makefile.in:$1/deps:$srcdir/]K5_TOPDIR[/config/post.in]) 660]) 661dnl 662dnl K5_GEN_FILE( <ac_output arguments> ) 663dnl 664AC_DEFUN(K5_GEN_FILE,[AC_CONFIG_FILES($1)])dnl 665dnl 666dnl K5_AC_OUTPUT 667dnl Note: Adds the variables to config.status for individual 668dnl Makefile generation from config.status 669AC_DEFUN(K5_AC_OUTPUT,[AC_OUTPUT])dnl 670dnl 671dnl V5_AC_OUTPUT_MAKEFILE 672dnl 673AC_DEFUN(V5_AC_OUTPUT_MAKEFILE, 674[ifelse($1, , [_V5_AC_OUTPUT_MAKEFILE(.,$2)],[_V5_AC_OUTPUT_MAKEFILE($1,$2)])]) 675dnl 676define(_V5_AC_OUTPUT_MAKEFILE, 677[ifelse($2, , ,AC_CONFIG_FILES($2)) 678m4_foreach_w([DIR], [$1],dnl 679 [AC_CONFIG_FILES(DIR[/Makefile:$srcdir/]K5_TOPDIR[/config/pre.in:]DIR[/Makefile.in:]DIR[/deps:$srcdir/]K5_TOPDIR[/config/post.in])]) 680K5_AC_OUTPUT])dnl 681dnl 682dnl 683dnl KRB5_SOCKADDR_SA_LEN: define HAVE_SA_LEN if sockaddr contains the sa_len 684dnl component 685dnl 686AC_DEFUN([KRB5_SOCKADDR_SA_LEN],[ dnl 687AC_CHECK_MEMBER(struct sockaddr.sa_len, 688 AC_DEFINE(HAVE_SA_LEN,1,[Define if struct sockaddr contains sa_len]) 689,,[#include <sys/types.h> 690#include <sys/socket.h>])]) 691dnl 692dnl WITH_NETLIB 693dnl 694dnl 695AC_DEFUN(WITH_NETLIB,[ 696AC_ARG_WITH([netlib], 697 [AS_HELP_STRING([--with-netlib=LIBS], [use user defined resolver library])], 698[ if test "$withval" = yes -o "$withval" = no ; then 699 AC_MSG_RESULT("netlib will link with C library resolver only") 700 else 701 LIBS="$LIBS $withval" 702 AC_MSG_RESULT("netlib will use \'$withval\'") 703 fi 704],dnl 705[AC_LIBRARY_NET] 706)])dnl 707dnl 708dnl 709AC_DEFUN(KRB5_AC_NEED_DAEMON, [ 710KRB5_NEED_PROTO([#ifdef HAVE_UNISTD_H 711#include <unistd.h> 712#endif],daemon,1)])dnl 713 714dnl 715dnl KRB5_AC_NEED_LIBGEN --- check if libgen needs to be linked in for 716dnl compile/step 717dnl 718dnl 719AC_DEFUN(KRB5_AC_NEED_LIBGEN,[ 720AC_REQUIRE([AC_PROG_CC])dnl 721dnl 722dnl regcomp is present but non-functional on Solaris 2.4 723dnl 724AC_MSG_CHECKING(for working regcomp) 725AC_CACHE_VAL(ac_cv_func_regcomp, 726[AC_RUN_IFELSE( 727 [AC_LANG_PROGRAM( 728 [[#include <sys/types.h> 729 #include <regex.h> 730 regex_t x; regmatch_t m;]], 731 [[return regcomp(&x,"pat.*",0) || regexec(&x,"pattern",1,&m,0);]])], 732 [ac_cv_func_regcomp=yes], [ac_cv_func_regcomp=no], 733 [AC_MSG_ERROR([Cannot test regcomp when cross compiling])])]) 734AC_MSG_RESULT($ac_cv_func_regcomp) 735test $ac_cv_func_regcomp = yes && AC_DEFINE(HAVE_REGCOMP,1,[Define if regcomp exists and functions]) 736dnl 737dnl Check for the compile and step functions - only if regcomp is not available 738dnl 739if test $ac_cv_func_regcomp = no; then 740 save_LIBS="$LIBS" 741 LIBS=-lgen 742dnl this will fail if there's no compile/step in -lgen, or if there's 743dnl no -lgen. This is fine. 744 AC_CHECK_FUNCS(compile step) 745 LIBS="$save_LIBS" 746dnl 747dnl Set GEN_LIB if necessary 748dnl 749 AC_CHECK_LIB(gen, compile, GEN_LIB=-lgen, GEN_LIB=) 750 AC_SUBST(GEN_LIB) 751fi 752]) 753dnl 754dnl KRB5_AC_REGEX_FUNCS --- check for different regular expression 755dnl support functions 756dnl 757AC_DEFUN(KRB5_AC_REGEX_FUNCS,[ 758AC_CHECK_FUNCS(re_comp re_exec regexec) 759AC_REQUIRE([KRB5_AC_NEED_LIBGEN])dnl 760])dnl 761dnl 762dnl WITH_HESIOD 763dnl 764AC_DEFUN(WITH_HESIOD, 765[AC_ARG_WITH(hesiod, 766 [AS_HELP_STRING([--with-hesiod[=path]], 767 [compile with hesiod support @<:@omitted@:>@])], 768 [hesiod=$with_hesiod], [with_hesiod=no]) 769if test "$with_hesiod" != "no"; then 770 HESIOD_DEFS=-DHESIOD 771 AC_CHECK_LIB(resolv, res_send, res_lib=-lresolv) 772 if test "$hesiod" != "yes"; then 773 HESIOD_LIBS="-L${hesiod}/lib -lhesiod $res_lib" 774 else 775 HESIOD_LIBS="-lhesiod $res_lib" 776 fi 777else 778 HESIOD_DEFS= 779 HESIOD_LIBS= 780fi 781AC_SUBST(HESIOD_DEFS) 782AC_SUBST(HESIOD_LIBS)]) 783 784 785dnl 786dnl KRB5_BUILD_LIBRARY 787dnl 788dnl Pull in the necessary stuff to create the libraries. 789 790AC_DEFUN(KRB5_BUILD_LIBRARY, 791[AC_REQUIRE([KRB5_LIB_AUX])dnl 792AC_REQUIRE([AC_PROG_LN_S])dnl 793AC_REQUIRE([AC_PROG_RANLIB])dnl 794AC_REQUIRE([AC_PROG_INSTALL])dnl 795AC_CHECK_TOOL(AR, ar, false) 796if test "$AR" = "false"; then 797 AC_MSG_ERROR([ar not found in PATH]) 798fi 799AC_CHECK_PROG(PERL, perl, perl, false) 800if test "$ac_cv_prog_PERL" = "false"; then 801 AC_MSG_ERROR(Perl is now required for Kerberos builds.) 802fi 803AC_SUBST(LIBLIST) 804AC_SUBST(LIBLINKS) 805AC_SUBST(PLUGIN) 806AC_SUBST(PLUGINLINK) 807AC_SUBST(PLUGININST) 808AC_SUBST(KDB5_PLUGIN_DEPLIBS) 809AC_SUBST(KDB5_PLUGIN_LIBS) 810AC_SUBST(MAKE_SHLIB_COMMAND) 811AC_SUBST(SHLIB_RPATH_FLAGS) 812AC_SUBST(SHLIB_EXPFLAGS) 813AC_SUBST(SHLIB_EXPORT_FILE_DEP) 814AC_SUBST(DYNOBJ_EXPDEPS) 815AC_SUBST(DYNOBJ_EXPFLAGS) 816AC_SUBST(INSTALL_SHLIB) 817AC_SUBST(STLIBEXT) 818AC_SUBST(SHLIBEXT) 819AC_SUBST(SHLIBVEXT) 820AC_SUBST(SHLIBSEXT) 821AC_SUBST(DEPLIBEXT) 822AC_SUBST(PFLIBEXT) 823AC_SUBST(LIBINSTLIST) 824AC_SUBST(DYNOBJEXT) 825AC_SUBST(MAKE_DYNOBJ_COMMAND) 826AC_SUBST(UNDEF_CHECK) 827]) 828 829dnl 830dnl KRB5_BUILD_LIBOBJS 831dnl 832dnl Pull in the necessary stuff to build library objects. 833 834AC_DEFUN(KRB5_BUILD_LIBOBJS, 835[AC_REQUIRE([KRB5_LIB_AUX])dnl 836AC_SUBST(OBJLISTS) 837AC_SUBST(STOBJEXT) 838AC_SUBST(SHOBJEXT) 839AC_SUBST(PFOBJEXT) 840AC_SUBST(PICFLAGS) 841AC_SUBST(PROFFLAGS)]) 842 843dnl 844dnl KRB5_BUILD_PROGRAM 845dnl 846dnl Set variables to build a program. 847 848AC_DEFUN(KRB5_BUILD_PROGRAM, 849[AC_REQUIRE([KRB5_LIB_AUX])dnl 850AC_REQUIRE([KRB5_AC_NEED_LIBGEN])dnl 851AC_SUBST(CC_LINK) 852AC_SUBST(CXX_LINK) 853AC_SUBST(RPATH_FLAG) 854AC_SUBST(PROG_RPATH_FLAGS) 855AC_SUBST(DEPLIBEXT)]) 856 857dnl 858dnl KRB5_RUN_FLAGS 859dnl 860dnl Set up environment for running dynamic executables out of build tree 861 862AC_DEFUN(KRB5_RUN_FLAGS, 863[AC_REQUIRE([KRB5_LIB_AUX])dnl 864KRB5_RUN_ENV="$RUN_ENV" 865KRB5_RUN_VARS="$RUN_VARS" 866AC_SUBST(KRB5_RUN_ENV) 867AC_SUBST(KRB5_RUN_VARS)]) 868 869dnl 870dnl KRB5_LIB_AUX 871dnl 872dnl Parse configure options related to library building. 873 874AC_DEFUN(KRB5_LIB_AUX, 875[AC_REQUIRE([KRB5_LIB_PARAMS])dnl 876 877AC_ARG_ENABLE([static],,, [enable_static=no]) 878AC_ARG_ENABLE([shared],,, [enable_shared=yes]) 879 880if test "x$enable_static" = "x$enable_shared"; then 881 AC_MSG_ERROR([--enable-static must be specified with --disable-shared]) 882fi 883 884AC_ARG_ENABLE([rpath], 885 [AS_HELP_STRING([--disable-rpath],[suppress run path flags in link lines])], 886 [], [enable_rpath=yes]) 887 888if test "x$enable_rpath" != xyes ; then 889 # Unset the rpath flag values set by shlib.conf 890 SHLIB_RPATH_FLAGS= 891 RPATH_FLAG= 892 PROG_RPATH_FLAGS= 893fi 894 895if test "$SHLIBEXT" = ".so-nobuild"; then 896 AC_MSG_ERROR([Shared libraries are not yet supported on this platform.]) 897fi 898 899DEPLIBEXT=$SHLIBEXT 900 901if test "x$enable_static" = xyes; then 902 AC_MSG_NOTICE([using static libraries]) 903 LIBLIST='lib$(LIBBASE)$(STLIBEXT)' 904 LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(STLIBEXT)' 905 PLUGIN='libkrb5_$(LIBBASE)$(STLIBEXT)' 906 PLUGINLINK='$(TOPLIBD)/libkrb5_$(LIBBASE)$(STLIBEXT)' 907 PLUGININST=install-static 908 OBJLISTS=OBJS.ST 909 LIBINSTLIST=install-static 910 DEPLIBEXT=$STLIBEXT 911 AC_DEFINE([STATIC_PLUGINS], 1, [Define for static plugin linkage]) 912 913 KDB5_PLUGIN_DEPLIBS='$(TOPLIBD)/libkrb5_db2$(DEPLIBEXT)' 914 KDB5_PLUGIN_LIBS='-lkrb5_db2' 915 if test "x$OPENLDAP_PLUGIN" = xyes; then 916 KDB5_PLUGIN_DEBLIBS=$KDB5_PLUGIN_DEPLIBS' $(TOPLIBD)/libkrb5_ldap$(DEPLIBEXT) $(TOPLIBD)/libkdb_ldap$(DEPLIBEXT)' 917 KDB5_PLUGIN_LIBS=$KDB5_PLUGIN_LIBS' -lkrb5_kldap -lkdb_ldap $(LDAP_LIBS)' 918 fi 919 # kadm5srv_mit normally comes before kdb on the link line. Add it 920 # again after the KDB plugins, since they depend on it for XDR stuff. 921 KDB5_PLUGIN_DEPLIBS=$KDB5_PLUGIN_DEPLIBS' $(TOPLIBD)/libkadm5srv_mit$(DEPLIBEXT)' 922 KDB5_PLUGIN_LIBS=$KDB5_PLUGIN_LIBS' -lkadm5srv_mit' 923 924 # avoid duplicate rules generation for AIX and such 925 SHLIBEXT=.so-nobuild 926 SHLIBVEXT=.so.v-nobuild 927 SHLIBSEXT=.so.s-nobuild 928else 929 AC_MSG_NOTICE([using shared libraries]) 930 931 # Clear some stuff in case of AIX, etc. 932 if test "$STLIBEXT" = "$SHLIBEXT" ; then 933 STLIBEXT=.a-nobuild 934 fi 935 case "$SHLIBSEXT" in 936 .so.s-nobuild) 937 LIBLIST='lib$(LIBBASE)$(SHLIBEXT)' 938 LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(SHLIBEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBVEXT)' 939 LIBINSTLIST="install-shared" 940 ;; 941 *) 942 LIBLIST='lib$(LIBBASE)$(SHLIBEXT) lib$(LIBBASE)$(SHLIBSEXT)' 943 LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(SHLIBEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBVEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBSEXT)' 944 LIBINSTLIST="install-shlib-soname" 945 ;; 946 esac 947 OBJLISTS="OBJS.SH" 948 PLUGIN='$(LIBBASE)$(DYNOBJEXT)' 949 PLUGINLINK='../$(PLUGIN)' 950 PLUGININST=install-plugin 951 KDB5_PLUGIN_DEPLIBS= 952 KDB5_PLUGIN_LIBS= 953fi 954CC_LINK="$CC_LINK_SHARED" 955CXX_LINK="$CXX_LINK_SHARED" 956 957if test -z "$LIBLIST"; then 958 AC_MSG_ERROR([must enable one of shared or static libraries]) 959fi 960 961# Check whether to build profiled libraries. 962AC_ARG_ENABLE([profiled], 963dnl [ --enable-profiled build profiled libraries @<:@disabled@:>@] 964, 965[if test "$enableval" = yes; then 966 AC_MSG_ERROR([Sorry, profiled libraries do not work in this release.]) 967fi])]) 968 969dnl 970dnl KRB5_LIB_PARAMS 971dnl 972dnl Determine parameters related to libraries, e.g. various extensions. 973 974AC_DEFUN(KRB5_LIB_PARAMS, 975[AC_REQUIRE([AC_CANONICAL_HOST])dnl 976krb5_cv_host=$host 977AC_SUBST(krb5_cv_host) 978AC_REQUIRE([AC_PROG_CC])dnl 979AC_REQUIRE([V5_SET_TOPDIR])dnl 980. $ac_topdir/config/shlib.conf]) 981dnl 982dnl The following was written by jhawk@mit.edu 983dnl 984dnl AC_LIBRARY_NET: Id: net.m4,v 1.4 1997/10/25 20:49:53 jhawk Exp 985dnl 986dnl This test is for network applications that need socket() and 987dnl gethostbyname() -ish functions. Under Solaris, those applications need to 988dnl link with "-lsocket -lnsl". Under IRIX, they should *not* link with 989dnl "-lsocket" because libsocket.a breaks a number of things (for instance: 990dnl gethostbyname() under IRIX 5.2, and snoop sockets under most versions of 991dnl IRIX). 992dnl 993dnl Unfortunately, many application developers are not aware of this, and 994dnl mistakenly write tests that cause -lsocket to be used under IRIX. It is 995dnl also easy to write tests that cause -lnsl to be used under operating 996dnl systems where neither are necessary (or useful), such as SunOS 4.1.4, which 997dnl uses -lnsl for TLI. 998dnl 999dnl This test exists so that every application developer does not test this in 1000dnl a different, and subtly broken fashion. 1001dnl 1002dnl It has been argued that this test should be broken up into two separate 1003dnl tests, one for the resolver libraries, and one for the libraries necessary 1004dnl for using Sockets API. Unfortunately, the two are carefully intertwined and 1005dnl allowing the autoconf user to use them independantly potentially results in 1006dnl unfortunate ordering dependencies -- as such, such component macros would 1007dnl have to carefully use indirection and be aware if the other components were 1008dnl executed. Since other autoconf macros do not go to this trouble, and almost 1009dnl no applications use sockets without the resolver, this complexity has not 1010dnl been implemented. 1011dnl 1012dnl The check for libresolv is in case you are attempting to link statically 1013dnl and happen to have a libresolv.a lying around (and no libnsl.a). 1014dnl 1015AC_DEFUN(AC_LIBRARY_NET, [ 1016 # Most operating systems have gethostbyname() in the default searched 1017 # libraries (i.e. libc): 1018 AC_CHECK_FUNC(gethostbyname, , [ 1019 # Some OSes (eg. Solaris) place it in libnsl: 1020 AC_CHECK_LIB(nsl, gethostbyname, , [ 1021 # Some strange OSes (SINIX) have it in libsocket: 1022 AC_CHECK_LIB(socket, gethostbyname, , [ 1023 # Unfortunately libsocket sometimes depends on libnsl. 1024 # AC_CHECK_LIB's API is essentially broken so the following 1025 # ugliness is necessary: 1026 AC_CHECK_LIB(socket, gethostbyname, 1027 LIBS="-lsocket -lnsl $LIBS", 1028 [AC_CHECK_LIB(resolv, gethostbyname, 1029 LIBS="-lresolv $LIBS" )], 1030 -lnsl) 1031 ]) 1032 ]) 1033 ]) 1034 AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, , 1035 AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl))) 1036 KRB5_AC_ENABLE_DNS 1037 if test "$enable_dns" = yes ; then 1038 # We assume that if libresolv exists we can link against it. 1039 # This may get us a gethostby* that doesn't respect nsswitch. 1040 AC_CHECK_LIB(resolv, main) 1041 1042_KRB5_AC_CHECK_RES_FUNCS(res_ninit res_nclose res_ndestroy res_nsearch dnl 1043ns_initparse ns_name_uncompress dn_skipname res_search) 1044 if test $krb5_cv_func_res_nsearch = no \ 1045 && test $krb5_cv_func_res_search = no; then 1046 # Attempt to link with res_search(), in case it's not prototyped. 1047 AC_CHECK_FUNC(res_search, 1048 [AC_DEFINE(HAVE_RES_SEARCH, 1, 1049 [Define to 1 if you have the `res_search' function])], 1050 [AC_MSG_ERROR([cannot find res_nsearch or res_search])]) 1051 fi 1052 fi 1053]) 1054AC_DEFUN([_KRB5_AC_CHECK_RES_FUNCS], 1055[m4_foreach_w([AC_Func], [$1], 1056 [AH_TEMPLATE(AS_TR_CPP(HAVE_[]AC_Func), 1057 [Define to 1 if you have the `]AC_Func[' function.])])dnl 1058for krb5_func in $1; do 1059_KRB5_AC_CHECK_RES_FUNC($krb5_func) 1060done 1061]) 1062AC_DEFUN([_KRB5_AC_CHECK_RES_FUNC], [ 1063# Solaris 9 prototypes ns_name_uncompress() in arpa/nameser.h, but 1064# doesn't export it from libresolv.so, so we use extreme paranoia here 1065# and check both for the declaration and that we can link against the 1066# function. 1067AC_CACHE_CHECK([for $1], [krb5_cv_func_$1], 1068[AC_LINK_IFELSE( 1069 [AC_LANG_PROGRAM( 1070 [[#include <sys/types.h> 1071 #include <netinet/in.h> 1072 #include <arpa/nameser.h> 1073 #include <resolv.h> 1074 ]], 1075 [[/* 1076 * Use volatile, or else optimization can cause false positives. 1077 */ 1078 void (* volatile p)() = (void (*)())$1;]])], 1079 [AS_VAR_SET(krb5_cv_func_$1, yes)], 1080 [AS_VAR_SET(krb5_cv_func_$1, no)])]) 1081AS_IF([test AS_VAR_GET(krb5_cv_func_$1) = yes], 1082 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]), 1, 1083 [Define to 1 if you have the `$1' function])])[]dnl 1084]) 1085dnl 1086dnl 1087dnl KRB5_AC_ENABLE_DNS 1088dnl 1089AC_DEFUN(KRB5_AC_ENABLE_DNS, [ 1090enable_dns=yes 1091 AC_ARG_ENABLE([dns-for-realm], 1092[ --enable-dns-for-realm enable DNS lookups of Kerberos realm names], , 1093[enable_dns_for_realm=no]) 1094 if test "$enable_dns_for_realm" = yes; then 1095 AC_DEFINE(KRB5_DNS_LOOKUP_REALM,1,[Define to enable DNS lookups of Kerberos realm names]) 1096 fi 1097 1098AC_DEFINE(KRB5_DNS_LOOKUP, 1,[Define for DNS support of locating realms and KDCs]) 1099 1100]) 1101dnl 1102dnl 1103dnl Check if we need the prototype for a function - we give it a bogus 1104dnl prototype and if it complains - then a valid prototype exists on the 1105dnl system. 1106dnl 1107dnl KRB5_NEED_PROTO(includes, function, [bypass]) 1108dnl if $3 set, don't see if library defined. 1109dnl Useful for case where we will define in libkrb5 the function if need be 1110dnl but want to know if a prototype exists in either case on system. 1111dnl 1112AC_DEFUN([KRB5_NEED_PROTO], [ 1113ifelse([$3], ,[if test "x$ac_cv_func_$2" = xyes; then]) 1114AC_CACHE_CHECK([if $2 needs a prototype provided], krb5_cv_func_$2_noproto, 1115[AC_COMPILE_IFELSE( 1116 [AC_LANG_PROGRAM( 1117 [[$1]], 1118 [[#undef $2 1119 struct k5foo {int foo; } xx; 1120 extern int $2 (struct k5foo*); 1121 $2(&xx);]])], 1122 [krb5_cv_func_$2_noproto=yes], [krb5_cv_func_$2_noproto=no])]) 1123if test $krb5_cv_func_$2_noproto = yes; then 1124 AC_DEFINE([NEED_]translit($2, [a-z], [A-Z])[_PROTO], 1, dnl 1125[define if the system header files are missing prototype for $2()]) 1126fi 1127ifelse([$3], ,[fi]) 1128]) 1129dnl 1130dnl ============================================================= 1131dnl Internal function for testing for getpeername prototype 1132dnl 1133AC_DEFUN([KRB5_GETPEERNAME_ARGS],[ 1134AC_DEFINE([GETPEERNAME_ARG3_TYPE],GETSOCKNAME_ARG3_TYPE,[Type of getpeername second argument.]) 1135]) 1136dnl 1137dnl ============================================================= 1138dnl Internal function for testing for getsockname arguments 1139dnl 1140AC_DEFUN([TRY_GETSOCK_INT],[ 1141krb5_lib_var=`echo "$1 $2" | sed 'y% ./+-*%___p_p%'` 1142AC_MSG_CHECKING([if getsockname() takes arguments $1 and $2]) 1143AC_CACHE_VAL(krb5_cv_getsockname_proto_$krb5_lib_var, 1144[AC_COMPILE_IFELSE( 1145 [AC_LANG_SOURCE( 1146 [[#include <sys/types.h> 1147 #include <sys/socket.h> 1148 extern int getsockname(int, $1, $2);]])], 1149 [eval "krb5_cv_getsockname_proto_$krb5_lib_var=yes"], 1150 [eval "krb5_cv_getsockname_proto_$krb5_lib_var=no"])]) 1151if eval "test \"`echo '$krb5_cv_getsockname_proto_'$krb5_lib_var`\" = yes"; then 1152 AC_MSG_RESULT(yes) 1153 sock_set=yes; res1="$1"; res2="$2" 1154else 1155 AC_MSG_RESULT(no) 1156fi 1157]) 1158dnl 1159dnl Determines the types of the second and third arguments to getsockname(). 1160dnl 1161AC_DEFUN([KRB5_GETSOCKNAME_ARGS],[ 1162sock_set=no 1163for sock_arg1 in "struct sockaddr *" "void *" 1164do 1165 for sock_arg2 in "size_t *" "int *" "socklen_t *" 1166 do 1167 if test $sock_set = no; then 1168 TRY_GETSOCK_INT($sock_arg1, $sock_arg2) 1169 fi 1170 done 1171done 1172if test "$sock_set" = no; then 1173 AC_MSG_NOTICE(assuming struct sockaddr and socklen_t for getsockname args) 1174 res1="struct sockaddr *" 1175 res2="socklen_t *" 1176fi 1177res1=`echo "$res1" | tr -d '*' | sed -e 's/ *$//'` 1178res2=`echo "$res2" | tr -d '*' | sed -e 's/ *$//'` 1179AC_DEFINE_UNQUOTED([GETSOCKNAME_ARG3_TYPE],$res2,[Type of pointer target for argument 3 to getsockname]) 1180]) 1181dnl 1182dnl 1183AC_DEFUN([KRB5_AC_CHOOSE_ET],[ 1184AC_ARG_WITH([system-et], 1185 [AS_HELP_STRING([--with-system-et], 1186 [use system compile_et and -lcom_err @<:@default: build and install a local version@:>@])]) 1187AC_MSG_CHECKING(which version of com_err to use) 1188if test "x$with_system_et" = xyes ; then 1189 # This will be changed to "intlsys" if textdomain support is present. 1190 COM_ERR_VERSION=sys 1191 AC_MSG_RESULT(system) 1192else 1193 COM_ERR_VERSION=k5 1194 AC_MSG_RESULT(krb5) 1195fi 1196OLDLIBS="$LIBS" 1197COM_ERR_LIB=-lcom_err 1198if test $COM_ERR_VERSION = sys; then 1199 PKG_CHECK_MODULES(COM_ERR, com_err, [have_com_err=yes], [have_com_err=no]) 1200 if test "x$have_com_err = xyes"; then 1201 COM_ERR_LIB="$COM_ERR_LIBS" 1202 fi 1203 LIBS="$LIBS $COM_ERR_LIB" 1204 # check for various functions we need 1205 AC_CHECK_LIB(com_err, add_error_table, :, AC_MSG_ERROR(cannot find add_error_table in com_err library)) 1206 AC_CHECK_LIB(com_err, remove_error_table, :, AC_MSG_ERROR(cannot find remove_error_table in com_err library)) 1207 # make sure compile_et provides "et_foo" name 1208 cat >> conf$$e.et <<EOF 1209error_table foo 1210error_code ERR_FOO, "foo" 1211end 1212EOF 1213 AC_CHECK_PROGS(compile_et,compile_et,false) 1214 if test "$compile_et" = false; then 1215 AC_MSG_ERROR(cannot find compile_et) 1216 fi 1217 AC_CACHE_CHECK(whether compile_et is useful,krb5_cv_compile_et_useful,[ 1218 if compile_et conf$$e.et >/dev/null 2>&1 ; then true ; else 1219 AC_MSG_ERROR(execution failed) 1220 fi 1221 AC_COMPILE_IFELSE( 1222 [AC_LANG_PROGRAM( 1223 [[#include "conf$$e.h" 1224 ]], 1225 [[&et_foo_error_table;]])], 1226 [], [AC_MSG_ERROR(cannot use et_foo_error_table)]) 1227 # Anything else we need to test for? 1228 rm -f conf$$e.c conf$$e.h 1229 krb5_cv_compile_et_useful=yes 1230 ]) 1231 AC_CACHE_CHECK(whether compile_et supports --textdomain, 1232 krb5_cv_compile_et_textdomain,[ 1233 krb5_cv_compile_et_textdomain=no 1234 if compile_et --textdomain=xyzw conf$$e.et >/dev/null 2>&1 ; then 1235 if grep -q xyzw conf$$e.c; then 1236 krb5_cv_compile_et_textdomain=yes 1237 fi 1238 fi 1239 rm -f conf$$e.c conf$$e.h 1240 ]) 1241 if test "$krb5_cv_compile_et_textdomain" = yes; then 1242 COM_ERR_VERSION=intlsys 1243 fi 1244 rm -f conf$$e.et 1245fi 1246AC_SUBST(COM_ERR_VERSION) 1247AC_SUBST(COM_ERR_LIB) 1248LIBS="$OLDLIBS" 1249if test "$COM_ERR_VERSION" = k5 -o "$COM_ERR_VERSION" = intlsys; then 1250 AC_DEFINE(HAVE_COM_ERR_INTL,1, 1251 [Define if com_err has compatible gettext support]) 1252fi 1253]) 1254AC_DEFUN([KRB5_AC_CHOOSE_SS],[ 1255AC_ARG_WITH(system-ss, 1256 [AS_HELP_STRING([--with-system-ss], 1257 [use system -lss and mk_cmds @<:@private version@:>@])]) 1258AC_ARG_VAR(SS_LIB,[system libraries for 'ss' package [-lss]]) 1259AC_MSG_CHECKING(which version of subsystem package to use) 1260if test "x$with_system_ss" = xyes ; then 1261 SS_VERSION=sys 1262 AC_MSG_RESULT(system) 1263 # todo: check for various libraries we might need 1264 # in the meantime... 1265 test "x${SS_LIB+set}" = xset || SS_LIB=-lss 1266 old_LIBS="$LIBS" 1267 LIBS="$LIBS $SS_LIB" 1268 AC_CACHE_CHECK(whether system ss package works, krb5_cv_system_ss_okay, 1269 [AC_RUN_IFELSE( 1270 [AC_LANG_SOURCE( 1271 [[#include <ss/ss.h> 1272 int main(int argc, char *argv[]) { 1273 if (argc == 42) { 1274 int i, err; 1275 i = ss_create_invocation("foo","foo","",0,&err); 1276 ss_listen(i); 1277 } 1278 return 0; 1279 }]])], 1280 [krb5_cv_system_ss_okay=yes], [AC_MSG_ERROR(cannot run test program)], 1281 [krb5_cv_system_ss_okay=assumed])]) 1282 LIBS="$old_LIBS" 1283 KRB5_NEED_PROTO([#include <ss/ss.h>],ss_execute_command,1) 1284else 1285 SS_VERSION=k5 1286 AC_MSG_RESULT(krb5) 1287fi 1288AC_SUBST(SS_LIB) 1289AC_SUBST(SS_VERSION) 1290]) 1291dnl 1292AC_DEFUN([KRB5_AC_CHOOSE_DB],[ 1293AC_ARG_WITH(system-db, 1294 [AS_HELP_STRING([--with-system-db], 1295 [use system Berkeley db @<:@private version@:>@])]) 1296AC_ARG_VAR(DB_HEADER,[header file for system Berkeley db package [db.h]]) 1297AC_ARG_VAR(DB_LIB,[library for system Berkeley db package [-ldb]]) 1298if test "x$with_system_db" = xyes ; then 1299 DB_VERSION=sys 1300 # TODO: Do we have specific routines we should check for? 1301 # How about known, easily recognizable bugs? 1302 # We want to use bt_rseq in some cases, but no other version but 1303 # ours has it right now. 1304 # 1305 # Okay, check the variables. 1306 test "x${DB_HEADER+set}" = xset || DB_HEADER=db.h 1307 test "x${DB_LIB+set}" = xset || DB_LIB=-ldb 1308 # 1309 if test "x${DB_HEADER}" = xdb.h ; then 1310 DB_HEADER_VERSION=sys 1311 else 1312 DB_HEADER_VERSION=redirect 1313 fi 1314 KDB5_DB_LIB="$DB_LIB" 1315else 1316 DB_VERSION=k5 1317 AC_DEFINE(HAVE_BT_RSEQ,1,[Define if bt_rseq is available, for recursive btree traversal.]) 1318 DB_HEADER=db.h 1319 DB_HEADER_VERSION=k5 1320 # libdb gets sucked into libkdb 1321 KDB5_DB_LIB= 1322 # needed for a couple of things that need libdb for its own sake 1323 DB_LIB=-ldb 1324fi 1325AC_SUBST(DB_VERSION) 1326AC_SUBST(DB_HEADER) 1327AC_SUBST(DB_HEADER_VERSION) 1328AC_SUBST(DB_LIB) 1329AC_SUBST(KDB5_DB_LIB) 1330]) 1331dnl 1332dnl KRB5_AC_PRIOCNTL_HACK 1333dnl 1334dnl 1335AC_DEFUN([KRB5_AC_PRIOCNTL_HACK], 1336[AC_REQUIRE([AC_PROG_AWK])dnl 1337AC_REQUIRE([AC_LANG_COMPILER_REQUIRE])dnl 1338AC_CACHE_CHECK([whether to use priocntl hack], [krb5_cv_priocntl_hack], 1339[case $krb5_cv_host in 1340*-*-solaris2.9*) 1341 if test "$cross_compiling" = yes; then 1342 krb5_cv_priocntl_hack=yes 1343 else 1344 # Solaris patch 117171-11 (sparc) or 117172-11 (x86) 1345 # fixes the Solaris 9 bug where final pty output 1346 # gets lost on close. 1347 if showrev -p | $AWK 'BEGIN { e = 1 } 1348/Patch: 11717[[12]]/ { x = index[]([$]2, "-"); 1349if (substr[]([$]2, x + 1, length([$]2) - x) >= 11) 1350{ e = 0 } else { e = 1 } } 1351END { exit e; }'; then 1352 krb5_cv_priocntl_hack=no 1353 else 1354 krb5_cv_priocntl_hack=yes 1355 fi 1356 fi 1357 ;; 1358*) 1359 krb5_cv_priocntl_hack=no 1360 ;; 1361esac]) 1362if test "$krb5_cv_priocntl_hack" = yes; then 1363 PRIOCNTL_HACK=1 1364else 1365 PRIOCNTL_HACK=0 1366fi 1367AC_SUBST(PRIOCNTL_HACK)]) 1368dnl 1369dnl 1370dnl KRB5_AC_GCC_ATTRS 1371AC_DEFUN([KRB5_AC_GCC_ATTRS], 1372[AC_CACHE_CHECK([for constructor/destructor attribute support],krb5_cv_attr_constructor_destructor, 1373[rm -f conftest.1 conftest.2 1374if test -r conftest.1 || test -r conftest.2 ; then 1375 AC_MSG_ERROR(write error in local file system?) 1376fi 1377true > conftest.1 1378true > conftest.2 1379if test -r conftest.1 && test -r conftest.2 ; then true ; else 1380 AC_MSG_ERROR(write error in local file system?) 1381fi 1382a=no 1383b=no 1384# blindly assume we have 'unlink' and unistd.h. 1385AC_RUN_IFELSE( 1386 [AC_LANG_SOURCE( 1387 [[#include <unistd.h> 1388 void foo1() __attribute__((constructor)); 1389 void foo1() { unlink("conftest.1"); } 1390 void foo2() __attribute__((destructor)); 1391 void foo2() { unlink("conftest.2"); } 1392 int main () { return 0; }]])], 1393 [test -r conftest.1 || a=yes 1394 test -r conftest.2 || b=yes], 1395 [], [AC_MSG_ERROR(Cannot test for constructor/destructor support when cross compiling)]) 1396case $krb5_cv_host in 1397*-*-aix4.*) 1398 # Under AIX 4.3.3, at least, shared library destructor functions 1399 # appear to get executed in reverse link order (right to left), 1400 # so that a library's destructor function may run after that of 1401 # libraries it depends on, and may still have to access in the 1402 # destructor. 1403 # 1404 # That counts as "not working", for me, but it's a much more 1405 # complicated test case to set up. 1406 b=no 1407 ;; 1408esac 1409krb5_cv_attr_constructor_destructor="$a,$b" 1410]) 1411# Okay, krb5_cv_... should be set now. 1412case $krb5_cv_attr_constructor_destructor in 1413 yes,*) 1414 AC_DEFINE(CONSTRUCTOR_ATTR_WORKS,1,[Define if __attribute__((constructor)) works]) ;; 1415esac 1416case $krb5_cv_attr_constructor_destructor in 1417 *,yes) 1418 AC_DEFINE(DESTRUCTOR_ATTR_WORKS,1,[Define if __attribute__((destructor)) works]) ;; 1419esac 1420dnl End of attributes we care about right now. 1421]) 1422dnl 1423dnl 1424dnl KRB5_AC_PRAGMA_WEAK_REF 1425AC_DEFUN([KRB5_AC_PRAGMA_WEAK_REF], 1426[AC_CACHE_CHECK([whether pragma weak references are supported], 1427krb5_cv_pragma_weak_ref, 1428[AC_LINK_IFELSE( 1429 [AC_LANG_PROGRAM( 1430 [[#pragma weak flurbl 1431 extern int flurbl(void);]], 1432 [[if (&flurbl != 0) return flurbl();]])], 1433 [krb5_cv_pragma_weak_ref=yes], [krb5_cv_pragma_weak_ref=no])]) 1434if test $krb5_cv_pragma_weak_ref = yes ; then 1435 AC_DEFINE(HAVE_PRAGMA_WEAK_REF,1,[Define if #pragma weak references work]) 1436fi]) 1437dnl 1438dnl 1439m4_include(config/ac-archive/ax_pthread.m4) 1440m4_include(config/ac-archive/ax_recursive_eval.m4) 1441m4_include(config/pkg.m4) 1442dnl 1443dnl 1444dnl 1445dnl --with-ldap=value 1446dnl 1447AC_DEFUN(WITH_LDAP,[ 1448AC_ARG_WITH([ldap], 1449[AS_HELP_STRING([--with-ldap], [compile OpenLDAP database backend module])], 1450[case "$withval" in 1451 OPENLDAP) with_ldap=yes ;; 1452 yes | no) ;; 1453 *) AC_MSG_ERROR(Invalid option value --with-ldap="$withval") ;; 1454esac], with_ldap=no)dnl 1455 1456if test "$with_ldap" = yes; then 1457 AC_MSG_NOTICE(enabling OpenLDAP database backend module support) 1458 OPENLDAP_PLUGIN=yes 1459fi 1460])dnl 1461