Fix initialization and pointer bugs in new code
[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 po=
70 AC_CHECK_HEADER(libintl.h, [
71         AC_SEARCH_LIBS(dgettext, intl, [
72                 po=po
73                 AC_DEFINE(ENABLE_NLS, 1,
74                         [Define if translation functions should be used.])])])
75 AC_SUBST(po)
76
77 # for kdc
78 AC_CHECK_HEADERS(syslog.h sys/sockio.h ifaddrs.h unistd.h fnmatch.h)
79 AC_CHECK_FUNCS(openlog syslog closelog strftime vsprintf vasprintf vsnprintf)
80 AC_CHECK_FUNCS(strlcpy fnmatch)
81
82 EXTRA_SUPPORT_SYMS=
83 AC_CHECK_FUNC(strlcpy,
84 [STRLCPY_ST_OBJ=
85 STRLCPY_OBJ=],
86 [STRLCPY_ST_OBJ=strlcpy.o
87 STRLCPY_OBJ='$(OUTPRE)strlcpy.$(OBJEXT)'
88 EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS krb5int_strlcpy krb5int_strlcat"])
89 AC_SUBST(STRLCPY_OBJ)
90 AC_SUBST(STRLCPY_ST_OBJ)
91
92 AC_CHECK_FUNC(fnmatch,
93 [FNMATCH_ST_OBJ=
94 FNMATCH_OBJ=],
95 [FNMATCH_ST_OBJ=fnmatch.o
96 FNMATCH_OBJ='$(OUTPRE)fnmatch.$(OBJEXT)'
97 EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS k5_fnmatch"])
98 AC_SUBST(FNMATCH_OBJ)
99 AC_SUBST(FNMATCH_ST_OBJ)
100
101 AC_CHECK_FUNC(vasprintf,
102 [PRINTF_ST_OBJ=
103 PRINTF_OBJ=],
104 [PRINTF_ST_OBJ=printf.o
105 PRINTF_OBJ='$(OUTPRE)printf.$(OBJEXT)'
106 EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS krb5int_asprintf krb5int_vasprintf"])
107 AC_SUBST(PRINTF_OBJ)
108 AC_SUBST(PRINTF_ST_OBJ)
109 KRB5_NEED_PROTO([#include <stdarg.h>
110 #include <stdio.h>
111 ],vasprintf)
112 KRB5_NEED_PROTO([#include <string.h>
113 #ifdef HAVE_UNISTD_H
114 #include <unistd.h>
115 #endif
116 /* Solaris 8 declares swab in stdlib.h.  */
117 #include <stdlib.h>
118 ],swab,1)
119 KRB5_NEED_PROTO([#include <ctype.h>],isblank,1)
120
121 AC_PROG_AWK
122 KRB5_AC_INET6
123 KRB5_SOCKADDR_SA_LEN
124 CHECK_SIGNALS
125
126 # --with-vague-errors disables useful error messages.
127
128 AC_ARG_WITH([vague-errors],
129 AC_HELP_STRING([--with-vague-errors],[Do not @<:@do@:>@ send helpful errors to client]), , withval=no)
130 if test "$withval" = yes; then
131         AC_MSG_RESULT(Supplying vague error messages to KDC clients)
132         AC_DEFINE(KRBCONF_VAGUE_ERRORS,1,[Define if the KDC should return only vague error codes to clients])
133 fi
134
135 # WITH_CRYPTO_IMPL
136
137 CRYPTO_IMPL="builtin"
138 AC_ARG_WITH([crypto-impl],
139 AC_HELP_STRING([--with-crypto-impl=IMPL], [use specified crypto implementation @<:@builtin@:>@]),
140 [CRYPTO_IMPL=$withval
141 AC_MSG_RESULT("k5crypto will use \'$withval\'")
142 ], withval=builtin)
143 case "$withval" in
144 builtin)
145   ;;
146 openssl)
147   AC_CHECK_LIB(crypto, PKCS7_get_signer_info)
148   ;;
149 nss)
150   if test "${CRYPTO_IMPL_CFLAGS+set}" != set; then
151     CRYPTO_IMPL_CFLAGS=`pkg-config --cflags nss`
152   fi
153   if test "${CRYPTO_IMPL_LIBS+set}" != set; then
154     CRYPTO_IMPL_LIBS="-lnss3 $(pkg-config --libs nss-util)"
155   fi
156   AC_DEFINE(CRYPTO_IMPL_NSS,1,[Define if crypto implementation is NSS])
157   save_CFLAGS=$CFLAGS
158   CFLAGS="$CFLAGS $CRYPTO_IMPL_CFLAGS"
159   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
160 #include <nss.h>
161 #if NSS_VMAJOR < 3 || (NSS_VMAJOR == 3 && NSS_VMINOR < 12)
162 #error
163 #elif NSS_VMAJOR == 3 && NSS_VMINOR == 12 && NSS_VPATCH < 9
164 #error
165 #endif
166   ])], [], [AC_MSG_ERROR([NSS version 3.12.9 or later required.])])
167   CFLAGS=$save_CFLAGS
168   ;;
169 *)
170   AC_MSG_ERROR([Unknown crypto implementation $withval])
171   ;;
172 esac
173 AC_CONFIG_COMMANDS(CRYPTO_IMPL, , CRYPTO_IMPL=$CRYPTO_IMPL)
174 AC_SUBST(CRYPTO_IMPL)
175 AC_SUBST(CRYPTO_IMPL_CFLAGS)
176 AC_SUBST(CRYPTO_IMPL_LIBS)
177
178 if test "$CRYPTO_IMPL" = nss; then
179         PRNG_ALG="nss"
180 else
181 AC_ARG_WITH([prng-alg],
182 AC_HELP_STRING([--with-prng-alg=ALG], [use specified PRNG algorithm. Ignored for nss. @<:@fortuna@:>@]),
183 [PRNG_ALG=$withval
184 AC_MSG_RESULT("k5crypto will use \'$withval\'")
185 ], PRNG_ALG=fortuna)
186 fi
187 AC_CONFIG_COMMANDS(PRNG_ALG, , PRNG_ALG=$PRNG_ALG)
188 AC_SUBST(PRNG_ALG)
189 if test "$PRNG_ALG" = fortuna; then
190         AC_DEFINE(FORTUNA,1,[Define if Fortuna PRNG is selected])
191 fi
192
193 # --with-kdc-kdb-update makes the KDC update the database with last request
194 # information and failure information.
195
196 AC_ARG_WITH([kdc-kdb-update],
197 AC_HELP_STRING([--with-kdc-kdb-update],[Update the database @<:@don't update@:>@]), , withval=no)
198 if test "$withval" = yes; then
199         AC_MSG_RESULT(Updating KDC database with each request)
200         AC_DEFINE(KRBCONF_KDC_MODIFIES_KDB,1,[Define if KDC should update database with each request])
201 fi
202
203 AC_ARG_ENABLE([kdc-lookaside-cache],
204 AC_HELP_STRING([--disable-kdc-lookaside-cache],
205                [Disable the cache which detects client retransmits]), ,
206                enableval=yes)
207 if test "$enableval" = no ; then
208         AC_DEFINE(NOCACHE,1,[Define if the KDC should use no lookaside cache])
209 fi
210 KRB5_RUN_FLAGS
211
212 AC_TYPE_SIGNAL
213
214 # from old include/configure.in
215 AH_TEMPLATE([HAVE_STRUCT_SOCKADDR_STORAGE], 
216 [Define if "struct sockaddr_storage" is available.])
217
218 AC_CONFIG_HEADERS(include/autoconf.h, [echo timestamp > include/autoconf.stamp])
219 AC_PROG_LEX
220 AC_C_CONST
221 AC_HEADER_DIRENT
222 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)
223
224 AC_CHECK_FUNC(mkstemp,
225 [MKSTEMP_ST_OBJ=
226 MKSTEMP_OBJ=],
227 [MKSTEMP_ST_OBJ='mkstemp.o'
228 MKSTEMP_OBJ='$(OUTPRE)mkstemp.$(OBJEXT)'
229 EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS krb5int_mkstemp"])
230 AC_SUBST(MKSTEMP_OBJ)
231 AC_SUBST(MKSTEMP_ST_OBJ)
232 AC_SUBST(EXTRA_SUPPORT_SYMS)
233
234 DECLARE_SYS_ERRLIST
235 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)
236 AC_CHECK_HEADER(regexp.h, [], [],
237 [#define INIT char *sp = instring;
238 #define GETC() (*sp++)
239 #define PEEKC() (*sp)
240 #define UNGETC(c) (--sp)
241 #define RETURN(c) return(c)
242 #define ERROR(c)
243 ])
244 AC_CHECK_MEMBERS([struct sockaddr_in.sin_len, struct sockaddr.sa_len], , ,
245   [#include <sys/types.h>
246 #include <netinet/in.h>])
247 AC_CHECK_MEMBERS([struct stat.st_mtimensec,struct stat.st_mtimespec.tv_nsec,struct stat.st_mtim.tv_nsec],,,[#include <sys/types.h>
248 #include <sys/stat.h>])
249 KRB5_AC_REGEX_FUNCS
250 AC_TYPE_OFF_T
251
252 # Fancy caching of perror result...
253 AC_MSG_CHECKING(for perror declaration)
254 AC_CACHE_VAL(krb5_cv_decl_perror,
255 [AC_EGREP_HEADER(perror, errno.h, 
256   krb5_cv_decl_perror=yes, krb5_cv_decl_perror=no)])
257 AC_MSG_RESULT($krb5_cv_decl_perror)
258 if test $krb5_cv_decl_perror = yes; then
259         AC_DEFINE(HDR_HAS_PERROR,1,[Define if errno.h declares perror])
260 fi
261
262 KRB5_NEED_PROTO([#include <time.h>],strptime)
263 CHECK_WAIT_TYPE
264 CHECK_SIGPROCMASK
265 AC_TYPE_GETGROUPS
266 CHECK_SETJMP
267
268 # *rpcent return types needed for lib/rpc
269
270 AC_MSG_CHECKING([return type of setrpcent])
271 AC_CACHE_VAL(k5_cv_type_setrpcent,
272 [AC_TRY_COMPILE([#include <netdb.h>
273 #ifdef __cplusplus
274 extern "C"
275 #endif
276 extern void setrpcent();],
277 [int i;], k5_cv_type_setrpcent=void, k5_cv_type_setrpcent=int)])
278 AC_MSG_RESULT($k5_cv_type_setrpcent)
279 AC_DEFINE_UNQUOTED(SETRPCENT_TYPE, $k5_cv_type_setrpcent, [Define as return type of setrpcent])
280
281 AC_MSG_CHECKING([return type of endrpcent])
282 AC_CACHE_VAL(k5_cv_type_endrpcent,
283 [AC_TRY_COMPILE([#include <netdb.h>
284 #ifdef __cplusplus
285 extern "C"
286 #endif
287 extern void endrpcent();],
288 [int i;], k5_cv_type_endrpcent=void, k5_cv_type_endrpcent=int)])
289 AC_MSG_RESULT($k5_cv_type_endrpcent)
290 AC_DEFINE_UNQUOTED(ENDRPCENT_TYPE, $k5_cv_type_endrpcent, [Define as return type of endrpcent])
291
292
293 # bswap_16 is a macro in byteswap.h under GNU libc
294 AC_MSG_CHECKING(for bswap_16)
295 AC_CACHE_VAL(krb5_cv_bswap_16,[
296 AC_TRY_LINK([#if HAVE_BYTESWAP_H
297 #include <byteswap.h>
298 #endif],[bswap_16(37);],krb5_cv_bswap_16=yes,krb5_cv_bswap_16=no)])
299 AC_MSG_RESULT($krb5_cv_bswap_16)
300 if test "$krb5_cv_bswap_16" = yes; then
301   AC_DEFINE(HAVE_BSWAP_16,1,[Define to 1 if bswap_16 is available via byteswap.h])
302 fi
303 AC_MSG_CHECKING(for bswap_64)
304 AC_CACHE_VAL(krb5_cv_bswap_64,[
305 AC_TRY_LINK([#if HAVE_BYTESWAP_H
306 #include <byteswap.h>
307 #endif],[bswap_64(37);],krb5_cv_bswap_64=yes,krb5_cv_bswap_64=no)])
308 AC_MSG_RESULT($krb5_cv_bswap_64)
309 if test "$krb5_cv_bswap_64" = yes; then
310   AC_DEFINE(HAVE_BSWAP_64,1,[Define to 1 if bswap_64 is available via byteswap.h])
311 fi
312
313 # Needed for ksu and some appl stuff.
314
315 case $krb5_cv_host in
316 alpha*-dec-osf*)
317         AC_CHECK_LIB(security,setluid,
318                 AC_DEFINE(HAVE_SETLUID,1,[Define if setluid provided in OSF/1 security library])
319                 KSU_LIBS="-lsecurity"
320         )
321         ;;
322 esac
323 AC_SUBST(KSU_LIBS)
324
325 if test $ac_cv_func_setenv = no || test $ac_cv_func_unsetenv = no \
326   || test $ac_cv_func_getenv = no; then
327   SETENVOBJ=setenv.o
328 else
329   SETENVOBJ=
330 fi
331 AC_SUBST(SETENVOBJ)
332
333 # Check what the return types for gethostbyname_r and getservbyname_r are.
334
335 AC_CHECK_FUNC(gethostbyname_r,[
336 ac_cv_func_gethostbyname_r=yes
337 if test "$ac_cv_func_gethostbyname_r" = yes; then
338   AC_MSG_CHECKING([if gethostbyname_r returns an int])
339   AC_CACHE_VAL(krb5_cv_gethostbyname_r_returns_int,
340   [AC_TRY_COMPILE([#include <netdb.h>
341   extern int gethostbyname_r ();], [1;],
342   krb5_cv_gethostbyname_r_returns_int=yes,
343   krb5_cv_gethostbyname_r_returns_int=no)])
344   AC_MSG_RESULT($krb5_cv_gethostbyname_r_returns_int)
345
346   AC_MSG_CHECKING([if gethostbyname_r returns a pointer])
347   AC_CACHE_VAL(krb5_cv_gethostbyname_r_returns_ptr,
348   [AC_TRY_COMPILE([#include <netdb.h>
349   extern struct hostent *gethostbyname_r ();], [1;],
350   krb5_cv_gethostbyname_r_returns_ptr=yes,
351   krb5_cv_gethostbyname_r_returns_ptr=no)])
352   AC_MSG_RESULT($krb5_cv_gethostbyname_r_returns_ptr)
353
354   if test "$krb5_cv_gethostbyname_r_returns_int" = "$krb5_cv_gethostbyname_r_returns_ptr"; then
355     AC_MSG_WARN(cannot determine return type of gethostbyname_r -- disabling)
356     ac_cv_func_gethostbyname_r=no
357   fi
358   if test "$krb5_cv_gethostbyname_r_returns_int" = yes; then
359     AC_DEFINE(GETHOSTBYNAME_R_RETURNS_INT, 1, [Define if gethostbyname_r returns int rather than struct hostent * ])
360   fi
361 fi
362 if test "$ac_cv_func_gethostbyname_r" = yes; then
363   AC_DEFINE(HAVE_GETHOSTBYNAME_R, 1, [Define if gethostbyname_r exists and its return type is known])
364   AC_CHECK_FUNC(gethostbyaddr_r)
365 fi
366 ])
367
368
369 AC_CHECK_FUNC(getpwnam_r,ac_cv_func_getpwnam_r=yes,ac_cv_func_getpwnam_r=no)
370 AC_CHECK_FUNC(getpwuid_r,ac_cv_func_getpwuid_r=yes,ac_cv_func_getpwuid_r=no)
371 if test "$ac_cv_func_getpwnam_r" = yes; then
372   AC_MSG_CHECKING([return type of getpwnam_r])
373   AC_CACHE_VAL(krb5_cv_getpwnam_r_return_type,
374   [AC_TRY_COMPILE([#include <pwd.h>
375    extern int getpwnam_r();], [1;],
376    getpwnam_r_returns_int=yes,getpwnam_r_returns_int=no)
377    AC_TRY_COMPILE([#include <pwd.h>
378    extern struct passwd *getpwnam_r();], [1;],
379    getpwnam_r_returns_ptr=yes,getpwnam_r_returns_ptr=no)
380    case "$getpwnam_r_returns_int/$getpwnam_r_returns_ptr" in
381      yes/no) krb5_cv_getpwnam_r_return_type=int ;;
382      no/yes) krb5_cv_getpwnam_r_return_type=ptr ;;
383      *) krb5_cv_getpwnam_r_return_type=unknown ;;
384    esac])
385   AC_MSG_RESULT($krb5_cv_getpwnam_r_return_type)
386   if test $krb5_cv_getpwnam_r_return_type = int; then
387     AC_DEFINE(GETPWNAM_R_RETURNS_INT, 1, [Define if getpwnam_r returns an int])
388   elif test $krb5_cv_getpwnam_r_return_type = unknown; then
389     AC_MSG_WARN([Cannot determine getpwnam_r return type, disabling getpwnam_r])
390     ac_cv_func_getpwnam_r=no
391   fi
392 fi
393 if test "$ac_cv_func_getpwnam_r" = yes; then
394   AC_MSG_CHECKING([number of arguments to getpwnam_r])
395   AC_CACHE_VAL(krb5_cv_getpwnam_r_args,
396   [AC_TRY_COMPILE([#include <pwd.h>
397    struct passwd pwx; char buf[1024];],
398    [getpwnam_r("", &pwx, buf, sizeof(buf));], args4=yes, args4=no)
399    AC_TRY_COMPILE([#include <pwd.h>
400    struct passwd pwx, *p; char buf[1024];],
401    [getpwnam_r("", &pwx, buf, sizeof(buf), &p);], args5=yes, args5=no)
402    case $args4/$args5 in
403      yes/no) krb5_cv_getpwnam_r_args=4 ;;
404      no/yes) krb5_cv_getpwnam_r_args=5 ;;
405      *) krb5_cv_getpwnam_r_args=unknown ;;
406    esac])
407   AC_MSG_RESULT($krb5_cv_getpwnam_r_args)
408   if test "$krb5_cv_getpwnam_r_args" = unknown; then
409     AC_MSG_WARN([Cannot determine number of arguments to getpwnam_r, disabling its use.])
410     ac_cv_func_getpwnam_r=no
411   else
412     AC_DEFINE(HAVE_GETPWNAM_R,1,[Define if getpwnam_r is available and useful.])
413     if test "$krb5_cv_getpwnam_r_args" = 4; then
414       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).])
415     fi
416   fi
417 fi
418
419 if test "$ac_cv_func_getpwnam_r" = no && test "$ac_cv_func_getpwuid_r" = yes; then
420   # Actually, we could do this check, and the corresponding checks
421   # for return type and number of arguments, but I doubt we'll run
422   # into a system where we'd get to use getpwuid_r but not getpwnam_r.
423   AC_MSG_NOTICE([getpwnam_r not useful, so disabling getpwuid_r too])
424   ac_cv_func_getpwuid_r=no
425 fi
426 if test "$ac_cv_func_getpwuid_r" = yes; then
427   AC_DEFINE(HAVE_GETPWUID_R,1,[Define if getpwuid_r is available and useful.])
428   # Hack: Assume getpwuid_r is the shorter form if getpwnam_r is.
429   if test "$krb5_cv_getpwnam_r_args" = 4; then
430     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).])
431   fi
432 fi
433
434 if test "$ac_cv_func_gmtime_r" = yes; then
435   AC_MSG_CHECKING([whether gmtime_r returns int])
436   AC_CACHE_VAL(krb5_cv_gmtime_r_returns_int,
437   [AC_TRY_COMPILE([#include <time.h>
438    extern int gmtime_r ();], [1;], return_int=yes, return_int=no)
439    AC_TRY_COMPILE([#include <time.h>
440    extern struct tm *gmtime_r ();], [1;], return_ptr=yes, return_ptr=no)
441    case $return_int/$return_ptr in
442      yes/no) krb5_cv_gmtime_r_returns_int=yes ;;
443      no/yes) krb5_cv_gmtime_r_returns_int=no ;;
444      *)      # Can't figure it out, punt the function.
445              ac_cv_func_gmtime_r=no ;;
446    esac])
447   if test "$ac_cv_func_gmtime_r" = no; then
448     AC_MSG_RESULT(unknown -- ignoring gmtime_r)
449   else
450     AC_MSG_RESULT($krb5_cv_gmtime_r_returns_int)
451     if test "$krb5_cv_gmtime_r_returns_int" = yes; then
452       AC_DEFINE(GMTIME_R_RETURNS_INT,1,[Define if gmtime_r returns int instead of struct tm pointer, as on old HP-UX systems.])
453     fi
454   fi
455 fi
456
457 AC_CHECK_FUNC(getservbyname_r,[
458 ac_cv_func_getservbyname_r=yes
459 if test "$ac_cv_func_getservbyname_r" = yes; then
460   AC_MSG_CHECKING([if getservbyname_r returns an int])
461   AC_CACHE_VAL(krb5_cv_getservbyname_r_returns_int,
462   [AC_TRY_COMPILE([#include <netdb.h>
463   extern int getservbyname_r ();], [1;],
464   krb5_cv_getservbyname_r_returns_int=yes,
465   krb5_cv_getservbyname_r_returns_int=no)])
466   AC_MSG_RESULT($krb5_cv_getservbyname_r_returns_int)
467
468   AC_MSG_CHECKING([if getservbyname_r returns a pointer])
469   AC_CACHE_VAL(krb5_cv_getservbyname_r_returns_ptr,
470   [AC_TRY_COMPILE([#include <netdb.h>
471   extern struct servent *getservbyname_r ();], [1;],
472   krb5_cv_getservbyname_r_returns_ptr=yes,
473   krb5_cv_getservbyname_r_returns_ptr=no)])
474   AC_MSG_RESULT($krb5_cv_getservbyname_r_returns_ptr)
475
476   if test "$krb5_cv_getservbyname_r_returns_int" = "$krb5_cv_getservbyname_r_returns_ptr"; then
477     AC_MSG_WARN(cannot determine return type of getservbyname_r -- disabling)
478     ac_cv_func_getservbyname_r=no
479   fi
480   if test "$krb5_cv_getservbyname_r_returns_int" = yes; then
481     AC_DEFINE(GETSERVBYNAME_R_RETURNS_INT, 1, [Define if getservbyname_r returns int rather than struct servent * ])
482   fi
483 fi
484 if test "$ac_cv_func_getservbyname_r" = yes; then
485   AC_DEFINE(HAVE_GETSERVBYNAME_R, 1, [Define if getservbyname_r exists and its return type is known])
486   AC_CHECK_FUNC(getservbyport_r)
487 fi
488 ])
489
490 HAVE_YYLINENO
491 CHECK_DIRENT
492 AC_TYPE_UID_T
493
494 AC_CHECK_HEADER(termios.h,
495 [AC_CHECK_FUNC([tcsetattr],
496   AC_DEFINE(POSIX_TERMIOS,1,[Define if termios.h exists and tcsetattr exists]))])
497
498 KRB5_SIGTYPE
499 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)
500
501 # If compiling with IPv6 support, test if in6addr_any functions.
502 # Irix 6.5.16 defines it, but lacks support in the C library.
503 if test $krb5_cv_inet6 = yes || test "$krb5_cv_inet6_with_dinet6" = yes ; then
504 AC_CACHE_CHECK([for in6addr_any definition in library], 
505   krb5_cv_var_in6addr_any,
506 [AC_TRY_LINK([
507 #ifdef HAVE_SYS_TYPES_H
508 #include <sys/types.h>
509 #endif
510 #include <sys/socket.h>
511 #include <netinet/in.h>
512 #include <netdb.h>
513 ],[
514   struct sockaddr_in6 in;
515   in.sin6_addr = in6addr_any;
516   printf("%x", &in);
517 ],krb5_cv_var_in6addr_any=yes, krb5_cv_var_in6addr_any=no)])
518   if test $krb5_cv_var_in6addr_any = no; then
519     AC_DEFINE(NEED_INSIXADDR_ANY,1,[Define if in6addr_any is not defined in libc])
520   fi
521 fi
522
523
524
525 # check for ANSI stdio, esp "b" option to fopen().  This (unfortunately)
526 # requires a run check...
527
528 AC_MSG_CHECKING([for ANSI stdio])
529 AC_CACHE_VAL(krb5_cv_has_ansi_stdio,
530 [AC_TRY_RUN(
531 [#include <stdio.h>
532 int main()
533 {
534   FILE *conftest;
535   if ((conftest = fopen("conftest.dat", "w")) == NULL) exit(1);
536   if (fclose(conftest)) exit(1);
537   if ((conftest = fopen("conftest.dat", "rb+")) == NULL) exit(1);
538   if (fputs("testing ANSI for stdio\n", conftest) == EOF) exit(1);
539   exit(0);
540 }],
541 krb5_cv_has_ansi_stdio=yes, krb5_cv_has_ansi_stdio=no,
542 krb5_cv_has_ansi_stdio=yes)])# assume ANSI in cross environment
543 AC_MSG_RESULT($krb5_cv_has_ansi_stdio)
544 if test $krb5_cv_has_ansi_stdio = yes; then
545 AC_DEFINE(ANSI_STDIO,1,[Define if ANSI stdio is present (in particular "b" option to fopen)])
546 fi
547
548 # then from osconf.h, we have
549
550 AC_HEADER_TIME
551 AC_CHECK_TYPE(time_t, long)
552
553 # Determine where to put the replay cache.
554
555 AC_MSG_CHECKING([for replay cache directory])
556 AC_CACHE_VAL(krb5_cv_sys_rcdir,
557 [
558 for t_dir in /var/tmp /usr/tmp /var/usr/tmp /tmp ; do
559         test -d $t_dir || continue
560         krb5_cv_sys_rcdir=$t_dir
561         break
562 done])
563 AC_MSG_RESULT($krb5_cv_sys_rcdir)
564 KRB5_RCTMPDIR=$krb5_cv_sys_rcdir
565 AC_SUBST(KRB5_RCTMPDIR)
566
567
568 AC_MSG_CHECKING(for socklen_t)
569 AC_CACHE_VAL(krb5_cv_has_type_socklen_t,
570 [AC_TRY_COMPILE(
571 [#include <sys/types.h>
572 #include <sys/socket.h>
573 ],[sizeof (socklen_t);],
574 krb5_cv_has_type_socklen_t=yes,krb5_cv_has_type_socklen_t=no)])
575 AC_MSG_RESULT($krb5_cv_has_type_socklen_t)
576 if test $krb5_cv_has_type_socklen_t = yes; then
577     AC_DEFINE(HAVE_SOCKLEN_T,1,[Define if there is a socklen_t type. If not, probably use size_t])
578 fi
579
580 AC_MSG_CHECKING(for struct lifconf)
581 AC_CACHE_VAL(krb5_cv_has_struct_lifconf,
582 [AC_TRY_COMPILE(
583 [#include <sys/socket.h>
584 #include <net/if.h>
585 ],[sizeof (struct lifconf);],
586 krb5_cv_has_struct_lifconf=yes,krb5_cv_has_struct_lifconf=no)])
587 AC_MSG_RESULT($krb5_cv_has_struct_lifconf)
588 if test $krb5_cv_has_struct_lifconf = yes; then
589     AC_DEFINE(HAVE_STRUCT_LIFCONF,1,[Define if there is a struct lifconf.])
590 fi
591 # HP-UX 11 uses stuct if_laddrconf
592 AC_MSG_CHECKING(for struct if_laddrconf)
593 AC_CACHE_VAL(krb5_cv_has_struct_if_laddrconf,
594 [AC_TRY_COMPILE(
595 [#include <sys/socket.h>
596 #include <net/if.h>
597 #include <net/if6.h>
598 ],[sizeof (struct if_laddrconf);],
599 krb5_cv_has_struct_if_laddrconf=yes,krb5_cv_has_struct_if_laddrconf=no)])
600 AC_MSG_RESULT($krb5_cv_has_struct_if_laddrconf)
601 if test $krb5_cv_has_struct_if_laddrconf = yes; then
602     AC_DEFINE(HAVE_STRUCT_IF_LADDRCONF,1,[Define if there is a struct if_laddrconf.])
603 fi
604
605
606 AC_MSG_CHECKING([for h_errno in netdb.h])
607 AC_CACHE_VAL(krb5_cv_header_netdb_h_h_errno,
608 [AC_TRY_COMPILE(
609         [#include <netdb.h>],
610         [int x = h_errno;], krb5_cv_header_netdb_h_h_errno=yes,
611         krb5_cv_header_netdb_h_h_errno=no)])
612 AC_MSG_RESULT($krb5_cv_header_netdb_h_h_errno)
613 if test $krb5_cv_header_netdb_h_h_errno = yes; then
614     AC_DEFINE([HAVE_NETDB_H_H_ERRNO], 1,
615         [Define if netdb.h declares h_errno])
616 fi
617
618
619 AC_ARG_ENABLE([athena],
620 [  --enable-athena         build with MIT Project Athena configuration],
621 AC_DEFINE(KRB5_ATHENA_COMPAT,1,[Define if MIT Project Athena default configuration should be used]),)
622
623
624 AC_C_INLINE
625 AH_TOP([
626 #ifndef KRB5_AUTOCONF_H
627 #define KRB5_AUTOCONF_H
628 ])
629 AH_BOTTOM([
630 #if defined(__GNUC__) && !defined(inline)
631 /* Silence gcc pedantic warnings about ANSI C.  */
632 # define inline __inline__
633 #endif
634 #endif /* KRB5_AUTOCONF_H */
635 ])
636
637 # Not used yet, but let's find out what we've got on the platforms
638 # we're working with....
639 AC_CHECK_HEADERS(inttypes.h stdint.h)
640 AC_CHECK_TYPES([uint32_t, int32_t, uint64_t, int64_t, uint_least32_t, uintptr_t, uintmax_t, long long], , , [
641 #ifdef HAVE_STDINT_H
642 # include <stdint.h>
643 #elif defined(HAVE_INTTYPES_H)
644 # include <inttypes.h>
645 #endif
646 ])
647 AC_CHECK_TYPES([struct cmsghdr, struct in_pktinfo, struct in6_pktinfo, struct sockaddr_storage], , , [
648 #include <sys/types.h>
649 #include <sys/socket.h>
650 #include <netinet/in.h>
651 ])
652 AC_CHECK_TYPES([struct rt_msghdr], , , [
653 #include <sys/socket.h>
654 #include <net/if.h>
655 #include <net/route.h>
656 ])
657
658 # stuff for util/profile
659
660 # AC_KRB5_TCL already done
661 DO_TCL=
662 test "$TCL_LIBS" != "" && DO_TCL=ok
663 AC_SUBST(DO_TCL)
664
665 # types libdb2 wants
666
667 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])
668
669 # Some libdb2 test programs want a shell that supports functions.
670 FCTSH=false
671 AC_PATH_PROG(SH,sh,false)
672 AC_PATH_PROG(SH5,sh5,false)
673 AC_PATH_PROG(BASH,bash,false)
674 for prog in $SH $SH5 $BASH; do
675   AC_MSG_CHECKING(if $prog supports functions)
676   if $prog -c 'foo() { true; }; foo' >/dev/null 2>&1; then
677     AC_MSG_RESULT(yes)
678     FCTSH=$prog
679     break
680   else
681     AC_MSG_RESULT(no)
682   fi
683 done
684 AC_SUBST(FCTSH)
685
686 # Test for POSIX 2001 *printf support (X/Open System Interfaces extension
687 # to ANSI/ISO C 1999 specification).  Specifically, positional
688 # specifications; not checking for other features like %zx at present.
689 AC_MSG_CHECKING(for POSIX printf positional specification support)
690 AC_CACHE_VAL(ac_cv_printf_positional,[
691 AC_TRY_RUN([
692 #include <stdio.h>
693 #include <string.h>
694 const char expected[] = "200 100";
695 int main () {
696     char buf[30];
697     sprintf(buf, "%2\$x %1\$d", 100, 512);
698     if (strcmp(expected, buf)) {
699         fprintf(stderr,"bad result: <%s> wanted: <%s>\n", buf, expected);
700         return 1;
701     }
702     return 0;
703 }],
704   ac_cv_printf_positional=yes,
705   ac_cv_printf_positional=no,
706   AC_MSG_ERROR([Cannot test for printf positional argument support when cross compiling]))])
707 # Nothing for autoconf.h for now.
708 AC_MSG_RESULT($ac_cv_printf_positional)
709
710
711 # for t_locate_kdc test
712
713 AC_PATH_PROG(DIG, dig, false)
714 AC_PATH_PROG(NSLOOKUP, nslookup, false)
715
716 # for kadmin
717
718 AC_PROG_YACC
719 ath_compat=
720 AC_ARG_ENABLE([athena],
721 [  --enable-athena         build with MIT Project Athena configuration],
722 ath_compat=compat,)
723 # The following are tests for the presence of programs required for
724 # kadmin testing.
725 AC_CHECK_PROG(have_RUNTEST,runtest,runtest)
726 AC_CHECK_PROG(have_PERL,perl,perl)
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([AC_LANG_SOURCE([#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
1051 if test "$COM_ERR_VERSION" = k5 ; then
1052   K5_GEN_MAKEFILE(util/et)
1053 fi
1054 if test "$SS_VERSION" = k5 ; then
1055   K5_GEN_MAKEFILE(util/ss)
1056 fi
1057
1058
1059 ldap_plugin_dir=""
1060 ldap_lib=""
1061 if test -n "$OPENLDAP_PLUGIN"; then
1062   AC_CHECK_HEADERS(ldap.h lber.h, :, [AC_MSG_ERROR($ac_header not found)])
1063   AC_CHECK_LIB(ldap, ldap_init, :, [AC_MSG_ERROR(libldap not found or missing ldap_init)])
1064   old_LIBS="$LIBS"
1065   LIBS="$LIBS -lldap"
1066   AC_CHECK_FUNCS(ldap_initialize ldap_url_parse_nodn ldap_unbind_ext_s ldap_str2dn ldap_explode_dn)
1067   LIBS="$old_LIBS"
1068
1069   BER_OKAY=0
1070   AC_CHECK_LIB(ldap, ber_init, [BER_OKAY=1])
1071   if test "$BER_OKAY" = "1"; then 
1072     LDAP_LIBS='-lldap'
1073   else
1074     AC_CHECK_LIB(lber, ber_init, [BER_OKAY=1], [AC_MSG_WARN([libber not found])])
1075     if test "$BER_OKAY" = "1"; then 
1076       LDAP_LIBS='-lldap -llber'
1077     else
1078       AC_ERROR("BER library missing - cannot build LDAP database module")
1079     fi
1080   fi
1081   AC_DEFINE([ENABLE_LDAP], 1, [Define if LDAP KDB support within the Kerberos library (mainly ASN.1 code) should be enabled.])
1082   AC_SUBST(LDAP_LIBS)
1083
1084   K5_GEN_MAKEFILE(plugins/kdb/ldap)
1085   K5_GEN_MAKEFILE(plugins/kdb/ldap/ldap_util)
1086   K5_GEN_MAKEFILE(plugins/kdb/ldap/libkdb_ldap)
1087   ldap_plugin_dir='plugins/kdb/ldap plugins/kdb/ldap/ldap_util'
1088   LDAP=yes
1089 else
1090   LDAP=no
1091 fi
1092 AC_SUBST(ldap_plugin_dir)
1093 AC_SUBST(LDAP)
1094 # This check is for plugins/preauth/securid_sam2
1095 sam2_plugin=""
1096 old_CFLAGS=$CFLAGS
1097 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1098 AC_CHECK_LIB(aceclnt, sd_init, [
1099              AC_MSG_NOTICE([Enabling RSA securID support])
1100              sam2_plugin=plugins/preauth/securid_sam2
1101              ])
1102 AC_SUBST(sam2_plugin)
1103 CFLAGS=$old_CFLAGS
1104
1105 # This checks is for plugins/locate/python, which isn't built by
1106 # default, so it's not a big deal that it isn't very good.  We should
1107 # use python-config instead.
1108 PYTHON_LIB=
1109 AC_CHECK_HEADERS(Python.h python2.3/Python.h python2.5/Python.h)
1110 AC_CHECK_LIB(python2.3,main,[PYTHON_LIB=-lpython2.3],
1111   AC_CHECK_LIB(python2.5,main,[PYTHON_LIB=-lpython2.5]))
1112 AC_SUBST(PYTHON_LIB)
1113
1114
1115 # Kludge for simple server --- FIXME is this the best way to do this?
1116
1117 if test "$ac_cv_lib_socket" = "yes" -a "$ac_cv_lib_nsl" = "yes"; then
1118         AC_DEFINE(BROKEN_STREAMS_SOCKETS,1,[Define if socket can't be bound to 0.0.0.0])
1119 fi
1120
1121 # Compile with libedit support in ss by default if available.  Compile
1122 # with readline only if asked, to avoid a default GPL dependency.
1123 # Building with readline also breaks the dejagnu test suite.
1124 AC_ARG_WITH([libedit],
1125             AC_HELP_STRING([--without-libedit], [do not compile with libedit]),
1126             [], [with_libedit=default])
1127 AC_ARG_WITH([readline],
1128             AC_HELP_STRING([--with-readline], [compile with GNU Readline]),
1129             [], [with_readline=no])
1130 AC_MSG_CHECKING([for readline support])
1131 if test "x$with_readline" = xyes; then
1132   with_libedit=no
1133 fi
1134 RL_CFLAGS=
1135 RL_LIBS=
1136 if test "x$with_libedit" != xno; then
1137   if rl_cflags=`pkg-config --cflags libedit 2>&1`; then
1138     RL_CFLAGS=$rl_cflags
1139     RL_LIBS=`pkg-config --libs libedit`
1140     AC_DEFINE([HAVE_LIBEDIT], 1, [Define if building with libedit.])
1141     AC_MSG_RESULT([using libedit])
1142   elif test "x$with_libedit" = yes; then
1143     # We were explicitly asked for libedit and couldn't find it.
1144     AC_MSG_ERROR([Could not detect libedit with pkg-config.])
1145   else
1146     AC_MSG_RESULT([not using any])
1147   fi
1148 elif test "x$with_readline" = xyes; then
1149   AC_MSG_RESULT([using GNU Readline])
1150   AC_CHECK_LIB([readline], [main], :,
1151                AC_MSG_FAILURE([Cannot find readline library.]), [-lncurses])
1152   AC_DEFINE([HAVE_READLINE], 1, [Define if building with GNU Readline.])
1153   RL_LIBS='-lreadline -lhistory -lncurses'
1154 else
1155   AC_MSG_RESULT([not using any])
1156 fi
1157 AC_SUBST([RL_CFLAGS])
1158 AC_SUBST([RL_LIBS])
1159
1160 AC_ARG_WITH([system-verto],
1161   [AC_HELP_STRING([--with-system-verto], [always use system verto library])],
1162   [], [with_system_verto=default])
1163 VERTO_CFLAGS=
1164 VERTO_LIBS="-lverto-k5ev -lverto"
1165 VERTO_VERSION=k5
1166 if test "x$with_system_verto" != xno; then
1167   if verto_cflags=`pkg-config --cflags libverto 2>&1`; then
1168     VERTO_CFLAGS=$verto_cflags
1169     VERTO_LIBS=`pkg-config --libs libverto`
1170     VERTO_VERSION=sys
1171   else
1172     AC_CHECK_LIB([verto], [verto_run], [VERTO_VERSION=sys],
1173       [if test "x$with_system_verto" = xyes; then
1174         AC_MSG_ERROR([cannot detect system libverto])
1175       fi])
1176   fi
1177 fi
1178 if test "x$VERTO_VERSION" = xsys; then
1179   AC_MSG_NOTICE([Using system libverto])
1180 else
1181   AC_MSG_RESULT([Using built-in libverto])
1182   AC_DEFINE([INTERNAL_VERTO],[1],[Define if using bundled libverto])
1183 fi
1184 AC_SUBST([VERTO_CFLAGS])
1185 AC_SUBST([VERTO_LIBS])
1186 AC_SUBST([VERTO_VERSION])
1187
1188 AC_CONFIG_FILES(krb5-config, [chmod +x krb5-config])
1189 V5_AC_OUTPUT_MAKEFILE(.
1190
1191         util util/support util/profile util/profile/testmod util/send-pr
1192         util/verto util/k5ev
1193
1194         lib lib/kdb
1195
1196         lib/crypto lib/crypto/krb lib/crypto/$CRYPTO_IMPL
1197         lib/crypto/$CRYPTO_IMPL/enc_provider
1198         lib/crypto/$CRYPTO_IMPL/hash_provider
1199         lib/crypto/$CRYPTO_IMPL/des
1200         lib/crypto/$CRYPTO_IMPL/md4 lib/crypto/$CRYPTO_IMPL/md5
1201         lib/crypto/$CRYPTO_IMPL/sha1 lib/crypto/$CRYPTO_IMPL/sha2
1202         lib/crypto/$CRYPTO_IMPL/aes lib/crypto/$CRYPTO_IMPL/camellia
1203         lib/crypto/crypto_tests
1204
1205         lib/krb5 lib/krb5/error_tables lib/krb5/asn.1 lib/krb5/ccache
1206 dnl     lib/krb5/ccache/ccapi
1207         lib/krb5/keytab lib/krb5/krb lib/krb5/rcache lib/krb5/os
1208         lib/krb5/unicode
1209
1210         lib/gssapi lib/gssapi/generic lib/gssapi/krb5 lib/gssapi/spnego
1211         lib/gssapi/mechglue
1212
1213         lib/rpc lib/rpc/unit-test
1214
1215         lib/kadm5 lib/kadm5/clnt lib/kadm5/srv lib/kadm5/unit-test
1216
1217         lib/apputils
1218
1219 dnl     ccapi ccapi/lib ccapi/lib/unix ccapi/server ccapi/server/unix ccapi/test
1220
1221         kdc slave config-files gen-manpages include
1222
1223         plugins/locate/python
1224         plugins/kadm5_hook/test
1225         plugins/kdb/db2
1226         plugins/kdb/db2/libdb2
1227         plugins/kdb/db2/libdb2/hash
1228         plugins/kdb/db2/libdb2/btree
1229         plugins/kdb/db2/libdb2/db
1230         plugins/kdb/db2/libdb2/mpool
1231         plugins/kdb/db2/libdb2/recno
1232         plugins/kdb/db2/libdb2/test
1233         plugins/kdb/hdb
1234         plugins/preauth/cksum_body
1235         plugins/preauth/securid_sam2
1236         plugins/preauth/wpse
1237         plugins/authdata/greet
1238         plugins/authdata/greet_client
1239         plugins/authdata/greet_server
1240
1241         clients clients/klist clients/kinit clients/kvno
1242         clients/kdestroy clients/kpasswd clients/ksu clients/kswitch
1243
1244         kadmin kadmin/cli kadmin/dbutil kadmin/ktutil kadmin/server
1245         kadmin/testing kadmin/testing/scripts kadmin/testing/util
1246
1247         appl
1248         appl/sample appl/sample/sclient appl/sample/sserver
1249         appl/simple appl/simple/client appl/simple/server
1250         appl/gss-sample appl/user_user
1251
1252         tests tests/resolve tests/asn.1 tests/create tests/hammer
1253         tests/verify tests/gssapi tests/dejagnu tests/threads tests/shlib
1254         tests/gss-threads tests/misc tests/mkeystash_compat
1255         util/gss-kernel-lib util/collected-client-lib
1256         po
1257 )