]> git.mxchange.org Git - simgear.git/blob - 3rdparty/udns/configure.lib
Initial commit for a DNS service resolver
[simgear.git] / 3rdparty / udns / configure.lib
1 # configure.lib
2 # a library of shell routines for simple autoconf system
3 #
4
5 set -e
6 ac_substitutes=
7 rm -f conftest* config.log
8 exec 5>config.log
9 cat <<EOF >&5
10 This file contains any messages produced by compilers etc while
11 running configure, to aid debugging if configure script makes a mistake.
12
13 EOF
14
15 case `echo "a\c"` in
16   *c*) ac_en=-n ac_ec= ;;
17   *)   ac_en= ac_ec='\c' ;;
18 esac
19
20 ##### Messages
21 ac_msg() {
22   echo $ac_en "$*... $ac_ec"
23   echo ">>> $*" >&5
24 }
25 ac_checking() {
26   echo $ac_en "checking $*... $ac_ec"
27   echo ">>> checking $*" >&5
28 }
29 ac_result() {
30   echo "$1"
31   echo "=== $1" >&5
32 }
33 ac_fatal() {
34   echo "configure: fatal: $*" >&2
35   echo "=== FATAL: $*" >&5
36   exit 1
37 }
38 ac_warning() {
39   echo "configure: warning: $*" >&2
40   echo "=== WARNING: $*" >&5
41 }
42 ac_ign() {
43   "$@" || :
44 }
45
46 # ac_run command...
47 # captures output in conftest.out
48 ac_run() {
49   # apparently UnixWare (for one) /bin/sh optimizes the following "if"
50   # "away", by checking if there's such a command BEFORE redirecting
51   # output.  So error message (like "gcc: command not found") goes
52   # to stderr instead of to conftest.out, and `cat conftest.out' below
53   # fails.
54   if "$@" >conftest.out 2>&1; then
55     return 0
56   else
57     echo "==== Command invocation failed. Command line was:" >&5
58     echo "$*" >&5
59     echo "==== compiler input was:" >&5
60     cat conftest.c >&5
61     echo "==== output was:" >&5
62     cat conftest.out >&5
63     echo "====" >&5
64     return 1
65   fi
66 }
67
68 # common case for ac_verbose: yes/no result
69 ac_yesno() {
70   ac_checking "$1"
71   shift
72   if "$@"; then
73     ac_result yes
74     return 0
75   else
76     ac_result no
77     return 1
78   fi
79 }
80
81 ac_subst() {
82   ac_substitutes="$ac_substitutes $*"
83 }
84
85 ac_define() {
86   CDEFS="$CDEFS -D$1=${2:-1}"
87 }
88
89 ac_have() {
90   ac_what=$1; shift
91   if "$@"; then
92     ac_define HAVE_$ac_what
93     eval ac_have_$ac_what=yes
94     return 0
95   else
96     eval ac_have_$ac_what=no
97     return 1
98   fi
99 }
100
101 ##### Compiling, linking
102
103 # run a compiler
104 ac_run_compiler() {
105   rm -f conftest*; cat >conftest.c
106   ac_run $CC $CFLAGS $CDEFS "$@" conftest.c
107 }
108
109 ac_compile() {
110   ac_run_compiler -c
111 }
112
113 ac_link() {
114   ac_run_compiler -o conftest $LIBS "$@"
115 }
116
117 ac_cpp() {
118   ac_run_compiler -E "$@"
119 }
120
121 ### check for C compiler.  Set $CC, $CFLAGS etc
122 ac_prog_c_compiler_v() {
123   ac_checking "for C compiler"
124   rm -f conftest*
125   echo 'int main(int argc, char **argv) { return 0; }' >conftest.c
126
127   if [ -n "$CC" ]; then
128     if ac_run $CC -o conftest conftest.c && ac_run ./conftest; then
129       ac_result "\$CC ($CC)"
130     else
131       ac_result no
132       ac_fatal "\$CC ($CC) is not a working compiler"
133     fi
134   else
135     for cc in gcc cc ; do
136       if ac_run $cc -o conftest conftest.c && ac_run ./conftest; then
137         ac_result "$cc"
138         CC=$cc
139         break
140       fi
141     done
142     if [ -z "$CC" ]; then
143       ac_result no
144       ac_fatal "no working C compiler found in \$PATH. please set \$CC variable"
145     fi
146   fi
147   if [ -z "$CFLAGS" ]; then
148     if ac_yesno "whenever C compiler ($CC) is GNU CC" \
149         ac_grep_cpp yEs_mAsTeR <<EOF
150 #ifdef __GNUC__
151   yEs_mAsTeR;
152 #endif
153 EOF
154     then
155       CFLAGS="-Wall -W -O2 -pipe"
156     else
157       CFLAGS=-O
158     fi
159   fi
160   cc="$CC $CFLAGS"
161   ccld="$cc"
162   if [ -n "$LDFLAGS" ]; then ccld="$ccld $LDFLAGS"; fi
163   if [ -n "$LIBS" ]; then ccld="$ccld $LIBS"; fi
164   if ac_yesno "whenever the C compiler ($ccld)
165            can produce executables" \
166      ac_compile_run <<EOF
167 int main() { return 0; }
168 EOF
169   then :
170   else
171     ac_fatal "no working C compiler found"
172   fi
173   LD='$(CC)'
174   [ -n "$AR" ] || AR=ar
175   [ -n "$ARFLAGS" ] || ARFLAGS=rv
176   [ -n "$AWK" ] || AWK=awk
177   ac_substitutes="$ac_substitutes CC CFLAGS CDEFS LD LDFLAGS LIBS AR ARFLAGS AWK"
178 }
179
180
181 ac_prog_ranlib_v() {
182   ac_checking "for ranlib"
183   if [ -n "$RANLIB" ]; then
184     ac_result "\$RANLIB ($RANLIB)"
185   else
186     ifs="$IFS"
187     IFS=:
188     for dir in $PATH; do
189       [ -n "$dir" ] || dir=.
190       if [ -f $dir/ranlib ]; then
191         RANLIB=ranlib
192         break
193       fi
194     done
195     IFS="$ifs"
196     if [ -z "$RANLIB" ]; then ac_result no; RANLIB=:
197     else ac_result "$RANLIB"
198     fi
199   fi
200   ac_substitutes="$ac_substitutes RANLIB"
201 }
202
203 ac_library_find_v() {
204   ac_checking "for libraries needed for $1"
205   shift
206   fond=
207   rm -f conftest*; cat >conftest.c
208   for lib in "$@"; do
209     if ac_run $CC $CFLAGS $LDFLAGS conftest.c -o conftest $LIBS $lib; then
210       found=y
211       break
212     fi
213   done
214   if [ ! "$found" ]; then
215     ac_result "not found"
216     return 1
217   fi
218   if [ -z "$lib" ]; then
219     ac_result "ok (none needed)"
220   else
221     ac_result "ok ($lib)"
222     LIBS="$LIBS $lib"
223   fi
224 }
225
226 ac_compile_run() {
227   ac_link "$@" && ac_run ./conftest
228 }
229
230 ac_grep_cpp() {
231   pattern="$1"; shift
232   ac_cpp "$@" && grep "$pattern" conftest.out >/dev/null
233 }
234
235 ac_output() {
236   for var in $ac_substitutes; do
237     eval echo "\"s|@$var@|\$$var|\""
238   done >conftest.sed
239   for file in "$@"; do
240     ac_msg "creating $file"
241     if [ -f $file.in ]; then
242       sed -f conftest.sed $file.in > $file.tmp
243       mv -f $file.tmp $file
244       ac_result ok
245     else
246       ac_result failed
247       ac_fatal "$file.in not found"
248     fi
249   done
250   rm -f conftest*
251 }
252
253 ac_config_h() {
254   h=${1:-config.h}
255   ac_msg "creating $h"
256   rm -f $1.tmp
257   echo "/* automatically generated by configure. */" > $h.tmp
258   echo "$CDEFS" | tr ' ' '
259 ' | sed -e 's/^-D/#define /' -e 's/=/ /' >> $h.tmp
260   if [ -f $h ] && cmp -s $h.tmp $h ; then
261     rm -f $h.tmp
262     ac_result unchanged
263   else
264     mv -f $h.tmp $h
265     ac_result ok
266   fi
267   CDEFS=-DHAVE_CONFIG_H
268 }