xref: /illumos-gate/usr/src/lib/libresolv2/include/probe_ipv6.sh (revision 201ceb75ab95f9bf1f42ea1dc9ab363b43ba47cf)
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;
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} ${CPPFLAGS} -c tmp$$a.c > /dev/null 2>&1
44then
45        echo "#define HAS_INET6_STRUCTS" >> ${new}
46        if ${CC} ${CPPFLAGS} -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} ${CPPFLAGS} -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