3 dnl some code to get roken working
9 AC_REQUIRE([rk_CONFIG_HEADER])
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])
22 AC_REQUIRE([AC_MIPS_ABI])
24 AC_DEFINE(rk_PATH_DELIM, '/', [Path name delimiter])
28 AC_REQUIRE([AC_C___ATTRIBUTE__])
29 AC_REQUIRE([AC_C_INLINE])
30 AC_REQUIRE([AC_C_CONST])
31 rk_WFLAGS(-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wmissing-prototypes -Wpointer-arith -Wbad-function-cast -Wmissing-declarations -Wnested-externs -Wshadow)
33 dnl -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wstrict-prototypes
34 dnl -Wcast-qual -Wswitch -Wformat=2 -Wwrite-strings
40 AC_REQUIRE([AC_TYPE_SIZE_T])
41 AC_HAVE_TYPE([ssize_t],[#include <unistd.h>])
42 AC_REQUIRE([AC_TYPE_PID_T])
43 AC_REQUIRE([AC_TYPE_UID_T])
44 AC_HAVE_TYPE([long long])
46 AC_REQUIRE([rk_RETSIGTYPE])
48 dnl Checks for header files.
49 AC_REQUIRE([AC_HEADER_STDC])
50 AC_REQUIRE([AC_HEADER_TIME])
101 AC_HAVE_TYPE([auxv_t],[#ifdef HAVE_AUXV_H
104 #ifdef HAVE_SYS_AUXV_H
105 #include <sys/auxv.h>
109 AC_HAVE_TYPE([uintptr_t],[#ifdef HAVE_STDINT_H
113 dnl Sunpro 5.2 has a vis.h which is something different.
114 AC_CHECK_HEADERS(vis.h, , , [
120 AC_CHECK_HEADERS(netdb.h, , , [AC_INCLUDES_DEFAULT
121 #ifdef HAVE_SYS_TYPES_H
122 #include <sys/types.h>
126 AC_CHECK_HEADERS(sys/socket.h, , , [AC_INCLUDES_DEFAULT
127 #ifdef HAVE_SYS_TYPES_H
128 #include <sys/types.h>
132 AC_CHECK_HEADERS(net/if.h, , , [AC_INCLUDES_DEFAULT
133 #ifdef HAVE_SYS_TYPES_H
134 #include <sys/types.h>
136 #if HAVE_SYS_SOCKET_H
137 #include <sys/socket.h>
140 AC_CHECK_HEADERS(netinet6/in6_var.h, , , [AC_INCLUDES_DEFAULT
141 #ifdef HAVE_SYS_TYPES_H
142 #include <sys/types.h>
144 #if HAVE_SYS_SOCKET_H
145 #include <sys/socket.h>
147 #ifdef HAVE_NETINET6_IN6_H
148 #include <netinet6/in6.h>
152 AC_CHECK_HEADERS(sys/sysctl.h, , , [AC_INCLUDES_DEFAULT
153 #ifdef HAVE_SYS_PARAM_H
154 #include <sys/param.h>
158 AC_CHECK_HEADERS(sys/proc.h, , , [AC_INCLUDES_DEFAULT
159 #ifdef HAVE_SYS_PARAM_H
160 #include <sys/param.h>
164 AC_REQUIRE([CHECK_NETINET_IP_AND_TCP])
166 AM_CONDITIONAL(have_err_h, test "$ac_cv_header_err_h" = yes)
167 AM_CONDITIONAL(have_ifaddrs_h, test "$ac_cv_header_ifaddrs_h" = yes)
168 AM_CONDITIONAL(have_search_h, test "$ac_cv_header_search_h" = yes)
169 AM_CONDITIONAL(have_vis_h, test "$ac_cv_header_vis_h" = yes)
171 dnl Check for functions and libraries
175 AC_FIND_FUNC(gethostbyname2, inet6 ip6)
218 AC_REQUIRE([AC_FUNC_GETLOGIN])
220 AC_REQUIRE([AC_FUNC_MMAP])
222 AC_FIND_FUNC_NO_LIBS(getsockopt,,
223 [#ifdef HAVE_SYS_TYPES_H
224 #include <sys/types.h>
226 #ifdef HAVE_SYS_SOCKET_H
227 #include <sys/socket.h>
230 AC_FIND_FUNC_NO_LIBS(setsockopt,,
231 [#ifdef HAVE_SYS_TYPES_H
232 #include <sys/types.h>
234 #ifdef HAVE_SYS_SOCKET_H
235 #include <sys/socket.h>
239 AC_FIND_IF_NOT_BROKEN(hstrerror, resolv,
250 AC_FOREACH([rk_func], [asprintf vasprintf asnprintf vasnprintf],
253 #include <string.h>],
256 AC_FIND_FUNC_NO_LIBS(bswap16,,
257 [#ifdef HAVE_SYS_TYPES_H
258 #include <sys/types.h>
260 #ifdef HAVE_SYS_BSWAP_H
261 #include <sys/bswap.h>
264 AC_FIND_FUNC_NO_LIBS(bswap32,,
265 [#ifdef HAVE_SYS_TYPES_H
266 #include <sys/types.h>
268 #ifdef HAVE_SYS_BSWAP_H
269 #include <sys/bswap.h>
272 AC_FIND_FUNC_NO_LIBS(bswap64,,
273 [#ifdef HAVE_SYS_TYPES_H
274 #include <sys/types.h>
276 #ifdef HAVE_SYS_BSWAP_H
277 #include <sys/bswap.h>
280 AC_FIND_FUNC_NO_LIBS(pidfile,util,
285 AC_FIND_IF_NOT_BROKEN(getaddrinfo,,
289 #ifdef HAVE_WS2TCPIP_H
290 #include <ws2tcpip.h>
293 AC_FIND_IF_NOT_BROKEN(getnameinfo,,
297 #ifdef HAVE_WS2TCPIP_H
298 #include <ws2tcpip.h>
299 #endif],[0,0,0,0,0,0,0])
301 AC_FIND_IF_NOT_BROKEN(freeaddrinfo,,
305 #ifdef HAVE_WS2TCPIP_H
306 #include <ws2tcpip.h>
309 AC_FIND_IF_NOT_BROKEN(gai_strerror,,
313 #ifdef HAVE_WS2TCPIP_H
314 #include <ws2tcpip.h>
317 AC_CHECK_LIB(util, emalloc)
323 AC_BROKEN([daemon]) ;;
403 AM_CONDITIONAL(have_fnmatch_h,
404 test "$ac_cv_header_fnmatch_h" = yes -a "$ac_cv_func_fnmatch" = yes)
406 AC_FOREACH([rk_func], [strndup strsep strtok_r],
407 [AC_NEED_PROTO([#include <string.h>], rk_func)])
409 AC_CHECK_FUNC([strtoll],
410 [AC_DEFINE_UNQUOTED(HAVE_STRTOLL, 1,
411 [Define if you have the function strtoll.])])
413 AC_CHECK_FUNC([strtoull],
414 [AC_DEFINE_UNQUOTED(HAVE_STRTOULL, 1,
415 [Define if you have the function strtoull.])])
417 AC_FOREACH([rk_func], [strsvis strsvisx strunvis strvis strvisx svis unvis vis],
418 [AC_NEED_PROTO([#ifdef HAVE_VIS_H
422 AC_MSG_CHECKING([checking for dirfd])
423 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
428 [[DIR *d = 0; dirfd(d);]])],
429 [ac_rk_have_dirfd=yes], [ac_rk_have_dirfd=no])
430 if test "$ac_rk_have_dirfd" = "yes" ; then
431 AC_DEFINE_UNQUOTED(HAVE_DIRFD, 1, [have a dirfd function/macro])
433 AC_MSG_RESULT($ac_rk_have_dirfd)
435 AC_HAVE_STRUCT_FIELD(DIR, dd_fd, [#include <sys/types.h>
440 AC_HAVE_STRUCT_FIELD(DIR, d_fd, [#include <sys/types.h>
445 AC_BROKEN2(inet_aton,
446 [#ifdef HAVE_SYS_TYPES_H
447 #include <sys/types.h>
449 #ifdef HAVE_SYS_SOCKET_H
450 #include <sys/socket.h>
452 #ifdef HAVE_NETINET_IN_H
453 #include <netinet/in.h>
455 #ifdef HAVE_ARPA_INET_H
456 #include <arpa/inet.h>
460 AC_BROKEN2(inet_ntop,
461 [#ifdef HAVE_SYS_TYPES_H
462 #include <sys/types.h>
464 #ifdef HAVE_SYS_SOCKET_H
465 #include <sys/socket.h>
467 #ifdef HAVE_NETINET_IN_H
468 #include <netinet/in.h>
470 #ifdef HAVE_ARPA_INET_H
471 #include <arpa/inet.h>
475 AC_BROKEN2(inet_pton,
476 [#ifdef HAVE_SYS_TYPES_H
477 #include <sys/types.h>
479 #ifdef HAVE_SYS_SOCKET_H
480 #include <sys/socket.h>
482 #ifdef HAVE_NETINET_IN_H
483 #include <netinet/in.h>
485 #ifdef HAVE_ARPA_INET_H
486 #include <arpa/inet.h>
491 dnl Check for sa_len in struct sockaddr,
492 dnl needs to come before the getnameinfo test
494 AC_HAVE_STRUCT_FIELD(struct sockaddr, sa_len, [#include <sys/types.h>
495 #include <sys/socket.h>])
497 #if test "$ac_cv_func_getaddrinfo" = "yes"; then
498 # rk_BROKEN_GETADDRINFO
499 # if test "$ac_cv_func_getaddrinfo_numserv" = no; then
500 # AC_LIBOBJ(getaddrinfo)
501 # AC_LIBOBJ(freeaddrinfo)
505 AC_NEED_PROTO([#include <stdlib.h>], setenv)
506 AC_NEED_PROTO([#include <stdlib.h>], unsetenv)
507 AC_NEED_PROTO([#include <unistd.h>], gethostname)
508 AC_NEED_PROTO([#include <unistd.h>], mkstemp)
509 AC_NEED_PROTO([#include <unistd.h>], getusershell)
510 AC_NEED_PROTO([#include <unistd.h>], daemon)
513 #ifdef HAVE_SYS_TYPES_H
514 #include <sys/types.h>
516 #ifdef HAVE_SYS_SOCKET_H
517 #include <sys/socket.h>
519 #ifdef HAVE_NETINET_IN_H
520 #include <netinet/in.h>
522 #ifdef HAVE_ARPA_INET_H
523 #include <arpa/inet.h>
527 AC_FIND_FUNC_NO_LIBS(crypt, crypt)dnl
529 AC_REQUIRE([rk_BROKEN_REALLOC])dnl
531 dnl strerror_r is great fun, on linux it exists before sus catched up,
532 dnl so the return type is diffrent, lets check for both
538 strerror_r, int strerror_r(int, char *, size_t))
540 AC_CHECK_FUNC([strerror_r],
541 [AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
542 [Define if you have the function strerror_r.])])
545 dnl Checks for prototypes and declarations
549 #ifdef HAVE_SYS_TYPES_H
550 #include <sys/types.h>
552 #ifdef HAVE_SYS_SOCKET_H
553 #include <sys/socket.h>
555 #ifdef HAVE_NETINET_IN_H
556 #include <netinet/in.h>
558 #ifdef HAVE_ARPA_INET_H
559 #include <arpa/inet.h>
565 gethostbyname, struct hostent *gethostbyname(const char *))
568 #ifdef HAVE_SYS_TYPES_H
569 #include <sys/types.h>
571 #ifdef HAVE_SYS_SOCKET_H
572 #include <sys/socket.h>
574 #ifdef HAVE_NETINET_IN_H
575 #include <netinet/in.h>
577 #ifdef HAVE_ARPA_INET_H
578 #include <arpa/inet.h>
584 gethostbyaddr, struct hostent *gethostbyaddr(const void *, size_t, int))
587 #ifdef HAVE_SYS_TYPES_H
588 #include <sys/types.h>
590 #ifdef HAVE_SYS_SOCKET_H
591 #include <sys/socket.h>
593 #ifdef HAVE_NETINET_IN_H
594 #include <netinet/in.h>
596 #ifdef HAVE_ARPA_INET_H
597 #include <arpa/inet.h>
603 getservbyname, struct servent *getservbyname(const char *, const char *))
606 #ifdef HAVE_SYS_TYPES_H
607 #include <sys/types.h>
609 #ifdef HAVE_SYS_SOCKET_H
610 #include <sys/socket.h>
613 getsockname, int getsockname(int, struct sockaddr*, socklen_t*))
620 openlog, void openlog(const char *, int, int))
634 rk_CHECK_VAR(h_errno,
635 [#ifdef HAVE_SYS_TYPES_H
636 #include <sys/types.h>
641 #ifdef HAVE_WS2TCPIP_H
642 #include <ws2tcpip.h>
646 rk_CHECK_VAR(h_errlist,
650 #ifdef HAVE_WS2TCPIP_H
651 #include <ws2tcpip.h>
658 #ifdef HAVE_WS2TCPIP_H
659 #include <ws2tcpip.h>
662 rk_CHECK_VAR([__progname],
667 AC_CHECK_DECLS([optarg, optind, opterr, optopt, environ],[],[],[
674 dnl Check for fields in struct tm
677 AC_HAVE_STRUCT_FIELD(struct tm, tm_gmtoff, [#include <time.h>])
678 AC_HAVE_STRUCT_FIELD(struct tm, tm_zone, [#include <time.h>])
681 dnl or do we have a variable `timezone' ?
684 rk_CHECK_VAR(timezone,[#include <time.h>])
685 rk_CHECK_VAR(altzone,[#include <time.h>])
687 AC_HAVE_TYPE([sa_family_t],[
688 #include <sys/types.h>
689 #ifdef HAVE_SYS_SOCKET_H
690 #include <sys/socket.h>
692 #ifdef HAVE_WS2TCPIP_H
693 #include <ws2tcpip.h>
695 AC_HAVE_TYPE([socklen_t],[
696 #include <sys/types.h>
697 #ifdef HAVE_SYS_SOCKET_H
698 #include <sys/socket.h>
700 #ifdef HAVE_WS2TCPIP_H
701 #include <ws2tcpip.h>
703 AC_HAVE_TYPE([struct sockaddr], [
704 #include <sys/types.h>
705 #ifdef HAVE_SYS_SOCKET_H
706 #include <sys/socket.h>
708 #ifdef HAVE_WS2TCPIP_H
709 #include <ws2tcpip.h>
711 AC_HAVE_TYPE([struct sockaddr_storage], [
712 #include <sys/types.h>
713 #ifdef HAVE_SYS_SOCKET_H
714 #include <sys/socket.h>
716 #ifdef HAVE_WS2TCPIP_H
717 #include <ws2tcpip.h>
719 AC_HAVE_TYPE([struct addrinfo], [
720 #include <sys/types.h>
724 #ifdef HAVE_WS2TCPIP_H
725 #include <ws2tcpip.h>
727 AC_HAVE_TYPE([struct ifaddrs], [#include <ifaddrs.h>])
728 AC_HAVE_TYPE([struct iovec],[
729 #include <sys/types.h>
732 AC_HAVE_TYPE([struct msghdr],[
733 #include <sys/types.h>
734 #ifdef HAVE_SYS_SOCKET_H
735 #include <sys/socket.h>
737 #ifdef HAVE_WS2TCPIP_H
738 #include <ws2tcpip.h>
742 dnl Check for struct winsize
745 AC_KRB_STRUCT_WINSIZE
748 dnl Check for struct spwd
754 # Check if we want samba's socket wrapper
759 dnl won't work with automake
760 dnl moved to AC_OUTPUT in configure.in
761 dnl AC_CONFIG_FILES($1/Makefile)
763 LIB_roken="${LIB_roken} \$(LIB_crypt) \$(LIB_dbopen)"
765 AC_SUBST(DIR_roken)dnl
766 AC_SUBST(LIB_roken)dnl
767 AC_SUBST(INCLUDES_roken)dnl