[HEIMDAL-646] malloc(0) checks for AIX
[heimdal.git] / cf / roken-frag.m4
blobb1a01420b4a353ebc570237e676dd41b4857c53f
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         strunvis                                \
192         strvis                                  \
193         strvisx                                 \
194         svis                                    \
195         sysconf                                 \
196         sysctl                                  \
197         uname                                   \
198         unvis                                   \
199         vasnprintf                              \
200         vasprintf                               \
201         vis                                     \
204 if test "$ac_cv_func_cgetent" = no; then
205         AC_LIBOBJ(getcap)
207 AM_CONDITIONAL(have_cgetent, test "$ac_cv_func_cgetent" = yes)
209 AC_REQUIRE([AC_FUNC_GETLOGIN])
211 AC_REQUIRE([AC_FUNC_MMAP])
213 AC_FIND_FUNC_NO_LIBS(getsockopt,,
214 [#ifdef HAVE_SYS_TYPES_H
215 #include <sys/types.h>
216 #endif
217 #ifdef HAVE_SYS_SOCKET_H
218 #include <sys/socket.h>
219 #endif],
220 [0,0,0,0,0])
221 AC_FIND_FUNC_NO_LIBS(setsockopt,,
222 [#ifdef HAVE_SYS_TYPES_H
223 #include <sys/types.h>
224 #endif
225 #ifdef HAVE_SYS_SOCKET_H
226 #include <sys/socket.h>
227 #endif],
228 [0,0,0,0,0])
230 AC_FIND_IF_NOT_BROKEN(hstrerror, resolv,
231 [#ifdef HAVE_NETDB_H
232 #include <netdb.h>
233 #endif],
235 AC_NEED_PROTO([
236 #ifdef HAVE_NETDB_H
237 #include <netdb.h>
238 #endif],
239 hstrerror)
241 AC_FOREACH([rk_func], [asprintf vasprintf asnprintf vasnprintf],
242         [AC_NEED_PROTO([
243         #include <stdio.h>
244         #include <string.h>],
245         rk_func)])
247 AC_FIND_FUNC_NO_LIBS(bswap16,,
248 [#ifdef HAVE_SYS_TYPES_H
249 #include <sys/types.h>
250 #endif
251 #ifdef HAVE_SYS_BSWAP_H
252 #include <sys/bswap.h>
253 #endif],0)
255 AC_FIND_FUNC_NO_LIBS(bswap32,,
256 [#ifdef HAVE_SYS_TYPES_H
257 #include <sys/types.h>
258 #endif
259 #ifdef HAVE_SYS_BSWAP_H
260 #include <sys/bswap.h>
261 #endif],0)
263 AC_FIND_FUNC_NO_LIBS(pidfile,util,
264 [#ifdef HAVE_UTIL_H
265 #include <util.h>
266 #endif],0)
268 AC_FIND_IF_NOT_BROKEN(getaddrinfo,,
269 [#ifdef HAVE_NETDB_H
270 #include <netdb.h>
271 #endif
272 #ifdef HAVE_WS2TCPIP_H
273 #include <ws2tcpip.h>
274 #endif],[0,0,0,0])
276 AC_FIND_IF_NOT_BROKEN(getnameinfo,,
277 [#ifdef HAVE_NETDB_H
278 #include <netdb.h>
279 #endif
280 #ifdef HAVE_WS2TCPIP_H
281 #include <ws2tcpip.h>
282 #endif],[0,0,0,0,0,0,0])
284 AC_FIND_IF_NOT_BROKEN(freeaddrinfo,,
285 [#ifdef HAVE_NETDB_H
286 #include <netdb.h>
287 #endif
288 #ifdef HAVE_WS2TCPIP_H
289 #include <ws2tcpip.h>
290 #endif],[0])
292 AC_FIND_IF_NOT_BROKEN(gai_strerror,,
293 [#ifdef HAVE_NETDB_H
294 #include <netdb.h>
295 #endif
296 #ifdef HAVE_WS2TCPIP_H
297 #include <ws2tcpip.h>
298 #endif],[0])
300 dnl Darwin is weird, and in some senses not unix, launchd doesn't want
301 dnl servers to use daemon(), so its deprecated.
302 case "$host_os" in
303         darwin*)
304                 ;;
305         *)
306                 AC_DEFINE([SUPPORT_DETACH], 1,
307                     [Define if os support want to detach is daemonens.])
308                 AC_BROKEN([daemon]) ;;
309 esac
312 AC_BROKEN([                                     \
313         chown                                   \
314         copyhostent                             \
315         closefrom                               \
316         ecalloc                                 \
317         emalloc                                 \
318         erealloc                                \
319         estrdup                                 \
320         err                                     \
321         errx                                    \
322         fchown                                  \
323         flock                                   \
324         fnmatch                                 \
325         freehostent                             \
326         getcwd                                  \
327         getdtablesize                           \
328         getegid                                 \
329         geteuid                                 \
330         getgid                                  \
331         gethostname                             \
332         getifaddrs                              \
333         getipnodebyaddr                         \
334         getipnodebyname                         \
335         getopt                                  \
336         gettimeofday                            \
337         getuid                                  \
338         getusershell                            \
339         initgroups                              \
340         innetgr                                 \
341         iruserok                                \
342         localtime_r                             \
343         lstat                                   \
344         memmove                                 \
345         mkstemp                                 \
346         putenv                                  \
347         rcmd                                    \
348         readv                                   \
349         recvmsg                                 \
350         sendmsg                                 \
351         setegid                                 \
352         setenv                                  \
353         seteuid                                 \
354         strcasecmp                              \
355         strdup                                  \
356         strerror                                \
357         strftime                                \
358         strlcat                                 \
359         strlcpy                                 \
360         strlwr                                  \
361         strncasecmp                             \
362         strndup                                 \
363         strnlen                                 \
364         strptime                                \
365         strsep                                  \
366         strsep_copy                             \
367         strtok_r                                \
368         strupr                                  \
369         swab                                    \
370         timegm                                  \
371         unsetenv                                \
372         verr                                    \
373         verrx                                   \
374         vsyslog                                 \
375         vwarn                                   \
376         vwarnx                                  \
377         warn                                    \
378         warnx                                   \
379         writev                                  \
382 AM_CONDITIONAL(have_fnmatch_h,
383         test "$ac_cv_header_fnmatch_h" = yes -a "$ac_cv_func_fnmatch" = yes)
385 AC_FOREACH([rk_func], [strndup strsep strtok_r],
386         [AC_NEED_PROTO([#include <string.h>], rk_func)])
388 AC_FOREACH([rk_func], [strsvis strunvis strvis strvisx svis unvis vis],
389 [AC_NEED_PROTO([#ifdef HAVE_VIS_H
390 #include <vis.h>
391 #endif], rk_func)])
393 AC_BROKEN2(inet_aton,
394 [#ifdef HAVE_SYS_TYPES_H
395 #include <sys/types.h>
396 #endif
397 #ifdef HAVE_SYS_SOCKET_H
398 #include <sys/socket.h>
399 #endif
400 #ifdef HAVE_NETINET_IN_H
401 #include <netinet/in.h>
402 #endif
403 #ifdef HAVE_ARPA_INET_H
404 #include <arpa/inet.h>
405 #endif],
406 [0,0])
408 AC_BROKEN2(inet_ntop,
409 [#ifdef HAVE_SYS_TYPES_H
410 #include <sys/types.h>
411 #endif
412 #ifdef HAVE_SYS_SOCKET_H
413 #include <sys/socket.h>
414 #endif
415 #ifdef HAVE_NETINET_IN_H
416 #include <netinet/in.h>
417 #endif
418 #ifdef HAVE_ARPA_INET_H
419 #include <arpa/inet.h>
420 #endif],
421 [0, 0, 0, 0])
423 AC_BROKEN2(inet_pton,
424 [#ifdef HAVE_SYS_TYPES_H
425 #include <sys/types.h>
426 #endif
427 #ifdef HAVE_SYS_SOCKET_H
428 #include <sys/socket.h>
429 #endif
430 #ifdef HAVE_NETINET_IN_H
431 #include <netinet/in.h>
432 #endif
433 #ifdef HAVE_ARPA_INET_H
434 #include <arpa/inet.h>
435 #endif],
436 [0,0,0])
439 dnl Check for sa_len in struct sockaddr, 
440 dnl needs to come before the getnameinfo test
442 AC_HAVE_STRUCT_FIELD(struct sockaddr, sa_len, [#include <sys/types.h>
443 #include <sys/socket.h>])
445 if test "$ac_cv_func_getaddrinfo" = "yes"; then
446   rk_BROKEN_GETADDRINFO
447   if test "$ac_cv_func_getaddrinfo_numserv" = no; then
448         AC_LIBOBJ(getaddrinfo)
449         AC_LIBOBJ(freeaddrinfo)
450   fi
453 AC_NEED_PROTO([#include <stdlib.h>], setenv)
454 AC_NEED_PROTO([#include <stdlib.h>], unsetenv)
455 AC_NEED_PROTO([#include <unistd.h>], gethostname)
456 AC_NEED_PROTO([#include <unistd.h>], mkstemp)
457 AC_NEED_PROTO([#include <unistd.h>], getusershell)
458 AC_NEED_PROTO([#include <unistd.h>], daemon)
459 AC_NEED_PROTO([
460 #ifdef HAVE_SYS_TYPES_H
461 #include <sys/types.h>
462 #endif
463 #ifdef HAVE_SYS_SOCKET_H
464 #include <sys/socket.h>
465 #endif
466 #ifdef HAVE_NETINET_IN_H
467 #include <netinet/in.h>
468 #endif
469 #ifdef HAVE_ARPA_INET_H
470 #include <arpa/inet.h>
471 #endif
472 #ifdef HAVE_NETDB_H
473 #include <netdb.h>
474 #endif
475 #ifdef HAVE_UNISTD_H
476 #include <unistd.h>
477 #endif],
478 iruserok)
480 AC_NEED_PROTO([
481 #ifdef HAVE_SYS_TYPES_H
482 #include <sys/types.h>
483 #endif
484 #ifdef HAVE_SYS_SOCKET_H
485 #include <sys/socket.h>
486 #endif
487 #ifdef HAVE_NETINET_IN_H
488 #include <netinet/in.h>
489 #endif
490 #ifdef HAVE_ARPA_INET_H
491 #include <arpa/inet.h>
492 #endif],
493 inet_aton)
495 AC_FIND_FUNC_NO_LIBS(crypt, crypt)dnl
497 AC_REQUIRE([rk_BROKEN_REALLOC])dnl
499 dnl AC_KRB_FUNC_GETCWD_BROKEN
502 dnl Checks for prototypes and declarations
505 AC_PROTO_COMPAT([
506 #ifdef HAVE_SYS_TYPES_H
507 #include <sys/types.h>
508 #endif
509 #ifdef HAVE_SYS_SOCKET_H
510 #include <sys/socket.h>
511 #endif
512 #ifdef HAVE_NETINET_IN_H
513 #include <netinet/in.h>
514 #endif
515 #ifdef HAVE_ARPA_INET_H
516 #include <arpa/inet.h>
517 #endif
518 #ifdef HAVE_NETDB_H
519 #include <netdb.h>
520 #endif
522 gethostbyname, struct hostent *gethostbyname(const char *))
524 AC_PROTO_COMPAT([
525 #ifdef HAVE_SYS_TYPES_H
526 #include <sys/types.h>
527 #endif
528 #ifdef HAVE_SYS_SOCKET_H
529 #include <sys/socket.h>
530 #endif
531 #ifdef HAVE_NETINET_IN_H
532 #include <netinet/in.h>
533 #endif
534 #ifdef HAVE_ARPA_INET_H
535 #include <arpa/inet.h>
536 #endif
537 #ifdef HAVE_NETDB_H
538 #include <netdb.h>
539 #endif
541 gethostbyaddr, struct hostent *gethostbyaddr(const void *, size_t, int))
543 AC_PROTO_COMPAT([
544 #ifdef HAVE_SYS_TYPES_H
545 #include <sys/types.h>
546 #endif
547 #ifdef HAVE_SYS_SOCKET_H
548 #include <sys/socket.h>
549 #endif
550 #ifdef HAVE_NETINET_IN_H
551 #include <netinet/in.h>
552 #endif
553 #ifdef HAVE_ARPA_INET_H
554 #include <arpa/inet.h>
555 #endif
556 #ifdef HAVE_NETDB_H
557 #include <netdb.h>
558 #endif
560 getservbyname, struct servent *getservbyname(const char *, const char *))
562 AC_PROTO_COMPAT([
563 #ifdef HAVE_SYS_TYPES_H
564 #include <sys/types.h>
565 #endif
566 #ifdef HAVE_SYS_SOCKET_H
567 #include <sys/socket.h>
568 #endif
570 getsockname, int getsockname(int, struct sockaddr*, socklen_t*))
572 AC_PROTO_COMPAT([
573 #ifdef HAVE_SYSLOG_H
574 #include <syslog.h>
575 #endif
577 openlog, void openlog(const char *, int, int))
579 AC_NEED_PROTO([
580 #ifdef HAVE_CRYPT_H
581 #include <crypt.h>
582 #endif
583 #ifdef HAVE_UNISTD_H
584 #include <unistd.h>
585 #endif
587 crypt)
589 dnl variables
591 rk_CHECK_VAR(h_errno, 
592 [#ifdef HAVE_SYS_TYPES_H
593 #include <sys/types.h>
594 #endif
595 #ifdef HAVE_NETDB_H
596 #include <netdb.h>
597 #endif
598 #ifdef HAVE_WS2TCPIP_H
599 #include <ws2tcpip.h>
600 #endif
603 rk_CHECK_VAR(h_errlist, 
604 [#ifdef HAVE_NETDB_H
605 #include <netdb.h>
606 #endif
607 #ifdef HAVE_WS2TCPIP_H
608 #include <ws2tcpip.h>
609 #endif])
611 rk_CHECK_VAR(h_nerr, 
612 [#ifdef HAVE_NETDB_H
613 #include <netdb.h>
614 #endif
615 #ifdef HAVE_WS2TCPIP_H
616 #include <ws2tcpip.h>
617 #endif])
619 rk_CHECK_VAR([__progname], 
620 [#ifdef HAVE_ERR_H
621 #include <err.h>
622 #endif])
624 AC_CHECK_DECLS([optarg, optind, opterr, optopt, environ],[],[],[
625 #include <stdlib.h>
626 #ifdef HAVE_UNISTD_H
627 #include <unistd.h>
628 #endif])
631 dnl Check for fields in struct tm
634 AC_HAVE_STRUCT_FIELD(struct tm, tm_gmtoff, [#include <time.h>])
635 AC_HAVE_STRUCT_FIELD(struct tm, tm_zone, [#include <time.h>])
638 dnl or do we have a variable `timezone' ?
641 rk_CHECK_VAR(timezone,[#include <time.h>])
642 rk_CHECK_VAR(altzone,[#include <time.h>])
644 AC_HAVE_TYPE([sa_family_t],[
645 #include <sys/types.h>
646 #ifdef HAVE_SYS_SOCKET_H
647 #include <sys/socket.h>
648 #endif
649 #ifdef HAVE_WS2TCPIP_H
650 #include <ws2tcpip.h>
651 #endif])
652 AC_HAVE_TYPE([socklen_t],[
653 #include <sys/types.h>
654 #ifdef HAVE_SYS_SOCKET_H
655 #include <sys/socket.h>
656 #endif
657 #ifdef HAVE_WS2TCPIP_H
658 #include <ws2tcpip.h>
659 #endif])
660 AC_HAVE_TYPE([struct sockaddr], [
661 #include <sys/types.h>
662 #ifdef HAVE_SYS_SOCKET_H
663 #include <sys/socket.h>
664 #endif
665 #ifdef HAVE_WS2TCPIP_H
666 #include <ws2tcpip.h>
667 #endif])
668 AC_HAVE_TYPE([struct sockaddr_storage], [
669 #include <sys/types.h>
670 #ifdef HAVE_SYS_SOCKET_H
671 #include <sys/socket.h>
672 #endif
673 #ifdef HAVE_WS2TCPIP_H
674 #include <ws2tcpip.h>
675 #endif])
676 AC_HAVE_TYPE([struct addrinfo], [
677 #include <sys/types.h>
678 #ifdef HAVE_NETDB_H
679 #include <netdb.h>
680 #endif
681 #ifdef HAVE_WS2TCPIP_H
682 #include <ws2tcpip.h>
683 #endif])
684 AC_HAVE_TYPE([struct ifaddrs], [#include <ifaddrs.h>])
685 AC_HAVE_TYPE([struct iovec],[
686 #include <sys/types.h>
687 #include <sys/uio.h>
689 AC_HAVE_TYPE([struct msghdr],[
690 #include <sys/types.h>
691 #ifdef HAVE_SYS_SOCKET_H
692 #include <sys/socket.h>
693 #endif
694 #ifdef HAVE_WS2TCPIP_H
695 #include <ws2tcpip.h>
696 #endif])
699 dnl Check for struct winsize
702 AC_KRB_STRUCT_WINSIZE
705 dnl Check for struct spwd
708 AC_KRB_STRUCT_SPWD
711 # Check if we want samba's socket wrapper
714 samba_SOCKET_WRAPPER
716 dnl won't work with automake
717 dnl moved to AC_OUTPUT in configure.in
718 dnl AC_CONFIG_FILES($1/Makefile)
720 LIB_roken="${LIB_roken} \$(LIB_crypt) \$(LIB_dbopen)"
722 AC_SUBST(DIR_roken)dnl
723 AC_SUBST(LIB_roken)dnl
724 AC_SUBST(INCLUDES_roken)dnl