Merge from vendor branch NTPD:
[dragonfly.git] / crypto / heimdal-0.6.3 / cf / roken-frag.m4
1 dnl $Id: roken-frag.m4,v 1.45.2.1 2004/04/01 07:27:35 joda Exp $
2 dnl
3 dnl some code to get roken working
4 dnl
5 dnl rk_ROKEN(subdir)
6 dnl
7 AC_DEFUN([rk_ROKEN], [
8
9 AC_REQUIRE([rk_CONFIG_HEADER])
10
11 DIR_roken=roken
12 LIB_roken='$(top_builddir)/$1/libroken.la'
13 INCLUDES_roken='-I$(top_builddir)/$1 -I$(top_srcdir)/$1'
14
15 dnl Checks for programs
16 AC_REQUIRE([AC_PROG_CC])
17 AC_REQUIRE([AC_PROG_AWK])
18 AC_REQUIRE([AC_OBJEXT])
19 AC_REQUIRE([AC_EXEEXT])
20 AC_REQUIRE([AC_PROG_LIBTOOL])
21
22 AC_REQUIRE([AC_MIPS_ABI])
23
24 dnl C characteristics
25
26 AC_REQUIRE([AC_C___ATTRIBUTE__])
27 AC_REQUIRE([AC_C_INLINE])
28 AC_REQUIRE([AC_C_CONST])
29 AC_WFLAGS(-Wall -Wmissing-prototypes -Wpointer-arith -Wbad-function-cast -Wmissing-declarations -Wnested-externs)
30
31 AC_REQUIRE([rk_DB])
32
33 dnl C types
34
35 AC_REQUIRE([AC_TYPE_SIZE_T])
36 AC_HAVE_TYPE([ssize_t],[#include <unistd.h>])
37 AC_REQUIRE([AC_TYPE_PID_T])
38 AC_REQUIRE([AC_TYPE_UID_T])
39 AC_HAVE_TYPE([long long])
40
41 AC_REQUIRE([rk_RETSIGTYPE])
42
43 dnl Checks for header files.
44 AC_REQUIRE([AC_HEADER_STDC])
45 AC_REQUIRE([AC_HEADER_TIME])
46
47 AC_CHECK_HEADERS([\
48         arpa/inet.h                             \
49         arpa/nameser.h                          \
50         config.h                                \
51         crypt.h                                 \
52         dirent.h                                \
53         errno.h                                 \
54         err.h                                   \
55         fcntl.h                                 \
56         grp.h                                   \
57         ifaddrs.h                               \
58         net/if.h                                \
59         netdb.h                                 \
60         netinet/in.h                            \
61         netinet/in6.h                           \
62         netinet/in_systm.h                      \
63         netinet6/in6.h                          \
64         netinet6/in6_var.h                      \
65         paths.h                                 \
66         pwd.h                                   \
67         resolv.h                                \
68         rpcsvc/ypclnt.h                         \
69         shadow.h                                \
70         sys/bswap.h                             \
71         sys/ioctl.h                             \
72         sys/mman.h                              \
73         sys/param.h                             \
74         sys/proc.h                              \
75         sys/resource.h                          \
76         sys/socket.h                            \
77         sys/sockio.h                            \
78         sys/stat.h                              \
79         sys/sysctl.h                            \
80         sys/time.h                              \
81         sys/tty.h                               \
82         sys/types.h                             \
83         sys/uio.h                               \
84         sys/utsname.h                           \
85         sys/wait.h                              \
86         syslog.h                                \
87         termios.h                               \
88         unistd.h                                \
89         userconf.h                              \
90         usersec.h                               \
91         util.h                                  \
92         vis.h                                   \
93 ])
94         
95 AC_REQUIRE([CHECK_NETINET_IP_AND_TCP])
96
97 AM_CONDITIONAL(have_err_h, test "$ac_cv_header_err_h" = yes)
98 AM_CONDITIONAL(have_fnmatch_h, test "$ac_cv_header_fnmatch_h" = yes)
99 AM_CONDITIONAL(have_ifaddrs_h, test "$ac_cv_header_ifaddrs_h" = yes)
100 AM_CONDITIONAL(have_vis_h, test "$ac_cv_header_vis_h" = yes)
101
102 dnl Check for functions and libraries
103
104 AC_FIND_FUNC(socket, socket)
105 AC_FIND_FUNC(gethostbyname, nsl)
106 AC_FIND_FUNC(syslog, syslog)
107
108 AC_KRB_IPV6
109
110 AC_FIND_FUNC(gethostbyname2, inet6 ip6)
111
112 AC_FIND_FUNC(res_search, resolv,
113 [
114 #include <stdio.h>
115 #ifdef HAVE_SYS_TYPES_H
116 #include <sys/types.h>
117 #endif
118 #ifdef HAVE_NETINET_IN_H
119 #include <netinet/in.h>
120 #endif
121 #ifdef HAVE_ARPA_NAMESER_H
122 #include <arpa/nameser.h>
123 #endif
124 #ifdef HAVE_RESOLV_H
125 #include <resolv.h>
126 #endif
127 ],
128 [0,0,0,0,0])
129
130 AC_FIND_FUNC(res_nsearch, resolv,
131 [
132 #include <stdio.h>
133 #ifdef HAVE_SYS_TYPES_H
134 #include <sys/types.h>
135 #endif
136 #ifdef HAVE_NETINET_IN_H
137 #include <netinet/in.h>
138 #endif
139 #ifdef HAVE_ARPA_NAMESER_H
140 #include <arpa/nameser.h>
141 #endif
142 #ifdef HAVE_RESOLV_H
143 #include <resolv.h>
144 #endif
145 ],
146 [0,0,0,0,0,0])
147
148 AC_FIND_FUNC(dn_expand, resolv,
149 [
150 #include <stdio.h>
151 #ifdef HAVE_SYS_TYPES_H
152 #include <sys/types.h>
153 #endif
154 #ifdef HAVE_NETINET_IN_H
155 #include <netinet/in.h>
156 #endif
157 #ifdef HAVE_ARPA_NAMESER_H
158 #include <arpa/nameser.h>
159 #endif
160 #ifdef HAVE_RESOLV_H
161 #include <resolv.h>
162 #endif
163 ],
164 [0,0,0,0,0])
165
166 rk_CHECK_VAR(_res, 
167 [#include <stdio.h>
168 #ifdef HAVE_SYS_TYPES_H
169 #include <sys/types.h>
170 #endif
171 #ifdef HAVE_NETINET_IN_H
172 #include <netinet/in.h>
173 #endif
174 #ifdef HAVE_ARPA_NAMESER_H
175 #include <arpa/nameser.h>
176 #endif
177 #ifdef HAVE_RESOLV_H
178 #include <resolv.h>
179 #endif])
180
181
182 AC_BROKEN_SNPRINTF
183 AC_BROKEN_VSNPRINTF
184
185 AC_BROKEN_GLOB
186 if test "$ac_cv_func_glob_working" != yes; then
187         AC_LIBOBJ(glob)
188 fi
189 AM_CONDITIONAL(have_glob_h, test "$ac_cv_func_glob_working" = yes)
190
191
192 AC_CHECK_FUNCS([                                \
193         asnprintf                               \
194         asprintf                                \
195         atexit                                  \
196         cgetent                                 \
197         getconfattr                             \
198         getprogname                             \
199         getrlimit                               \
200         getspnam                                \
201         initstate                               \
202         issetugid                               \
203         on_exit                                 \
204         random                                  \
205         setprogname                             \
206         setstate                                \
207         strsvis                                 \
208         strunvis                                \
209         strvis                                  \
210         strvisx                                 \
211         svis                                    \
212         sysconf                                 \
213         sysctl                                  \
214         uname                                   \
215         unvis                                   \
216         vasnprintf                              \
217         vasprintf                               \
218         vis                                     \
219 ])
220
221 if test "$ac_cv_func_cgetent" = no; then
222         AC_LIBOBJ(getcap)
223 fi
224
225 AC_REQUIRE([AC_FUNC_GETLOGIN])
226
227 AC_REQUIRE([AC_FUNC_MMAP])
228
229 AC_FIND_FUNC_NO_LIBS(getsockopt,,
230 [#ifdef HAVE_SYS_TYPES_H
231 #include <sys/types.h>
232 #endif
233 #ifdef HAVE_SYS_SOCKET_H
234 #include <sys/socket.h>
235 #endif],
236 [0,0,0,0,0])
237 AC_FIND_FUNC_NO_LIBS(setsockopt,,
238 [#ifdef HAVE_SYS_TYPES_H
239 #include <sys/types.h>
240 #endif
241 #ifdef HAVE_SYS_SOCKET_H
242 #include <sys/socket.h>
243 #endif],
244 [0,0,0,0,0])
245
246 AC_FIND_IF_NOT_BROKEN(hstrerror, resolv,
247 [#ifdef HAVE_NETDB_H
248 #include <netdb.h>
249 #endif],
250 17)
251 AC_NEED_PROTO([
252 #ifdef HAVE_NETDB_H
253 #include <netdb.h>
254 #endif],
255 hstrerror)
256
257 AC_FOREACH([rk_func], [asprintf vasprintf asnprintf vasnprintf],
258         [AC_NEED_PROTO([
259         #include <stdio.h>
260         #include <string.h>],
261         rk_func)])
262
263 AC_FIND_FUNC_NO_LIBS(bswap16,,
264 [#ifdef HAVE_SYS_BSWAP_H
265 #include <sys/bswap.h>
266 #endif],0)
267
268 AC_FIND_FUNC_NO_LIBS(bswap32,,
269 [#ifdef HAVE_SYS_BSWAP_H
270 #include <sys/bswap.h>
271 #endif],0)
272
273 AC_FIND_FUNC_NO_LIBS(pidfile,util,
274 [#ifdef HAVE_UTIL_H
275 #include <util.h>
276 #endif],0)
277
278 AC_FIND_IF_NOT_BROKEN(getaddrinfo,,
279 [#ifdef HAVE_NETDB_H
280 #include <netdb.h>
281 #endif],[0,0,0,0])
282
283 AC_FIND_IF_NOT_BROKEN(getnameinfo,,
284 [#ifdef HAVE_NETDB_H
285 #include <netdb.h>
286 #endif],[0,0,0,0,0,0,0])
287
288 AC_FIND_IF_NOT_BROKEN(freeaddrinfo,,
289 [#ifdef HAVE_NETDB_H
290 #include <netdb.h>
291 #endif],[0])
292
293 AC_FIND_IF_NOT_BROKEN(gai_strerror,,
294 [#ifdef HAVE_NETDB_H
295 #include <netdb.h>
296 #endif],[0])
297
298 AC_BROKEN([                                     \
299         chown                                   \
300         copyhostent                             \
301         daemon                                  \
302         ecalloc                                 \
303         emalloc                                 \
304         erealloc                                \
305         estrdup                                 \
306         err                                     \
307         errx                                    \
308         fchown                                  \
309         flock                                   \
310         fnmatch                                 \
311         freehostent                             \
312         getcwd                                  \
313         getdtablesize                           \
314         getegid                                 \
315         geteuid                                 \
316         getgid                                  \
317         gethostname                             \
318         getifaddrs                              \
319         getipnodebyaddr                         \
320         getipnodebyname                         \
321         getopt                                  \
322         gettimeofday                            \
323         getuid                                  \
324         getusershell                            \
325         initgroups                              \
326         innetgr                                 \
327         iruserok                                \
328         localtime_r                             \
329         lstat                                   \
330         memmove                                 \
331         mkstemp                                 \
332         putenv                                  \
333         rcmd                                    \
334         readv                                   \
335         recvmsg                                 \
336         sendmsg                                 \
337         setegid                                 \
338         setenv                                  \
339         seteuid                                 \
340         strcasecmp                              \
341         strdup                                  \
342         strerror                                \
343         strftime                                \
344         strlcat                                 \
345         strlcpy                                 \
346         strlwr                                  \
347         strncasecmp                             \
348         strndup                                 \
349         strnlen                                 \
350         strptime                                \
351         strsep                                  \
352         strsep_copy                             \
353         strtok_r                                \
354         strupr                                  \
355         swab                                    \
356         unsetenv                                \
357         verr                                    \
358         verrx                                   \
359         vsyslog                                 \
360         vwarn                                   \
361         vwarnx                                  \
362         warn                                    \
363         warnx                                   \
364         writev                                  \
365 ])
366
367 AC_FOREACH([rk_func], [strndup strsep strtok_r],
368         [AC_NEED_PROTO([#include <string.h>], rk_func)])
369
370 AC_FOREACH([rk_func], [strsvis strunvis strvis strvisx svis unvis vis],
371 [AC_NEED_PROTO([#ifdef HAVE_VIS_H
372 #include <vis.h>
373 #endif], rk_func)])
374
375 AC_BROKEN2(inet_aton,
376 [#ifdef HAVE_SYS_TYPES_H
377 #include <sys/types.h>
378 #endif
379 #ifdef HAVE_SYS_SOCKET_H
380 #include <sys/socket.h>
381 #endif
382 #ifdef HAVE_NETINET_IN_H
383 #include <netinet/in.h>
384 #endif
385 #ifdef HAVE_ARPA_INET_H
386 #include <arpa/inet.h>
387 #endif],
388 [0,0])
389
390 AC_BROKEN2(inet_ntop,
391 [#ifdef HAVE_SYS_TYPES_H
392 #include <sys/types.h>
393 #endif
394 #ifdef HAVE_SYS_SOCKET_H
395 #include <sys/socket.h>
396 #endif
397 #ifdef HAVE_NETINET_IN_H
398 #include <netinet/in.h>
399 #endif
400 #ifdef HAVE_ARPA_INET_H
401 #include <arpa/inet.h>
402 #endif],
403 [0, 0, 0, 0])
404
405 AC_BROKEN2(inet_pton,
406 [#ifdef HAVE_SYS_TYPES_H
407 #include <sys/types.h>
408 #endif
409 #ifdef HAVE_SYS_SOCKET_H
410 #include <sys/socket.h>
411 #endif
412 #ifdef HAVE_NETINET_IN_H
413 #include <netinet/in.h>
414 #endif
415 #ifdef HAVE_ARPA_INET_H
416 #include <arpa/inet.h>
417 #endif],
418 [0,0,0])
419
420 dnl
421 dnl Check for sa_len in struct sockaddr, 
422 dnl needs to come before the getnameinfo test
423 dnl
424 AC_HAVE_STRUCT_FIELD(struct sockaddr, sa_len, [#include <sys/types.h>
425 #include <sys/socket.h>])
426
427 if test "$ac_cv_func_getnameinfo" = "yes"; then
428   rk_BROKEN_GETNAMEINFO
429   if test "$ac_cv_func_getnameinfo_broken" = yes; then
430         AC_LIBOBJ(getnameinfo)
431   fi
432 fi
433
434 if test "$ac_cv_func_getaddrinfo" = "yes"; then
435   rk_BROKEN_GETADDRINFO
436   if test "$ac_cv_func_getaddrinfo_numserv" = no; then
437         AC_LIBOBJ(getaddrinfo)
438         AC_LIBOBJ(freeaddrinfo)
439   fi
440 fi
441
442 AC_NEED_PROTO([#include <stdlib.h>], setenv)
443 AC_NEED_PROTO([#include <stdlib.h>], unsetenv)
444 AC_NEED_PROTO([#include <unistd.h>], gethostname)
445 AC_NEED_PROTO([#include <unistd.h>], mkstemp)
446 AC_NEED_PROTO([#include <unistd.h>], getusershell)
447
448 AC_NEED_PROTO([
449 #ifdef HAVE_SYS_TYPES_H
450 #include <sys/types.h>
451 #endif
452 #ifdef HAVE_SYS_SOCKET_H
453 #include <sys/socket.h>
454 #endif
455 #ifdef HAVE_NETINET_IN_H
456 #include <netinet/in.h>
457 #endif
458 #ifdef HAVE_ARPA_INET_H
459 #include <arpa/inet.h>
460 #endif],
461 inet_aton)
462
463 AC_FIND_FUNC_NO_LIBS(crypt, crypt)dnl
464
465 AC_REQUIRE([rk_BROKEN_REALLOC])dnl
466
467 dnl AC_KRB_FUNC_GETCWD_BROKEN
468
469 dnl
470 dnl Checks for prototypes and declarations
471 dnl
472
473 AC_PROTO_COMPAT([
474 #ifdef HAVE_SYS_TYPES_H
475 #include <sys/types.h>
476 #endif
477 #ifdef HAVE_SYS_SOCKET_H
478 #include <sys/socket.h>
479 #endif
480 #ifdef HAVE_NETINET_IN_H
481 #include <netinet/in.h>
482 #endif
483 #ifdef HAVE_ARPA_INET_H
484 #include <arpa/inet.h>
485 #endif
486 #ifdef HAVE_NETDB_H
487 #include <netdb.h>
488 #endif
489 ],
490 gethostbyname, struct hostent *gethostbyname(const char *))
491
492 AC_PROTO_COMPAT([
493 #ifdef HAVE_SYS_TYPES_H
494 #include <sys/types.h>
495 #endif
496 #ifdef HAVE_SYS_SOCKET_H
497 #include <sys/socket.h>
498 #endif
499 #ifdef HAVE_NETINET_IN_H
500 #include <netinet/in.h>
501 #endif
502 #ifdef HAVE_ARPA_INET_H
503 #include <arpa/inet.h>
504 #endif
505 #ifdef HAVE_NETDB_H
506 #include <netdb.h>
507 #endif
508 ],
509 gethostbyaddr, struct hostent *gethostbyaddr(const void *, size_t, int))
510
511 AC_PROTO_COMPAT([
512 #ifdef HAVE_SYS_TYPES_H
513 #include <sys/types.h>
514 #endif
515 #ifdef HAVE_SYS_SOCKET_H
516 #include <sys/socket.h>
517 #endif
518 #ifdef HAVE_NETINET_IN_H
519 #include <netinet/in.h>
520 #endif
521 #ifdef HAVE_ARPA_INET_H
522 #include <arpa/inet.h>
523 #endif
524 #ifdef HAVE_NETDB_H
525 #include <netdb.h>
526 #endif
527 ],
528 getservbyname, struct servent *getservbyname(const char *, const char *))
529
530 AC_PROTO_COMPAT([
531 #ifdef HAVE_SYS_TYPES_H
532 #include <sys/types.h>
533 #endif
534 #ifdef HAVE_SYS_SOCKET_H
535 #include <sys/socket.h>
536 #endif
537 ],
538 getsockname, int getsockname(int, struct sockaddr*, socklen_t*))
539
540 AC_PROTO_COMPAT([
541 #ifdef HAVE_SYSLOG_H
542 #include <syslog.h>
543 #endif
544 ],
545 openlog, void openlog(const char *, int, int))
546
547 AC_NEED_PROTO([
548 #ifdef HAVE_CRYPT_H
549 #include <crypt.h>
550 #endif
551 #ifdef HAVE_UNISTD_H
552 #include <unistd.h>
553 #endif
554 ],
555 crypt)
556
557 dnl variables
558
559 rk_CHECK_VAR(h_errno, 
560 [#ifdef HAVE_SYS_TYPES_H
561 #include <sys/types.h>
562 #endif
563 #ifdef HAVE_NETDB_H
564 #include <netdb.h>
565 #endif])
566
567 rk_CHECK_VAR(h_errlist, 
568 [#ifdef HAVE_NETDB_H
569 #include <netdb.h>
570 #endif])
571
572 rk_CHECK_VAR(h_nerr, 
573 [#ifdef HAVE_NETDB_H
574 #include <netdb.h>
575 #endif])
576
577 rk_CHECK_VAR([__progname], 
578 [#ifdef HAVE_ERR_H
579 #include <err.h>
580 #endif])
581
582 AC_CHECK_DECLARATION([#include <stdlib.h>
583 #ifdef HAVE_UNISTD_H
584 #include <unistd.h>
585 #endif], optarg)
586 AC_CHECK_DECLARATION([#include <stdlib.h>
587 #ifdef HAVE_UNISTD_H
588 #include <unistd.h>
589 #endif], optind)
590 AC_CHECK_DECLARATION([#include <stdlib.h>
591 #ifdef HAVE_UNISTD_H
592 #include <unistd.h>
593 #endif], opterr)
594 AC_CHECK_DECLARATION([#include <stdlib.h>
595 #ifdef HAVE_UNISTD_H
596 #include <unistd.h>
597 #endif], optopt)
598
599 AC_CHECK_DECLARATION([#include <stdlib.h>], environ)
600
601 dnl
602 dnl Check for fields in struct tm
603 dnl
604
605 AC_HAVE_STRUCT_FIELD(struct tm, tm_gmtoff, [#include <time.h>])
606 AC_HAVE_STRUCT_FIELD(struct tm, tm_zone, [#include <time.h>])
607
608 dnl
609 dnl or do we have a variable `timezone' ?
610 dnl
611
612 rk_CHECK_VAR(timezone,[#include <time.h>])
613 rk_CHECK_VAR(altzone,[#include <time.h>])
614
615 AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])
616 AC_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])
617 AC_HAVE_TYPE([struct sockaddr], [#include <sys/socket.h>])
618 AC_HAVE_TYPE([struct sockaddr_storage], [#include <sys/socket.h>])
619 AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
620 AC_HAVE_TYPE([struct ifaddrs], [#include <ifaddrs.h>])
621 AC_HAVE_TYPE([struct iovec],[
622 #include <sys/types.h>
623 #include <sys/uio.h>
624 ])
625 AC_HAVE_TYPE([struct msghdr],[
626 #include <sys/types.h>
627 #include <sys/socket.h>
628 ])
629
630 dnl
631 dnl Check for struct winsize
632 dnl
633
634 AC_KRB_STRUCT_WINSIZE
635
636 dnl
637 dnl Check for struct spwd
638 dnl
639
640 AC_KRB_STRUCT_SPWD
641
642 dnl won't work with automake
643 dnl moved to AC_OUTPUT in configure.in
644 dnl AC_CONFIG_FILES($1/Makefile)
645
646 LIB_roken="${LIB_roken} \$(LIB_crypt) \$(LIB_dbopen)"
647
648 AC_SUBST(DIR_roken)dnl
649 AC_SUBST(LIB_roken)dnl
650 AC_SUBST(INCLUDES_roken)dnl
651 ])