configure: check for availability of s6_addr16

this should fix the build of the recently added ipv6 code on MacOS X,
OpenBSD and eventually FreeBSD.

closes #83
closes #85

thanks to @cam13 and @vonnyfly for reporting/testing.
pull/93/head
rofl0r 2015-10-01 14:06:14 +01:00
parent e9bf9623ba
commit 1294d0a004
1 changed files with 22 additions and 0 deletions

22
configure vendored
View File

@ -18,6 +18,20 @@ isopenbsd() {
uname -s | grep OpenBSD >/dev/null
}
check_compile() {
printf "checking %s ... " "$1"
local tmp=$(mktemp)
printf "$3" > "$tmp".c
local res=0
$CC $CPPFLAGS $2 $CFLAGS -c "$tmp".c -o "$tmp".o >/dev/null 2>&1 \
|| res=1
rm -f "$tmp".c "$tmp".o
test x$res = x0 && \
{ printf "yes\n" ; test x"$2" = x || CPPFLAGS="$CPPFLAGS $2" ; } \
|| printf "no\n"
return $res
}
usage() {
echo "supported arguments"
echo "--prefix=/path default: $prefix"
@ -89,6 +103,14 @@ if [ -z "$CC" ] ; then
CC=cc
fi
check_compile 'whether netinet/in.h defines s6_addr16' "" \
'#include <netinet/in.h>\nint main(int a, char**c){struct in6_addr x={.s6_addr32[0]=a};return x.s6_addr16[0]; }' \
|| {
check_compile 'whether netinet/in.h defines __u6_addr.__u6_addr16' \
'-Ds6_addr16=__u6_addr.__u6_addr16 -Ds6_addr32=__u6_addr.__u6_addr32' \
'#include <netinet/in.h>\nint main(int a, char**c){struct in6_addr x={.s6_addr32[0]=a};return x.s6_addr16[0]; }'
}
echo CC?=$CC>config.mak
[ -z "$CPPFLAGS" ] || echo CPPFLAGS?=$CPPFLAGS>>config.mak
[ -z "$CFLAGS" ] || echo USER_CFLAGS?=$CFLAGS>>config.mak