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