Install path-substituted man pages
[krb5.git] / src / configure.in
1 K5_AC_INIT([aclocal.m4])
2
3 CONFIG_RULES
4 KRB5_VERSION=K5_VERSION
5 AC_SUBST(KRB5_VERSION)
6
7
8 AC_REQUIRE_CPP
9
10 AC_CACHE_CHECK(if va_copy is available, krb5_cv_va_copy,
11 [AC_LINK_IFELSE([AC_LANG_SOURCE([
12 #include <stdarg.h>
13 void f(va_list ap) {
14   va_list ap2;
15   va_copy(ap2, ap);
16   va_end(ap2);
17 }
18 va_list x;
19 int main()
20 {
21   f(x);
22   return 0;
23 }])], krb5_cv_va_copy=yes, krb5_cv_va_copy=no)])
24 if test "$krb5_cv_va_copy" = yes; then
25   AC_DEFINE(HAS_VA_COPY,1,[Define if va_copy macro or function is available.])
26 fi
27
28 # Note that this isn't checking if the copied value *works*, just
29 # whether the C language constraints permit the copying.  If
30 # va_list is defined as an array type, it can't be assigned.
31 AC_CACHE_CHECK(if va_list objects can be copied by assignment,
32                krb5_cv_va_simple_copy,
33 [AC_COMPILE_IFELSE([
34 AC_LANG_SOURCE([#include <stdarg.h>
35 void f(va_list va2) {
36   va_list va1;
37   va1 = va2;
38 }])], krb5_cv_va_simple_copy=yes, krb5_cv_va_simple_copy=no)])
39 if test "$krb5_cv_va_simple_copy" = yes; then
40   AC_DEFINE(CAN_COPY_VA_LIST,1,[Define if va_list objects can be simply copied by assignment.])
41 fi
42
43 # The following lines are so that configure --help gives some global 
44 # configuration options.
45
46 KRB5_LIB_AUX
47 AC_KRB5_TCL
48 AC_ARG_ENABLE([athena],
49 [  --enable-athena         build with MIT Project Athena configuration],,)
50
51 # Begin autoconf tests for the Makefiles generated out of the top-level
52 # configure.in...
53
54 KRB5_BUILD_LIBOBJS
55 KRB5_BUILD_LIBRARY
56 KRB5_BUILD_PROGRAM
57 # for slave
58 AC_TYPE_MODE_T
59 AC_PROG_INSTALL
60 KRB5_AC_NEED_DAEMON
61 KRB5_GETSOCKNAME_ARGS
62 KRB5_GETPEERNAME_ARGS
63 LIBUTIL=
64 AC_CHECK_LIB(util,main,[AC_DEFINE(HAVE_LIBUTIL,1,[Define if the util library is available])
65 LIBUTIL=-lutil
66 ])
67 AC_SUBST(LIBUTIL)
68
69 AC_CHECK_HEADER(libintl.h, [
70         AC_SEARCH_LIBS(dgettext, intl, [
71                 AC_DEFINE(ENABLE_NLS, 1,
72                         [Define if translation functions should be used.])])])
73
74 AC_CHECK_PROG(MSGFMT,msgfmt,msgfmt)
75 po=
76 if test x"$MSGFMT" != x; then
77         po=po
78 fi
79 AC_SUBST(po)
80
81 # for kdc
82 AC_CHECK_HEADERS(syslog.h sys/sockio.h ifaddrs.h unistd.h fnmatch.h)
83 AC_CHECK_FUNCS(openlog syslog closelog strftime vsprintf vasprintf vsnprintf)
84 AC_CHECK_FUNCS(strlcpy fnmatch)
85
86 EXTRA_SUPPORT_SYMS=
87 AC_CHECK_FUNC(strlcpy,
88 [STRLCPY_ST_OBJ=
89 STRLCPY_OBJ=],
90 [STRLCPY_ST_OBJ=strlcpy.o
91 STRLCPY_OBJ='$(OUTPRE)strlcpy.$(OBJEXT)'
92 EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS krb5int_strlcpy krb5int_strlcat"])
93 AC_SUBST(STRLCPY_OBJ)
94 AC_SUBST(STRLCPY_ST_OBJ)
95
96 AC_CHECK_FUNC(fnmatch,
97 [FNMATCH_ST_OBJ=
98 FNMATCH_OBJ=],
99 [FNMATCH_ST_OBJ=fnmatch.o
100 FNMATCH_OBJ='$(OUTPRE)fnmatch.$(OBJEXT)'
101 EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS k5_fnmatch"])
102 AC_SUBST(FNMATCH_OBJ)
103 AC_SUBST(FNMATCH_ST_OBJ)
104
105 AC_CHECK_FUNC(vasprintf,
106 [PRINTF_ST_OBJ=
107 PRINTF_OBJ=],
108 [PRINTF_ST_OBJ=printf.o
109 PRINTF_OBJ='$(OUTPRE)printf.$(OBJEXT)'
110 EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS krb5int_asprintf krb5int_vasprintf"])
111 AC_SUBST(PRINTF_OBJ)
112 AC_SUBST(PRINTF_ST_OBJ)
113 KRB5_NEED_PROTO([#include <stdarg.h>
114 #include <stdio.h>
115 ],vasprintf)
116 KRB5_NEED_PROTO([#include <string.h>
117 #ifdef HAVE_UNISTD_H
118 #include <unistd.h>
119 #endif
120 /* Solaris 8 declares swab in stdlib.h.  */
121 #include <stdlib.h>
122 ],swab,1)
123 KRB5_NEED_PROTO([#include <ctype.h>],isblank,1)
124
125 AC_PROG_AWK
126 KRB5_AC_INET6
127 KRB5_SOCKADDR_SA_LEN
128 CHECK_SIGNALS
129
130 # --with-vague-errors disables useful error messages.
131
132 AC_ARG_WITH([vague-errors],
133 AC_HELP_STRING([--with-vague-errors],[Do not @<:@do@:>@ send helpful errors to client]), , withval=no)
134 if test "$withval" = yes; then
135         AC_MSG_RESULT(Supplying vague error messages to KDC clients)
136         AC_DEFINE(KRBCONF_VAGUE_ERRORS,1,[Define if the KDC should return only vague error codes to clients])
137 fi
138
139 # WITH_CRYPTO_IMPL
140
141 CRYPTO_IMPL="builtin"
142 AC_ARG_WITH([crypto-impl],
143 AC_HELP_STRING([--with-crypto-impl=IMPL], [use specified crypto implementation @<:@builtin@:>@]),
144 [CRYPTO_IMPL=$withval
145 AC_MSG_RESULT("k5crypto will use \'$withval\'")
146 ], withval=builtin)
147 case "$withval" in
148 builtin)
149   ;;
150 openssl)
151   AC_CHECK_LIB(crypto, PKCS7_get_signer_info)
152   ;;
153 nss)
154   if test "${CRYPTO_IMPL_CFLAGS+set}" != set; then
155     CRYPTO_IMPL_CFLAGS=`pkg-config --cflags nss`
156   fi
157   if test "${CRYPTO_IMPL_LIBS+set}" != set; then
158     CRYPTO_IMPL_LIBS="-lnss3 $(pkg-config --libs nss-util)"
159   fi
160   AC_DEFINE(CRYPTO_IMPL_NSS,1,[Define if crypto implementation is NSS])
161   save_CFLAGS=$CFLAGS
162   CFLAGS="$CFLAGS $CRYPTO_IMPL_CFLAGS"
163   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
164 #include <nss.h>
165 #if NSS_VMAJOR < 3 || (NSS_VMAJOR == 3 && NSS_VMINOR < 13)
166 #error
167 #endif
168   ])], [], [AC_MSG_ERROR([NSS version 3.13 or later required.])])
169   CFLAGS=$save_CFLAGS
170   ;;
171 *)
172   AC_MSG_ERROR([Unknown crypto implementation $withval])
173   ;;
174 esac
175 AC_CONFIG_COMMANDS(CRYPTO_IMPL, , CRYPTO_IMPL=$CRYPTO_IMPL)
176 AC_SUBST(CRYPTO_IMPL)
177 AC_SUBST(CRYPTO_IMPL_CFLAGS)
178 AC_SUBST(CRYPTO_IMPL_LIBS)
179
180 if test "$CRYPTO_IMPL" = nss; then
181         PRNG_ALG="nss"
182 else
183 AC_ARG_WITH([prng-alg],
184 AC_HELP_STRING([--with-prng-alg=ALG], [use specified PRNG algorithm. Ignored for nss. @<:@fortuna@:>@]),
185 [PRNG_ALG=$withval
186 AC_MSG_RESULT("k5crypto will use \'$withval\'")
187 ], PRNG_ALG=fortuna)
188 fi
189 AC_CONFIG_COMMANDS(PRNG_ALG, , PRNG_ALG=$PRNG_ALG)
190 AC_SUBST(PRNG_ALG)
191 if test "$PRNG_ALG" = fortuna; then
192         AC_DEFINE(FORTUNA,1,[Define if Fortuna PRNG is selected])
193 fi
194
195 # WITH_PKINIT_CRYPTO_IMPL
196
197 PKINIT_CRYPTO_IMPL="$CRYPTO_IMPL"
198 AC_ARG_WITH([pkinit-crypto-impl],
199 AC_HELP_STRING([--with-pkinit-crypto-impl=IMPL], [use specified pkinit crypto implementation @<:@openssl@:>@]),
200 [PKINIT_CRYPTO_IMPL=$withval
201 AC_MSG_RESULT("pkinit will use \'$withval\'")
202 ], withval=$PKINIT_CRYPTO_IMPL)
203 case "$withval" in
204 builtin|openssl)
205   AC_CHECK_LIB(crypto, PKCS7_get_signer_info, PKINIT_CRYPTO_IMPL_LIBS=-lcrypto)
206   PKINIT_CRYPTO_IMPL=openssl
207   ;;
208 nss)
209   if test "${PKINIT_CRYPTO_IMPL_CFLAGS+set}" != set; then
210     PKINIT_CRYPTO_IMPL_CFLAGS=`pkg-config --cflags nss`
211   fi
212   if test "${PKINIT_CRYPTO_IMPL_LIBS+set}" != set; then
213     PKINIT_CRYPTO_IMPL_LIBS=`pkg-config --libs nss`
214   fi
215   AC_DEFINE(PKINIT_CRYPTO_IMPL_NSS,1,[Define if pkinit crypto implementation is NSS])
216   save_CFLAGS=$CFLAGS
217   CFLAGS="$CFLAGS $PKINIT_CRYPTO_IMPL_CFLAGS"
218   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
219 #include <nss.h>
220 #if NSS_VMAJOR < 3 || (NSS_VMAJOR == 3 && NSS_VMINOR < 12)
221 #error
222 #elif NSS_VMAJOR == 3 && NSS_VMINOR == 12 && NSS_VPATCH < 11
223 #error
224 #endif
225   ])], [], [AC_MSG_ERROR([NSS version 3.12.11 or later required.])])
226   CFLAGS=$save_CFLAGS
227   ;;
228 *)
229   AC_MSG_ERROR([Unknown crypto implementation $withval])
230   ;;
231 esac
232 AC_CONFIG_COMMANDS(PKINIT_CRYPTO_IMPL,,PKINIT_CRYPTO_IMPL=$PKINIT_CRYPTO_IMPL)
233 AC_SUBST(PKINIT_CRYPTO_IMPL)
234 AC_SUBST(PKINIT_CRYPTO_IMPL_CFLAGS)
235 AC_SUBST(PKINIT_CRYPTO_IMPL_LIBS)
236
237 # --with-kdc-kdb-update makes the KDC update the database with last request
238 # information and failure information.
239
240 AC_ARG_WITH([kdc-kdb-update],
241 AC_HELP_STRING([--with-kdc-kdb-update],[Update the database @<:@don't update@:>@]), , withval=no)
242 if test "$withval" = yes; then
243         AC_MSG_RESULT(Updating KDC database with each request)
244         AC_DEFINE(KRBCONF_KDC_MODIFIES_KDB,1,[Define if KDC should update database with each request])
245 fi
246
247 AC_ARG_ENABLE([kdc-lookaside-cache],
248 AC_HELP_STRING([--disable-kdc-lookaside-cache],
249                [Disable the cache which detects client retransmits]), ,
250                enableval=yes)
251 if test "$enableval" = no ; then
252         AC_DEFINE(NOCACHE,1,[Define if the KDC should use no lookaside cache])
253 fi
254 KRB5_RUN_FLAGS
255
256 AC_TYPE_SIGNAL
257
258 # from old include/configure.in
259 AH_TEMPLATE([HAVE_STRUCT_SOCKADDR_STORAGE], 
260 [Define if "struct sockaddr_storage" is available.])
261
262 AC_CONFIG_HEADERS(include/autoconf.h, [echo timestamp > include/autoconf.stamp])
263 AC_PROG_LEX
264 AC_C_CONST
265 AC_HEADER_DIRENT
266 AC_CHECK_FUNCS(strdup setvbuf seteuid setresuid setreuid setegid setresgid setregid setsid flock fchmod chmod strftime strptime geteuid setenv unsetenv getenv gmtime_r localtime_r bswap16 bswap64 mkstemp getusershell access getcwd srand48 srand srandom stat strchr strerror strerror_r timegm isblank)
267
268 AC_CHECK_FUNC(mkstemp,
269 [MKSTEMP_ST_OBJ=
270 MKSTEMP_OBJ=],
271 [MKSTEMP_ST_OBJ='mkstemp.o'
272 MKSTEMP_OBJ='$(OUTPRE)mkstemp.$(OBJEXT)'
273 EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS krb5int_mkstemp"])
274 AC_SUBST(MKSTEMP_OBJ)
275 AC_SUBST(MKSTEMP_ST_OBJ)
276
277 AC_CHECK_FUNC(gettimeofday,
278         [GETTIMEOFDAY_ST_OBJ=
279         GETTIMEOFDAY_OBJ=
280         AC_DEFINE(HAVE_GETTIMEOFDAY, 1, [Have the gettimeofday function])
281 ],
282         [GETTIMEOFDAY_ST_OBJ='gettimeofday.o'
283         GETTIMEOFDAY_OBJ='$(OUTPRE)gettimeofday.$(OBJEXT)'
284         EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS krb5int_gettimeofday"])
285 AC_SUBST(GETTIMEOFDAY_OBJ)
286 AC_SUBST(GETTIMEOFDAY_ST_OBJ)
287 AC_SUBST(EXTRA_SUPPORT_SYMS)
288
289 DECLARE_SYS_ERRLIST
290 AC_CHECK_HEADERS(unistd.h paths.h regex.h regexpr.h fcntl.h memory.h ifaddrs.h sys/filio.h byteswap.h machine/endian.h machine/byte_order.h sys/bswap.h endian.h pwd.h arpa/inet.h alloca.h dlfcn.h limits.h)
291 AC_CHECK_HEADER(regexp.h, [], [],
292 [#define INIT char *sp = instring;
293 #define GETC() (*sp++)
294 #define PEEKC() (*sp)
295 #define UNGETC(c) (--sp)
296 #define RETURN(c) return(c)
297 #define ERROR(c)
298 ])
299 AC_CHECK_MEMBERS([struct sockaddr_in.sin_len, struct sockaddr.sa_len], , ,
300   [#include <sys/types.h>
301 #include <netinet/in.h>])
302 AC_CHECK_MEMBERS([struct stat.st_mtimensec,struct stat.st_mtimespec.tv_nsec,struct stat.st_mtim.tv_nsec],,,[#include <sys/types.h>
303 #include <sys/stat.h>])
304 KRB5_AC_REGEX_FUNCS
305 AC_TYPE_OFF_T
306
307 # Fancy caching of perror result...
308 AC_MSG_CHECKING(for perror declaration)
309 AC_CACHE_VAL(krb5_cv_decl_perror,
310 [AC_EGREP_HEADER(perror, errno.h, 
311   krb5_cv_decl_perror=yes, krb5_cv_decl_perror=no)])
312 AC_MSG_RESULT($krb5_cv_decl_perror)
313 if test $krb5_cv_decl_perror = yes; then
314         AC_DEFINE(HDR_HAS_PERROR,1,[Define if errno.h declares perror])
315 fi
316
317 KRB5_NEED_PROTO([#include <time.h>],strptime)
318 CHECK_WAIT_TYPE
319 CHECK_SIGPROCMASK
320 AC_TYPE_GETGROUPS
321 CHECK_SETJMP
322
323 # *rpcent return types needed for lib/rpc
324
325 AC_MSG_CHECKING([return type of setrpcent])
326 AC_CACHE_VAL(k5_cv_type_setrpcent,
327 [AC_TRY_COMPILE([#include <netdb.h>
328 #ifdef __cplusplus
329 extern "C"
330 #endif
331 extern void setrpcent();],
332 [int i;], k5_cv_type_setrpcent=void, k5_cv_type_setrpcent=int)])
333 AC_MSG_RESULT($k5_cv_type_setrpcent)
334 AC_DEFINE_UNQUOTED(SETRPCENT_TYPE, $k5_cv_type_setrpcent, [Define as return type of setrpcent])
335
336 AC_MSG_CHECKING([return type of endrpcent])
337 AC_CACHE_VAL(k5_cv_type_endrpcent,
338 [AC_TRY_COMPILE([#include <netdb.h>
339 #ifdef __cplusplus
340 extern "C"
341 #endif
342 extern void endrpcent();],
343 [int i;], k5_cv_type_endrpcent=void, k5_cv_type_endrpcent=int)])
344 AC_MSG_RESULT($k5_cv_type_endrpcent)
345 AC_DEFINE_UNQUOTED(ENDRPCENT_TYPE, $k5_cv_type_endrpcent, [Define as return type of endrpcent])
346
347
348 # bswap_16 is a macro in byteswap.h under GNU libc
349 AC_MSG_CHECKING(for bswap_16)
350 AC_CACHE_VAL(krb5_cv_bswap_16,[
351 AC_TRY_LINK([#if HAVE_BYTESWAP_H
352 #include <byteswap.h>
353 #endif],[bswap_16(37);],krb5_cv_bswap_16=yes,krb5_cv_bswap_16=no)])
354 AC_MSG_RESULT($krb5_cv_bswap_16)
355 if test "$krb5_cv_bswap_16" = yes; then
356   AC_DEFINE(HAVE_BSWAP_16,1,[Define to 1 if bswap_16 is available via byteswap.h])
357 fi
358 AC_MSG_CHECKING(for bswap_64)
359 AC_CACHE_VAL(krb5_cv_bswap_64,[
360 AC_TRY_LINK([#if HAVE_BYTESWAP_H
361 #include <byteswap.h>
362 #endif],[bswap_64(37);],krb5_cv_bswap_64=yes,krb5_cv_bswap_64=no)])
363 AC_MSG_RESULT($krb5_cv_bswap_64)
364 if test "$krb5_cv_bswap_64" = yes; then
365   AC_DEFINE(HAVE_BSWAP_64,1,[Define to 1 if bswap_64 is available via byteswap.h])
366 fi
367
368 # Needed for ksu and some appl stuff.
369
370 case $krb5_cv_host in
371 alpha*-dec-osf*)
372         AC_CHECK_LIB(security,setluid,
373                 AC_DEFINE(HAVE_SETLUID,1,[Define if setluid provided in OSF/1 security library])
374                 KSU_LIBS="-lsecurity"
375         )
376         ;;
377 esac
378 AC_SUBST(KSU_LIBS)
379
380 if test $ac_cv_func_setenv = no || test $ac_cv_func_unsetenv = no \
381   || test $ac_cv_func_getenv = no; then
382   SETENVOBJ=setenv.o
383 else
384   SETENVOBJ=
385 fi
386 AC_SUBST(SETENVOBJ)
387
388 # Check what the return types for gethostbyname_r and getservbyname_r are.
389
390 AC_CHECK_FUNC(gethostbyname_r,[
391 ac_cv_func_gethostbyname_r=yes
392 if test "$ac_cv_func_gethostbyname_r" = yes; then
393   AC_MSG_CHECKING([if gethostbyname_r returns an int])
394   AC_CACHE_VAL(krb5_cv_gethostbyname_r_returns_int,
395   [AC_TRY_COMPILE([#include <netdb.h>
396   extern int gethostbyname_r ();], [1;],
397   krb5_cv_gethostbyname_r_returns_int=yes,
398   krb5_cv_gethostbyname_r_returns_int=no)])
399   AC_MSG_RESULT($krb5_cv_gethostbyname_r_returns_int)
400
401   AC_MSG_CHECKING([if gethostbyname_r returns a pointer])
402   AC_CACHE_VAL(krb5_cv_gethostbyname_r_returns_ptr,
403   [AC_TRY_COMPILE([#include <netdb.h>
404   extern struct hostent *gethostbyname_r ();], [1;],
405   krb5_cv_gethostbyname_r_returns_ptr=yes,
406   krb5_cv_gethostbyname_r_returns_ptr=no)])
407   AC_MSG_RESULT($krb5_cv_gethostbyname_r_returns_ptr)
408
409   if test "$krb5_cv_gethostbyname_r_returns_int" = "$krb5_cv_gethostbyname_r_returns_ptr"; then
410     AC_MSG_WARN(cannot determine return type of gethostbyname_r -- disabling)
411     ac_cv_func_gethostbyname_r=no
412   fi
413   if test "$krb5_cv_gethostbyname_r_returns_int" = yes; then
414     AC_DEFINE(GETHOSTBYNAME_R_RETURNS_INT, 1, [Define if gethostbyname_r returns int rather than struct hostent * ])
415   fi
416 fi
417 if test "$ac_cv_func_gethostbyname_r" = yes; then
418   AC_DEFINE(HAVE_GETHOSTBYNAME_R, 1, [Define if gethostbyname_r exists and its return type is known])
419   AC_CHECK_FUNC(gethostbyaddr_r)
420 fi
421 ])
422
423
424 AC_CHECK_FUNC(getpwnam_r,ac_cv_func_getpwnam_r=yes,ac_cv_func_getpwnam_r=no)
425 AC_CHECK_FUNC(getpwuid_r,ac_cv_func_getpwuid_r=yes,ac_cv_func_getpwuid_r=no)
426 if test "$ac_cv_func_getpwnam_r" = yes; then
427   AC_MSG_CHECKING([return type of getpwnam_r])
428   AC_CACHE_VAL(krb5_cv_getpwnam_r_return_type,
429   [AC_TRY_COMPILE([#include <pwd.h>
430    extern int getpwnam_r();], [1;],
431    getpwnam_r_returns_int=yes,getpwnam_r_returns_int=no)
432    AC_TRY_COMPILE([#include <pwd.h>
433    extern struct passwd *getpwnam_r();], [1;],
434    getpwnam_r_returns_ptr=yes,getpwnam_r_returns_ptr=no)
435    case "$getpwnam_r_returns_int/$getpwnam_r_returns_ptr" in
436      yes/no) krb5_cv_getpwnam_r_return_type=int ;;
437      no/yes) krb5_cv_getpwnam_r_return_type=ptr ;;
438      *) krb5_cv_getpwnam_r_return_type=unknown ;;
439    esac])
440   AC_MSG_RESULT($krb5_cv_getpwnam_r_return_type)
441   if test $krb5_cv_getpwnam_r_return_type = int; then
442     AC_DEFINE(GETPWNAM_R_RETURNS_INT, 1, [Define if getpwnam_r returns an int])
443   elif test $krb5_cv_getpwnam_r_return_type = unknown; then
444     AC_MSG_WARN([Cannot determine getpwnam_r return type, disabling getpwnam_r])
445     ac_cv_func_getpwnam_r=no
446   fi
447 fi
448 if test "$ac_cv_func_getpwnam_r" = yes; then
449   AC_MSG_CHECKING([number of arguments to getpwnam_r])
450   AC_CACHE_VAL(krb5_cv_getpwnam_r_args,
451   [AC_TRY_COMPILE([#include <pwd.h>
452    struct passwd pwx; char buf[1024];],
453    [getpwnam_r("", &pwx, buf, sizeof(buf));], args4=yes, args4=no)
454    AC_TRY_COMPILE([#include <pwd.h>
455    struct passwd pwx, *p; char buf[1024];],
456    [getpwnam_r("", &pwx, buf, sizeof(buf), &p);], args5=yes, args5=no)
457    case $args4/$args5 in
458      yes/no) krb5_cv_getpwnam_r_args=4 ;;
459      no/yes) krb5_cv_getpwnam_r_args=5 ;;
460      *) krb5_cv_getpwnam_r_args=unknown ;;
461    esac])
462   AC_MSG_RESULT($krb5_cv_getpwnam_r_args)
463   if test "$krb5_cv_getpwnam_r_args" = unknown; then
464     AC_MSG_WARN([Cannot determine number of arguments to getpwnam_r, disabling its use.])
465     ac_cv_func_getpwnam_r=no
466   else
467     AC_DEFINE(HAVE_GETPWNAM_R,1,[Define if getpwnam_r is available and useful.])
468     if test "$krb5_cv_getpwnam_r_args" = 4; then
469       AC_DEFINE(GETPWNAM_R_4_ARGS,1,[Define if getpwnam_r exists but takes only 4 arguments (e.g., POSIX draft 6 implementations like some Solaris releases).])
470     fi
471   fi
472 fi
473
474 if test "$ac_cv_func_getpwnam_r" = no && test "$ac_cv_func_getpwuid_r" = yes; then
475   # Actually, we could do this check, and the corresponding checks
476   # for return type and number of arguments, but I doubt we'll run
477   # into a system where we'd get to use getpwuid_r but not getpwnam_r.
478   AC_MSG_NOTICE([getpwnam_r not useful, so disabling getpwuid_r too])
479   ac_cv_func_getpwuid_r=no
480 fi
481 if test "$ac_cv_func_getpwuid_r" = yes; then
482   AC_DEFINE(HAVE_GETPWUID_R,1,[Define if getpwuid_r is available and useful.])
483   # Hack: Assume getpwuid_r is the shorter form if getpwnam_r is.
484   if test "$krb5_cv_getpwnam_r_args" = 4; then
485     AC_DEFINE(GETPWUID_R_4_ARGS,1,[Define if getpwuid_r exists but takes only 4 arguments (e.g., POSIX draft 6 implementations like some Solaris releases).])
486   fi
487 fi
488
489 if test "$ac_cv_func_gmtime_r" = yes; then
490   AC_MSG_CHECKING([whether gmtime_r returns int])
491   AC_CACHE_VAL(krb5_cv_gmtime_r_returns_int,
492   [AC_TRY_COMPILE([#include <time.h>
493    extern int gmtime_r ();], [1;], return_int=yes, return_int=no)
494    AC_TRY_COMPILE([#include <time.h>
495    extern struct tm *gmtime_r ();], [1;], return_ptr=yes, return_ptr=no)
496    case $return_int/$return_ptr in
497      yes/no) krb5_cv_gmtime_r_returns_int=yes ;;
498      no/yes) krb5_cv_gmtime_r_returns_int=no ;;
499      *)      # Can't figure it out, punt the function.
500              ac_cv_func_gmtime_r=no ;;
501    esac])
502   if test "$ac_cv_func_gmtime_r" = no; then
503     AC_MSG_RESULT(unknown -- ignoring gmtime_r)
504   else
505     AC_MSG_RESULT($krb5_cv_gmtime_r_returns_int)
506     if test "$krb5_cv_gmtime_r_returns_int" = yes; then
507       AC_DEFINE(GMTIME_R_RETURNS_INT,1,[Define if gmtime_r returns int instead of struct tm pointer, as on old HP-UX systems.])
508     fi
509   fi
510 fi
511
512 AC_CHECK_FUNC(getservbyname_r,[
513 ac_cv_func_getservbyname_r=yes
514 if test "$ac_cv_func_getservbyname_r" = yes; then
515   AC_MSG_CHECKING([if getservbyname_r returns an int])
516   AC_CACHE_VAL(krb5_cv_getservbyname_r_returns_int,
517   [AC_TRY_COMPILE([#include <netdb.h>
518   extern int getservbyname_r ();], [1;],
519   krb5_cv_getservbyname_r_returns_int=yes,
520   krb5_cv_getservbyname_r_returns_int=no)])
521   AC_MSG_RESULT($krb5_cv_getservbyname_r_returns_int)
522
523   AC_MSG_CHECKING([if getservbyname_r returns a pointer])
524   AC_CACHE_VAL(krb5_cv_getservbyname_r_returns_ptr,
525   [AC_TRY_COMPILE([#include <netdb.h>
526   extern struct servent *getservbyname_r ();], [1;],
527   krb5_cv_getservbyname_r_returns_ptr=yes,
528   krb5_cv_getservbyname_r_returns_ptr=no)])
529   AC_MSG_RESULT($krb5_cv_getservbyname_r_returns_ptr)
530
531   if test "$krb5_cv_getservbyname_r_returns_int" = "$krb5_cv_getservbyname_r_returns_ptr"; then
532     AC_MSG_WARN(cannot determine return type of getservbyname_r -- disabling)
533     ac_cv_func_getservbyname_r=no
534   fi
535   if test "$krb5_cv_getservbyname_r_returns_int" = yes; then
536     AC_DEFINE(GETSERVBYNAME_R_RETURNS_INT, 1, [Define if getservbyname_r returns int rather than struct servent * ])
537   fi
538 fi
539 if test "$ac_cv_func_getservbyname_r" = yes; then
540   AC_DEFINE(HAVE_GETSERVBYNAME_R, 1, [Define if getservbyname_r exists and its return type is known])
541   AC_CHECK_FUNC(getservbyport_r)
542 fi
543 ])
544
545 HAVE_YYLINENO
546 CHECK_DIRENT
547 AC_TYPE_UID_T
548
549 AC_CHECK_HEADER(termios.h,
550 [AC_CHECK_FUNC([tcsetattr],
551   AC_DEFINE(POSIX_TERMIOS,1,[Define if termios.h exists and tcsetattr exists]))])
552
553 KRB5_SIGTYPE
554 AC_CHECK_HEADERS(poll.h stdlib.h string.h stddef.h sys/types.h sys/file.h sys/param.h sys/stat.h sys/time.h netinet/in.h sys/uio.h sys/filio.h sys/select.h time.h paths.h errno.h)
555
556 # If compiling with IPv6 support, test if in6addr_any functions.
557 # Irix 6.5.16 defines it, but lacks support in the C library.
558 if test $krb5_cv_inet6 = yes || test "$krb5_cv_inet6_with_dinet6" = yes ; then
559 AC_CACHE_CHECK([for in6addr_any definition in library], 
560   krb5_cv_var_in6addr_any,
561 [AC_TRY_LINK([
562 #ifdef HAVE_SYS_TYPES_H
563 #include <sys/types.h>
564 #endif
565 #include <sys/socket.h>
566 #include <netinet/in.h>
567 #include <netdb.h>
568 ],[
569   struct sockaddr_in6 in;
570   in.sin6_addr = in6addr_any;
571   printf("%x", &in);
572 ],krb5_cv_var_in6addr_any=yes, krb5_cv_var_in6addr_any=no)])
573   if test $krb5_cv_var_in6addr_any = no; then
574     AC_DEFINE(NEED_INSIXADDR_ANY,1,[Define if in6addr_any is not defined in libc])
575   fi
576 fi
577
578
579
580 # check for ANSI stdio, esp "b" option to fopen().  This (unfortunately)
581 # requires a run check...
582
583 AC_MSG_CHECKING([for ANSI stdio])
584 AC_CACHE_VAL(krb5_cv_has_ansi_stdio,
585 [AC_TRY_RUN(
586 [#include <stdio.h>
587 int main()
588 {
589   FILE *conftest;
590   if ((conftest = fopen("conftest.dat", "w")) == NULL) exit(1);
591   if (fclose(conftest)) exit(1);
592   if ((conftest = fopen("conftest.dat", "rb+")) == NULL) exit(1);
593   if (fputs("testing ANSI for stdio\n", conftest) == EOF) exit(1);
594   exit(0);
595 }],
596 krb5_cv_has_ansi_stdio=yes, krb5_cv_has_ansi_stdio=no,
597 krb5_cv_has_ansi_stdio=yes)])# assume ANSI in cross environment
598 AC_MSG_RESULT($krb5_cv_has_ansi_stdio)
599 if test $krb5_cv_has_ansi_stdio = yes; then
600 AC_DEFINE(ANSI_STDIO,1,[Define if ANSI stdio is present (in particular "b" option to fopen)])
601 fi
602
603 # then from osconf.h, we have
604
605 AC_HEADER_TIME
606 AC_CHECK_TYPE(time_t, long)
607
608 # Determine where to put the replay cache.
609
610 AC_MSG_CHECKING([for replay cache directory])
611 AC_CACHE_VAL(krb5_cv_sys_rcdir,
612 [
613 for t_dir in /var/tmp /usr/tmp /var/usr/tmp /tmp ; do
614         test -d $t_dir || continue
615         krb5_cv_sys_rcdir=$t_dir
616         break
617 done])
618 AC_MSG_RESULT($krb5_cv_sys_rcdir)
619 KRB5_RCTMPDIR=$krb5_cv_sys_rcdir
620 AC_SUBST(KRB5_RCTMPDIR)
621
622
623 AC_MSG_CHECKING(for socklen_t)
624 AC_CACHE_VAL(krb5_cv_has_type_socklen_t,
625 [AC_TRY_COMPILE(
626 [#include <sys/types.h>
627 #include <sys/socket.h>
628 ],[sizeof (socklen_t);],
629 krb5_cv_has_type_socklen_t=yes,krb5_cv_has_type_socklen_t=no)])
630 AC_MSG_RESULT($krb5_cv_has_type_socklen_t)
631 if test $krb5_cv_has_type_socklen_t = yes; then
632     AC_DEFINE(HAVE_SOCKLEN_T,1,[Define if there is a socklen_t type. If not, probably use size_t])
633 fi
634
635 AC_MSG_CHECKING(for struct lifconf)
636 AC_CACHE_VAL(krb5_cv_has_struct_lifconf,
637 [AC_TRY_COMPILE(
638 [#include <sys/socket.h>
639 #include <net/if.h>
640 ],[sizeof (struct lifconf);],
641 krb5_cv_has_struct_lifconf=yes,krb5_cv_has_struct_lifconf=no)])
642 AC_MSG_RESULT($krb5_cv_has_struct_lifconf)
643 if test $krb5_cv_has_struct_lifconf = yes; then
644     AC_DEFINE(HAVE_STRUCT_LIFCONF,1,[Define if there is a struct lifconf.])
645 fi
646 # HP-UX 11 uses stuct if_laddrconf
647 AC_MSG_CHECKING(for struct if_laddrconf)
648 AC_CACHE_VAL(krb5_cv_has_struct_if_laddrconf,
649 [AC_TRY_COMPILE(
650 [#include <sys/socket.h>
651 #include <net/if.h>
652 #include <net/if6.h>
653 ],[sizeof (struct if_laddrconf);],
654 krb5_cv_has_struct_if_laddrconf=yes,krb5_cv_has_struct_if_laddrconf=no)])
655 AC_MSG_RESULT($krb5_cv_has_struct_if_laddrconf)
656 if test $krb5_cv_has_struct_if_laddrconf = yes; then
657     AC_DEFINE(HAVE_STRUCT_IF_LADDRCONF,1,[Define if there is a struct if_laddrconf.])
658 fi
659
660
661 AC_MSG_CHECKING([for h_errno in netdb.h])
662 AC_CACHE_VAL(krb5_cv_header_netdb_h_h_errno,
663 [AC_TRY_COMPILE(
664         [#include <netdb.h>],
665         [int x = h_errno;], krb5_cv_header_netdb_h_h_errno=yes,
666         krb5_cv_header_netdb_h_h_errno=no)])
667 AC_MSG_RESULT($krb5_cv_header_netdb_h_h_errno)
668 if test $krb5_cv_header_netdb_h_h_errno = yes; then
669     AC_DEFINE([HAVE_NETDB_H_H_ERRNO], 1,
670         [Define if netdb.h declares h_errno])
671 fi
672
673
674 AC_ARG_ENABLE([athena],
675 [  --enable-athena         build with MIT Project Athena configuration],
676 AC_DEFINE(KRB5_ATHENA_COMPAT,1,[Define if MIT Project Athena default configuration should be used]),)
677
678
679 AC_C_INLINE
680 AH_TOP([
681 #ifndef KRB5_AUTOCONF_H
682 #define KRB5_AUTOCONF_H
683 ])
684 AH_BOTTOM([
685 #if defined(__GNUC__) && !defined(inline)
686 /* Silence gcc pedantic warnings about ANSI C.  */
687 # define inline __inline__
688 #endif
689 #endif /* KRB5_AUTOCONF_H */
690 ])
691
692 # Not used yet, but let's find out what we've got on the platforms
693 # we're working with....
694 AC_CHECK_HEADERS(inttypes.h stdint.h)
695 AC_CHECK_TYPES([uint32_t, int32_t, uint64_t, int64_t, uint_least32_t, uintptr_t, uintmax_t, long long], , , [
696 #ifdef HAVE_STDINT_H
697 # include <stdint.h>
698 #elif defined(HAVE_INTTYPES_H)
699 # include <inttypes.h>
700 #endif
701 ])
702 AC_CHECK_TYPES([struct cmsghdr, struct in_pktinfo, struct in6_pktinfo, struct sockaddr_storage], , , [
703 #include <sys/types.h>
704 #include <sys/socket.h>
705 #include <netinet/in.h>
706 ])
707 AC_CHECK_TYPES([struct rt_msghdr], , , [
708 #include <sys/socket.h>
709 #include <net/if.h>
710 #include <net/route.h>
711 ])
712
713 # stuff for util/profile
714
715 # AC_KRB5_TCL already done
716 DO_TCL=
717 test "$TCL_LIBS" != "" && DO_TCL=ok
718 AC_SUBST(DO_TCL)
719
720 # types libdb2 wants
721
722 AC_CHECK_TYPES([ssize_t, u_char, u_int, u_long, u_int8_t, u_int16_t, u_int32_t, int8_t, int16_t, int32_t])
723
724 # Some libdb2 test programs want a shell that supports functions.
725 FCTSH=false
726 AC_PATH_PROG(SH,sh,false)
727 AC_PATH_PROG(SH5,sh5,false)
728 AC_PATH_PROG(BASH,bash,false)
729 for prog in $SH $SH5 $BASH; do
730   AC_MSG_CHECKING(if $prog supports functions)
731   if $prog -c 'foo() { true; }; foo' >/dev/null 2>&1; then
732     AC_MSG_RESULT(yes)
733     FCTSH=$prog
734     break
735   else
736     AC_MSG_RESULT(no)
737   fi
738 done
739 AC_SUBST(FCTSH)
740
741 # Test for POSIX 2001 *printf support (X/Open System Interfaces extension
742 # to ANSI/ISO C 1999 specification).  Specifically, positional
743 # specifications; not checking for other features like %zx at present.
744 AC_MSG_CHECKING(for POSIX printf positional specification support)
745 AC_CACHE_VAL(ac_cv_printf_positional,[
746 AC_TRY_RUN([
747 #include <stdio.h>
748 #include <string.h>
749 const char expected[] = "200 100";
750 int main () {
751     char buf[30];
752     sprintf(buf, "%2\$x %1\$d", 100, 512);
753     if (strcmp(expected, buf)) {
754         fprintf(stderr,"bad result: <%s> wanted: <%s>\n", buf, expected);
755         return 1;
756     }
757     return 0;
758 }],
759   ac_cv_printf_positional=yes,
760   ac_cv_printf_positional=no,
761   AC_MSG_ERROR([Cannot test for printf positional argument support when cross compiling]))])
762 # Nothing for autoconf.h for now.
763 AC_MSG_RESULT($ac_cv_printf_positional)
764
765
766 # for t_locate_kdc test
767
768 AC_PATH_PROG(DIG, dig, false)
769 AC_PATH_PROG(NSLOOKUP, nslookup, false)
770
771 # for kadmin
772
773 AC_PROG_YACC
774 ath_compat=
775 AC_ARG_ENABLE([athena],
776 [  --enable-athena         build with MIT Project Athena configuration],
777 ath_compat=compat,)
778 # The following are tests for the presence of programs required for
779 # kadmin testing.
780 AC_CHECK_PROG(have_RUNTEST,runtest,runtest)
781 AC_CHECK_PROG(have_PERL,perl,perl)
782 if test "$have_PERL" = perl -a "$have_RUNTEST" = runtest -a "$TCL_LIBS" != ""; then
783         DO_TEST=ok
784 fi
785 AC_SUBST(DO_TEST) 
786
787 # The following are substituted into kadmin/testing/scripts/env-setup.sh
788 RBUILD=`pwd`
789 AC_SUBST(RBUILD)
790 case "$srcdir" in
791 /*)     S_TOP=$srcdir ;;
792 *)      S_TOP=`pwd`/$srcdir ;;
793 esac
794 AC_SUBST(S_TOP)
795 AC_PATH_PROG(PERL_PATH,perl)
796 AC_PATH_PROG(EXPECT,expect)
797 # For kadmin/testing/util/Makefile.in
798 if test "$TCL_LIBS" != "" ;  then
799         DO_ALL=tcl
800 fi
801 AC_SUBST(DO_ALL)
802 KRB5_AC_PRIOCNTL_HACK
803 K5_GEN_FILE(kadmin/testing/scripts/env-setup.sh:kadmin/testing/scripts/env-setup.shin)
804 # for lib/kadm5
805 AC_CHECK_PROG(RUNTEST,runtest,runtest)
806 AC_CHECK_PROG(PERL,perl,perl)
807
808 # lib/gssapi
809 AC_CHECK_HEADER(stdint.h,[
810         include_stdint='awk '\''END{printf("%cinclude <stdint.h>\n", 35);}'\'' < /dev/null'],
811         include_stdint='echo "/* no stdint.h */"')
812 AC_SUBST(include_stdint)
813 AC_CHECK_HEADER(inttypes.h,[
814         include_inttypes='awk '\''END{printf("%cinclude <inttypes.h>\n", 35);}'\'' < /dev/null'],
815         include_inttypes='echo "/* no inttypes.h */"')
816 AC_SUBST(include_inttypes)
817 AC_CHECK_HEADER(xom.h,[
818         include_xom='awk '\''END{printf("%cinclude <xom.h>\n", 35);}'\'' < /dev/null'], [
819         include_xom='echo "/* no xom.h */"'])
820 AC_SUBST(include_xom)
821
822
823 # lib/rpc
824 ### Check where struct rpcent is declared.
825
826 # This is necessary to determine:
827 # 1. If /usr/include/netdb.h declares struct rpcent
828 # 2. If /usr/include/rpc/netdb.h declares struct rpcent
829
830 # We have our own rpc/netdb.h, and if /usr/include/netdb.h includes
831 # rpc/netdb.h, then nastiness could happen.
832
833 # Logic: If /usr/include/netdb.h declares struct rpcent, then check
834 # rpc/netdb.h.  If /usr/include/rpc/netdb.h declares struct rpcent,
835 # then define STRUCT_RPCENT_IN_RPC_NETDB_H, otherwise do not.  If
836 # neither netdb.h nor rpc/netdb.h declares struct rpcent, then define
837 # STRUCT_RPCENT_IN_RPC_NETDB_H anyway.
838
839 AC_MSG_CHECKING([where struct rpcent is declared])
840 AC_TRY_COMPILE([#include <netdb.h>],
841 [struct rpcent e;
842 char c = e.r_name[0];
843 int i = e.r_number;],
844 [AC_TRY_COMPILE([#include <rpc/netdb.h>],
845 [struct rpcent e;
846 char c = e.r_name[0];
847 int i = e.r_number;],
848 [AC_MSG_RESULT([rpc/netdb.h])
849 rpcent_define='#define STRUCT_RPCENT_IN_RPC_NETDB_H'],
850 [AC_MSG_RESULT([netdb.h])])],
851 [AC_MSG_RESULT([nowhere])
852 rpcent_define='#define STRUCT_RPCENT_IN_RPC_NETDB_H'])
853 AC_SUBST(rpcent_define)
854
855 AC_CHECK_HEADERS(sys/select.h sys/time.h unistd.h)
856 if test $ac_cv_header_sys_select_h = yes; then
857   GSSRPC__SYS_SELECT_H='#include <sys/select.h>'
858 else
859   GSSRPC__SYS_SELECT_H='/* #include <sys/select.h> */'
860 fi
861 AC_SUBST(GSSRPC__SYS_SELECT_H)
862 if test $ac_cv_header_sys_time_h = yes; then
863   GSSRPC__SYS_TIME_H='#include <sys/time.h>'
864 else
865   GSSRPC__SYS_TIME_H='/* #include <sys/time.h> */'
866 fi
867 AC_SUBST(GSSRPC__SYS_TIME_H)
868 if test $ac_cv_header_unistd_h = yes; then
869   GSSRPC__UNISTD_H='#include <unistd.h>'
870 else
871   GSSRPC__UNISTD_H='/* #include <unistd.h> */'
872 fi
873 AC_SUBST(GSSRPC__UNISTD_H)
874
875 AC_CACHE_CHECK([for MAXHOSTNAMELEN in sys/param.h],
876   [krb5_cv_header_sys_param_h_maxhostnamelen],
877   [AC_TRY_COMPILE([#include <sys/param.h>],
878     [int i = MAXHOSTNAMELEN;],
879     [krb5_cv_header_sys_param_h_maxhostnamelen=yes],
880     [krb5_cv_header_sys_param_h_maxhostnamelen=no])])
881 AC_CACHE_CHECK([for MAXHOSTNAMELEN in netdb.h],
882   [krb5_cv_header_netdb_h_maxhostnamelen],
883   [AC_TRY_COMPILE([#include <netdb.h>],
884     [int i = MAXHOSTNAMELEN;],
885     [krb5_cv_header_netdb_h_maxhostnamelen=yes],
886     [krb5_cv_header_netdb_h_maxhostnamelen=no])])
887
888 GSSRPC__SYS_PARAM_H='/* #include <sys/param.h> */'
889 GSSRPC__NETDB_H='/* #include <netdb.h> */'
890 if test $krb5_cv_header_sys_param_h_maxhostnamelen = yes; then
891   GSSRPC__SYS_PARAM_H='#include <sys/param.h>'
892 else
893   if test $krb5_cv_header_netdb_h_maxhostnamelen = yes; then
894     GSSRPC__NETDB_H='#include <netdb.h>'
895   else
896     AC_MSG_WARN([can't find MAXHOSTNAMELEN definition; faking it])
897   fi
898 fi
899 AC_SUBST(GSSRPC__SYS_PARAM_H)
900 AC_SUBST(GSSRPC__NETDB_H)
901
902 AC_CACHE_CHECK([for uint32_t in sys/types.h],
903   [krb5_cv_header_sys_types_h_uint32_t],
904   [AC_TRY_COMPILE([#include <sys/types.h>],
905       [uint32_t i = 0;],
906       [krb5_cv_header_sys_types_h_uint32_t=yes],
907       [krb5_cv_header_sys_types_h_uint32_t=no])])
908 AC_CACHE_CHECK([for uint32_t in stdint.h],
909   [krb5_cv_header_stdint_h_uint32_t],
910   [AC_TRY_COMPILE([#include <stdint.h>],
911       [uint32_t i = 0;],
912       [krb5_cv_header_stdint_h_uint32_t=yes],
913       [krb5_cv_header_stdint_h_uint32_t=no])])
914 AC_CACHE_CHECK([for uint32_t in inttypes.h],
915   [krb5_cv_header_inttypes_h_uint32_t],
916   [AC_TRY_COMPILE([#include <inttypes.h>],
917       [uint32_t i = 0;],
918       [krb5_cv_header_inttypes_h_uint32_t=yes],
919       [krb5_cv_header_inttypes_h_uint32_t=no])])
920 GSSRPC__STDINT_H='/* #include <stdint.h> */'
921 GSSRPC__INTTYPES_H='/* #include <inttypes.h> */'
922 GSSRPC__FAKE_UINT32='/* #undef GSSRPC__FAKE_INT32 */'
923 if test $krb5_cv_header_sys_types_h_uint32_t = yes; then
924   : # already included sys/types.h
925 else
926   if test $krb5_cv_header_stdint_h_uint32_t = yes; then
927     GSSRPC__STDINT_H='#include <stdint.h>'
928   else
929     if test $krb5_cv_header_inttypes_h_uint32_t = yes; then
930       GSSRPC__INTTYPES_H='#include <inttypes.h>'
931     else
932       AC_MSG_WARN([can't find a fixed-width 32-bit type anywhere; faking it])
933       GSSRPC__FAKE_UINT32='#define GSSRPC__FAKE_UINT32 1'
934     fi
935   fi
936 fi
937 AC_SUBST(GSSRPC__STDINT_H)
938 AC_SUBST(GSSRPC__INTTYPES_H)
939 AC_SUBST(GSSRPC__FAKE_UINT32)
940
941 AC_CACHE_CHECK([for BSD type aliases], [krb5_cv_type_bsdaliases],
942   [AC_TRY_COMPILE(
943     [#include <sys/types.h>
944 #if HAVE_UNISTD_H
945 #include <unistd.h>
946 #endif],
947     [u_char c;
948 u_int i;
949 u_long l;], [krb5_cv_type_bsdaliases=yes], [krb5_cv_type_bsdaliases=no])])
950 if test $krb5_cv_type_bsdaliases = yes; then
951   GSSRPC__BSD_TYPEALIASES='/* #undef GSSRPC__BSD_TYPEALIASES */'
952 else
953   GSSRPC__BSD_TYPEALIASES='#define GSSRPC__BSD_TYPEALIASES 1'
954 fi
955 AC_SUBST(GSSRPC__BSD_TYPEALIASES)
956
957 # sockaddr length field checks
958
959 AC_CHECK_MEMBERS([struct sockaddr_in.sin_len], , ,
960   [#include <sys/types.h>
961 @%:@include <netinet/in.h>])
962 AC_CHECK_MEMBERS([struct sockaddr.sa_len], , ,
963   [#include <sys/types.h>
964 @%:@include <sys/socket.h>])
965
966 AC_MSG_CHECKING([return type of setrpcent])
967 AC_CACHE_VAL(k5_cv_type_setrpcent,
968 [AC_TRY_COMPILE([#include <netdb.h>
969 #ifdef __cplusplus
970 extern "C"
971 #endif
972 extern void setrpcent();],
973 [int i;], k5_cv_type_setrpcent=void, k5_cv_type_setrpcent=int)])
974 AC_MSG_RESULT($k5_cv_type_setrpcent)
975 AC_DEFINE_UNQUOTED(SETRPCENT_TYPE, $k5_cv_type_setrpcent, [Define as return type of setrpcent])
976
977 AC_MSG_CHECKING([return type of endrpcent])
978 AC_CACHE_VAL(k5_cv_type_endrpcent,
979 [AC_TRY_COMPILE([#include <netdb.h>
980 #ifdef __cplusplus
981 extern "C"
982 #endif
983 extern void endrpcent();],
984 [int i;], k5_cv_type_endrpcent=void, k5_cv_type_endrpcent=int)])
985 AC_MSG_RESULT($k5_cv_type_endrpcent)
986 AC_DEFINE_UNQUOTED(ENDRPCENT_TYPE, $k5_cv_type_endrpcent, [Define as return type of endrpcent])
987 K5_GEN_FILE(include/gssrpc/types.h:include/gssrpc/types.hin)
988 changequote(<<, >>)
989 case "$krb5_cv_host" in
990 *-*-solaris2.[012345]*)
991         PASS=tcp
992         ;;
993 *)
994         PASS="tcp udp"
995         ;;
996 esac
997 changequote([, ])
998 AC_SUBST(PASS)
999
1000 # for pkinit
1001 AC_ARG_ENABLE([pkinit],
1002 [  --disable-pkinit        disable PKINIT plugin support],,
1003 enable_pkinit=try)
1004 if test "$enable_pkinit" = yes || test "$enable_pkinit" = try; then
1005   AC_CACHE_CHECK(for a recent enough OpenSSL, k5_cv_openssl_version_okay,
1006 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <openssl/opensslv.h>
1007 #if OPENSSL_VERSION_NUMBER < 0x00908000L
1008 # error openssl is too old, need 0.9.8
1009 #endif
1010 int i = 1;
1011 ])], k5_cv_openssl_version_okay=yes, k5_cv_openssl_version_okay=no)])
1012   old_LIBS="$LIBS"
1013   AC_CHECK_LIB(crypto, PKCS7_get_signer_info)
1014   LIBS="$old_LIBS"
1015 fi
1016 if test "$k5_cv_openssl_version_okay" = yes && (test "$enable_pkinit" = yes || test "$enable_pkinit" = try); then
1017   K5_GEN_MAKEFILE(plugins/preauth/pkinit)
1018   PKINIT=yes
1019 elif test "$k5_cv_openssl_version_okay" = no && test "$enable_pkinit" = yes; then
1020   AC_MSG_ERROR([Version of OpenSSL is too old; cannot enable PKINIT.])
1021 else
1022   AC_DEFINE([DISABLE_PKINIT], 1, [Define to disable PKINIT plugin support])
1023   AC_MSG_NOTICE([Disabling PKINIT support.])
1024   PKINIT=no
1025 fi
1026 AC_SUBST(PKINIT)
1027
1028 # for lib/apputils
1029 AC_REPLACE_FUNCS(daemon)
1030
1031 # for tests/
1032 if test x"$RUNTEST" != x; then
1033         HAVE_RUNTEST=yes
1034 else
1035         HAVE_RUNTEST=no
1036 fi
1037 AC_SUBST(HAVE_RUNTEST)
1038
1039 # For Python tests.
1040 AC_CHECK_PROG(PYTHON,python,python)
1041 HAVE_PYTHON=no
1042 if test x"$PYTHON" != x; then
1043         # k5test.py requires python 2.4 (for the subprocess module).
1044         vercheck="import sys;sys.exit((sys.hexversion < 0x2040000) and 1 or 0)"
1045         if python -c "$vercheck"; then
1046                 HAVE_PYTHON=yes
1047         fi
1048 fi
1049 AC_SUBST(HAVE_PYTHON)
1050
1051 # for plugins/kdb/db2
1052
1053 # AIX is unusual in that it wants all symbols resolved at link time
1054 #  Fortunately, it will allow us to link the kdb library now, even if
1055 # it is linked again later.
1056 case $krb5_cv_host in
1057 *-*-aix*)
1058         DB_EXTRA_LIBS=-ldb
1059         ;;
1060 *)
1061         DB_EXTRA_LIBS=
1062         ;;
1063 esac
1064 AC_SUBST(DB_EXTRA_LIBS)
1065
1066
1067
1068 # Check for thread safety issues.
1069 # (Is there a better place for this?)
1070 # tsfuncs="getpwnam_r getpwuid_r gethostbyname_r getservbyname_r gmtime_r localtime_r"
1071 # Removed getpwnam_r and getpwuid_r because include/configure.in has some
1072 # more careful checks, and may decide to pretend that they're not found if
1073 # the function signatures can't be figured out.
1074 tsfuncs="gethostbyname_r getservbyname_r gmtime_r localtime_r"
1075 AC_CHECK_FUNCS($tsfuncs)
1076 if test "$enable_thread_support" = yes; then
1077   tsmissing=""
1078   for ts in $tsfuncs; do
1079     if eval "test \"\${ac_cv_func_$ts}\" != yes"; then
1080       tsmissing="$tsmissing $ts"
1081     fi
1082   done
1083   if test "$ac_cv_func_res_nsearch/$ac_cv_lib_resolv_res_nsearch" = "no/no"; then
1084     tsmissing="$tsmissing res_nsearch"
1085   fi
1086   if test "$tsmissing" != ""; then
1087     AC_MSG_WARN([Some functions that are needed for library thread])
1088     AC_MSG_WARN([safety appear to be missing.])
1089     for ts in $tsmissing; do
1090       AC_MSG_WARN([  missing thread-safe function: $ts])
1091     done
1092     AC_MSG_WARN([Without these functions, the installed libraries])
1093     AC_MSG_WARN([may not be thread-safe.])
1094   fi # tsmissing not empty
1095 fi # enable_thread_support
1096
1097 # Sadly, we seem to have accidentally committed ourselves in 1.4 to
1098 # an ABI that includes the existence of libkrb5support.0 even
1099 # though random apps should never use anything from it.  And on
1100 # the Mac, to which that didn't apply, we can't use major version 0.
1101
1102 case $krb5_cv_host in
1103 *-*-darwin* | *-*-rhapsody*) SUPPORTLIB_MAJOR=1 ;;
1104 *)                           SUPPORTLIB_MAJOR=0 ;;
1105 esac
1106 AC_SUBST(SUPPORTLIB_MAJOR)
1107
1108
1109 if test "$COM_ERR_VERSION" = k5 ; then
1110   K5_GEN_MAKEFILE(util/et)
1111 fi
1112 if test "$SS_VERSION" = k5 ; then
1113   K5_GEN_MAKEFILE(util/ss)
1114 fi
1115
1116
1117 ldap_plugin_dir=""
1118 ldap_lib=""
1119 if test -n "$OPENLDAP_PLUGIN"; then
1120   AC_CHECK_HEADERS(ldap.h lber.h, :, [AC_MSG_ERROR($ac_header not found)])
1121   AC_CHECK_LIB(ldap, ldap_init, :, [AC_MSG_ERROR(libldap not found or missing ldap_init)])
1122   old_LIBS="$LIBS"
1123   LIBS="$LIBS -lldap"
1124   AC_CHECK_FUNCS(ldap_initialize ldap_url_parse_nodn ldap_unbind_ext_s ldap_str2dn ldap_explode_dn)
1125   LIBS="$old_LIBS"
1126
1127   BER_OKAY=0
1128   AC_CHECK_LIB(ldap, ber_init, [BER_OKAY=1])
1129   if test "$BER_OKAY" = "1"; then 
1130     LDAP_LIBS='-lldap'
1131   else
1132     AC_CHECK_LIB(lber, ber_init, [BER_OKAY=1], [AC_MSG_WARN([libber not found])])
1133     if test "$BER_OKAY" = "1"; then 
1134       LDAP_LIBS='-lldap -llber'
1135     else
1136       AC_ERROR("BER library missing - cannot build LDAP database module")
1137     fi
1138   fi
1139   AC_DEFINE([ENABLE_LDAP], 1, [Define if LDAP KDB support within the Kerberos library (mainly ASN.1 code) should be enabled.])
1140   AC_SUBST(LDAP_LIBS)
1141
1142   K5_GEN_MAKEFILE(plugins/kdb/ldap)
1143   K5_GEN_MAKEFILE(plugins/kdb/ldap/ldap_util)
1144   K5_GEN_MAKEFILE(plugins/kdb/ldap/libkdb_ldap)
1145   ldap_plugin_dir='plugins/kdb/ldap plugins/kdb/ldap/ldap_util'
1146   LDAP=yes
1147 else
1148   LDAP=no
1149 fi
1150 AC_SUBST(ldap_plugin_dir)
1151 AC_SUBST(LDAP)
1152 # This check is for plugins/preauth/securid_sam2
1153 sam2_plugin=""
1154 old_CFLAGS=$CFLAGS
1155 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1156 AC_CHECK_LIB(aceclnt, sd_init, [
1157              AC_MSG_NOTICE([Enabling RSA securID support])
1158              sam2_plugin=plugins/preauth/securid_sam2
1159              ])
1160 AC_SUBST(sam2_plugin)
1161 CFLAGS=$old_CFLAGS
1162
1163 # This checks is for plugins/locate/python, which isn't built by
1164 # default, so it's not a big deal that it isn't very good.  We should
1165 # use python-config instead.
1166 PYTHON_LIB=
1167 AC_CHECK_HEADERS(Python.h python2.3/Python.h python2.5/Python.h)
1168 AC_CHECK_LIB(python2.3,main,[PYTHON_LIB=-lpython2.3],
1169   AC_CHECK_LIB(python2.5,main,[PYTHON_LIB=-lpython2.5]))
1170 AC_SUBST(PYTHON_LIB)
1171
1172
1173 # Kludge for simple server --- FIXME is this the best way to do this?
1174
1175 if test "$ac_cv_lib_socket" = "yes" -a "$ac_cv_lib_nsl" = "yes"; then
1176         AC_DEFINE(BROKEN_STREAMS_SOCKETS,1,[Define if socket can't be bound to 0.0.0.0])
1177 fi
1178
1179 # Compile with libedit support in ss by default if available.  Compile
1180 # with readline only if asked, to avoid a default GPL dependency.
1181 # Building with readline also breaks the dejagnu test suite.
1182 AC_ARG_WITH([libedit],
1183             AC_HELP_STRING([--without-libedit], [do not compile with libedit]),
1184             [], [with_libedit=default])
1185 AC_ARG_WITH([readline],
1186             AC_HELP_STRING([--with-readline], [compile with GNU Readline]),
1187             [], [with_readline=no])
1188 AC_MSG_CHECKING([for readline support])
1189 if test "x$with_readline" = xyes; then
1190   with_libedit=no
1191 fi
1192 RL_CFLAGS=
1193 RL_LIBS=
1194 if test "x$with_libedit" != xno; then
1195   if rl_cflags=`pkg-config --cflags libedit 2>&1`; then
1196     RL_CFLAGS=$rl_cflags
1197     RL_LIBS=`pkg-config --libs libedit`
1198     AC_DEFINE([HAVE_LIBEDIT], 1, [Define if building with libedit.])
1199     AC_MSG_RESULT([using libedit])
1200   elif test "x$with_libedit" = yes; then
1201     # We were explicitly asked for libedit and couldn't find it.
1202     AC_MSG_ERROR([Could not detect libedit with pkg-config.])
1203   else
1204     AC_MSG_RESULT([not using any])
1205   fi
1206 elif test "x$with_readline" = xyes; then
1207   AC_MSG_RESULT([using GNU Readline])
1208   AC_CHECK_LIB([readline], [main], :,
1209                AC_MSG_FAILURE([Cannot find readline library.]), [-lncurses])
1210   AC_DEFINE([HAVE_READLINE], 1, [Define if building with GNU Readline.])
1211   RL_LIBS='-lreadline -lhistory -lncurses'
1212 else
1213   AC_MSG_RESULT([not using any])
1214 fi
1215 AC_SUBST([RL_CFLAGS])
1216 AC_SUBST([RL_LIBS])
1217
1218 AC_ARG_WITH([system-verto],
1219   [AC_HELP_STRING([--with-system-verto], [always use system verto library])],
1220   [], [with_system_verto=default])
1221 VERTO_CFLAGS=
1222 VERTO_LIBS="-lverto-k5ev -lverto"
1223 VERTO_VERSION=k5
1224 if test "x$with_system_verto" != xno; then
1225   if verto_cflags=`pkg-config --cflags libverto 2>&1`; then
1226     VERTO_CFLAGS=$verto_cflags
1227     VERTO_LIBS=`pkg-config --libs libverto`
1228     VERTO_VERSION=sys
1229   else
1230     AC_CHECK_LIB([verto], [verto_run], [VERTO_VERSION=sys; VERTO_LIBS=-lverto],
1231       [if test "x$with_system_verto" = xyes; then
1232         AC_MSG_ERROR([cannot detect system libverto])
1233       fi])
1234   fi
1235 fi
1236 if test "x$VERTO_VERSION" = xsys; then
1237   AC_MSG_NOTICE([Using system libverto])
1238 else
1239   AC_MSG_RESULT([Using built-in libverto])
1240   AC_DEFINE([INTERNAL_VERTO],[1],[Define if using bundled libverto])
1241 fi
1242 AC_SUBST([VERTO_CFLAGS])
1243 AC_SUBST([VERTO_LIBS])
1244 AC_SUBST([VERTO_VERSION])
1245
1246 AC_PATH_PROG(GROFF, groff)
1247
1248 # Make localedir work in autoconf 2.5x.
1249 if test "${localedir+set}" != set; then
1250     localedir='$(datadir)/locale'
1251 fi
1252 AC_SUBST(localedir)
1253
1254 AC_CONFIG_FILES(krb5-config, [chmod +x krb5-config])
1255 V5_AC_OUTPUT_MAKEFILE(.
1256
1257         util util/support util/profile util/profile/testmod util/send-pr
1258         util/verto util/k5ev
1259
1260         lib lib/kdb
1261
1262         lib/crypto lib/crypto/krb lib/crypto/$CRYPTO_IMPL
1263         lib/crypto/$CRYPTO_IMPL/enc_provider
1264         lib/crypto/$CRYPTO_IMPL/hash_provider
1265         lib/crypto/$CRYPTO_IMPL/des
1266         lib/crypto/$CRYPTO_IMPL/md4 lib/crypto/$CRYPTO_IMPL/md5
1267         lib/crypto/$CRYPTO_IMPL/sha1 lib/crypto/$CRYPTO_IMPL/sha2
1268         lib/crypto/$CRYPTO_IMPL/aes lib/crypto/$CRYPTO_IMPL/camellia
1269         lib/crypto/crypto_tests
1270
1271         lib/krb5 lib/krb5/error_tables lib/krb5/asn.1 lib/krb5/ccache
1272 dnl     lib/krb5/ccache/ccapi
1273         lib/krb5/keytab lib/krb5/krb lib/krb5/rcache lib/krb5/os
1274         lib/krb5/unicode
1275
1276         lib/gssapi lib/gssapi/generic lib/gssapi/krb5 lib/gssapi/spnego
1277         lib/gssapi/mechglue
1278
1279         lib/rpc lib/rpc/unit-test
1280
1281         lib/kadm5 lib/kadm5/clnt lib/kadm5/srv lib/kadm5/unit-test
1282
1283         lib/apputils
1284
1285 dnl     ccapi ccapi/lib ccapi/lib/unix ccapi/server ccapi/server/unix ccapi/test
1286
1287         kdc slave config-files gen-manpages man doc include
1288
1289         plugins/locate/python
1290         plugins/kadm5_hook/test
1291         plugins/kdb/db2
1292         plugins/kdb/db2/libdb2
1293         plugins/kdb/db2/libdb2/hash
1294         plugins/kdb/db2/libdb2/btree
1295         plugins/kdb/db2/libdb2/db
1296         plugins/kdb/db2/libdb2/mpool
1297         plugins/kdb/db2/libdb2/recno
1298         plugins/kdb/db2/libdb2/test
1299         plugins/kdb/hdb
1300         plugins/preauth/cksum_body
1301         plugins/preauth/securid_sam2
1302         plugins/preauth/wpse
1303         plugins/authdata/greet
1304         plugins/authdata/greet_client
1305         plugins/authdata/greet_server
1306
1307         clients clients/klist clients/kinit clients/kvno
1308         clients/kdestroy clients/kpasswd clients/ksu clients/kswitch
1309
1310         kadmin kadmin/cli kadmin/dbutil kadmin/ktutil kadmin/server
1311         kadmin/testing kadmin/testing/scripts kadmin/testing/util
1312
1313         appl
1314         appl/sample appl/sample/sclient appl/sample/sserver
1315         appl/simple appl/simple/client appl/simple/server
1316         appl/gss-sample appl/user_user
1317
1318         tests tests/resolve tests/asn.1 tests/create tests/hammer
1319         tests/verify tests/gssapi tests/dejagnu tests/threads tests/shlib
1320         tests/gss-threads tests/misc tests/mkeystash_compat
1321         util/gss-kernel-lib util/collected-client-lib
1322         po
1323 )