17c478bd9Sstevel@tonic-gate#!/bin/sh
27c478bd9Sstevel@tonic-gate
37c478bd9Sstevel@tonic-gate# Copyright 2003 by Sun Microsystems, Inc. All rights reserved.
47c478bd9Sstevel@tonic-gate# Use is subject to license terms.
57c478bd9Sstevel@tonic-gate#
67c478bd9Sstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
77c478bd9Sstevel@tonic-gate
87c478bd9Sstevel@tonic-gateset -e
97c478bd9Sstevel@tonic-gatePATH=/bin:/usr/bin:$PATH; export PATH
107c478bd9Sstevel@tonic-gatetrap "rm -f tmp$$[abc].[oc]" 0
117c478bd9Sstevel@tonic-gatetarget=port_ipv6
127c478bd9Sstevel@tonic-gatenew=new_${target}.h
137c478bd9Sstevel@tonic-gateold=${target}.h
147c478bd9Sstevel@tonic-gate
157c478bd9Sstevel@tonic-gatecat > tmp$$a.c <<EOF
167c478bd9Sstevel@tonic-gate#include <sys/types.h>
177c478bd9Sstevel@tonic-gate#include <netinet/in.h>
187c478bd9Sstevel@tonic-gatestruct sockaddr_in6 xx;
197c478bd9Sstevel@tonic-gateEOF
207c478bd9Sstevel@tonic-gate
217c478bd9Sstevel@tonic-gatecat > tmp$$b.c <<EOF
227c478bd9Sstevel@tonic-gate#include <sys/types.h>
237c478bd9Sstevel@tonic-gate#include <netinet/in.h>
247c478bd9Sstevel@tonic-gatestruct in6_addr xx;
257c478bd9Sstevel@tonic-gateEOF
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gatecat > tmp$$c.c <<EOF
287c478bd9Sstevel@tonic-gate#include <sys/types.h>
297c478bd9Sstevel@tonic-gate#include <netinet/in.h>
307c478bd9Sstevel@tonic-gatestruct sockaddr_in6 xx;
317c478bd9Sstevel@tonic-gatemain() { xx.sin6_scope_id = 0; }
327c478bd9Sstevel@tonic-gateEOF
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gatecat > ${new} <<EOF
357c478bd9Sstevel@tonic-gate
367c478bd9Sstevel@tonic-gate/* This file is automatically generated. Do Not Edit. */
377c478bd9Sstevel@tonic-gate
387c478bd9Sstevel@tonic-gate#ifndef ${target}_h
397c478bd9Sstevel@tonic-gate#define ${target}_h
407c478bd9Sstevel@tonic-gate
417c478bd9Sstevel@tonic-gateEOF
427c478bd9Sstevel@tonic-gate
437c478bd9Sstevel@tonic-gateif ${CC} -c tmp$$a.c > /dev/null 2>&1
447c478bd9Sstevel@tonic-gatethen
457c478bd9Sstevel@tonic-gate        echo "#define HAS_INET6_STRUCTS" >> ${new}
467c478bd9Sstevel@tonic-gate        if ${CC} -c tmp$$b.c > /dev/null 2>&1
477c478bd9Sstevel@tonic-gate        then
487c478bd9Sstevel@tonic-gate		:
497c478bd9Sstevel@tonic-gate	else
507c478bd9Sstevel@tonic-gate                echo "#define in6_addr in_addr6" >> ${new}
517c478bd9Sstevel@tonic-gate        fi
527c478bd9Sstevel@tonic-gate	if ${CC} -c tmp$$c.c > /dev/null 2>&1
537c478bd9Sstevel@tonic-gate	then
547c478bd9Sstevel@tonic-gate		echo "#define HAVE_SIN6_SCOPE_ID" >> ${new}
557c478bd9Sstevel@tonic-gate	else
567c478bd9Sstevel@tonic-gate		echo "#undef HAVE_SIN6_SCOPE_ID" >> ${new}
577c478bd9Sstevel@tonic-gate	fi
587c478bd9Sstevel@tonic-gateelse
597c478bd9Sstevel@tonic-gate        echo "#undef HAS_INET6_STRUCTS" >> ${new}
607c478bd9Sstevel@tonic-gatefi
617c478bd9Sstevel@tonic-gateecho  >> ${new}
627c478bd9Sstevel@tonic-gateecho "#endif" >> ${new}
637c478bd9Sstevel@tonic-gateif [ -f ${old} ]; then
647c478bd9Sstevel@tonic-gate        if cmp -s ${new} ${old} ; then
657c478bd9Sstevel@tonic-gate                rm -f ${new}
667c478bd9Sstevel@tonic-gate        else
677c478bd9Sstevel@tonic-gate                rm -f ${old}
687c478bd9Sstevel@tonic-gate                mv ${new} ${old}
697c478bd9Sstevel@tonic-gate        fi
707c478bd9Sstevel@tonic-gateelse
717c478bd9Sstevel@tonic-gate        mv ${new} ${old}
727c478bd9Sstevel@tonic-gatefi
737c478bd9Sstevel@tonic-gateexit 0
74