1#! /bin/sh
2# autoconf-style configuration script
3#
4
5set -e
6
7name=udns
8
9if [ -f udns.h -a -f udns_resolver.c ] ; then :
10else
11  echo "configure: error: sources not found at `pwd`" >&2
12  exit 1
13fi
14
15options="ipv6"
16
17for opt in $options; do
18  eval enable_$opt=
19done
20
21if [ -f config.status ]; then
22  . ./config.status
23fi
24
25enable() {
26  opt=`echo "$1" | sed 's/^--[^-]*-//'`
27  case "$opt" in
28    ipv6) ;;
29    *) echo "configure: unrecognized option \`$1'" >&2; exit 1;;
30  esac
31  eval enable_$opt=$2
32}
33
34while [ $# -gt 0 ]; do
35  case "$1" in
36    --disable-*|--without-*|--no-*) enable "$1" n;;
37    --enable-*|--with-*) enable "$1" y;;
38    --help | --hel | --he | --h | -help | -hel | -he | -h )
39      cat <<EOF
40configure: configure $name package.
41Usage: ./configure [options]
42where options are:
43 --enable-option, --with-option --
44   enable the named option/feature
45 --disable-option, --without-option, --no-option --
46   disable the named option/feature
47 --help - print this help and exit
48Optional features (all enabled by default if system supports a feature):
49  ipv6 - enable/disable IP version 6 (IPv6) support
50EOF
51      exit 0
52      ;;
53    *) echo "configure: unknown option \`$1'" >&2; exit 1 ;;
54  esac
55  shift
56done
57
58. ./configure.lib
59
60ac_msg "configure"
61ac_result "$name package"
62
63ac_prog_c_compiler_v
64ac_prog_ranlib_v
65
66ac_ign ac_yesno "for getopt()" ac_have GETOPT ac_link <<EOF
67#include <stdio.h>
68extern int optind;
69extern char *optarg;
70extern int getopt(int, char **, char *);
71int main(int argc, char **argv) {
72  getopt(argc, argv, "abc");
73  return optarg ? optind : 0;
74}
75EOF
76
77if ac_library_find_v 'socket and connect' "" "-lsocket -lnsl" <<EOF
78int main() { socket(); connect(); return 0; }
79EOF
80then :
81else
82  ac_fatal "cannot find libraries needed for sockets"
83fi
84
85ac_ign \
86 ac_yesno "for inet_pton() && inet_ntop()" \
87 ac_have INET_PTON_NTOP \
88 ac_link <<EOF
89#include <sys/types.h>
90#include <sys/socket.h>
91#include <arpa/inet.h>
92int main() {
93  char buf[64];
94  long x = 0;
95  inet_pton(AF_INET, &x, buf);
96  return inet_ntop(AF_INET, &x, buf, sizeof(buf));
97} 
98EOF
99
100if ac_yesno "for socklen_t" ac_compile <<EOF
101#include <sys/types.h>
102#include <sys/socket.h>
103int foo() { socklen_t len; len = 0; return len; }
104EOF
105then :
106else
107  ac_define socklen_t int
108fi
109
110if [ n != "$enable_ipv6" ]; then
111if ac_yesno "for IPv6" ac_have IPv6 ac_compile <<EOF
112#include <sys/types.h>
113#include <sys/socket.h>
114#include <netinet/in.h>
115int main() {
116  struct sockaddr_in6 sa;
117  sa.sin6_family = AF_INET6;
118  return 0;
119}
120EOF
121then :
122elif [ "$enable_ipv6" ]; then
123  ac_fatal "IPv6 is requested but not available"
124fi
125fi # !disable_ipv6?
126
127if ac_yesno "for poll()" ac_have POLL ac_link <<EOF
128#include <sys/types.h>
129#include <sys/poll.h>
130int main() {
131  struct pollfd pfd[2];
132  return poll(pfd, 2, 10);
133}
134EOF
135then :
136else
137  ac_ign ac_yesno "for sys/select.h" ac_have SYS_SELECT_H ac_cpp <<EOF
138#include <sys/types.h>
139#include <sys/select.h>
140EOF
141fi
142
143ac_config_h
144ac_output Makefile
145ac_msg "creating config.status"
146rm -f config.status
147{
148echo "# automatically generated by configure to hold command-line options"
149echo
150found=
151for opt in $options; do
152  eval val=\$enable_$opt
153  if [ -n "$val" ]; then
154    echo enable_$opt=$val
155    found=y
156  fi
157done
158if [ ! "$found" ]; then
159  echo "# (no options encountered)"
160fi
161} > config.status
162ac_result ok
163
164ac_result "all done."
165exit 0
166