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)
219 if test "$ac_cv_func_cgetent" = no; then
222 AM_CONDITIONAL(have_cgetent, test "$ac_cv_func_cgetent" = yes)
224 AC_REQUIRE([AC_FUNC_GETLOGIN])
226 AC_REQUIRE([AC_FUNC_MMAP])
228 AC_FIND_FUNC_NO_LIBS(getsockopt,,
229 [#ifdef HAVE_SYS_TYPES_H
230 #include <sys/types.h>
232 #ifdef HAVE_SYS_SOCKET_H
233 #include <sys/socket.h>
236 AC_FIND_FUNC_NO_LIBS(setsockopt,,
237 [#ifdef HAVE_SYS_TYPES_H
238 #include <sys/types.h>
240 #ifdef HAVE_SYS_SOCKET_H
241 #include <sys/socket.h>
245 AC_FIND_IF_NOT_BROKEN(hstrerror, resolv,
256 AC_FOREACH([rk_func], [asprintf vasprintf asnprintf vasnprintf],
259 #include <string.h>],
262 AC_FIND_FUNC_NO_LIBS(bswap16,,
263 [#ifdef HAVE_SYS_TYPES_H
264 #include <sys/types.h>
266 #ifdef HAVE_SYS_BSWAP_H
267 #include <sys/bswap.h>
270 AC_FIND_FUNC_NO_LIBS(bswap32,,
271 [#ifdef HAVE_SYS_TYPES_H
272 #include <sys/types.h>
274 #ifdef HAVE_SYS_BSWAP_H
275 #include <sys/bswap.h>
278 AC_FIND_FUNC_NO_LIBS(bswap64,,
279 [#ifdef HAVE_SYS_TYPES_H
280 #include <sys/types.h>
282 #ifdef HAVE_SYS_BSWAP_H
283 #include <sys/bswap.h>
286 AC_FIND_FUNC_NO_LIBS(pidfile,util,
291 AC_FIND_IF_NOT_BROKEN(getaddrinfo,,
295 #ifdef HAVE_WS2TCPIP_H
296 #include <ws2tcpip.h>
299 AC_FIND_IF_NOT_BROKEN(getnameinfo,,
303 #ifdef HAVE_WS2TCPIP_H
304 #include <ws2tcpip.h>
305 #endif],[0,0,0,0,0,0,0])
307 AC_FIND_IF_NOT_BROKEN(freeaddrinfo,,
311 #ifdef HAVE_WS2TCPIP_H
312 #include <ws2tcpip.h>
315 AC_FIND_IF_NOT_BROKEN(gai_strerror,,
319 #ifdef HAVE_WS2TCPIP_H
320 #include <ws2tcpip.h>
323 AC_CHECK_LIB(util, emalloc)
329 AC_BROKEN([daemon]) ;;
407 AM_CONDITIONAL(have_fnmatch_h,
408 test "$ac_cv_header_fnmatch_h" = yes -a "$ac_cv_func_fnmatch" = yes)
410 AC_FOREACH([rk_func], [strndup strsep strtok_r],
411 [AC_NEED_PROTO([#include <string.h>], rk_func)])
413 AC_CHECK_FUNC([strtoll],
414 [AC_DEFINE_UNQUOTED(HAVE_STRTOLL, 1,
415 [Define if you have the function strtoll.])])
417 AC_CHECK_FUNC([strtoull],
418 [AC_DEFINE_UNQUOTED(HAVE_STRTOULL, 1,
419 [Define if you have the function strtoull.])])
421 AC_FOREACH([rk_func], [strsvis strsvisx strunvis strvis strvisx svis unvis vis],
422 [AC_NEED_PROTO([#ifdef HAVE_VIS_H
426 AC_MSG_CHECKING([checking for dirfd])
427 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
432 [[DIR *d = 0; dirfd(d);]])],
433 [ac_rk_have_dirfd=yes], [ac_rk_have_dirfd=no])
434 if test "$ac_rk_have_dirfd" = "yes" ; then
435 AC_DEFINE_UNQUOTED(HAVE_DIRFD, 1, [have a dirfd function/macro])
437 AC_MSG_RESULT($ac_rk_have_dirfd)
439 AC_HAVE_STRUCT_FIELD(DIR, dd_fd, [#include <sys/types.h>
444 AC_HAVE_STRUCT_FIELD(DIR, d_fd, [#include <sys/types.h>
449 AC_BROKEN2(inet_aton,
450 [#ifdef HAVE_SYS_TYPES_H
451 #include <sys/types.h>
453 #ifdef HAVE_SYS_SOCKET_H
454 #include <sys/socket.h>
456 #ifdef HAVE_NETINET_IN_H
457 #include <netinet/in.h>
459 #ifdef HAVE_ARPA_INET_H
460 #include <arpa/inet.h>
464 AC_BROKEN2(inet_ntop,
465 [#ifdef HAVE_SYS_TYPES_H
466 #include <sys/types.h>
468 #ifdef HAVE_SYS_SOCKET_H
469 #include <sys/socket.h>
471 #ifdef HAVE_NETINET_IN_H
472 #include <netinet/in.h>
474 #ifdef HAVE_ARPA_INET_H
475 #include <arpa/inet.h>
479 AC_BROKEN2(inet_pton,
480 [#ifdef HAVE_SYS_TYPES_H
481 #include <sys/types.h>
483 #ifdef HAVE_SYS_SOCKET_H
484 #include <sys/socket.h>
486 #ifdef HAVE_NETINET_IN_H
487 #include <netinet/in.h>
489 #ifdef HAVE_ARPA_INET_H
490 #include <arpa/inet.h>
495 dnl Check for sa_len in struct sockaddr,
496 dnl needs to come before the getnameinfo test
498 AC_HAVE_STRUCT_FIELD(struct sockaddr, sa_len, [#include <sys/types.h>
499 #include <sys/socket.h>])
501 if test "$ac_cv_func_getaddrinfo" = "yes"; then
502 rk_BROKEN_GETADDRINFO
503 if test "$ac_cv_func_getaddrinfo_numserv" = no; then
504 AC_LIBOBJ(getaddrinfo)
505 AC_LIBOBJ(freeaddrinfo)
509 AC_NEED_PROTO([#include <stdlib.h>], setenv)
510 AC_NEED_PROTO([#include <stdlib.h>], unsetenv)
511 AC_NEED_PROTO([#include <unistd.h>], gethostname)
512 AC_NEED_PROTO([#include <unistd.h>], mkstemp)
513 AC_NEED_PROTO([#include <unistd.h>], getusershell)
514 AC_NEED_PROTO([#include <unistd.h>], daemon)
517 #ifdef HAVE_SYS_TYPES_H
518 #include <sys/types.h>
520 #ifdef HAVE_SYS_SOCKET_H
521 #include <sys/socket.h>
523 #ifdef HAVE_NETINET_IN_H
524 #include <netinet/in.h>
526 #ifdef HAVE_ARPA_INET_H
527 #include <arpa/inet.h>
531 AC_FIND_FUNC_NO_LIBS(crypt, crypt)dnl
533 AC_REQUIRE([rk_BROKEN_REALLOC])dnl
535 dnl strerror_r is great fun, on linux it exists before sus catched up,
536 dnl so the return type is diffrent, lets check for both
542 strerror_r, int strerror_r(int, char *, size_t))
544 AC_CHECK_FUNC([strerror_r],
545 [AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
546 [Define if you have the function strerror_r.])])
549 dnl Checks for prototypes and declarations
553 #ifdef HAVE_SYS_TYPES_H
554 #include <sys/types.h>
556 #ifdef HAVE_SYS_SOCKET_H
557 #include <sys/socket.h>
559 #ifdef HAVE_NETINET_IN_H
560 #include <netinet/in.h>
562 #ifdef HAVE_ARPA_INET_H
563 #include <arpa/inet.h>
569 gethostbyname, struct hostent *gethostbyname(const char *))
572 #ifdef HAVE_SYS_TYPES_H
573 #include <sys/types.h>
575 #ifdef HAVE_SYS_SOCKET_H
576 #include <sys/socket.h>
578 #ifdef HAVE_NETINET_IN_H
579 #include <netinet/in.h>
581 #ifdef HAVE_ARPA_INET_H
582 #include <arpa/inet.h>
588 gethostbyaddr, struct hostent *gethostbyaddr(const void *, size_t, int))
591 #ifdef HAVE_SYS_TYPES_H
592 #include <sys/types.h>
594 #ifdef HAVE_SYS_SOCKET_H
595 #include <sys/socket.h>
597 #ifdef HAVE_NETINET_IN_H
598 #include <netinet/in.h>
600 #ifdef HAVE_ARPA_INET_H
601 #include <arpa/inet.h>
607 getservbyname, struct servent *getservbyname(const char *, const char *))
610 #ifdef HAVE_SYS_TYPES_H
611 #include <sys/types.h>
613 #ifdef HAVE_SYS_SOCKET_H
614 #include <sys/socket.h>
617 getsockname, int getsockname(int, struct sockaddr*, socklen_t*))
624 openlog, void openlog(const char *, int, int))
638 rk_CHECK_VAR(h_errno,
639 [#ifdef HAVE_SYS_TYPES_H
640 #include <sys/types.h>
645 #ifdef HAVE_WS2TCPIP_H
646 #include <ws2tcpip.h>
650 rk_CHECK_VAR(h_errlist,
654 #ifdef HAVE_WS2TCPIP_H
655 #include <ws2tcpip.h>
662 #ifdef HAVE_WS2TCPIP_H
663 #include <ws2tcpip.h>
666 rk_CHECK_VAR([__progname],
671 AC_CHECK_DECLS([optarg, optind, opterr, optopt, environ],[],[],[
678 dnl Check for fields in struct tm
681 AC_HAVE_STRUCT_FIELD(struct tm, tm_gmtoff, [#include <time.h>])
682 AC_HAVE_STRUCT_FIELD(struct tm, tm_zone, [#include <time.h>])
685 dnl or do we have a variable `timezone' ?
688 rk_CHECK_VAR(timezone,[#include <time.h>])
689 rk_CHECK_VAR(altzone,[#include <time.h>])
691 AC_HAVE_TYPE([sa_family_t],[
692 #include <sys/types.h>
693 #ifdef HAVE_SYS_SOCKET_H
694 #include <sys/socket.h>
696 #ifdef HAVE_WS2TCPIP_H
697 #include <ws2tcpip.h>
699 AC_HAVE_TYPE([socklen_t],[
700 #include <sys/types.h>
701 #ifdef HAVE_SYS_SOCKET_H
702 #include <sys/socket.h>
704 #ifdef HAVE_WS2TCPIP_H
705 #include <ws2tcpip.h>
707 AC_HAVE_TYPE([struct sockaddr], [
708 #include <sys/types.h>
709 #ifdef HAVE_SYS_SOCKET_H
710 #include <sys/socket.h>
712 #ifdef HAVE_WS2TCPIP_H
713 #include <ws2tcpip.h>
715 AC_HAVE_TYPE([struct sockaddr_storage], [
716 #include <sys/types.h>
717 #ifdef HAVE_SYS_SOCKET_H
718 #include <sys/socket.h>
720 #ifdef HAVE_WS2TCPIP_H
721 #include <ws2tcpip.h>
723 AC_HAVE_TYPE([struct addrinfo], [
724 #include <sys/types.h>
728 #ifdef HAVE_WS2TCPIP_H
729 #include <ws2tcpip.h>
731 AC_HAVE_TYPE([struct ifaddrs], [#include <ifaddrs.h>])
732 AC_HAVE_TYPE([struct iovec],[
733 #include <sys/types.h>
736 AC_HAVE_TYPE([struct msghdr],[
737 #include <sys/types.h>
738 #ifdef HAVE_SYS_SOCKET_H
739 #include <sys/socket.h>
741 #ifdef HAVE_WS2TCPIP_H
742 #include <ws2tcpip.h>
746 dnl Check for struct winsize
749 AC_KRB_STRUCT_WINSIZE
752 dnl Check for struct spwd
758 # Check if we want samba's socket wrapper
763 dnl won't work with automake
764 dnl moved to AC_OUTPUT in configure.in
765 dnl AC_CONFIG_FILES($1/Makefile)
767 LIB_roken="${LIB_roken} \$(LIB_crypt) \$(LIB_dbopen)"
769 AC_SUBST(DIR_roken)dnl
770 AC_SUBST(LIB_roken)dnl
771 AC_SUBST(INCLUDES_roken)dnl