define rk_PATH_DELIM
[heimdal.git] / cf / roken-frag.m4
blob479f755c6c3efd7a69c76f61679be421a451962c
1 dnl $Id$
2 dnl
3 dnl some code to get roken working
4 dnl
5 dnl rk_ROKEN(subdir)
6 dnl
7 AC_DEFUN([rk_ROKEN], [
9 AC_REQUIRE([rk_CONFIG_HEADER])
11 DIR_roken=roken
12 LIB_roken='$(top_builddir)/$1/libroken.la'
13 INCLUDES_roken='-I$(top_builddir)/$1 -I$(top_srcdir)/$1'
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])
22 AC_REQUIRE([AC_MIPS_ABI])
24 AC_DEFINE(rk_PATH_DELIM, '/', [Path name delimiter])
26 dnl C characteristics
28 AC_REQUIRE([AC_C___ATTRIBUTE__])
29 AC_REQUIRE([AC_C_INLINE])
30 AC_REQUIRE([AC_C_CONST])
31 rk_WFLAGS(-Wall -Wmissing-prototypes -Wpointer-arith -Wbad-function-cast -Wmissing-declarations -Wnested-externs)
33 AC_REQUIRE([rk_DB])
35 dnl C types
37 AC_REQUIRE([AC_TYPE_SIZE_T])
38 AC_HAVE_TYPE([ssize_t],[#include <unistd.h>])
39 AC_REQUIRE([AC_TYPE_PID_T])
40 AC_REQUIRE([AC_TYPE_UID_T])
41 AC_HAVE_TYPE([long long])
43 AC_REQUIRE([rk_RETSIGTYPE])
45 dnl Checks for header files.
46 AC_REQUIRE([AC_HEADER_STDC])
47 AC_REQUIRE([AC_HEADER_TIME])
49 AC_CHECK_HEADERS([\
50         arpa/inet.h                             \
51         config.h                                \
52         crypt.h                                 \
53         dirent.h                                \
54         errno.h                                 \
55         err.h                                   \
56         fcntl.h                                 \
57         fnmatch.h                               \
58         grp.h                                   \
59         ifaddrs.h                               \
60         netinet/in.h                            \
61         netinet/in6.h                           \
62         netinet/in_systm.h                      \
63         netinet6/in6.h                          \
64         paths.h                                 \
65         poll.h                                  \
66         pwd.h                                   \
67         rpcsvc/ypclnt.h                         \
68         shadow.h                                \
69         stdint.h                                \
70         sys/bswap.h                             \
71         sys/ioctl.h                             \
72         sys/mman.h                              \
73         sys/param.h                             \
74         sys/resource.h                          \
75         sys/sockio.h                            \
76         sys/stat.h                              \
77         sys/time.h                              \
78         sys/tty.h                               \
79         sys/types.h                             \
80         sys/uio.h                               \
81         sys/utsname.h                           \
82         sys/wait.h                              \
83         syslog.h                                \
84         termios.h                               \
85         winsock2.h                              \
86         ws2tcpip.h                              \
87         unistd.h                                \
88         userconf.h                              \
89         usersec.h                               \
90         util.h                                  \
93 AC_HAVE_TYPE([uintptr_t],[#ifdef HAVE_STDINT_H
94 #include <stdint.h>
95 #endif])
97 dnl Sunpro 5.2 has a vis.h which is something different.
98 AC_CHECK_HEADERS(vis.h, , , [
99 #include <vis.h>
100 #ifndef VIS_SP
101 #error invis
102 #endif])
103         
104 AC_CHECK_HEADERS(netdb.h, , , [AC_INCLUDES_DEFAULT
105 #ifdef HAVE_SYS_TYPES_H
106 #include <sys/types.h>
107 #endif
110 AC_CHECK_HEADERS(sys/socket.h, , , [AC_INCLUDES_DEFAULT
111 #ifdef HAVE_SYS_TYPES_H
112 #include <sys/types.h>
113 #endif
116 AC_CHECK_HEADERS(net/if.h, , , [AC_INCLUDES_DEFAULT
117 #ifdef HAVE_SYS_TYPES_H
118 #include <sys/types.h>
119 #endif
120 #if HAVE_SYS_SOCKET_H
121 #include <sys/socket.h>
122 #endif])
124 AC_CHECK_HEADERS(netinet6/in6_var.h, , , [AC_INCLUDES_DEFAULT
125 #ifdef HAVE_SYS_TYPES_H
126 #include <sys/types.h>
127 #endif
128 #if HAVE_SYS_SOCKET_H
129 #include <sys/socket.h>
130 #endif
131 #ifdef HAVE_NETINET6_IN6_H
132 #include <netinet6/in6.h>
133 #endif
136 AC_CHECK_HEADERS(sys/sysctl.h, , , [AC_INCLUDES_DEFAULT
137 #ifdef HAVE_SYS_PARAM_H
138 #include <sys/param.h>
139 #endif
142 AC_CHECK_HEADERS(sys/proc.h, , , [AC_INCLUDES_DEFAULT
143 #ifdef HAVE_SYS_PARAM_H
144 #include <sys/param.h>
145 #endif
148 AC_REQUIRE([CHECK_NETINET_IP_AND_TCP])
150 AM_CONDITIONAL(have_err_h, test "$ac_cv_header_err_h" = yes)
151 AM_CONDITIONAL(have_ifaddrs_h, test "$ac_cv_header_ifaddrs_h" = yes)
152 AM_CONDITIONAL(have_vis_h, test "$ac_cv_header_vis_h" = yes)
154 dnl Check for functions and libraries
156 AC_FIND_FUNC(socket, socket)
157 AC_FIND_FUNC(gethostbyname, nsl)
158 AC_FIND_FUNC(syslog, syslog)
160 AC_KRB_IPV6
162 AC_FIND_FUNC(gethostbyname2, inet6 ip6)
164 rk_RESOLV
166 AC_BROKEN_SNPRINTF
167 AC_BROKEN_VSNPRINTF
169 AC_BROKEN_GLOB
170 if test "$ac_cv_func_glob_working" != yes; then
171         AC_LIBOBJ(glob)
173 AM_CONDITIONAL(have_glob_h, test "$ac_cv_func_glob_working" = yes)
176 AC_CHECK_FUNCS([                                \
177         asnprintf                               \
178         asprintf                                \
179         atexit                                  \
180         cgetent                                 \
181         getconfattr                             \
182         getprogname                             \
183         getrlimit                               \
184         getspnam                                \
185         initstate                               \
186         issetugid                               \
187         on_exit                                 \
188         poll                                    \
189         random                                  \
190         setprogname                             \
191         setstate                                \
192         strsvis                                 \
193         strunvis                                \
194         strvis                                  \
195         strvisx                                 \
196         svis                                    \
197         sysconf                                 \
198         sysctl                                  \
199         uname                                   \
200         unvis                                   \
201         vasnprintf                              \
202         vasprintf                               \
203         vis                                     \
206 if test "$ac_cv_func_cgetent" = no; then
207         AC_LIBOBJ(getcap)
209 AM_CONDITIONAL(have_cgetent, test "$ac_cv_func_cgetent" = yes)
211 AC_REQUIRE([AC_FUNC_GETLOGIN])
213 AC_REQUIRE([AC_FUNC_MMAP])
215 AC_FIND_FUNC_NO_LIBS(getsockopt,,
216 [#ifdef HAVE_SYS_TYPES_H
217 #include <sys/types.h>
218 #endif
219 #ifdef HAVE_SYS_SOCKET_H
220 #include <sys/socket.h>
221 #endif],
222 [0,0,0,0,0])
223 AC_FIND_FUNC_NO_LIBS(setsockopt,,
224 [#ifdef HAVE_SYS_TYPES_H
225 #include <sys/types.h>
226 #endif
227 #ifdef HAVE_SYS_SOCKET_H
228 #include <sys/socket.h>
229 #endif],
230 [0,0,0,0,0])
232 AC_FIND_IF_NOT_BROKEN(hstrerror, resolv,
233 [#ifdef HAVE_NETDB_H
234 #include <netdb.h>
235 #endif],
237 AC_NEED_PROTO([
238 #ifdef HAVE_NETDB_H
239 #include <netdb.h>
240 #endif],
241 hstrerror)
243 AC_FOREACH([rk_func], [asprintf vasprintf asnprintf vasnprintf],
244         [AC_NEED_PROTO([
245         #include <stdio.h>
246         #include <string.h>],
247         rk_func)])
249 AC_FIND_FUNC_NO_LIBS(bswap16,,
250 [#ifdef HAVE_SYS_TYPES_H
251 #include <sys/types.h>
252 #endif
253 #ifdef HAVE_SYS_BSWAP_H
254 #include <sys/bswap.h>
255 #endif],0)
257 AC_FIND_FUNC_NO_LIBS(bswap32,,
258 [#ifdef HAVE_SYS_TYPES_H
259 #include <sys/types.h>
260 #endif
261 #ifdef HAVE_SYS_BSWAP_H
262 #include <sys/bswap.h>
263 #endif],0)
265 AC_FIND_FUNC_NO_LIBS(pidfile,util,
266 [#ifdef HAVE_UTIL_H
267 #include <util.h>
268 #endif],0)
270 AC_FIND_IF_NOT_BROKEN(getaddrinfo,,
271 [#ifdef HAVE_NETDB_H
272 #include <netdb.h>
273 #endif
274 #ifdef HAVE_WS2TCPIP_H
275 #include <ws2tcpip.h>
276 #endif],[0,0,0,0])
278 AC_FIND_IF_NOT_BROKEN(getnameinfo,,
279 [#ifdef HAVE_NETDB_H
280 #include <netdb.h>
281 #endif
282 #ifdef HAVE_WS2TCPIP_H
283 #include <ws2tcpip.h>
284 #endif],[0,0,0,0,0,0,0])
286 AC_FIND_IF_NOT_BROKEN(freeaddrinfo,,
287 [#ifdef HAVE_NETDB_H
288 #include <netdb.h>
289 #endif
290 #ifdef HAVE_WS2TCPIP_H
291 #include <ws2tcpip.h>
292 #endif],[0])
294 AC_FIND_IF_NOT_BROKEN(gai_strerror,,
295 [#ifdef HAVE_NETDB_H
296 #include <netdb.h>
297 #endif
298 #ifdef HAVE_WS2TCPIP_H
299 #include <ws2tcpip.h>
300 #endif],[0])
302 dnl Darwin is weird, and in some senses not unix, launchd doesn't want
303 dnl servers to use daemon(), so its deprecated.
304 case "$host_os" in
305         darwin*)
306                 ;;
307         *)
308                 AC_DEFINE([SUPPORT_DETACH], 1,
309                     [Define if os support want to detach is daemonens.])
310                 AC_BROKEN([daemon]) ;;
311 esac
314 AC_BROKEN([                                     \
315         chown                                   \
316         copyhostent                             \
317         closefrom                               \
318         ecalloc                                 \
319         emalloc                                 \
320         erealloc                                \
321         estrdup                                 \
322         err                                     \
323         errx                                    \
324         fchown                                  \
325         flock                                   \
326         fnmatch                                 \
327         freehostent                             \
328         getcwd                                  \
329         getdtablesize                           \
330         getegid                                 \
331         geteuid                                 \
332         getgid                                  \
333         gethostname                             \
334         getifaddrs                              \
335         getipnodebyaddr                         \
336         getipnodebyname                         \
337         getopt                                  \
338         gettimeofday                            \
339         getuid                                  \
340         getusershell                            \
341         initgroups                              \
342         innetgr                                 \
343         iruserok                                \
344         localtime_r                             \
345         lstat                                   \
346         memmove                                 \
347         mkstemp                                 \
348         putenv                                  \
349         rcmd                                    \
350         readv                                   \
351         recvmsg                                 \
352         sendmsg                                 \
353         setegid                                 \
354         setenv                                  \
355         seteuid                                 \
356         strcasecmp                              \
357         strdup                                  \
358         strerror                                \
359         strerror_r                              \
360         strftime                                \
361         strlcat                                 \
362         strlcpy                                 \
363         strlwr                                  \
364         strncasecmp                             \
365         strndup                                 \
366         strnlen                                 \
367         strptime                                \
368         strsep                                  \
369         strsep_copy                             \
370         strtok_r                                \
371         strupr                                  \
372         swab                                    \
373         timegm                                  \
374         unsetenv                                \
375         verr                                    \
376         verrx                                   \
377         vsyslog                                 \
378         vwarn                                   \
379         vwarnx                                  \
380         warn                                    \
381         warnx                                   \
382         writev                                  \
385 AM_CONDITIONAL(have_fnmatch_h,
386         test "$ac_cv_header_fnmatch_h" = yes -a "$ac_cv_func_fnmatch" = yes)
388 AC_FOREACH([rk_func], [strndup strsep strtok_r],
389         [AC_NEED_PROTO([#include <string.h>], rk_func)])
391 AC_FOREACH([rk_func], [strsvis strunvis strvis strvisx svis unvis vis],
392 [AC_NEED_PROTO([#ifdef HAVE_VIS_H
393 #include <vis.h>
394 #endif], rk_func)])
396 AC_BROKEN2(inet_aton,
397 [#ifdef HAVE_SYS_TYPES_H
398 #include <sys/types.h>
399 #endif
400 #ifdef HAVE_SYS_SOCKET_H
401 #include <sys/socket.h>
402 #endif
403 #ifdef HAVE_NETINET_IN_H
404 #include <netinet/in.h>
405 #endif
406 #ifdef HAVE_ARPA_INET_H
407 #include <arpa/inet.h>
408 #endif],
409 [0,0])
411 AC_BROKEN2(inet_ntop,
412 [#ifdef HAVE_SYS_TYPES_H
413 #include <sys/types.h>
414 #endif
415 #ifdef HAVE_SYS_SOCKET_H
416 #include <sys/socket.h>
417 #endif
418 #ifdef HAVE_NETINET_IN_H
419 #include <netinet/in.h>
420 #endif
421 #ifdef HAVE_ARPA_INET_H
422 #include <arpa/inet.h>
423 #endif],
424 [0, 0, 0, 0])
426 AC_BROKEN2(inet_pton,
427 [#ifdef HAVE_SYS_TYPES_H
428 #include <sys/types.h>
429 #endif
430 #ifdef HAVE_SYS_SOCKET_H
431 #include <sys/socket.h>
432 #endif
433 #ifdef HAVE_NETINET_IN_H
434 #include <netinet/in.h>
435 #endif
436 #ifdef HAVE_ARPA_INET_H
437 #include <arpa/inet.h>
438 #endif],
439 [0,0,0])
442 dnl Check for sa_len in struct sockaddr, 
443 dnl needs to come before the getnameinfo test
445 AC_HAVE_STRUCT_FIELD(struct sockaddr, sa_len, [#include <sys/types.h>
446 #include <sys/socket.h>])
448 if test "$ac_cv_func_getaddrinfo" = "yes"; then
449   rk_BROKEN_GETADDRINFO
450   if test "$ac_cv_func_getaddrinfo_numserv" = no; then
451         AC_LIBOBJ(getaddrinfo)
452         AC_LIBOBJ(freeaddrinfo)
453   fi
456 AC_NEED_PROTO([#include <stdlib.h>], setenv)
457 AC_NEED_PROTO([#include <stdlib.h>], unsetenv)
458 AC_NEED_PROTO([#include <unistd.h>], gethostname)
459 AC_NEED_PROTO([#include <unistd.h>], mkstemp)
460 AC_NEED_PROTO([#include <unistd.h>], getusershell)
461 AC_NEED_PROTO([#include <unistd.h>], daemon)
462 AC_NEED_PROTO([
463 #ifdef HAVE_SYS_TYPES_H
464 #include <sys/types.h>
465 #endif
466 #ifdef HAVE_SYS_SOCKET_H
467 #include <sys/socket.h>
468 #endif
469 #ifdef HAVE_NETINET_IN_H
470 #include <netinet/in.h>
471 #endif
472 #ifdef HAVE_ARPA_INET_H
473 #include <arpa/inet.h>
474 #endif
475 #ifdef HAVE_NETDB_H
476 #include <netdb.h>
477 #endif
478 #ifdef HAVE_UNISTD_H
479 #include <unistd.h>
480 #endif],
481 iruserok)
483 AC_NEED_PROTO([
484 #ifdef HAVE_SYS_TYPES_H
485 #include <sys/types.h>
486 #endif
487 #ifdef HAVE_SYS_SOCKET_H
488 #include <sys/socket.h>
489 #endif
490 #ifdef HAVE_NETINET_IN_H
491 #include <netinet/in.h>
492 #endif
493 #ifdef HAVE_ARPA_INET_H
494 #include <arpa/inet.h>
495 #endif],
496 inet_aton)
498 AC_FIND_FUNC_NO_LIBS(crypt, crypt)dnl
500 AC_REQUIRE([rk_BROKEN_REALLOC])dnl
502 dnl AC_KRB_FUNC_GETCWD_BROKEN
505 dnl Checks for prototypes and declarations
508 AC_PROTO_COMPAT([
509 #ifdef HAVE_SYS_TYPES_H
510 #include <sys/types.h>
511 #endif
512 #ifdef HAVE_SYS_SOCKET_H
513 #include <sys/socket.h>
514 #endif
515 #ifdef HAVE_NETINET_IN_H
516 #include <netinet/in.h>
517 #endif
518 #ifdef HAVE_ARPA_INET_H
519 #include <arpa/inet.h>
520 #endif
521 #ifdef HAVE_NETDB_H
522 #include <netdb.h>
523 #endif
525 gethostbyname, struct hostent *gethostbyname(const char *))
527 AC_PROTO_COMPAT([
528 #ifdef HAVE_SYS_TYPES_H
529 #include <sys/types.h>
530 #endif
531 #ifdef HAVE_SYS_SOCKET_H
532 #include <sys/socket.h>
533 #endif
534 #ifdef HAVE_NETINET_IN_H
535 #include <netinet/in.h>
536 #endif
537 #ifdef HAVE_ARPA_INET_H
538 #include <arpa/inet.h>
539 #endif
540 #ifdef HAVE_NETDB_H
541 #include <netdb.h>
542 #endif
544 gethostbyaddr, struct hostent *gethostbyaddr(const void *, size_t, int))
546 AC_PROTO_COMPAT([
547 #ifdef HAVE_SYS_TYPES_H
548 #include <sys/types.h>
549 #endif
550 #ifdef HAVE_SYS_SOCKET_H
551 #include <sys/socket.h>
552 #endif
553 #ifdef HAVE_NETINET_IN_H
554 #include <netinet/in.h>
555 #endif
556 #ifdef HAVE_ARPA_INET_H
557 #include <arpa/inet.h>
558 #endif
559 #ifdef HAVE_NETDB_H
560 #include <netdb.h>
561 #endif
563 getservbyname, struct servent *getservbyname(const char *, const char *))
565 AC_PROTO_COMPAT([
566 #ifdef HAVE_SYS_TYPES_H
567 #include <sys/types.h>
568 #endif
569 #ifdef HAVE_SYS_SOCKET_H
570 #include <sys/socket.h>
571 #endif
573 getsockname, int getsockname(int, struct sockaddr*, socklen_t*))
575 AC_PROTO_COMPAT([
576 #ifdef HAVE_SYSLOG_H
577 #include <syslog.h>
578 #endif
580 openlog, void openlog(const char *, int, int))
582 AC_NEED_PROTO([
583 #ifdef HAVE_CRYPT_H
584 #include <crypt.h>
585 #endif
586 #ifdef HAVE_UNISTD_H
587 #include <unistd.h>
588 #endif
590 crypt)
592 dnl variables
594 rk_CHECK_VAR(h_errno, 
595 [#ifdef HAVE_SYS_TYPES_H
596 #include <sys/types.h>
597 #endif
598 #ifdef HAVE_NETDB_H
599 #include <netdb.h>
600 #endif
601 #ifdef HAVE_WS2TCPIP_H
602 #include <ws2tcpip.h>
603 #endif
606 rk_CHECK_VAR(h_errlist, 
607 [#ifdef HAVE_NETDB_H
608 #include <netdb.h>
609 #endif
610 #ifdef HAVE_WS2TCPIP_H
611 #include <ws2tcpip.h>
612 #endif])
614 rk_CHECK_VAR(h_nerr, 
615 [#ifdef HAVE_NETDB_H
616 #include <netdb.h>
617 #endif
618 #ifdef HAVE_WS2TCPIP_H
619 #include <ws2tcpip.h>
620 #endif])
622 rk_CHECK_VAR([__progname], 
623 [#ifdef HAVE_ERR_H
624 #include <err.h>
625 #endif])
627 AC_CHECK_DECLS([optarg, optind, opterr, optopt, environ],[],[],[
628 #include <stdlib.h>
629 #ifdef HAVE_UNISTD_H
630 #include <unistd.h>
631 #endif])
634 dnl Check for fields in struct tm
637 AC_HAVE_STRUCT_FIELD(struct tm, tm_gmtoff, [#include <time.h>])
638 AC_HAVE_STRUCT_FIELD(struct tm, tm_zone, [#include <time.h>])
641 dnl or do we have a variable `timezone' ?
644 rk_CHECK_VAR(timezone,[#include <time.h>])
645 rk_CHECK_VAR(altzone,[#include <time.h>])
647 AC_HAVE_TYPE([sa_family_t],[
648 #include <sys/types.h>
649 #ifdef HAVE_SYS_SOCKET_H
650 #include <sys/socket.h>
651 #endif
652 #ifdef HAVE_WS2TCPIP_H
653 #include <ws2tcpip.h>
654 #endif])
655 AC_HAVE_TYPE([socklen_t],[
656 #include <sys/types.h>
657 #ifdef HAVE_SYS_SOCKET_H
658 #include <sys/socket.h>
659 #endif
660 #ifdef HAVE_WS2TCPIP_H
661 #include <ws2tcpip.h>
662 #endif])
663 AC_HAVE_TYPE([struct sockaddr], [
664 #include <sys/types.h>
665 #ifdef HAVE_SYS_SOCKET_H
666 #include <sys/socket.h>
667 #endif
668 #ifdef HAVE_WS2TCPIP_H
669 #include <ws2tcpip.h>
670 #endif])
671 AC_HAVE_TYPE([struct sockaddr_storage], [
672 #include <sys/types.h>
673 #ifdef HAVE_SYS_SOCKET_H
674 #include <sys/socket.h>
675 #endif
676 #ifdef HAVE_WS2TCPIP_H
677 #include <ws2tcpip.h>
678 #endif])
679 AC_HAVE_TYPE([struct addrinfo], [
680 #include <sys/types.h>
681 #ifdef HAVE_NETDB_H
682 #include <netdb.h>
683 #endif
684 #ifdef HAVE_WS2TCPIP_H
685 #include <ws2tcpip.h>
686 #endif])
687 AC_HAVE_TYPE([struct ifaddrs], [#include <ifaddrs.h>])
688 AC_HAVE_TYPE([struct iovec],[
689 #include <sys/types.h>
690 #include <sys/uio.h>
692 AC_HAVE_TYPE([struct msghdr],[
693 #include <sys/types.h>
694 #ifdef HAVE_SYS_SOCKET_H
695 #include <sys/socket.h>
696 #endif
697 #ifdef HAVE_WS2TCPIP_H
698 #include <ws2tcpip.h>
699 #endif])
702 dnl Check for struct winsize
705 AC_KRB_STRUCT_WINSIZE
708 dnl Check for struct spwd
711 AC_KRB_STRUCT_SPWD
714 # Check if we want samba's socket wrapper
717 samba_SOCKET_WRAPPER
719 dnl won't work with automake
720 dnl moved to AC_OUTPUT in configure.in
721 dnl AC_CONFIG_FILES($1/Makefile)
723 LIB_roken="${LIB_roken} \$(LIB_crypt) \$(LIB_dbopen)"
725 AC_SUBST(DIR_roken)dnl
726 AC_SUBST(LIB_roken)dnl
727 AC_SUBST(INCLUDES_roken)dnl