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