#!/bin/sh
#require compiletest
#require cflags
#phase init
#after init_cflags
#phase header
case $PHASE in
	init)
		dispn "Checking for IPv6 transport support..."
		PROGRAM="#include <sys/socket.h>
#include <netinet/in.h>

int main () {
	struct sockaddr_in6 addr6;
	addr6.sin6_family = AF_INET6;

	/* don't detect return code of socket(); program should do this at runtime */
	socket(PF_INET6,SOCK_STREAM,0);

	return 0;
}"
		FM_IPV6_SOCKET="y"
		compile_test_wrapper "$PROGRAM" "-DHAVE_IPV6" "" "" || \
		{
			disp "not found, some functionality may be missing"
			FM_IPV6_SOCKET="n"
		}
		;;
	header)
		if test "$FM_IPV6_SOCKET" = "y"; then
			disp "Adding \"#include <sys/socket.h>\" to header"
			$ECHO "#include <sys/socket.h>"
			disp "Adding \"#include <netinet/in.h>\" to header"
			$ECHO "#include <netinet/in.h>"
		fi
		;;
esac
