1#!/bin/sh 2 3# Copyright 2003 by Sun Microsystems, Inc. All rights reserved. 4# Use is subject to license terms. 5# 6 7set -e 8PATH=/bin:/usr/bin:$PATH; export PATH 9trap "rm -f tmp$$[abc].[oc]" 0 10target=port_ipv6 11new=new_${target}.h 12old=${target}.h 13 14cat > tmp$$a.c <<EOF 15#include <sys/types.h> 16#include <netinet/in.h> 17struct sockaddr_in6 xx; 18EOF 19 20cat > tmp$$b.c <<EOF 21#include <sys/types.h> 22#include <netinet/in.h> 23struct in6_addr xx; 24EOF 25 26cat > tmp$$c.c <<EOF 27#include <sys/types.h> 28#include <netinet/in.h> 29 30struct sockaddr_in6 xx; 31int 32main() { xx.sin6_scope_id = 0; } 33EOF 34 35cat > ${new} <<EOF 36 37/* This file is automatically generated. Do Not Edit. */ 38 39#ifndef ${target}_h 40#define ${target}_h 41 42EOF 43 44if ${CC} ${CPPFLAGS} -c tmp$$a.c > /dev/null 2>&1 45then 46 echo "#define HAS_INET6_STRUCTS" >> ${new} 47 if ${CC} ${CPPFLAGS} -c tmp$$b.c > /dev/null 2>&1 48 then 49 : 50 else 51 printf "build failed to detect struct in6_addr\n" >&2 52 exit 1 53 fi 54 if ${CC} ${CPPFLAGS} -c tmp$$c.c > /dev/null 2>&1 55 then 56 echo "#define HAVE_SIN6_SCOPE_ID" >> ${new} 57 else 58 printf "build failed to detect sin6_scope_id\n" >&2 59 exit 1 60 fi 61else 62 printf "build failed to detect struct sockaddr_in6\n" >&2 63 exit 1 64fi 65echo >> ${new} 66echo "#endif" >> ${new} 67if [ -f ${old} ]; then 68 if cmp -s ${new} ${old} ; then 69 rm -f ${new} 70 else 71 rm -f ${old} 72 mv ${new} ${old} 73 fi 74else 75 mv ${new} ${old} 76fi 77exit 0 78