1dnl Copyright (C) 2000-2016 Hajimu UMEMOTO <ume@mahoroba.org>. 2dnl All rights reserved. 3dnl 4dnl Redistribution and use in source and binary forms, with or without 5dnl modification, are permitted provided that the following conditions 6dnl are met: 7dnl 1. Redistributions of source code must retain the above copyright 8dnl notice, this list of conditions and the following disclaimer. 9dnl 2. Redistributions in binary form must reproduce the above copyright 10dnl notice, this list of conditions and the following disclaimer in the 11dnl documentation and/or other materials provided with the distribution. 12dnl 3. Neither the name of the project nor the names of its contributors 13dnl may be used to endorse or promote products derived from this software 14dnl without specific prior written permission. 15dnl 16dnl THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17dnl ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19dnl ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22dnl OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26dnl SUCH DAMAGE. 27 28dnl $Id: aclocal.m4 682 2016-07-11 05:44:06Z ume $ 29 30dnl SOCKET6_CHECK_PL_SV_UNDEF(VALUE-IF-FOUND , VALUE-IF-NOT-FOUND 31dnl [, PERL-PATH]) 32AC_DEFUN([SOCKET6_CHECK_PL_SV_UNDEF], [ 33AC_MSG_CHECKING([whether your Perl5 have PL_sv_undef]) 34AC_CACHE_VAL(socket6_cv_pl_sv_undef,[ 35rm -rf conftest 36mkdir conftest 37cd conftest 38cat >Makefile.PL <<EOF 39use ExtUtils::MakeMaker; 40WriteMakefile( 41 NAME => 'conftest', 42 VERSION_FROM => 'conftest.pm', 43 XSPROTOARG => '-noprototypes', 44); 45EOF 46cat > conftest.pm <<EOF 47package conftest; 48use vars qw(\$VERSION); 49\$VERSION = "0.0"; 50EOF 51cat > conftest.xs <<EOF 52#include "EXTERN.h" 53#include "perl.h" 54#include "XSUB.h" 55MODULE = conftest PACKAGE = conftest 56void 57conftest() 58 CODE: 59 ST(0) = &PL_sv_undef; 60EOF 61ifelse([$3], , socket6_cv_perl_path='perl', socket6_cv_perl_path=$3) 62if { (eval $socket6_cv_perl_path Makefile.PL) 2>&5 >/dev/null; (eval make) 2>&5 >/dev/null; }; then 63 socket6_cv_pl_sv_undef='yes' 64else 65 socket6_cv_pl_sv_undef='no' 66fi 67cd .. 68rm -rf conftest 69]) 70if test $socket6_cv_pl_sv_undef = 'yes'; then 71 AC_MSG_RESULT(yes) 72 ifelse([$1], , :, [$1]) 73else 74 AC_MSG_RESULT(no) 75 ifelse([$2], , :, [$2]) 76fi 77]) 78 79dnl IPv6_CHECK_SIN6_SCOPE_ID(VALUE-IF-FOUND , VALUE-IF-NOT-FOUND) 80AC_DEFUN([IPv6_CHECK_SIN6_SCOPE_ID], [ 81AC_MSG_CHECKING([whether you have sin6_scope_id in struct sockaddr_in6]) 82AC_CACHE_VAL(ipv6_cv_sin6_scope_id, [dnl 83AC_TRY_COMPILE([#include <sys/types.h> 84#include <sys/socket.h> 85#include <netinet/in.h>], 86 [struct sockaddr_in6 sin6; int i = sin6.sin6_scope_id;], 87 [ipv6_cv_sin6_scope_id=yes], [ipv6_cv_sin6_scope_id=no])])dnl 88if test $ipv6_cv_sin6_scope_id = yes; then 89 ifelse([$1], , AC_DEFINE(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID,[1],[Do we have a sin6_scope_id in struct sockaddr_in6?]), [$1]) 90else 91 ifelse([$2], , :, [$2]) 92fi 93AC_MSG_RESULT($ipv6_cv_sin6_scope_id)]) 94dnl 95dnl whether you have sa_len in struct sockaddr 96AC_DEFUN([IPv6_CHECK_SA_LEN], [ 97AC_MSG_CHECKING([whether you have sa_len in struct sockaddr]) 98AC_CACHE_VAL(ipv6_cv_sa_len, [dnl 99AC_TRY_COMPILE([#include <sys/types.h> 100#include <sys/socket.h>], 101 [struct sockaddr sa; int i = sa.sa_len;], 102 [ipv6_cv_sa_len=yes], [ipv6_cv_sa_len=no])])dnl 103if test $ipv6_cv_sa_len = yes; then 104 ifelse([$1], , AC_DEFINE(HAVE_SOCKADDR_SA_LEN,[1],[Does sockaddr have an sa_len?]), [$1]) 105else 106 ifelse([$2], , :, [$2]) 107fi 108AC_MSG_RESULT($ipv6_cv_sa_len)]) 109dnl 110dnl See whether we can use IPv6 related functions 111AC_DEFUN([IPv6_CHECK_FUNC], [ 112AH_TEMPLATE(AS_TR_CPP(HAVE_$1), [Define to 1 if you have the `]$1[' function.]) 113AC_CHECK_FUNC($1, [dnl 114 ac_cv_lib_socket_$1=no 115 ac_cv_lib_inet6_$1=no 116], [dnl 117 AC_CHECK_LIB(socket, $1, [dnl 118 LIBS="$LIBS -lsocket -lnsl" 119 ac_cv_lib_inet6_$1=no 120 ], [dnl 121 AC_MSG_CHECKING([whether your system has IPv6 directory]) 122 AC_CACHE_VAL(ipv6_cv_dir, [dnl 123 for ipv6_cv_dir in /usr/local/v6 /usr/inet6 no; do 124 if test $ipv6_cv_dir = no -o -d $ipv6_cv_dir; then 125 break 126 fi 127 done])dnl 128 AC_MSG_RESULT($ipv6_cv_dir) 129 if test $ipv6_cv_dir = no; then 130 ac_cv_lib_inet6_$1=no 131 else 132 if test x$ipv6_libinet6 = x; then 133 ipv6_libinet6=no 134 SAVELDFLAGS="$LDFLAGS" 135 LDFLAGS="$LDFLAGS -L$ipv6_cv_dir/lib" 136 fi 137 AC_CHECK_LIB(inet6, $1, [dnl 138 if test $ipv6_libinet6 = no; then 139 ipv6_libinet6=yes 140 LIBS="$LIBS -linet6" 141 fi],)dnl 142 if test $ipv6_libinet6 = no; then 143 LDFLAGS="$SAVELDFLAGS" 144 fi 145 fi])dnl 146])dnl 147ipv6_cv_$1=no 148if test $ac_cv_func_$1 = yes -o $ac_cv_lib_socket_$1 = yes \ 149 -o $ac_cv_lib_inet6_$1 = yes 150then 151 ipv6_cv_$1=yes 152fi 153if test $ipv6_cv_$1 = no; then 154 if test $1 = getaddrinfo; then 155 for ipv6_cv_pfx in o n; do 156 AC_EGREP_HEADER(${ipv6_cv_pfx}$1, netdb.h, 157 [AC_CHECK_FUNC(${ipv6_cv_pfx}$1)]) 158 if eval test X\$ac_cv_func_${ipv6_cv_pfx}$1 = Xyes; then 159 ipv6_cv_$1=yes 160 break 161 fi 162 done 163 fi 164fi 165if test $ipv6_cv_$1 = yes; then 166 AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1)) 167 ifelse([$2], , :, [$2]) 168else 169 ifelse([$3], , :, [$3]) 170fi]) 171dnl 172dnl See whether sys/socket.h has socklen_t 173AC_DEFUN([IPv6_CHECK_SOCKLEN_T], [ 174AC_MSG_CHECKING(for socklen_t) 175AC_CACHE_VAL(ipv6_cv_socklen_t, [dnl 176AC_TRY_LINK([#include <sys/types.h> 177#include <sys/socket.h>], 178 [socklen_t len = 0;], 179 [ipv6_cv_socklen_t=yes], [ipv6_cv_socklen_t=no])])dnl 180if test $ipv6_cv_socklen_t = yes; then 181 ifelse([$1], , AC_DEFINE(HAVE_SOCKLEN_T,[1],[Do we have a socklen_t?]), [$1]) 182else 183 ifelse([$2], , :, [$2]) 184fi 185AC_MSG_RESULT($ipv6_cv_socklen_t)]) 186dnl 187dnl Check if darwin inet_ntop is broken 188AC_DEFUN([IPv6_CHECK_INET_NTOP], [ 189AC_MSG_CHECKING(for working inet_ntop) 190AC_CACHE_VAL(ipv6_cv_can_inet_ntop, [dnl 191AC_RUN_IFELSE([AC_LANG_SOURCE[ 192#include <string.h> 193#include <stdlib.h> 194#include <sys/types.h> 195#include <sys/socket.h> 196#include <netinet/in.h> 197#include <arpa/inet.h> 198 199int 200main() { 201 static struct in6_addr addr; 202 static char str[INET6_ADDRSTRLEN]; 203 204 addr.s6_addr[15] = 0x21; 205 inet_ntop(AF_INET6, &addr, str, sizeof(str)); 206 if (strcmp(str, "::21") && strcmp(str, "::0.0.0.33")) 207 exit(1); 208} 209]], [ipv6_cv_can_inet_ntop=yes], [ipv6_cv_can_inet_ntop=no])])dnl 210dnl 211if test $ipv6_cv_can_inet_ntop = yes; then 212 ifelse([$1], , AC_DEFINE(CAN_INET_NTOP,[1],[Do we have a working inet_ntop?]), [$1]) 213else 214 ifelse([$2], , :, [$2]) 215fi 216AC_MSG_RESULT($ipv6_cv_can_inet_ntop)]) 217