1 dnl RACOON_PATH_LIBS(FUNCTION, LIB, SEARCH-PATHS [, ACTION-IF-FOUND
2 dnl [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
3 dnl Search for a library defining FUNC, if it's not already available.
5 AC_DEFUN([RACOON_PATH_LIBS],
7 AC_CACHE_CHECK([for $2 containing $1], [ac_cv_search_$1],
8 [ac_func_search_save_LIBS="$LIBS"
10 AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"],
12 AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="-l$2"], [])])
13 LIBS="$ac_func_search_save_LIBS"
14 ifelse("x$3", "x", , [ test "$ac_cv_search_$1" = "no" && for i in $3; do
15 LIBS="-L$i -l$2 $ac_func_search_save_LIBS"
16 AC_TRY_LINK_FUNC([$1],
17 [ac_cv_search_$1="-L$i -l$2"
20 LIBS="$ac_func_search_save_LIBS" ]) ])
21 if test "$ac_cv_search_$1" != "no"; then
22 test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
28 dnl Check if either va_copy() or __va_copy() is available. On linux systems
29 dnl at least one of these should be present.
30 AC_DEFUN([RACOON_CHECK_VA_COPY], [
33 AC_CACHE_CHECK([for an implementation of va_copy()],
35 AC_TRY_RUN([#include <stdarg.h>
36 void func (int i, ...) {
39 va_copy (args2, args1);
40 if (va_arg (args1, int) != 1 || va_arg (args2, int) != 1)
53 if test x$ac_cv_va_copy != xyes; then
54 AC_CACHE_CHECK([for an implementation of __va_copy()],
56 AC_TRY_RUN([#include <stdarg.h>
57 void func (int i, ...) {
60 __va_copy (args2, args1);
61 if (va_arg (args1, int) != 1 || va_arg (args2, int) != 1)
70 [ac_cv___va_copy=yes],
76 if test "x$ac_cv_va_copy" = "xyes"; then
78 elif test "x$ac_cv___va_copy" = "xyes"; then
79 va_copy_func=__va_copy
82 if test -n "$va_copy_func"; then
83 AC_DEFINE_UNQUOTED(VA_COPY,$va_copy_func,
84 [A 'va_copy' style function])
86 AC_MSG_WARN([Hmm, neither va_copy() nor __va_copy() found.])
87 AC_MSG_WARN([Using a generic fallback.])
93 AC_DEFUN([RACOON_CHECK_BUGGY_GETADDRINFO], [
94 AC_MSG_CHECKING(getaddrinfo bug)
98 #include <sys/types.h>
99 #include <sys/socket.h>
103 #include <netinet/in.h>
107 int passive, gaierr, inet4 = 0, inet6 = 0;
108 struct addrinfo hints, *ai, *aitop;
109 char straddr[INET6_ADDRSTRLEN], strport[16];
111 for (passive = 0; passive <= 1; passive++) {
112 memset(&hints, 0, sizeof(hints));
113 hints.ai_family = AF_UNSPEC;
114 hints.ai_flags = passive ? AI_PASSIVE : 0;
115 hints.ai_protocol = IPPROTO_TCP;
116 hints.ai_socktype = SOCK_STREAM;
117 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
118 (void)gai_strerror(gaierr);
121 for (ai = aitop; ai; ai = ai->ai_next) {
122 if (ai->ai_addr == NULL ||
123 ai->ai_addrlen == 0 ||
124 getnameinfo(ai->ai_addr, ai->ai_addrlen,
125 straddr, sizeof(straddr), strport, sizeof(strport),
126 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
129 switch (ai->ai_family) {
131 if (strcmp(strport, "54321") != 0) {
135 if (strcmp(straddr, "0.0.0.0") != 0) {
139 if (strcmp(straddr, "127.0.0.1") != 0) {
146 if (strcmp(strport, "54321") != 0) {
150 if (strcmp(straddr, "::") != 0) {
154 if (strcmp(straddr, "::1") != 0) {
164 /* another family support? */
170 if (!(inet4 == 0 || inet4 == 2))
172 if (!(inet6 == 0 || inet6 == 2))
188 buggygetaddrinfo=yes,
190 buggygetaddrinfo=yes)