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