Skip to content

Commit

Permalink
configure: check for availability of s6_addr16
Browse files Browse the repository at this point in the history
this should fix the build of the recently added ipv6 code on MacOS X,
OpenBSD and eventually FreeBSD.

closes rofl0r#83
closes rofl0r#85

thanks to @cam13 and @vonnyfly for reporting/testing.
  • Loading branch information
rofl0r committed Oct 1, 2015
1 parent e9bf962 commit 1294d0a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1294d0a

Please sign in to comment.