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