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]) ;;
401 AM_CONDITIONAL(have_fnmatch_h,
402 test "$ac_cv_header_fnmatch_h" = yes -a "$ac_cv_func_fnmatch" = yes)
404 AC_FOREACH([rk_func], [strndup strsep strtok_r],
405 [AC_NEED_PROTO([#include <string.h>], rk_func)])
407 AC_CHECK_FUNC([strtoll],
408 [AC_DEFINE_UNQUOTED(HAVE_STRTOLL, 1,
409 [Define if you have the function strtoll.])])
411 AC_CHECK_FUNC([strtoull],
412 [AC_DEFINE_UNQUOTED(HAVE_STRTOULL, 1,
413 [Define if you have the function strtoull.])])
415 AC_FOREACH([rk_func], [strsvis strsvisx strunvis strvis strvisx svis unvis vis],
416 [AC_NEED_PROTO([#ifdef HAVE_VIS_H
420 AC_MSG_CHECKING([checking for dirfd])
421 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
426 [[DIR *d = 0; dirfd(d);]])],
427 [ac_rk_have_dirfd=yes], [ac_rk_have_dirfd=no])
428 if test "$ac_rk_have_dirfd" = "yes" ; then
429 AC_DEFINE_UNQUOTED(HAVE_DIRFD, 1, [have a dirfd function/macro])
431 AC_MSG_RESULT($ac_rk_have_dirfd)
433 AC_HAVE_STRUCT_FIELD(DIR, dd_fd, [#include <sys/types.h>
438 AC_HAVE_STRUCT_FIELD(DIR, d_fd, [#include <sys/types.h>
443 AC_BROKEN2(inet_aton,
444 [#ifdef HAVE_SYS_TYPES_H
445 #include <sys/types.h>
447 #ifdef HAVE_SYS_SOCKET_H
448 #include <sys/socket.h>
450 #ifdef HAVE_NETINET_IN_H
451 #include <netinet/in.h>
453 #ifdef HAVE_ARPA_INET_H
454 #include <arpa/inet.h>
458 AC_BROKEN2(inet_ntop,
459 [#ifdef HAVE_SYS_TYPES_H
460 #include <sys/types.h>
462 #ifdef HAVE_SYS_SOCKET_H
463 #include <sys/socket.h>
465 #ifdef HAVE_NETINET_IN_H
466 #include <netinet/in.h>
468 #ifdef HAVE_ARPA_INET_H
469 #include <arpa/inet.h>
473 AC_BROKEN2(inet_pton,
474 [#ifdef HAVE_SYS_TYPES_H
475 #include <sys/types.h>
477 #ifdef HAVE_SYS_SOCKET_H
478 #include <sys/socket.h>
480 #ifdef HAVE_NETINET_IN_H
481 #include <netinet/in.h>
483 #ifdef HAVE_ARPA_INET_H
484 #include <arpa/inet.h>
489 dnl Check for sa_len in struct sockaddr,
490 dnl needs to come before the getnameinfo test
492 AC_HAVE_STRUCT_FIELD(struct sockaddr, sa_len, [#include <sys/types.h>
493 #include <sys/socket.h>])
495 if test "$ac_cv_func_getaddrinfo" = "yes"; then
496 rk_BROKEN_GETADDRINFO
497 if test "$ac_cv_func_getaddrinfo_numserv" = no; then
498 AC_LIBOBJ(getaddrinfo)
499 AC_LIBOBJ(freeaddrinfo)
503 AC_NEED_PROTO([#include <stdlib.h>], setenv)
504 AC_NEED_PROTO([#include <stdlib.h>], unsetenv)
505 AC_NEED_PROTO([#include <unistd.h>], gethostname)
506 AC_NEED_PROTO([#include <unistd.h>], mkstemp)
507 AC_NEED_PROTO([#include <unistd.h>], getusershell)
508 AC_NEED_PROTO([#include <unistd.h>], daemon)
511 #ifdef HAVE_SYS_TYPES_H
512 #include <sys/types.h>
514 #ifdef HAVE_SYS_SOCKET_H
515 #include <sys/socket.h>
517 #ifdef HAVE_NETINET_IN_H
518 #include <netinet/in.h>
520 #ifdef HAVE_ARPA_INET_H
521 #include <arpa/inet.h>
525 AC_FIND_FUNC_NO_LIBS(crypt, crypt)dnl
527 AC_REQUIRE([rk_BROKEN_REALLOC])dnl
529 dnl strerror_r is great fun, on linux it exists before sus catched up,
530 dnl so the return type is diffrent, lets check for both
536 strerror_r, int strerror_r(int, char *, size_t))
538 AC_CHECK_FUNC([strerror_r],
539 [AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
540 [Define if you have the function strerror_r.])])
543 dnl Checks for prototypes and declarations
547 #ifdef HAVE_SYS_TYPES_H
548 #include <sys/types.h>
550 #ifdef HAVE_SYS_SOCKET_H
551 #include <sys/socket.h>
553 #ifdef HAVE_NETINET_IN_H
554 #include <netinet/in.h>
556 #ifdef HAVE_ARPA_INET_H
557 #include <arpa/inet.h>
563 gethostbyname, struct hostent *gethostbyname(const char *))
566 #ifdef HAVE_SYS_TYPES_H
567 #include <sys/types.h>
569 #ifdef HAVE_SYS_SOCKET_H
570 #include <sys/socket.h>
572 #ifdef HAVE_NETINET_IN_H
573 #include <netinet/in.h>
575 #ifdef HAVE_ARPA_INET_H
576 #include <arpa/inet.h>
582 gethostbyaddr, struct hostent *gethostbyaddr(const void *, size_t, int))
585 #ifdef HAVE_SYS_TYPES_H
586 #include <sys/types.h>
588 #ifdef HAVE_SYS_SOCKET_H
589 #include <sys/socket.h>
591 #ifdef HAVE_NETINET_IN_H
592 #include <netinet/in.h>
594 #ifdef HAVE_ARPA_INET_H
595 #include <arpa/inet.h>
601 getservbyname, struct servent *getservbyname(const char *, const char *))
604 #ifdef HAVE_SYS_TYPES_H
605 #include <sys/types.h>
607 #ifdef HAVE_SYS_SOCKET_H
608 #include <sys/socket.h>
611 getsockname, int getsockname(int, struct sockaddr*, socklen_t*))
618 openlog, void openlog(const char *, int, int))
632 rk_CHECK_VAR(h_errno,
633 [#ifdef HAVE_SYS_TYPES_H
634 #include <sys/types.h>
639 #ifdef HAVE_WS2TCPIP_H
640 #include <ws2tcpip.h>
644 rk_CHECK_VAR(h_errlist,
648 #ifdef HAVE_WS2TCPIP_H
649 #include <ws2tcpip.h>
656 #ifdef HAVE_WS2TCPIP_H
657 #include <ws2tcpip.h>
660 rk_CHECK_VAR([__progname],
665 AC_CHECK_DECLS([optarg, optind, opterr, optopt, environ],[],[],[
672 dnl Check for fields in struct tm
675 AC_HAVE_STRUCT_FIELD(struct tm, tm_gmtoff, [#include <time.h>])
676 AC_HAVE_STRUCT_FIELD(struct tm, tm_zone, [#include <time.h>])
679 dnl or do we have a variable `timezone' ?
682 rk_CHECK_VAR(timezone,[#include <time.h>])
683 rk_CHECK_VAR(altzone,[#include <time.h>])
685 AC_HAVE_TYPE([sa_family_t],[
686 #include <sys/types.h>
687 #ifdef HAVE_SYS_SOCKET_H
688 #include <sys/socket.h>
690 #ifdef HAVE_WS2TCPIP_H
691 #include <ws2tcpip.h>
693 AC_HAVE_TYPE([socklen_t],[
694 #include <sys/types.h>
695 #ifdef HAVE_SYS_SOCKET_H
696 #include <sys/socket.h>
698 #ifdef HAVE_WS2TCPIP_H
699 #include <ws2tcpip.h>
701 AC_HAVE_TYPE([struct sockaddr], [
702 #include <sys/types.h>
703 #ifdef HAVE_SYS_SOCKET_H
704 #include <sys/socket.h>
706 #ifdef HAVE_WS2TCPIP_H
707 #include <ws2tcpip.h>
709 AC_HAVE_TYPE([struct sockaddr_storage], [
710 #include <sys/types.h>
711 #ifdef HAVE_SYS_SOCKET_H
712 #include <sys/socket.h>
714 #ifdef HAVE_WS2TCPIP_H
715 #include <ws2tcpip.h>
717 AC_HAVE_TYPE([struct addrinfo], [
718 #include <sys/types.h>
722 #ifdef HAVE_WS2TCPIP_H
723 #include <ws2tcpip.h>
725 AC_HAVE_TYPE([struct ifaddrs], [#include <ifaddrs.h>])
726 AC_HAVE_TYPE([struct iovec],[
727 #include <sys/types.h>
730 AC_HAVE_TYPE([struct msghdr],[
731 #include <sys/types.h>
732 #ifdef HAVE_SYS_SOCKET_H
733 #include <sys/socket.h>
735 #ifdef HAVE_WS2TCPIP_H
736 #include <ws2tcpip.h>
740 dnl Check for struct winsize
743 AC_KRB_STRUCT_WINSIZE
746 dnl Check for struct spwd
752 # Check if we want samba's socket wrapper
757 dnl won't work with automake
758 dnl moved to AC_OUTPUT in configure.in
759 dnl AC_CONFIG_FILES($1/Makefile)
761 LIB_roken="${LIB_roken} \$(LIB_crypt) \$(LIB_dbopen)"
763 AC_SUBST(DIR_roken)dnl
764 AC_SUBST(LIB_roken)dnl
765 AC_SUBST(INCLUDES_roken)dnl