From 1294d0a004686e390df9d65a08b9e2f90fd7b709 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Thu, 1 Oct 2015 14:06:14 +0100 Subject: [PATCH] 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. --- configure | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/configure b/configure index a4dac46..1cd85af 100755 --- a/configure +++ b/configure @@ -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 \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 \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