xref: /illumos-gate/usr/src/lib/libresolv2/include/probe_ipv6.sh (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
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>
29struct sockaddr_in6 xx;
30main() { xx.sin6_scope_id = 0; }
31EOF
32
33cat > ${new} <<EOF
34
35/* This file is automatically generated. Do Not Edit. */
36
37#ifndef ${target}_h
38#define ${target}_h
39
40EOF
41
42if ${CC} -c tmp$$a.c > /dev/null 2>&1
43then
44        echo "#define HAS_INET6_STRUCTS" >> ${new}
45        if ${CC} -c tmp$$b.c > /dev/null 2>&1
46        then
47		:
48	else
49                echo "#define in6_addr in_addr6" >> ${new}
50        fi
51	if ${CC} -c tmp$$c.c > /dev/null 2>&1
52	then
53		echo "#define HAVE_SIN6_SCOPE_ID" >> ${new}
54	else
55		echo "#undef HAVE_SIN6_SCOPE_ID" >> ${new}
56	fi
57else
58        echo "#undef HAS_INET6_STRUCTS" >> ${new}
59fi
60echo  >> ${new}
61echo "#endif" >> ${new}
62if [ -f ${old} ]; then
63        if cmp -s ${new} ${old} ; then
64                rm -f ${new}
65        else
66                rm -f ${old}
67                mv ${new} ${old}
68        fi
69else
70        mv ${new} ${old}
71fi
72exit 0
73