autoconf-2.13-wait3test
[platform/upstream/autoconf213.git] / acspecific.m4
1 dnl Macros that test for specific features.
2 dnl This file is part of Autoconf.
3 dnl Copyright (C) 1992, 93, 94, 95, 96, 1998 Free Software Foundation, Inc.
4 dnl
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 2, or (at your option)
8 dnl any later version.
9 dnl
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 dnl GNU General Public License for more details.
14 dnl
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with this program; if not, write to the Free Software
17 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 dnl 02111-1307, USA.
19 dnl
20 dnl As a special exception, the Free Software Foundation gives unlimited
21 dnl permission to copy, distribute and modify the configure scripts that
22 dnl are the output of Autoconf.  You need not follow the terms of the GNU
23 dnl General Public License when using or distributing such scripts, even
24 dnl though portions of the text of Autoconf appear in them.  The GNU
25 dnl General Public License (GPL) does govern all other use of the material
26 dnl that constitutes the Autoconf program.
27 dnl
28 dnl Certain portions of the Autoconf source text are designed to be copied
29 dnl (in certain cases, depending on the input) into the output of
30 dnl Autoconf.  We call these the "data" portions.  The rest of the Autoconf
31 dnl source text consists of comments plus executable code that decides which
32 dnl of the data portions to output in any given case.  We call these
33 dnl comments and executable code the "non-data" portions.  Autoconf never
34 dnl copies any of the non-data portions into its output.
35 dnl
36 dnl This special exception to the GPL applies to versions of Autoconf
37 dnl released by the Free Software Foundation.  When you make and
38 dnl distribute a modified version of Autoconf, you may extend this special
39 dnl exception to the GPL to apply to your modified version as well, *unless*
40 dnl your modified version has the potential to copy into its output some
41 dnl of the text that was the non-data portion of the version that you started
42 dnl with.  (In other words, unless your change moves or copies text from
43 dnl the non-data portions to the data portions.)  If your modification has
44 dnl such potential, you must delete any notice of this special exception
45 dnl to the GPL from your modified version.
46 dnl
47 dnl Written by David MacKenzie, with help from
48 dnl Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
49 dnl Roland McGrath, Noah Friedman, david d zuhn, and many others.
50
51
52 dnl ### Checks for programs
53
54
55 dnl Check whether to use -n, \c, or newline-tab to separate
56 dnl checking messages from result messages.
57 dnl Idea borrowed from dist 3.0.
58 dnl Internal use only.
59 AC_DEFUN(AC_PROG_ECHO_N,
60 [if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
61   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
62   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
63     ac_n= ac_c='
64 ' ac_t='        '
65   else
66     ac_n=-n ac_c= ac_t=
67   fi
68 else
69   ac_n= ac_c='\c' ac_t=
70 fi
71 ])
72
73 AC_DEFUN(AC_PROG_CC,
74 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
75 AC_CHECK_PROG(CC, gcc, gcc)
76 if test -z "$CC"; then
77   AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
78   if test -z "$CC"; then
79     case "`uname -s`" in
80     *win32* | *WIN32*)
81       AC_CHECK_PROG(CC, cl, cl) ;;
82     esac
83   fi
84   test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
85 fi
86
87 AC_PROG_CC_WORKS
88 AC_PROG_CC_GNU
89
90 if test $ac_cv_prog_gcc = yes; then
91   GCC=yes
92 else
93   GCC=
94 fi
95
96 dnl Check whether -g works, even if CFLAGS is set, in case the package
97 dnl plays around with CFLAGS (such as to build both debugging and
98 dnl normal versions of a library), tasteless as that idea is.
99 ac_test_CFLAGS="${CFLAGS+set}"
100 ac_save_CFLAGS="$CFLAGS"
101 CFLAGS=
102 AC_PROG_CC_G
103 if test "$ac_test_CFLAGS" = set; then
104   CFLAGS="$ac_save_CFLAGS"
105 elif test $ac_cv_prog_cc_g = yes; then
106   if test "$GCC" = yes; then
107     CFLAGS="-g -O2"
108   else
109     CFLAGS="-g"
110   fi
111 else
112   if test "$GCC" = yes; then
113     CFLAGS="-O2"
114   else
115     CFLAGS=
116   fi
117 fi
118 ])
119
120 AC_DEFUN(AC_PROG_CXX,
121 [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
122 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, gcc)
123
124 AC_PROG_CXX_WORKS
125 AC_PROG_CXX_GNU
126
127 if test $ac_cv_prog_gxx = yes; then
128   GXX=yes
129 else
130   GXX=
131 fi
132
133 dnl Check whether -g works, even if CXXFLAGS is set, in case the package
134 dnl plays around with CXXFLAGS (such as to build both debugging and
135 dnl normal versions of a library), tasteless as that idea is.
136 ac_test_CXXFLAGS="${CXXFLAGS+set}"
137 ac_save_CXXFLAGS="$CXXFLAGS"
138 CXXFLAGS=
139 AC_PROG_CXX_G
140 if test "$ac_test_CXXFLAGS" = set; then
141   CXXFLAGS="$ac_save_CXXFLAGS"
142 elif test $ac_cv_prog_cxx_g = yes; then
143   if test "$GXX" = yes; then
144     CXXFLAGS="-g -O2"
145   else
146     CXXFLAGS="-g"
147   fi
148 else
149   if test "$GXX" = yes; then
150     CXXFLAGS="-O2"
151   else
152     CXXFLAGS=
153   fi
154 fi
155
156 AC_PROG_CXX_EXIT_DECLARATION
157 ])
158
159
160 # AC_PROG_CXX_EXIT_DECLARATION
161 # -----------------------------
162 # Find a valid prototype for exit and declare it in confdefs.h.
163 AC_DEFUN(AC_PROG_CXX_EXIT_DECLARATION,
164 [for ac_declaration in \
165    ''\
166    '#include <stdlib.h>' \
167    'extern "C" void std::exit (int) throw (); using std::exit;' \
168    'extern "C" void std::exit (int); using std::exit;' \
169    'extern "C" void exit (int) throw ();' \
170    'extern "C" void exit (int);' \
171    'void exit (int);'
172 do
173   AC_TRY_COMPILE([#include <stdlib.h>
174 $ac_declaration], 
175                  [exit (42);],
176                  [],
177                  [continue])
178   AC_TRY_COMPILE([$ac_declaration],
179                  [exit (42);],
180                  [break])
181 done
182 if test -n "$ac_declaration"; then
183   echo '#ifdef __cplusplus' >>confdefs.h
184   echo $ac_declaration      >>confdefs.h
185   echo '#endif'             >>confdefs.h
186 fi
187 ])# AC_PROG_CXX_EXIT_DECLARATION
188
189
190 dnl Determine a Fortran 77 compiler to use.  If `F77' is not already set
191 dnl in the environment, check for `g77', `f77' and `f2c', in that order.
192 dnl Set the output variable `F77' to the name of the compiler found.
193 dnl 
194 dnl If using `g77' (the GNU Fortran 77 compiler), then `AC_PROG_F77'
195 dnl will set the shell variable `G77' to `yes', and empty otherwise.  If
196 dnl the output variable `FFLAGS' was not already set in the environment,
197 dnl then set it to `-g -02' for `g77' (or `-O2' where `g77' does not
198 dnl accept `-g').  Otherwise, set `FFLAGS' to `-g' for all other Fortran
199 dnl 77 compilers.
200 dnl 
201 dnl AC_PROG_F77()
202 AC_DEFUN(AC_PROG_F77,
203 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
204 if test -z "$F77"; then
205   AC_CHECK_PROGS(F77, g77 f77 f2c)
206     test -z "$F77" && AC_MSG_ERROR([no acceptable Fortran 77 compiler found in \$PATH])
207 fi
208
209 AC_PROG_F77_WORKS
210 AC_PROG_F77_GNU
211
212 if test $ac_cv_prog_g77 = yes; then
213   G77=yes
214 dnl Check whether -g works, even if FFLAGS is set, in case the package
215 dnl plays around with FFLAGS (such as to build both debugging and
216 dnl normal versions of a library), tasteless as that idea is.
217   ac_test_FFLAGS="${FFLAGS+set}"
218   ac_save_FFLAGS="$FFLAGS"
219   FFLAGS=
220   AC_PROG_F77_G
221   if test "$ac_test_FFLAGS" = set; then
222     FFLAGS="$ac_save_FFLAGS"
223   elif test $ac_cv_prog_f77_g = yes; then
224     FFLAGS="-g -O2"
225   else
226     FFLAGS="-O2"
227   fi
228 else
229   G77=
230   test "${FFLAGS+set}" = set || FFLAGS="-g"
231 fi
232 ])
233
234 AC_DEFUN(AC_PROG_CC_WORKS,
235 [AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $LDFLAGS) works])
236 AC_LANG_SAVE
237 AC_LANG_C
238 AC_TRY_COMPILER([main(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross)
239 AC_LANG_RESTORE
240 AC_MSG_RESULT($ac_cv_prog_cc_works)
241 if test $ac_cv_prog_cc_works = no; then
242   AC_MSG_ERROR([installation or configuration problem: C compiler cannot create executables.])
243 fi
244 AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler])
245 AC_MSG_RESULT($ac_cv_prog_cc_cross)
246 cross_compiling=$ac_cv_prog_cc_cross
247 ])
248
249 AC_DEFUN(AC_PROG_CXX_WORKS,
250 [AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works])
251 AC_LANG_SAVE
252 AC_LANG_CPLUSPLUS
253 AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross)
254 AC_LANG_RESTORE
255 AC_MSG_RESULT($ac_cv_prog_cxx_works)
256 if test $ac_cv_prog_cxx_works = no; then
257   AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.])
258 fi
259 AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler])
260 AC_MSG_RESULT($ac_cv_prog_cxx_cross)
261 cross_compiling=$ac_cv_prog_cxx_cross
262 ])
263
264 dnl Test whether the Fortran 77 compiler can compile and link a trivial
265 dnl Fortran program.  Also, test whether the Fortran 77 compiler is a
266 dnl cross-compiler (which may realistically be the case if the Fortran
267 dnl compiler is `g77').
268 dnl 
269 dnl AC_PROG_F77_WORKS()
270 AC_DEFUN(AC_PROG_F77_WORKS,
271 [AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) works])
272 AC_LANG_SAVE
273 AC_LANG_FORTRAN77
274 AC_TRY_COMPILER(dnl
275 [      program conftest
276       end
277 ], ac_cv_prog_f77_works, ac_cv_prog_f77_cross)
278 AC_LANG_RESTORE
279 AC_MSG_RESULT($ac_cv_prog_f77_works)
280 if test $ac_cv_prog_f77_works = no; then
281   AC_MSG_ERROR([installation or configuration problem: Fortran 77 compiler cannot create executables.])
282 fi
283 AC_MSG_CHECKING([whether the Fortran 77 compiler ($F77 $FFLAGS $LDFLAGS) is a cross-compiler])
284 AC_MSG_RESULT($ac_cv_prog_f77_cross)
285 cross_compiling=$ac_cv_prog_f77_cross
286 ])
287
288 AC_DEFUN(AC_PROG_CC_GNU,
289 [AC_CACHE_CHECK(whether we are using GNU C, ac_cv_prog_gcc,
290 [dnl The semicolon is to pacify NeXT's syntax-checking cpp.
291 cat > conftest.c <<EOF
292 #ifdef __GNUC__
293   yes;
294 #endif
295 EOF
296 if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
297   ac_cv_prog_gcc=yes
298 else
299   ac_cv_prog_gcc=no
300 fi])])
301
302 AC_DEFUN(AC_PROG_CXX_GNU,
303 [AC_CACHE_CHECK(whether we are using GNU C++, ac_cv_prog_gxx,
304 [dnl The semicolon is to pacify NeXT's syntax-checking cpp.
305 cat > conftest.C <<EOF
306 #ifdef __GNUC__
307   yes;
308 #endif
309 EOF
310 if AC_TRY_COMMAND(${CXX-g++} -E conftest.C) | egrep yes >/dev/null 2>&1; then
311   ac_cv_prog_gxx=yes
312 else
313   ac_cv_prog_gxx=no
314 fi])])
315
316 dnl Test whether for Fortran 77 compiler is `g77' (the GNU Fortran 77
317 dnl Compiler).  This test depends on whether the Fortran 77 compiler can
318 dnl do CPP pre-processing.
319 dnl 
320 dnl AC_PROG_F77_GNU()
321 AC_DEFUN(AC_PROG_F77_GNU,
322 [AC_CACHE_CHECK(whether we are using GNU Fortran 77, ac_cv_prog_g77,
323 [cat > conftest.fpp <<EOF
324 #ifdef __GNUC__
325   yes
326 #endif
327 EOF
328 if AC_TRY_COMMAND($F77 -E conftest.fpp) | egrep yes >/dev/null 2>&1; then
329   ac_cv_prog_g77=yes
330 else
331   ac_cv_prog_g77=no
332 fi])])
333
334 AC_DEFUN(AC_PROG_CC_G,
335 [AC_CACHE_CHECK(whether ${CC-cc} accepts -g, ac_cv_prog_cc_g,
336 [echo 'void f(){}' > conftest.c
337 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
338   ac_cv_prog_cc_g=yes
339 else
340   ac_cv_prog_cc_g=no
341 fi
342 rm -f conftest*
343 ])])
344
345 AC_DEFUN(AC_PROG_CXX_G,
346 [AC_CACHE_CHECK(whether ${CXX-g++} accepts -g, ac_cv_prog_cxx_g,
347 [echo 'void f(){}' > conftest.cc
348 if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
349   ac_cv_prog_cxx_g=yes
350 else
351   ac_cv_prog_cxx_g=no
352 fi
353 rm -f conftest*
354 ])])
355
356 dnl Test whether the Fortran 77 compiler can accept the `-g' option to
357 dnl enable debugging.
358 dnl 
359 dnl AC_PROG_F77_G()
360 AC_DEFUN(AC_PROG_F77_G,
361 [AC_CACHE_CHECK(whether $F77 accepts -g, ac_cv_prog_f77_g,
362 [cat > conftest.f << EOF
363        program conftest
364        end
365 EOF
366 if test -z "`$F77 -g -c conftest.f 2>&1`"; then
367   ac_cv_prog_f77_g=yes
368 else
369   ac_cv_prog_f77_g=no
370 fi
371 rm -f conftest*
372 ])])
373
374 AC_DEFUN(AC_PROG_GCC_TRADITIONAL,
375 [AC_REQUIRE([AC_PROG_CC])dnl
376 AC_REQUIRE([AC_PROG_CPP])dnl
377 if test $ac_cv_prog_gcc = yes; then
378     AC_CACHE_CHECK(whether ${CC-cc} needs -traditional,
379       ac_cv_prog_gcc_traditional,
380 [  ac_pattern="Autoconf.*'x'"
381   AC_EGREP_CPP($ac_pattern, [#include <sgtty.h>
382 Autoconf TIOCGETP],
383   ac_cv_prog_gcc_traditional=yes, ac_cv_prog_gcc_traditional=no)
384
385   if test $ac_cv_prog_gcc_traditional = no; then
386     AC_EGREP_CPP($ac_pattern, [#include <termio.h>
387 Autoconf TCGETA],
388     ac_cv_prog_gcc_traditional=yes)
389   fi])
390   if test $ac_cv_prog_gcc_traditional = yes; then
391     CC="$CC -traditional"
392   fi
393 fi
394 ])
395
396 AC_DEFUN(AC_PROG_CC_C_O,
397 [if test "x$CC" != xcc; then
398   AC_MSG_CHECKING(whether $CC and cc understand -c and -o together)
399 else
400   AC_MSG_CHECKING(whether cc understands -c and -o together)
401 fi
402 set dummy $CC; ac_cc="`echo [$]2 |
403 changequote(, )dnl
404                        sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"
405 changequote([, ])dnl
406 AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
407 [echo 'foo(){}' > conftest.c
408 # Make sure it works both with $CC and with simple cc.
409 # We do the test twice because some compilers refuse to overwrite an
410 # existing .o file with -o, though they will create one.
411 ac_try='${CC-cc} -c conftest.c -o conftest.o 1>&AC_FD_CC'
412 if AC_TRY_EVAL(ac_try) &&
413    test -f conftest.o && AC_TRY_EVAL(ac_try);
414 then
415   eval ac_cv_prog_cc_${ac_cc}_c_o=yes
416   if test "x$CC" != xcc; then
417     # Test first that cc exists at all.
418     if AC_TRY_COMMAND(cc -c conftest.c 1>&AC_FD_CC); then
419       ac_try='cc -c conftest.c -o conftest.o 1>&AC_FD_CC'
420       if AC_TRY_EVAL(ac_try) &&
421          test -f conftest.o && AC_TRY_EVAL(ac_try);
422       then
423         # cc works too.
424         :
425       else
426         # cc exists but doesn't like -o.
427         eval ac_cv_prog_cc_${ac_cc}_c_o=no
428       fi
429     fi
430   fi
431 else
432   eval ac_cv_prog_cc_${ac_cc}_c_o=no
433 fi
434 rm -f conftest*
435 ])dnl
436 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then
437   AC_MSG_RESULT(yes)
438 else
439   AC_MSG_RESULT(no)
440   AC_DEFINE(NO_MINUS_C_MINUS_O)
441 fi
442 ])
443
444 dnl Test if the Fortran 77 compiler accepts the options `-c' and `-o'
445 dnl simultaneously, and define `F77_NO_MINUS_C_MINUS_O' if it does not.
446 dnl
447 dnl The usefulness of this macro is questionable, as I can't really see
448 dnl why anyone would use it.  The only reason I include it is for
449 dnl completeness, since a similar test exists for the C compiler.
450 dnl 
451 dnl AC_PROG_F77_C_O
452 AC_DEFUN(AC_PROG_F77_C_O,
453 [AC_BEFORE([$0], [AC_PROG_F77])dnl
454 AC_MSG_CHECKING(whether $F77 understand -c and -o together)
455 set dummy $F77; ac_f77="`echo [$]2 |
456 changequote(, )dnl
457 sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"
458 changequote([, ])dnl
459 AC_CACHE_VAL(ac_cv_prog_f77_${ac_f77}_c_o,
460 [cat > conftest.f << EOF
461        program conftest
462        end
463 EOF
464 # We do the `AC_TRY_EVAL' test twice because some compilers refuse to
465 # overwrite an existing `.o' file with `-o', although they will create
466 # one.
467 ac_try='$F77 $FFLAGS -c conftest.f -o conftest.o 1>&AC_FD_CC'
468 if AC_TRY_EVAL(ac_try) && test -f conftest.o && AC_TRY_EVAL(ac_try); then
469   eval ac_cv_prog_f77_${ac_f77}_c_o=yes
470 else
471   eval ac_cv_prog_f77_${ac_f77}_c_o=no
472 fi
473 rm -f conftest*
474 ])dnl
475 if eval "test \"`echo '$ac_cv_prog_f77_'${ac_f77}_c_o`\" = yes"; then
476   AC_MSG_RESULT(yes)
477 else
478   AC_MSG_RESULT(no)
479   AC_DEFINE(F77_NO_MINUS_C_MINUS_O)
480 fi
481 ])
482
483 dnl Define SET_MAKE to set ${MAKE} if make doesn't.
484 AC_DEFUN(AC_PROG_MAKE_SET,
485 [AC_MSG_CHECKING(whether ${MAKE-make} sets \${MAKE})
486 set dummy ${MAKE-make}; ac_make=`echo "[$]2" | sed 'y%./+-%__p_%'`
487 AC_CACHE_VAL(ac_cv_prog_make_${ac_make}_set,
488 [cat > conftestmake <<\EOF
489 all:
490         @echo 'ac_maketemp="${MAKE}"'
491 EOF
492 changequote(, )dnl
493 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
494 eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
495 changequote([, ])dnl
496 if test -n "$ac_maketemp"; then
497   eval ac_cv_prog_make_${ac_make}_set=yes
498 else
499   eval ac_cv_prog_make_${ac_make}_set=no
500 fi
501 rm -f conftestmake])dnl
502 if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
503   AC_MSG_RESULT(yes)
504   SET_MAKE=
505 else
506   AC_MSG_RESULT(no)
507   SET_MAKE="MAKE=${MAKE-make}"
508 fi
509 AC_SUBST([SET_MAKE])dnl
510 ])
511
512 AC_DEFUN(AC_PROG_RANLIB,
513 [AC_CHECK_PROG(RANLIB, ranlib, ranlib, :)])
514
515 dnl Don't check for mawk first even if it's generally faster.
516 AC_DEFUN(AC_PROG_AWK,
517 [AC_CHECK_PROGS(AWK, gawk mawk nawk awk, )])
518
519 AC_DEFUN(AC_PROG_YACC,
520 [AC_CHECK_PROGS(YACC, 'bison -y' byacc, yacc)])
521
522 AC_DEFUN(AC_PROG_CPP,
523 [AC_MSG_CHECKING(how to run the C preprocessor)
524 # On Suns, sometimes $CPP names a directory.
525 if test -n "$CPP" && test -d "$CPP"; then
526   CPP=
527 fi
528 if test -z "$CPP"; then
529 AC_CACHE_VAL(ac_cv_prog_CPP,
530 [  # This must be in double quotes, not single quotes, because CPP may get
531   # substituted into the Makefile and "${CC-cc}" will confuse make.
532   CPP="${CC-cc} -E"
533   # On the NeXT, cc -E runs the code through the compiler's parser,
534   # not just through cpp.
535 dnl Use a header file that comes with gcc, so configuring glibc
536 dnl with a fresh cross-compiler works.
537   AC_TRY_CPP([#include <assert.h>
538 Syntax Error], ,
539   CPP="${CC-cc} -E -traditional-cpp"
540   AC_TRY_CPP([#include <assert.h>
541 Syntax Error], ,
542   CPP="${CC-cc} -nologo -E"
543   AC_TRY_CPP([#include <assert.h>
544 Syntax Error], , CPP=/lib/cpp)))
545   ac_cv_prog_CPP="$CPP"])dnl
546   CPP="$ac_cv_prog_CPP"
547 else
548   ac_cv_prog_CPP="$CPP"
549 fi
550 AC_MSG_RESULT($CPP)
551 AC_SUBST(CPP)dnl
552 ])
553
554 AC_DEFUN(AC_PROG_CXXCPP,
555 [AC_MSG_CHECKING(how to run the C++ preprocessor)
556 if test -z "$CXXCPP"; then
557 AC_CACHE_VAL(ac_cv_prog_CXXCPP,
558 [AC_LANG_SAVE[]dnl
559 AC_LANG_CPLUSPLUS[]dnl
560   CXXCPP="${CXX-g++} -E"
561   AC_TRY_CPP([#include <stdlib.h>], , CXXCPP=/lib/cpp)
562   ac_cv_prog_CXXCPP="$CXXCPP"
563 AC_LANG_RESTORE[]dnl
564 fi])dnl
565 CXXCPP="$ac_cv_prog_CXXCPP"
566 AC_MSG_RESULT($CXXCPP)
567 AC_SUBST(CXXCPP)dnl
568 ])
569
570 dnl Require finding the C or C++ preprocessor, whichever is the
571 dnl current language.
572 AC_DEFUN(AC_REQUIRE_CPP,
573 [ifelse(AC_LANG, C, [AC_REQUIRE([AC_PROG_CPP])], [AC_REQUIRE([AC_PROG_CXXCPP])])])
574
575 AC_DEFUN(AC_PROG_LEX,
576 [AC_CHECK_PROG(LEX, flex, flex, lex)
577 if test -z "$LEXLIB"
578 then
579   case "$LEX" in
580   flex*) ac_lib=fl ;;
581   *) ac_lib=l ;;
582   esac
583   AC_CHECK_LIB($ac_lib, yywrap, LEXLIB="-l$ac_lib")
584 fi
585 AC_SUBST(LEXLIB)])
586
587 dnl Check if lex declares yytext as a char * by default, not a char[].
588 undefine([AC_DECL_YYTEXT])
589 AC_DEFUN(AC_DECL_YYTEXT,
590 [AC_REQUIRE_CPP()dnl
591 AC_REQUIRE([AC_PROG_LEX])dnl
592 AC_CACHE_CHECK(lex output file root, ac_cv_prog_lex_root,
593 [# The minimal lex program is just a single line: %%.  But some broken lexes
594 # (Solaris, I think it was) want two %% lines, so accommodate them.
595 echo '%%
596 %%' | $LEX
597 if test -f lex.yy.c; then
598   ac_cv_prog_lex_root=lex.yy
599 elif test -f lexyy.c; then
600   ac_cv_prog_lex_root=lexyy
601 else
602   AC_MSG_ERROR(cannot find output from $LEX; giving up)
603 fi])
604 LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root
605 AC_SUBST(LEX_OUTPUT_ROOT)dnl
606
607 AC_CACHE_CHECK(whether yytext is a pointer, ac_cv_prog_lex_yytext_pointer,
608 [# POSIX says lex can declare yytext either as a pointer or an array; the
609 # default is implementation-dependent. Figure out which it is, since
610 # not all implementations provide the %pointer and %array declarations.
611 ac_cv_prog_lex_yytext_pointer=no
612 echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c
613 ac_save_LIBS="$LIBS"
614 LIBS="$LIBS $LEXLIB"
615 AC_TRY_LINK(`cat $LEX_OUTPUT_ROOT.c`, , ac_cv_prog_lex_yytext_pointer=yes)
616 LIBS="$ac_save_LIBS"
617 rm -f "${LEX_OUTPUT_ROOT}.c"
618 ])
619 dnl
620 if test $ac_cv_prog_lex_yytext_pointer = yes; then
621   AC_DEFINE(YYTEXT_POINTER)
622 fi
623 ])
624
625 AC_DEFUN(AC_PROG_INSTALL,
626 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
627 # Find a good install program.  We prefer a C program (faster),
628 # so one script is as good as another.  But avoid the broken or
629 # incompatible versions:
630 # SysV /etc/install, /usr/sbin/install
631 # SunOS /usr/etc/install
632 # IRIX /sbin/install
633 # AIX /bin/install
634 # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
635 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
636 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
637 # ./install, which can be erroneously created by make from ./install.sh.
638 AC_MSG_CHECKING(for a BSD compatible install)
639 if test -z "$INSTALL"; then
640 AC_CACHE_VAL(ac_cv_path_install,
641 [  IFS="${IFS=  }"; ac_save_IFS="$IFS"; IFS=":"
642   for ac_dir in $PATH; do
643     # Account for people who put trailing slashes in PATH elements.
644     case "$ac_dir/" in
645     /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
646     *)
647       # OSF1 and SCO ODT 3.0 have their own names for install.
648       # Don't use installbsd from OSF since it installs stuff as root
649       # by default.
650       for ac_prog in ginstall scoinst install; do
651         if test -f $ac_dir/$ac_prog; then
652           if test $ac_prog = install &&
653             grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
654             # AIX install.  It has an incompatible calling convention.
655             :
656           else
657             ac_cv_path_install="$ac_dir/$ac_prog -c"
658             break 2
659           fi
660         fi
661       done
662       ;;
663     esac
664   done
665   IFS="$ac_save_IFS"
666 ])dnl
667   if test "${ac_cv_path_install+set}" = set; then
668     INSTALL="$ac_cv_path_install"
669   else
670     # As a last resort, use the slow shell script.  We don't cache a
671     # path for INSTALL within a source directory, because that will
672     # break other packages using the cache if that directory is
673     # removed, or if the path is relative.
674     INSTALL="$ac_install_sh"
675   fi
676 fi
677 dnl We do special magic for INSTALL instead of AC_SUBST, to get
678 dnl relative paths right.
679 AC_MSG_RESULT($INSTALL)
680
681 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
682 # It thinks the first close brace ends the variable substitution.
683 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
684 AC_SUBST(INSTALL_PROGRAM)dnl
685
686 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
687 AC_SUBST(INSTALL_SCRIPT)dnl
688
689 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
690 AC_SUBST(INSTALL_DATA)dnl
691 ])
692
693 AC_DEFUN(AC_PROG_LN_S,
694 [AC_MSG_CHECKING(whether ln -s works)
695 AC_CACHE_VAL(ac_cv_prog_LN_S,
696 [rm -f conftestdata
697 if ln -s X conftestdata 2>/dev/null
698 then
699   rm -f conftestdata
700   ac_cv_prog_LN_S="ln -s"
701 else
702   ac_cv_prog_LN_S=ln
703 fi])dnl
704 LN_S="$ac_cv_prog_LN_S"
705 if test "$ac_cv_prog_LN_S" = "ln -s"; then
706   AC_MSG_RESULT(yes)
707 else
708   AC_MSG_RESULT(no)
709 fi
710 AC_SUBST(LN_S)dnl
711 ])
712
713 define(AC_RSH,
714 [errprint(__file__:__line__: [$0] has been removed; replace it with equivalent code
715 )m4exit(4)])
716
717
718 dnl ### Checks for header files
719
720
721 AC_DEFUN(AC_HEADER_STDC,
722 [AC_REQUIRE_CPP()dnl
723 AC_CACHE_CHECK(for ANSI C header files, ac_cv_header_stdc,
724 [AC_TRY_CPP([#include <stdlib.h>
725 #include <stdarg.h>
726 #include <string.h>
727 #include <float.h>], ac_cv_header_stdc=yes, ac_cv_header_stdc=no)
728
729 if test $ac_cv_header_stdc = yes; then
730   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
731 AC_EGREP_HEADER(memchr, string.h, , ac_cv_header_stdc=no)
732 fi
733
734 if test $ac_cv_header_stdc = yes; then
735   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
736 AC_EGREP_HEADER(free, stdlib.h, , ac_cv_header_stdc=no)
737 fi
738
739 if test $ac_cv_header_stdc = yes; then
740   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
741 AC_TRY_RUN([#include <ctype.h>
742 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
743 #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
744 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
745 int main () { int i; for (i = 0; i < 256; i++)
746 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
747 exit (0); }
748 ], , ac_cv_header_stdc=no, :)
749 fi])
750 if test $ac_cv_header_stdc = yes; then
751   AC_DEFINE(STDC_HEADERS)
752 fi
753 ])
754
755 AC_DEFUN(AC_UNISTD_H,
756 [AC_OBSOLETE([$0], [; instead use AC_CHECK_HEADERS(unistd.h)])dnl
757 AC_CHECK_HEADER(unistd.h, AC_DEFINE(HAVE_UNISTD_H))])
758
759 AC_DEFUN(AC_USG,
760 [AC_OBSOLETE([$0],
761   [; instead use AC_CHECK_HEADERS(string.h) and HAVE_STRING_H])dnl
762 AC_MSG_CHECKING([for BSD string and memory functions])
763 AC_TRY_LINK([#include <strings.h>], [rindex(0, 0); bzero(0, 0);],
764   [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no); AC_DEFINE(USG)])])
765
766
767 dnl If memchr and the like aren't declared in <string.h>, include <memory.h>.
768 dnl To avoid problems, don't check for gcc2 built-ins.
769 AC_DEFUN(AC_MEMORY_H,
770 [AC_OBSOLETE([$0], [; instead use AC_CHECK_HEADERS(memory.h) and HAVE_MEMORY_H])dnl
771 AC_MSG_CHECKING(whether string.h declares mem functions)
772 AC_EGREP_HEADER(memchr, string.h, ac_found=yes, ac_found=no)
773 AC_MSG_RESULT($ac_found)
774 if test $ac_found = no; then
775   AC_CHECK_HEADER(memory.h, [AC_DEFINE(NEED_MEMORY_H)])
776 fi
777 ])
778
779 AC_DEFUN(AC_HEADER_MAJOR,
780 [AC_CACHE_CHECK(whether sys/types.h defines makedev,
781   ac_cv_header_sys_types_h_makedev,
782 [AC_TRY_LINK([#include <sys/types.h>], [return makedev(0, 0);],
783   ac_cv_header_sys_types_h_makedev=yes, ac_cv_header_sys_types_h_makedev=no)
784 ])
785
786 if test $ac_cv_header_sys_types_h_makedev = no; then
787 AC_CHECK_HEADER(sys/mkdev.h, [AC_DEFINE(MAJOR_IN_MKDEV)])
788
789   if test $ac_cv_header_sys_mkdev_h = no; then
790 AC_CHECK_HEADER(sys/sysmacros.h, [AC_DEFINE(MAJOR_IN_SYSMACROS)])
791   fi
792 fi
793 ])
794
795 AC_DEFUN(AC_HEADER_DIRENT,
796 [ac_header_dirent=no
797 AC_CHECK_HEADERS_DIRENT(dirent.h sys/ndir.h sys/dir.h ndir.h,
798   [ac_header_dirent=$ac_hdr; break])
799 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
800 if test $ac_header_dirent = dirent.h; then
801 AC_CHECK_LIB(dir, opendir, LIBS="$LIBS -ldir")
802 else
803 AC_CHECK_LIB(x, opendir, LIBS="$LIBS -lx")
804 fi
805 ])
806
807 dnl Like AC_CHECK_HEADER, except also make sure that HEADER-FILE
808 dnl defines the type `DIR'.  dirent.h on NextStep 3.2 doesn't.
809 dnl AC_CHECK_HEADER_DIRENT(HEADER-FILE, ACTION-IF-FOUND)
810 AC_DEFUN(AC_CHECK_HEADER_DIRENT,
811 [ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
812 AC_MSG_CHECKING([for $1 that defines DIR])
813 AC_CACHE_VAL(ac_cv_header_dirent_$ac_safe,
814 [AC_TRY_COMPILE([#include <sys/types.h>
815 #include <$1>], [DIR *dirp = 0;],
816   eval "ac_cv_header_dirent_$ac_safe=yes",
817   eval "ac_cv_header_dirent_$ac_safe=no")])dnl
818 if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then
819   AC_MSG_RESULT(yes)
820   $2
821 else
822   AC_MSG_RESULT(no)
823 fi
824 ])
825
826 dnl Like AC_CHECK_HEADERS, except succeed only for a HEADER-FILE that
827 dnl defines `DIR'.
828 dnl AC_CHECK_HEADERS_DIRENT(HEADER-FILE... [, ACTION])
829 define(AC_CHECK_HEADERS_DIRENT,
830 [for ac_hdr in $1
831 do
832 AC_CHECK_HEADER_DIRENT($ac_hdr,
833 [changequote(, )dnl
834   ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
835 changequote([, ])dnl
836   AC_DEFINE_UNQUOTED($ac_tr_hdr) $2])dnl
837 done])
838
839 AC_DEFUN(AC_DIR_HEADER,
840 [AC_OBSOLETE([$0], [; instead use AC_HEADER_DIRENT])dnl
841 ac_header_dirent=no
842 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
843   AC_CHECK_HEADER_DIRENT($ac_hdr, [ac_header_dirent=$ac_hdr; break])
844 done
845
846 case "$ac_header_dirent" in
847 dirent.h) AC_DEFINE(DIRENT) ;;
848 sys/ndir.h) AC_DEFINE(SYSNDIR) ;;
849 sys/dir.h) AC_DEFINE(SYSDIR) ;;
850 ndir.h) AC_DEFINE(NDIR) ;;
851 esac
852
853 AC_CACHE_CHECK(whether closedir returns void, ac_cv_func_closedir_void,
854 [AC_TRY_RUN([#include <sys/types.h>
855 #include <$ac_header_dirent>
856 int closedir(); main() { exit(closedir(opendir(".")) != 0); }],
857   ac_cv_func_closedir_void=no, ac_cv_func_closedir_void=yes, ac_cv_func_closedir_void=yes)])
858 if test $ac_cv_func_closedir_void = yes; then
859   AC_DEFINE(VOID_CLOSEDIR)
860 fi
861 ])
862
863 AC_DEFUN(AC_HEADER_STAT,
864 [AC_CACHE_CHECK(whether stat file-mode macros are broken,
865   ac_cv_header_stat_broken,
866 [AC_EGREP_CPP([You lose], [#include <sys/types.h>
867 #include <sys/stat.h>
868
869 #if defined(S_ISBLK) && defined(S_IFDIR)
870 # if S_ISBLK (S_IFDIR)
871 You lose.
872 # endif
873 #endif
874
875 #if defined(S_ISBLK) && defined(S_IFCHR)
876 # if S_ISBLK (S_IFCHR)
877 You lose.
878 # endif
879 #endif
880
881 #if defined(S_ISLNK) && defined(S_IFREG)
882 # if S_ISLNK (S_IFREG)
883 You lose.
884 # endif
885 #endif
886
887 #if defined(S_ISSOCK) && defined(S_IFREG)
888 # if S_ISSOCK (S_IFREG)
889 You lose.
890 # endif
891 #endif
892 ], ac_cv_header_stat_broken=yes, ac_cv_header_stat_broken=no)])
893 if test $ac_cv_header_stat_broken = yes; then
894   AC_DEFINE(STAT_MACROS_BROKEN)
895 fi
896 ])
897
898 AC_DEFUN(AC_DECL_SYS_SIGLIST,
899 [AC_CACHE_CHECK([for sys_siglist declaration in signal.h or unistd.h],
900   ac_cv_decl_sys_siglist,
901 [AC_TRY_COMPILE([#include <sys/types.h>
902 #include <signal.h>
903 /* NetBSD declares sys_siglist in unistd.h.  */
904 #ifdef HAVE_UNISTD_H
905 #include <unistd.h>
906 #endif], [char *msg = *(sys_siglist + 1);],
907   ac_cv_decl_sys_siglist=yes, ac_cv_decl_sys_siglist=no)])
908 if test $ac_cv_decl_sys_siglist = yes; then
909   AC_DEFINE(SYS_SIGLIST_DECLARED)
910 fi
911 ])
912
913 AC_DEFUN(AC_HEADER_SYS_WAIT,
914 [AC_CACHE_CHECK([for sys/wait.h that is POSIX.1 compatible],
915   ac_cv_header_sys_wait_h,
916 [AC_TRY_COMPILE([#include <sys/types.h>
917 #include <sys/wait.h>
918 #ifndef WEXITSTATUS
919 #define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
920 #endif
921 #ifndef WIFEXITED
922 #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
923 #endif], [int s;
924 wait (&s);
925 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;],
926 ac_cv_header_sys_wait_h=yes, ac_cv_header_sys_wait_h=no)])
927 if test $ac_cv_header_sys_wait_h = yes; then
928   AC_DEFINE(HAVE_SYS_WAIT_H)
929 fi
930 ])
931
932
933 dnl ### Checks for typedefs
934
935
936 AC_DEFUN(AC_TYPE_GETGROUPS,
937 [AC_REQUIRE([AC_TYPE_UID_T])dnl
938 AC_CACHE_CHECK(type of array argument to getgroups, ac_cv_type_getgroups,
939 [AC_TRY_RUN(
940 changequote(<<, >>)dnl
941 <<
942 /* Thanks to Mike Rendell for this test.  */
943 #include <sys/types.h>
944 #define NGID 256
945 #undef MAX
946 #define MAX(x, y) ((x) > (y) ? (x) : (y))
947 main()
948 {
949   gid_t gidset[NGID];
950   int i, n;
951   union { gid_t gval; long lval; }  val;
952
953   val.lval = -1;
954   for (i = 0; i < NGID; i++)
955     gidset[i] = val.gval;
956   n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1,
957                  gidset);
958   /* Exit non-zero if getgroups seems to require an array of ints.  This
959      happens when gid_t is short but getgroups modifies an array of ints.  */
960   exit ((n > 0 && gidset[n] != val.gval) ? 1 : 0);
961 }
962 >>,
963 changequote([, ])dnl
964   ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int,
965   ac_cv_type_getgroups=cross)
966 if test $ac_cv_type_getgroups = cross; then
967   dnl When we can't run the test program (we are cross compiling), presume
968   dnl that <unistd.h> has either an accurate prototype for getgroups or none.
969   dnl Old systems without prototypes probably use int.
970   AC_EGREP_HEADER([getgroups.*int.*gid_t], unistd.h,
971                   ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int)
972 fi])
973 AC_DEFINE_UNQUOTED(GETGROUPS_T, $ac_cv_type_getgroups)
974 ])
975
976 AC_DEFUN(AC_TYPE_UID_T,
977 [AC_CACHE_CHECK(for uid_t in sys/types.h, ac_cv_type_uid_t,
978 [AC_EGREP_HEADER(uid_t, sys/types.h,
979   ac_cv_type_uid_t=yes, ac_cv_type_uid_t=no)])
980 if test $ac_cv_type_uid_t = no; then
981   AC_DEFINE(uid_t, int)
982   AC_DEFINE(gid_t, int)
983 fi
984 ])
985
986 AC_DEFUN(AC_TYPE_SIZE_T,
987 [AC_CHECK_TYPE(size_t, unsigned)])
988
989 AC_DEFUN(AC_TYPE_PID_T,
990 [AC_CHECK_TYPE(pid_t, int)])
991
992 AC_DEFUN(AC_TYPE_OFF_T,
993 [AC_CHECK_TYPE(off_t, long)])
994
995 AC_DEFUN(AC_TYPE_MODE_T,
996 [AC_CHECK_TYPE(mode_t, int)])
997
998 dnl Note that identifiers starting with SIG are reserved by ANSI C.
999 AC_DEFUN(AC_TYPE_SIGNAL,
1000 [AC_CACHE_CHECK([return type of signal handlers], ac_cv_type_signal,
1001 [AC_TRY_COMPILE([#include <sys/types.h>
1002 #include <signal.h>
1003 #ifdef signal
1004 #undef signal
1005 #endif
1006 #ifdef __cplusplus
1007 extern "C" void (*signal (int, void (*)(int)))(int);
1008 #else
1009 void (*signal ()) ();
1010 #endif
1011 ],
1012 [int i;], ac_cv_type_signal=void, ac_cv_type_signal=int)])
1013 AC_DEFINE_UNQUOTED(RETSIGTYPE, $ac_cv_type_signal)
1014 ])
1015
1016
1017 dnl ### Checks for functions
1018
1019
1020 AC_DEFUN(AC_FUNC_CLOSEDIR_VOID,
1021 [AC_REQUIRE([AC_HEADER_DIRENT])dnl
1022 AC_CACHE_CHECK(whether closedir returns void, ac_cv_func_closedir_void,
1023 [AC_TRY_RUN([#include <sys/types.h>
1024 #include <$ac_header_dirent>
1025 int closedir(); main() { exit(closedir(opendir(".")) != 0); }],
1026   ac_cv_func_closedir_void=no, ac_cv_func_closedir_void=yes, ac_cv_func_closedir_void=yes)])
1027 if test $ac_cv_func_closedir_void = yes; then
1028   AC_DEFINE(CLOSEDIR_VOID)
1029 fi
1030 ])
1031
1032 AC_DEFUN(AC_FUNC_FNMATCH,
1033 [AC_CACHE_CHECK(for working fnmatch, ac_cv_func_fnmatch_works,
1034 # Some versions of Solaris or SCO have a broken fnmatch function.
1035 # So we run a test program.  If we are cross-compiling, take no chance.
1036 # Thanks to John Oleynick and Franc,ois Pinard for this test.
1037 [AC_TRY_RUN([main() { exit (fnmatch ("a*", "abc", 0) != 0); }],
1038 ac_cv_func_fnmatch_works=yes, ac_cv_func_fnmatch_works=no,
1039 ac_cv_func_fnmatch_works=no)])
1040 if test $ac_cv_func_fnmatch_works = yes; then
1041   AC_DEFINE(HAVE_FNMATCH)
1042 fi
1043 ])
1044
1045 AC_DEFUN(AC_FUNC_MMAP,
1046 [AC_CHECK_HEADERS(stdlib.h unistd.h sys/stat.h sys/types.h)
1047 AC_CHECK_FUNCS(getpagesize)
1048 AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,
1049 [AC_TRY_RUN([
1050 /* Thanks to Mike Haertel and Jim Avera for this test.
1051    Here is a matrix of mmap possibilities:
1052         mmap private not fixed
1053         mmap private fixed at somewhere currently unmapped
1054         mmap private fixed at somewhere already mapped
1055         mmap shared not fixed
1056         mmap shared fixed at somewhere currently unmapped
1057         mmap shared fixed at somewhere already mapped
1058    For private mappings, we should verify that changes cannot be read()
1059    back from the file, nor mmap's back from the file at a different
1060    address.  (There have been systems where private was not correctly
1061    implemented like the infamous i386 svr4.0, and systems where the
1062    VM page cache was not coherent with the filesystem buffer cache
1063    like early versions of FreeBSD and possibly contemporary NetBSD.)
1064    For shared mappings, we should conversely verify that changes get
1065    propogated back to all the places they're supposed to be.
1066
1067    Grep wants private fixed already mapped.
1068    The main things grep needs to know about mmap are:
1069    * does it exist and is it safe to write into the mmap'd area
1070    * how to use it (BSD variants)  */
1071 #include <sys/types.h>
1072 #include <fcntl.h>
1073 #include <sys/mman.h>
1074
1075 #if HAVE_SYS_TYPES_H
1076 # include <sys/types.h>
1077 #endif
1078
1079 #if HAVE_STDLIB_H
1080 # include <stdlib.h>
1081 #endif
1082
1083 #if HAVE_SYS_STAT_H
1084 # include <sys/stat.h>
1085 #endif
1086
1087 #if HAVE_UNISTD_H
1088 # include <unistd.h>
1089 #endif
1090
1091 /* This mess was copied from the GNU getpagesize.h.  */
1092 #ifndef HAVE_GETPAGESIZE
1093
1094 /* Assume that all systems that can run configure have sys/param.h.  */
1095 # ifndef HAVE_SYS_PARAM_H
1096 #  define HAVE_SYS_PARAM_H 1
1097 # endif
1098
1099 # ifdef _SC_PAGESIZE
1100 #  define getpagesize() sysconf(_SC_PAGESIZE)
1101 # else /* no _SC_PAGESIZE */
1102 #  ifdef HAVE_SYS_PARAM_H
1103 #   include <sys/param.h>
1104 #   ifdef EXEC_PAGESIZE
1105 #    define getpagesize() EXEC_PAGESIZE
1106 #   else /* no EXEC_PAGESIZE */
1107 #    ifdef NBPG
1108 #     define getpagesize() NBPG * CLSIZE
1109 #     ifndef CLSIZE
1110 #      define CLSIZE 1
1111 #     endif /* no CLSIZE */
1112 #    else /* no NBPG */
1113 #     ifdef NBPC
1114 #      define getpagesize() NBPC
1115 #     else /* no NBPC */
1116 #      ifdef PAGESIZE
1117 #       define getpagesize() PAGESIZE
1118 #      endif /* PAGESIZE */
1119 #     endif /* no NBPC */
1120 #    endif /* no NBPG */
1121 #   endif /* no EXEC_PAGESIZE */
1122 #  else /* no HAVE_SYS_PARAM_H */
1123 #   define getpagesize() 8192   /* punt totally */
1124 #  endif /* no HAVE_SYS_PARAM_H */
1125 # endif /* no _SC_PAGESIZE */
1126
1127 #endif /* no HAVE_GETPAGESIZE */
1128
1129 #ifdef __cplusplus
1130 extern "C" { void *malloc(unsigned); }
1131 #else
1132 char *malloc();
1133 #endif
1134
1135 int
1136 main()
1137 {
1138         char *data, *data2, *data3;
1139         int i, pagesize;
1140         int fd;
1141
1142         pagesize = getpagesize();
1143
1144         /*
1145          * First, make a file with some known garbage in it.
1146          */
1147         data = malloc(pagesize);
1148         if (!data)
1149                 exit(1);
1150         for (i = 0; i < pagesize; ++i)
1151                 *(data + i) = rand();
1152         umask(0);
1153         fd = creat("conftestmmap", 0600);
1154         if (fd < 0)
1155                 exit(1);
1156         if (write(fd, data, pagesize) != pagesize)
1157                 exit(1);
1158         close(fd);
1159
1160         /*
1161          * Next, try to mmap the file at a fixed address which
1162          * already has something else allocated at it.  If we can,
1163          * also make sure that we see the same garbage.
1164          */
1165         fd = open("conftestmmap", O_RDWR);
1166         if (fd < 0)
1167                 exit(1);
1168         data2 = malloc(2 * pagesize);
1169         if (!data2)
1170                 exit(1);
1171         data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
1172         if (data2 != mmap(data2, pagesize, PROT_READ | PROT_WRITE,
1173             MAP_PRIVATE | MAP_FIXED, fd, 0L))
1174                 exit(1);
1175         for (i = 0; i < pagesize; ++i)
1176                 if (*(data + i) != *(data2 + i))
1177                         exit(1);
1178
1179         /*
1180          * Finally, make sure that changes to the mapped area
1181          * do not percolate back to the file as seen by read().
1182          * (This is a bug on some variants of i386 svr4.0.)
1183          */
1184         for (i = 0; i < pagesize; ++i)
1185                 *(data2 + i) = *(data2 + i) + 1;
1186         data3 = malloc(pagesize);
1187         if (!data3)
1188                 exit(1);
1189         if (read(fd, data3, pagesize) != pagesize)
1190                 exit(1);
1191         for (i = 0; i < pagesize; ++i)
1192                 if (*(data + i) != *(data3 + i))
1193                         exit(1);
1194         close(fd);
1195         unlink("conftestmmap");
1196         exit(0);
1197 }
1198 ], ac_cv_func_mmap_fixed_mapped=yes, ac_cv_func_mmap_fixed_mapped=no,
1199 ac_cv_func_mmap_fixed_mapped=no)])
1200 if test $ac_cv_func_mmap_fixed_mapped = yes; then
1201   AC_DEFINE(HAVE_MMAP)
1202 fi
1203 ])
1204
1205 AC_DEFUN(AC_FUNC_GETPGRP,
1206 [AC_CACHE_CHECK(whether getpgrp takes no argument, ac_cv_func_getpgrp_void,
1207 [AC_TRY_RUN([
1208 /*
1209  * If this system has a BSD-style getpgrp(),
1210  * which takes a pid argument, exit unsuccessfully.
1211  *
1212  * Snarfed from Chet Ramey's bash pgrp.c test program
1213  */
1214 #include <stdio.h>
1215 #include <sys/types.h>
1216
1217 int     pid;
1218 int     pg1, pg2, pg3, pg4;
1219 int     ng, np, s, child;
1220
1221 main()
1222 {
1223         pid = getpid();
1224         pg1 = getpgrp(0);
1225         pg2 = getpgrp();
1226         pg3 = getpgrp(pid);
1227         pg4 = getpgrp(1);
1228
1229         /*
1230          * If all of these values are the same, it's pretty sure that
1231          * we're on a system that ignores getpgrp's first argument.
1232          */
1233         if (pg2 == pg4 && pg1 == pg3 && pg2 == pg3)
1234                 exit(0);
1235
1236         child = fork();
1237         if (child < 0)
1238                 exit(1);
1239         else if (child == 0) {
1240                 np = getpid();
1241                 /*
1242                  * If this is Sys V, this will not work; pgrp will be
1243                  * set to np because setpgrp just changes a pgrp to be
1244                  * the same as the pid.
1245                  */
1246                 setpgrp(np, pg1);
1247                 ng = getpgrp(0);        /* Same result for Sys V and BSD */
1248                 if (ng == pg1) {
1249                         exit(1);
1250                 } else {
1251                         exit(0);
1252                 }
1253         } else {
1254                 wait(&s);
1255                 exit(s>>8);
1256         }
1257 }
1258 ], ac_cv_func_getpgrp_void=yes, ac_cv_func_getpgrp_void=no,
1259    AC_MSG_ERROR(cannot check getpgrp if cross compiling))
1260 ])
1261 if test $ac_cv_func_getpgrp_void = yes; then
1262   AC_DEFINE(GETPGRP_VOID)
1263 fi
1264 ])
1265
1266 AC_DEFUN(AC_FUNC_SETPGRP,
1267 [AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
1268 AC_TRY_RUN([
1269 #ifdef HAVE_UNISTD_H
1270 #include <unistd.h>
1271 #endif
1272
1273 /*
1274  * If this system has a BSD-style setpgrp, which takes arguments, exit
1275  * successfully.
1276  */
1277 main()
1278 {
1279     if (setpgrp(1,1) == -1)
1280         exit(0);
1281     else
1282         exit(1);
1283 }
1284 ], ac_cv_func_setpgrp_void=no, ac_cv_func_setpgrp_void=yes,
1285    AC_MSG_ERROR(cannot check setpgrp if cross compiling))
1286 )
1287 if test $ac_cv_func_setpgrp_void = yes; then
1288   AC_DEFINE(SETPGRP_VOID)
1289 fi
1290 ])
1291
1292 AC_DEFUN(AC_FUNC_VPRINTF,
1293 [AC_CHECK_FUNC(vprintf, AC_DEFINE(HAVE_VPRINTF))
1294 if test "$ac_cv_func_vprintf" != yes; then
1295 AC_CHECK_FUNC(_doprnt, AC_DEFINE(HAVE_DOPRNT))
1296 fi
1297 ])
1298
1299 AC_DEFUN(AC_FUNC_VFORK,
1300 [AC_REQUIRE([AC_TYPE_PID_T])dnl
1301 AC_CHECK_HEADER(vfork.h, AC_DEFINE(HAVE_VFORK_H))
1302 AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
1303 [AC_TRY_RUN([/* Thanks to Paul Eggert for this test.  */
1304 #include <stdio.h>
1305 #include <sys/types.h>
1306 #include <sys/stat.h>
1307 #ifdef HAVE_UNISTD_H
1308 #include <unistd.h>
1309 #endif
1310 #ifdef HAVE_VFORK_H
1311 #include <vfork.h>
1312 #endif
1313 /* On some sparc systems, changes by the child to local and incoming
1314    argument registers are propagated back to the parent.
1315    The compiler is told about this with #include <vfork.h>,
1316    but some compilers (e.g. gcc -O) don't grok <vfork.h>.
1317    Test for this by using a static variable whose address
1318    is put into a register that is clobbered by the vfork.  */
1319 static
1320 #ifdef __cplusplus
1321 sparc_address_test (int arg)
1322 #else
1323 sparc_address_test (arg) int arg;
1324 #endif
1325 {
1326   static pid_t child;
1327   if (!child) {
1328     child = vfork ();
1329     if (child < 0) {
1330       perror ("vfork");
1331       _exit(2);
1332     }
1333     if (!child) {
1334       arg = getpid();
1335       write(-1, "", 0);
1336       _exit (arg);
1337     }
1338   }
1339 }
1340 main() {
1341   pid_t parent = getpid ();
1342   pid_t child;
1343
1344   sparc_address_test ();
1345
1346   child = vfork ();
1347
1348   if (child == 0) {
1349     /* Here is another test for sparc vfork register problems.
1350        This test uses lots of local variables, at least
1351        as many local variables as main has allocated so far
1352        including compiler temporaries.  4 locals are enough for
1353        gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe.
1354        A buggy compiler should reuse the register of parent
1355        for one of the local variables, since it will think that
1356        parent can't possibly be used any more in this routine.
1357        Assigning to the local variable will thus munge parent
1358        in the parent process.  */
1359     pid_t
1360       p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
1361       p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
1362     /* Convince the compiler that p..p7 are live; otherwise, it might
1363        use the same hardware register for all 8 local variables.  */
1364     if (p != p1 || p != p2 || p != p3 || p != p4
1365         || p != p5 || p != p6 || p != p7)
1366       _exit(1);
1367
1368     /* On some systems (e.g. IRIX 3.3),
1369        vfork doesn't separate parent from child file descriptors.
1370        If the child closes a descriptor before it execs or exits,
1371        this munges the parent's descriptor as well.
1372        Test for this by closing stdout in the child.  */
1373     _exit(close(fileno(stdout)) != 0);
1374   } else {
1375     int status;
1376     struct stat st;
1377
1378     while (wait(&status) != child)
1379       ;
1380     exit(
1381          /* Was there some problem with vforking?  */
1382          child < 0
1383
1384          /* Did the child fail?  (This shouldn't happen.)  */
1385          || status
1386
1387          /* Did the vfork/compiler bug occur?  */
1388          || parent != getpid()
1389
1390          /* Did the file descriptor bug occur?  */
1391          || fstat(fileno(stdout), &st) != 0
1392          );
1393   }
1394 }],
1395 ac_cv_func_vfork_works=yes, ac_cv_func_vfork_works=no, AC_CHECK_FUNC(vfork)
1396 ac_cv_func_vfork_works=$ac_cv_func_vfork)])
1397 if test $ac_cv_func_vfork_works = no; then
1398   AC_DEFINE(vfork, fork)
1399 fi
1400 ])
1401
1402 AC_DEFUN(AC_FUNC_WAIT3,
1403 [AC_CACHE_CHECK(for wait3 that fills in rusage, ac_cv_func_wait3_rusage,
1404 [AC_TRY_RUN([#include <sys/types.h>
1405 #include <sys/time.h>
1406 #include <sys/resource.h>
1407 #include <stdio.h>
1408 /* HP-UX has wait3 but does not fill in rusage at all.  */
1409 main() {
1410   struct rusage r;
1411   int i;
1412   /* Use a field that we can force nonzero --
1413      voluntary context switches.
1414      For systems like NeXT and OSF/1 that don't set it,
1415      also use the system CPU time.  And page faults (I/O) for Linux.  */
1416   r.ru_nvcsw = 0;
1417   r.ru_stime.tv_sec = 0;
1418   r.ru_stime.tv_usec = 0;
1419   r.ru_majflt = r.ru_minflt = 0;
1420   switch (fork()) {
1421   case 0: /* Child.  */
1422     /* Unless we actually _do_ something, the kernel sometimes doesn't chalk up any system time to this process. */
1423     if(fork()) { i = 123; wait(NULL); } else { i = 234; exit(0); }
1424     sleep(1); /* Give up the CPU.  */
1425     _exit(0);
1426   case -1: _exit(0); /* What can we do?  */
1427   default: /* Parent.  */
1428     wait3(&i, 0, &r);
1429     sleep(2); /* Avoid "text file busy" from rm on fast HP-UX machines.  */
1430     exit(r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0
1431          && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
1432   }
1433 }], ac_cv_func_wait3_rusage=yes, ac_cv_func_wait3_rusage=no,
1434 ac_cv_func_wait3_rusage=no)])
1435 if test $ac_cv_func_wait3_rusage = yes; then
1436   AC_DEFINE(HAVE_WAIT3)
1437 fi
1438 ])
1439
1440 AC_DEFUN(AC_FUNC_ALLOCA,
1441 [AC_REQUIRE_CPP()dnl Set CPP; we run AC_EGREP_CPP conditionally.
1442 # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
1443 # for constant arguments.  Useless!
1444 AC_CACHE_CHECK([for working alloca.h], ac_cv_header_alloca_h,
1445 [AC_TRY_LINK([#include <alloca.h>], [char *p = alloca(2 * sizeof(int));],
1446   ac_cv_header_alloca_h=yes, ac_cv_header_alloca_h=no)])
1447 if test $ac_cv_header_alloca_h = yes; then
1448   AC_DEFINE(HAVE_ALLOCA_H)
1449 fi
1450
1451 AC_CACHE_CHECK([for alloca], ac_cv_func_alloca_works,
1452 [AC_TRY_LINK([
1453 #ifdef __GNUC__
1454 # define alloca __builtin_alloca
1455 #else
1456 # ifdef _MSC_VER
1457 #  include <malloc.h>
1458 #  define alloca _alloca
1459 # else
1460 #  if HAVE_ALLOCA_H
1461 #   include <alloca.h>
1462 #  else
1463 #   ifdef _AIX
1464  #pragma alloca
1465 #   else
1466 #    ifndef alloca /* predefined by HP cc +Olibcalls */
1467 char *alloca ();
1468 #    endif
1469 #   endif
1470 #  endif
1471 # endif
1472 #endif
1473 ], [char *p = (char *) alloca(1);],
1474   ac_cv_func_alloca_works=yes, ac_cv_func_alloca_works=no)])
1475 if test $ac_cv_func_alloca_works = yes; then
1476   AC_DEFINE(HAVE_ALLOCA)
1477 fi
1478
1479 if test $ac_cv_func_alloca_works = no; then
1480   # The SVR3 libPW and SVR4 libucb both contain incompatible functions
1481   # that cause trouble.  Some versions do not even contain alloca or
1482   # contain a buggy version.  If you still want to use their alloca,
1483   # use ar to extract alloca.o from them instead of compiling alloca.c.
1484   ALLOCA=alloca.${ac_objext}
1485   AC_DEFINE(C_ALLOCA)
1486
1487 AC_CACHE_CHECK(whether alloca needs Cray hooks, ac_cv_os_cray,
1488 [AC_EGREP_CPP(webecray,
1489 [#if defined(CRAY) && ! defined(CRAY2)
1490 webecray
1491 #else
1492 wenotbecray
1493 #endif
1494 ], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
1495 if test $ac_cv_os_cray = yes; then
1496 for ac_func in _getb67 GETB67 getb67; do
1497   AC_CHECK_FUNC($ac_func, [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func)
1498   break])
1499 done
1500 fi
1501
1502 AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
1503 [AC_TRY_RUN([find_stack_direction ()
1504 {
1505   static char *addr = 0;
1506   auto char dummy;
1507   if (addr == 0)
1508     {
1509       addr = &dummy;
1510       return find_stack_direction ();
1511     }
1512   else
1513     return (&dummy > addr) ? 1 : -1;
1514 }
1515 main ()
1516 {
1517   exit (find_stack_direction() < 0);
1518 }], ac_cv_c_stack_direction=1, ac_cv_c_stack_direction=-1,
1519   ac_cv_c_stack_direction=0)])
1520 AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
1521 fi
1522 AC_SUBST(ALLOCA)dnl
1523 ])
1524
1525 AC_DEFUN(AC_FUNC_GETLOADAVG,
1526 [ac_have_func=no # yes means we've found a way to get the load average.
1527
1528 # Some systems with -lutil have (and need) -lkvm as well, some do not.
1529 # On Solaris, -lkvm requires nlist from -lelf, so check that first
1530 # to get the right answer into the cache.
1531 AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
1532 AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
1533 # Check for the 4.4BSD definition of getloadavg.
1534 AC_CHECK_LIB(util, getloadavg,
1535   [LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
1536
1537 if test $ac_have_func = no; then
1538   # There is a commonly available library for RS/6000 AIX.
1539   # Since it is not a standard part of AIX, it might be installed locally.
1540   ac_getloadavg_LIBS="$LIBS"; LIBS="-L/usr/local/lib $LIBS"
1541   AC_CHECK_LIB(getloadavg, getloadavg,
1542     LIBS="-lgetloadavg $LIBS", LIBS="$ac_getloadavg_LIBS")
1543 fi
1544
1545 # Make sure it is really in the library, if we think we found it.
1546 AC_REPLACE_FUNCS(getloadavg)
1547
1548 if test $ac_cv_func_getloadavg = yes; then
1549   AC_DEFINE(HAVE_GETLOADAVG)
1550   ac_have_func=yes
1551 else
1552   # Figure out what our getloadavg.c needs.
1553   ac_have_func=no
1554   AC_CHECK_HEADER(sys/dg_sys_info.h,
1555   [ac_have_func=yes; AC_DEFINE(DGUX)
1556   AC_CHECK_LIB(dgc, dg_sys_info)])
1557
1558   # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
1559   # uses stabs), but it is still SVR4.  We cannot check for <elf.h> because
1560   # Irix 4.0.5F has the header but not the library.
1561   if test $ac_have_func = no && test $ac_cv_lib_elf_elf_begin = yes; then
1562     ac_have_func=yes; AC_DEFINE(SVR4)
1563   fi
1564
1565   if test $ac_have_func = no; then
1566     AC_CHECK_HEADER(inq_stats/cpustats.h,
1567     [ac_have_func=yes; AC_DEFINE(UMAX)
1568     AC_DEFINE(UMAX4_3)])
1569   fi
1570
1571   if test $ac_have_func = no; then
1572     AC_CHECK_HEADER(sys/cpustats.h,
1573     [ac_have_func=yes; AC_DEFINE(UMAX)])
1574   fi
1575
1576   if test $ac_have_func = no; then
1577     AC_CHECK_HEADERS(mach/mach.h)
1578   fi
1579
1580   AC_CHECK_HEADER(nlist.h,
1581   [AC_DEFINE(NLIST_STRUCT)
1582   AC_CACHE_CHECK([for n_un in struct nlist], ac_cv_struct_nlist_n_un,
1583   [AC_TRY_COMPILE([#include <nlist.h>],
1584   [struct nlist n; n.n_un.n_name = 0;],
1585   ac_cv_struct_nlist_n_un=yes, ac_cv_struct_nlist_n_un=no)])
1586   if test $ac_cv_struct_nlist_n_un = yes; then
1587     AC_DEFINE(NLIST_NAME_UNION)
1588   fi
1589   ])dnl
1590 fi # Do not have getloadavg in system libraries.
1591
1592 # Some definitions of getloadavg require that the program be installed setgid.
1593 dnl FIXME Don't hardwire the path of getloadavg.c in the top-level directory.
1594 AC_CACHE_CHECK(whether getloadavg requires setgid,
1595   ac_cv_func_getloadavg_setgid,
1596 [AC_EGREP_CPP([Yowza Am I SETGID yet],
1597 [#include "$srcdir/getloadavg.c"
1598 #ifdef LDAV_PRIVILEGED
1599 Yowza Am I SETGID yet
1600 #endif],
1601   ac_cv_func_getloadavg_setgid=yes, ac_cv_func_getloadavg_setgid=no)])
1602 if test $ac_cv_func_getloadavg_setgid = yes; then
1603   NEED_SETGID=true; AC_DEFINE(GETLOADAVG_PRIVILEGED)
1604 else
1605   NEED_SETGID=false
1606 fi
1607 AC_SUBST(NEED_SETGID)dnl
1608
1609 if test $ac_cv_func_getloadavg_setgid = yes; then
1610   AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
1611 [changequote(, )dnl
1612   # On Solaris, /dev/kmem is a symlink.  Get info on the real file.
1613   ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
1614   # If we got an error (system does not support symlinks), try without -L.
1615   test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
1616   ac_cv_group_kmem=`echo $ac_ls_output \
1617     | sed -ne 's/[      ][      ]*/ /g;
1618                s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\)  *.*/\1/;
1619                / /s/.* //;p;'`
1620 changequote([, ])dnl
1621 ])
1622   KMEM_GROUP=$ac_cv_group_kmem
1623 fi
1624 AC_SUBST(KMEM_GROUP)dnl
1625 ])
1626
1627 AC_DEFUN(AC_FUNC_UTIME_NULL,
1628 [AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
1629 [rm -f conftestdata; > conftestdata
1630 # Sequent interprets utime(file, 0) to mean use start of epoch.  Wrong.
1631 AC_TRY_RUN([#include <sys/types.h>
1632 #include <sys/stat.h>
1633 main() {
1634 struct stat s, t;
1635 exit(!(stat ("conftestdata", &s) == 0 && utime("conftestdata", (long *)0) == 0
1636 && stat("conftestdata", &t) == 0 && t.st_mtime >= s.st_mtime
1637 && t.st_mtime - s.st_mtime < 120));
1638 }], ac_cv_func_utime_null=yes, ac_cv_func_utime_null=no,
1639   ac_cv_func_utime_null=no)
1640 rm -f core core.* *.core])
1641 if test $ac_cv_func_utime_null = yes; then
1642   AC_DEFINE(HAVE_UTIME_NULL)
1643 fi
1644 ])
1645
1646 AC_DEFUN(AC_FUNC_STRCOLL,
1647 [AC_CACHE_CHECK(for working strcoll, ac_cv_func_strcoll_works,
1648 [AC_TRY_RUN([#include <string.h>
1649 main ()
1650 {
1651   exit (strcoll ("abc", "def") >= 0 ||
1652         strcoll ("ABC", "DEF") >= 0 ||
1653         strcoll ("123", "456") >= 0);
1654 }], ac_cv_func_strcoll_works=yes, ac_cv_func_strcoll_works=no,
1655 ac_cv_func_strcoll_works=no)])
1656 if test $ac_cv_func_strcoll_works = yes; then
1657   AC_DEFINE(HAVE_STRCOLL)
1658 fi
1659 ])
1660
1661 AC_DEFUN(AC_FUNC_SETVBUF_REVERSED,
1662 [AC_CACHE_CHECK(whether setvbuf arguments are reversed,
1663   ac_cv_func_setvbuf_reversed,
1664 [AC_TRY_RUN([#include <stdio.h>
1665 /* If setvbuf has the reversed format, exit 0. */
1666 main () {
1667   /* This call has the arguments reversed.
1668      A reversed system may check and see that the address of main
1669      is not _IOLBF, _IONBF, or _IOFBF, and return nonzero.  */
1670   if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0)
1671     exit(1);
1672   putc('\r', stdout);
1673   exit(0);                      /* Non-reversed systems segv here.  */
1674 }], ac_cv_func_setvbuf_reversed=yes, ac_cv_func_setvbuf_reversed=no)
1675 rm -f core core.* *.core])
1676 if test $ac_cv_func_setvbuf_reversed = yes; then
1677   AC_DEFINE(SETVBUF_REVERSED)
1678 fi
1679 ])
1680
1681 AC_DEFUN(AC_FUNC_GETMNTENT,
1682 [# getmntent is in -lsun on Irix 4, -lseq on Dynix/PTX, -lgen on Unixware.
1683 AC_CHECK_LIB(sun, getmntent, LIBS="-lsun $LIBS",
1684   [AC_CHECK_LIB(seq, getmntent, LIBS="-lseq $LIBS",
1685     [AC_CHECK_LIB(gen, getmntent, LIBS="-lgen $LIBS")])])
1686 AC_CHECK_FUNC(getmntent, [AC_DEFINE(HAVE_GETMNTENT)])])
1687
1688 AC_DEFUN(AC_FUNC_STRFTIME,
1689 [AC_CHECK_FUNC(strftime, [AC_DEFINE(HAVE_STRFTIME)],
1690 [# strftime is in -lintl on SCO UNIX.
1691 AC_CHECK_LIB(intl, strftime, 
1692 [AC_DEFINE(HAVE_STRFTIME)
1693 LIBS="-lintl $LIBS"])])])
1694
1695 AC_DEFUN(AC_FUNC_MEMCMP,
1696 [AC_CACHE_CHECK(for 8-bit clean memcmp, ac_cv_func_memcmp_clean,
1697 [AC_TRY_RUN([
1698 main()
1699 {
1700   char c0 = 0x40, c1 = 0x80, c2 = 0x81;
1701   exit(memcmp(&c0, &c2, 1) < 0 && memcmp(&c1, &c2, 1) < 0 ? 0 : 1);
1702 }
1703 ], ac_cv_func_memcmp_clean=yes, ac_cv_func_memcmp_clean=no,
1704 ac_cv_func_memcmp_clean=no)])
1705 test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
1706 AC_SUBST(LIBOBJS)dnl
1707 ])
1708
1709 AC_DEFUN(AC_FUNC_SELECT_ARGTYPES,
1710 [AC_MSG_CHECKING([types of arguments for select()])
1711  AC_CACHE_VAL(ac_cv_func_select_arg234,dnl
1712  [AC_CACHE_VAL(ac_cv_func_select_arg1,dnl
1713   [AC_CACHE_VAL(ac_cv_func_select_arg5,dnl
1714    [for ac_cv_func_select_arg234 in 'fd_set *' 'int *' 'void *'; do
1715      for ac_cv_func_select_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do
1716       for ac_cv_func_select_arg5 in 'struct timeval *' 'const struct timeval *'; do
1717        AC_TRY_COMPILE(dnl
1718 [#ifdef HAVE_SYS_TYPES_H
1719 #include <sys/types.h>
1720 #endif
1721 #ifdef HAVE_SYS_TIME_H
1722 #include <sys/time.h>
1723 #endif
1724 #ifdef HAVE_SYS_SELECT_H
1725 #include <sys/select.h>
1726 #endif
1727 #ifdef HAVE_SYS_SOCKET_H
1728 #include <sys/socket.h>
1729 #endif
1730 extern select ($ac_cv_func_select_arg1,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg5);],,dnl
1731         [ac_not_found=no ; break 3],ac_not_found=yes)
1732       done
1733      done
1734     done
1735    ])dnl AC_CACHE_VAL
1736   ])dnl AC_CACHE_VAL
1737  ])dnl AC_CACHE_VAL
1738  if test "$ac_not_found" = yes; then
1739   ac_cv_func_select_arg1=int 
1740   ac_cv_func_select_arg234='int *' 
1741   ac_cv_func_select_arg5='struct timeval *'
1742  fi
1743  AC_MSG_RESULT([$ac_cv_func_select_arg1,$ac_cv_func_select_arg234,$ac_cv_func_select_arg5])
1744  AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1,$ac_cv_func_select_arg1)
1745  AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234,($ac_cv_func_select_arg234))
1746  AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5,($ac_cv_func_select_arg5))
1747 ])
1748
1749
1750 dnl ### Checks for structure members
1751
1752
1753 AC_DEFUN(AC_HEADER_TIME,
1754 [AC_CACHE_CHECK([whether time.h and sys/time.h may both be included],
1755   ac_cv_header_time,
1756 [AC_TRY_COMPILE([#include <sys/types.h>
1757 #include <sys/time.h>
1758 #include <time.h>],
1759 [struct tm *tp;], ac_cv_header_time=yes, ac_cv_header_time=no)])
1760 if test $ac_cv_header_time = yes; then
1761   AC_DEFINE(TIME_WITH_SYS_TIME)
1762 fi
1763 ])
1764
1765 AC_DEFUN(AC_STRUCT_TM,
1766 [AC_CACHE_CHECK([whether struct tm is in sys/time.h or time.h],
1767   ac_cv_struct_tm,
1768 [AC_TRY_COMPILE([#include <sys/types.h>
1769 #include <time.h>],
1770 [struct tm *tp; tp->tm_sec;],
1771   ac_cv_struct_tm=time.h, ac_cv_struct_tm=sys/time.h)])
1772 if test $ac_cv_struct_tm = sys/time.h; then
1773   AC_DEFINE(TM_IN_SYS_TIME)
1774 fi
1775 ])
1776
1777 AC_DEFUN(AC_STRUCT_TIMEZONE,
1778 [AC_REQUIRE([AC_STRUCT_TM])dnl
1779 AC_CACHE_CHECK([for tm_zone in struct tm], ac_cv_struct_tm_zone,
1780 [AC_TRY_COMPILE([#include <sys/types.h>
1781 #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;],
1782   ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)])
1783 if test "$ac_cv_struct_tm_zone" = yes; then
1784   AC_DEFINE(HAVE_TM_ZONE)
1785 else
1786   AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
1787 [AC_TRY_LINK(
1788 changequote(<<, >>)dnl
1789 <<#include <time.h>
1790 #ifndef tzname /* For SGI.  */
1791 extern char *tzname[]; /* RS6000 and others reject char **tzname.  */
1792 #endif>>,
1793 changequote([, ])dnl
1794 [atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
1795   if test $ac_cv_var_tzname = yes; then
1796     AC_DEFINE(HAVE_TZNAME)
1797   fi
1798 fi
1799 ])
1800
1801 AC_DEFUN(AC_STRUCT_ST_BLOCKS,
1802 [AC_CACHE_CHECK([for st_blocks in struct stat], ac_cv_struct_st_blocks,
1803 [AC_TRY_COMPILE([#include <sys/types.h>
1804 #include <sys/stat.h>], [struct stat s; s.st_blocks;],
1805 ac_cv_struct_st_blocks=yes, ac_cv_struct_st_blocks=no)])
1806 if test $ac_cv_struct_st_blocks = yes; then
1807   AC_DEFINE(HAVE_ST_BLOCKS)
1808 else
1809   LIBOBJS="$LIBOBJS fileblocks.${ac_objext}"
1810 fi
1811 AC_SUBST(LIBOBJS)dnl
1812 ])
1813
1814 AC_DEFUN(AC_STRUCT_ST_BLKSIZE,
1815 [AC_CACHE_CHECK([for st_blksize in struct stat], ac_cv_struct_st_blksize,
1816 [AC_TRY_COMPILE([#include <sys/types.h>
1817 #include <sys/stat.h>], [struct stat s; s.st_blksize;],
1818 ac_cv_struct_st_blksize=yes, ac_cv_struct_st_blksize=no)])
1819 if test $ac_cv_struct_st_blksize = yes; then
1820   AC_DEFINE(HAVE_ST_BLKSIZE)
1821 fi
1822 ])
1823
1824 AC_DEFUN(AC_STRUCT_ST_RDEV,
1825 [AC_CACHE_CHECK([for st_rdev in struct stat], ac_cv_struct_st_rdev,
1826 [AC_TRY_COMPILE([#include <sys/types.h>
1827 #include <sys/stat.h>], [struct stat s; s.st_rdev;],
1828 ac_cv_struct_st_rdev=yes, ac_cv_struct_st_rdev=no)])
1829 if test $ac_cv_struct_st_rdev = yes; then
1830   AC_DEFINE(HAVE_ST_RDEV)
1831 fi
1832 ])
1833
1834
1835 dnl ### Checks for compiler characteristics
1836
1837
1838 AC_DEFUN(AC_C_CROSS,
1839 [AC_OBSOLETE([$0], [; it has been merged into AC_PROG_CC])])
1840
1841 AC_DEFUN(AC_C_CHAR_UNSIGNED,
1842 [AC_CACHE_CHECK(whether char is unsigned, ac_cv_c_char_unsigned,
1843 [if test "$GCC" = yes; then
1844   # GCC predefines this symbol on systems where it applies.
1845 AC_EGREP_CPP(yes,
1846 [#ifdef __CHAR_UNSIGNED__
1847   yes
1848 #endif
1849 ], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
1850 else
1851 AC_TRY_RUN(
1852 [/* volatile prevents gcc2 from optimizing the test away on sparcs.  */
1853 #if !defined(__STDC__) || __STDC__ != 1
1854 #define volatile
1855 #endif
1856 main() {
1857   volatile char c = 255; exit(c < 0);
1858 }], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
1859 fi])
1860 if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
1861   AC_DEFINE(__CHAR_UNSIGNED__)
1862 fi
1863 ])
1864
1865 AC_DEFUN(AC_C_LONG_DOUBLE,
1866 [AC_CACHE_CHECK(for long double, ac_cv_c_long_double,
1867 [if test "$GCC" = yes; then
1868   ac_cv_c_long_double=yes
1869 else
1870 AC_TRY_RUN([int main() {
1871 /* The Stardent Vistra knows sizeof(long double), but does not support it.  */
1872 long double foo = 0.0;
1873 /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
1874 exit(sizeof(long double) < sizeof(double)); }],
1875 ac_cv_c_long_double=yes, ac_cv_c_long_double=no)
1876 fi])
1877 if test $ac_cv_c_long_double = yes; then
1878   AC_DEFINE(HAVE_LONG_DOUBLE)
1879 fi
1880 ])
1881
1882 AC_DEFUN(AC_INT_16_BITS,
1883 [AC_OBSOLETE([$0], [; instead use AC_CHECK_SIZEOF(int)])dnl
1884 AC_MSG_CHECKING(whether int is 16 bits)
1885 AC_TRY_RUN([main() { exit(sizeof(int) != 2); }],
1886  [AC_MSG_RESULT(yes)
1887  AC_DEFINE(INT_16_BITS)], AC_MSG_RESULT(no))
1888 ])
1889
1890 AC_DEFUN(AC_LONG_64_BITS,
1891 [AC_OBSOLETE([$0], [; instead use AC_CHECK_SIZEOF(long)])dnl
1892 AC_MSG_CHECKING(whether long int is 64 bits)
1893 AC_TRY_RUN([main() { exit(sizeof(long int) != 8); }],
1894  [AC_MSG_RESULT(yes)
1895  AC_DEFINE(LONG_64_BITS)], AC_MSG_RESULT(no))
1896 ])
1897
1898 AC_DEFUN(AC_C_BIGENDIAN,
1899 [AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
1900 [ac_cv_c_bigendian=unknown
1901 # See if sys/param.h defines the BYTE_ORDER macro.
1902 AC_TRY_COMPILE([#include <sys/types.h>
1903 #include <sys/param.h>], [
1904 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
1905  bogus endian macros
1906 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
1907 AC_TRY_COMPILE([#include <sys/types.h>
1908 #include <sys/param.h>], [
1909 #if BYTE_ORDER != BIG_ENDIAN
1910  not big endian
1911 #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
1912 if test $ac_cv_c_bigendian = unknown; then
1913 AC_TRY_RUN([main () {
1914   /* Are we little or big endian?  From Harbison&Steele.  */
1915   union
1916   {
1917     long l;
1918     char c[sizeof (long)];
1919   } u;
1920   u.l = 1;
1921   exit (u.c[sizeof (long) - 1] == 1);
1922 }], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes)
1923 fi])
1924 if test $ac_cv_c_bigendian = yes; then
1925   AC_DEFINE(WORDS_BIGENDIAN)
1926 fi
1927 ])
1928
1929 dnl Do nothing if the compiler accepts the inline keyword.
1930 dnl Otherwise define inline to __inline__ or __inline if one of those work,
1931 dnl otherwise define inline to be empty.
1932 AC_DEFUN(AC_C_INLINE,
1933 [AC_CACHE_CHECK([for inline], ac_cv_c_inline,
1934 [ac_cv_c_inline=no
1935 for ac_kw in inline __inline__ __inline; do
1936   AC_TRY_COMPILE(, [} $ac_kw foo() {], [ac_cv_c_inline=$ac_kw; break])
1937 done
1938 ])
1939 case "$ac_cv_c_inline" in
1940   inline | yes) ;;
1941   no) AC_DEFINE(inline, ) ;;
1942   *)  AC_DEFINE_UNQUOTED(inline, $ac_cv_c_inline) ;;
1943 esac
1944 ])
1945
1946 AC_DEFUN(AC_C_CONST,
1947 [dnl This message is consistent in form with the other checking messages,
1948 dnl and with the result message.
1949 AC_CACHE_CHECK([for working const], ac_cv_c_const,
1950 [AC_TRY_COMPILE(,
1951 changequote(<<, >>)dnl
1952 <<
1953 /* Ultrix mips cc rejects this.  */
1954 typedef int charset[2]; const charset x;
1955 /* SunOS 4.1.1 cc rejects this.  */
1956 char const *const *ccp;
1957 char **p;
1958 /* NEC SVR4.0.2 mips cc rejects this.  */
1959 struct point {int x, y;};
1960 static struct point const zero = {0,0};
1961 /* AIX XL C 1.02.0.0 rejects this.
1962    It does not let you subtract one const X* pointer from another in an arm
1963    of an if-expression whose if-part is not a constant expression */
1964 const char *g = "string";
1965 ccp = &g + (g ? g-g : 0);
1966 /* HPUX 7.0 cc rejects these. */
1967 ++ccp;
1968 p = (char**) ccp;
1969 ccp = (char const *const *) p;
1970 { /* SCO 3.2v4 cc rejects this.  */
1971   char *t;
1972   char const *s = 0 ? (char *) 0 : (char const *) 0;
1973
1974   *t++ = 0;
1975 }
1976 { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
1977   int x[] = {25, 17};
1978   const int *foo = &x[0];
1979   ++foo;
1980 }
1981 { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
1982   typedef const int *iptr;
1983   iptr p = 0;
1984   ++p;
1985 }
1986 { /* AIX XL C 1.02.0.0 rejects this saying
1987      "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
1988   struct s { int j; const int *ap[3]; };
1989   struct s *b; b->j = 5;
1990 }
1991 { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
1992   const int foo = 10;
1993 }
1994 >>,
1995 changequote([, ])dnl
1996 ac_cv_c_const=yes, ac_cv_c_const=no)])
1997 if test $ac_cv_c_const = no; then
1998   AC_DEFINE(const, )
1999 fi
2000 ])
2001
2002 AC_DEFUN(AC_C_STRINGIZE, [
2003 AC_REQUIRE([AC_PROG_CPP])
2004 AC_MSG_CHECKING([for preprocessor stringizing operator])
2005 AC_CACHE_VAL(ac_cv_c_stringize,
2006 AC_EGREP_CPP([#teststring],[
2007 #define x(y) #y
2008
2009 char *s = x(teststring);
2010 ], ac_cv_c_stringize=no, ac_cv_c_stringize=yes))
2011 if test "${ac_cv_c_stringize}" = yes
2012 then
2013         AC_DEFINE(HAVE_STRINGIZE)
2014 fi
2015 AC_MSG_RESULT([${ac_cv_c_stringize}])
2016 ])dnl
2017
2018 define(AC_ARG_ARRAY,
2019 [errprint(__file__:__line__: [$0] has been removed; don't do unportable things with arguments
2020 )m4exit(4)])
2021
2022 dnl Check the object extension used by the compiler: typically .o or
2023 dnl .obj.  If this is called, some other behaviour will change,
2024 dnl determined by ac_objext.
2025 AC_DEFUN(AC_OBJEXT,
2026 [AC_MSG_CHECKING([for object suffix])
2027 AC_CACHE_VAL(ac_cv_objext,
2028 [rm -f conftest*
2029 echo 'int i = 1;' > conftest.$ac_ext
2030 if AC_TRY_EVAL(ac_compile); then
2031   for ac_file in conftest.*; do
2032     case $ac_file in
2033     *.c) ;;
2034     *) ac_cv_objext=`echo $ac_file | sed -e s/conftest.//` ;;
2035     esac
2036   done
2037 else
2038   AC_MSG_ERROR([installation or configuration problem; compiler does not work])
2039 fi
2040 rm -f conftest*])
2041 AC_MSG_RESULT($ac_cv_objext)
2042 OBJEXT=$ac_cv_objext
2043 ac_objext=$ac_cv_objext
2044 AC_SUBST(OBJEXT)])
2045
2046 dnl Determine the linker flags (e.g. `-L' and `-l') for the Fortran 77
2047 dnl intrinsic and run-time libraries that are required to successfully
2048 dnl link a Fortran 77 program or shared library.  The output variable
2049 dnl FLIBS is set to these flags.
2050 dnl 
2051 dnl This macro is intended to be used in those situations when it is
2052 dnl necessary to mix, e.g. C++ and Fortran 77, source code into a single
2053 dnl program or shared library.
2054 dnl 
2055 dnl For example, if object files from a C++ and Fortran 77 compiler must
2056 dnl be linked together, then the C++ compiler/linker must be used for
2057 dnl linking (since special C++-ish things need to happen at link time
2058 dnl like calling global constructors, instantiating templates, enabling
2059 dnl exception support, etc.).
2060 dnl 
2061 dnl However, the Fortran 77 intrinsic and run-time libraries must be
2062 dnl linked in as well, but the C++ compiler/linker doesn't know how to
2063 dnl add these Fortran 77 libraries.  Hence, the macro
2064 dnl `AC_F77_LIBRARY_LDFLAGS' was created to determine these Fortran 77
2065 dnl libraries.
2066 dnl
2067 dnl This macro was packaged in its current form by Matthew D. Langston
2068 dnl <langston@SLAC.Stanford.EDU>.  However, nearly all of this macro
2069 dnl came from the `OCTAVE_FLIBS' macro in `octave-2.0.13/aclocal.m4',
2070 dnl and full credit should go to John W. Eaton for writing this
2071 dnl extremely useful macro.  Thank you John.
2072 dnl
2073 dnl AC_F77_LIBRARY_LDFLAGS()
2074 AC_DEFUN(AC_F77_LIBRARY_LDFLAGS,
2075 [AC_MSG_CHECKING([for Fortran 77 libraries])
2076 AC_REQUIRE([AC_PROG_F77])
2077 AC_REQUIRE([AC_CANONICAL_HOST])
2078 AC_CACHE_VAL(ac_cv_flibs,
2079 [changequote(, )dnl
2080 dnl Write a minimal program and compile it with -v.  I don't know what
2081 dnl to do if your compiler doesn't have -v...
2082 echo "      END" > conftest.f
2083 foutput=`${F77} -v -o conftest conftest.f 2>&1`
2084 dnl
2085 dnl The easiest thing to do for xlf output is to replace all the commas
2086 dnl with spaces.  Try to only do that if the output is really from xlf,
2087 dnl since doing that causes problems on other systems.
2088 dnl
2089 xlf_p=`echo $foutput | grep xlfentry`
2090 if test -n "$xlf_p"; then
2091   foutput=`echo $foutput | sed 's/,/ /g'`
2092 fi
2093 dnl
2094 ld_run_path=`echo $foutput | \
2095   sed -n -e 's/^.*LD_RUN_PATH *= *\([^ ]*\).*/\1/p'`
2096 dnl
2097 dnl We are only supposed to find this on Solaris systems...
2098 dnl Uh, the run path should be absolute, shouldn't it?
2099 dnl
2100 case "$ld_run_path" in
2101   /*)
2102     if test "$ac_cv_prog_gcc" = yes; then
2103       ld_run_path="-Xlinker -R -Xlinker $ld_run_path"
2104     else
2105       ld_run_path="-R $ld_run_path"
2106     fi
2107   ;;
2108   *)
2109     ld_run_path=
2110   ;;
2111 esac
2112 dnl
2113 flibs=
2114 lflags=
2115 dnl
2116 dnl If want_arg is set, we know we want the arg to be added to the list,
2117 dnl so we don't have to examine it.
2118 dnl
2119 want_arg=
2120 dnl
2121 for arg in $foutput; do
2122   old_want_arg=$want_arg
2123   want_arg=
2124 dnl
2125 dnl None of the options that take arguments expect the argument to
2126 dnl start with a -, so pretend we didn't see anything special.
2127 dnl
2128   if test -n "$old_want_arg"; then
2129     case "$arg" in
2130       -*)
2131         old_want_arg=
2132       ;;
2133     esac
2134   fi
2135   case "$old_want_arg" in
2136     '')
2137       case $arg in
2138         /*.a)
2139           exists=false
2140           for f in $lflags; do
2141             if test x$arg = x$f; then
2142               exists=true
2143             fi
2144           done
2145           if $exists; then
2146             arg=
2147           else
2148             lflags="$lflags $arg"
2149           fi
2150         ;;
2151         -bI:*)
2152           exists=false
2153           for f in $lflags; do
2154             if test x$arg = x$f; then
2155               exists=true
2156             fi
2157           done
2158           if $exists; then
2159             arg=
2160           else
2161             if test "$ac_cv_prog_gcc" = yes; then
2162               lflags="$lflags -Xlinker $arg"
2163             else
2164               lflags="$lflags $arg"
2165             fi
2166           fi
2167         ;;
2168         -lang* | -lcrt0.o | -lc | -lgcc)
2169           arg=
2170         ;;
2171         -[lLR])
2172           want_arg=$arg
2173           arg=
2174         ;;
2175         -[lLR]*)
2176           exists=false
2177           for f in $lflags; do
2178             if test x$arg = x$f; then
2179               exists=true
2180             fi
2181           done
2182           if $exists; then
2183             arg=
2184           else
2185             case "$arg" in
2186               -lkernel32)
2187                 case "$canonical_host_type" in
2188                   *-*-cygwin*)
2189                     arg=
2190                   ;;
2191                   *)
2192                     lflags="$lflags $arg"
2193                   ;;
2194                 esac
2195               ;;
2196               -lm)
2197               ;;
2198               *)
2199                 lflags="$lflags $arg"
2200               ;;
2201             esac
2202           fi
2203         ;;
2204         -u)
2205           want_arg=$arg
2206           arg=
2207         ;;
2208         -Y)
2209           want_arg=$arg
2210           arg=
2211         ;;
2212         *)
2213           arg=
2214         ;;
2215       esac
2216     ;;
2217     -[lLR])
2218       arg="$old_want_arg $arg"
2219     ;;
2220     -u)
2221       arg="-u $arg"
2222     ;;
2223     -Y)
2224 dnl
2225 dnl Should probably try to ensure unique directory options here too.
2226 dnl This probably only applies to Solaris systems, and then will only
2227 dnl work with gcc...
2228 dnl
2229       arg=`echo $arg | sed -e 's%^P,%%'`
2230       SAVE_IFS=$IFS
2231       IFS=:
2232       list=
2233       for elt in $arg; do
2234         list="$list -L$elt"
2235       done
2236       IFS=$SAVE_IFS
2237       arg="$list"
2238     ;;
2239   esac
2240 dnl
2241   if test -n "$arg"; then
2242     flibs="$flibs $arg"
2243   fi
2244 done
2245 if test -n "$ld_run_path"; then
2246   flibs_result="$ld_run_path $flibs"
2247 else
2248   flibs_result="$flibs"
2249 fi
2250 changequote([, ])dnl
2251 ac_cv_flibs="$flibs_result"])
2252 FLIBS="$ac_cv_flibs"
2253 AC_SUBST(FLIBS)dnl
2254 AC_MSG_RESULT($FLIBS)
2255 ])
2256
2257
2258 dnl ### Checks for operating system services
2259
2260
2261 AC_DEFUN(AC_SYS_INTERPRETER,
2262 [# Pull the hash mark out of the macro call to avoid m4 problems.
2263 ac_msg="whether #! works in shell scripts"
2264 AC_CACHE_CHECK($ac_msg, ac_cv_sys_interpreter,
2265 [echo '#! /bin/cat
2266 exit 69
2267 ' > conftest
2268 chmod u+x conftest
2269 (SHELL=/bin/sh; export SHELL; ./conftest >/dev/null)
2270 if test $? -ne 69; then
2271    ac_cv_sys_interpreter=yes
2272 else
2273    ac_cv_sys_interpreter=no
2274 fi
2275 rm -f conftest])
2276 interpval="$ac_cv_sys_interpreter"
2277 ])
2278
2279 define(AC_HAVE_POUNDBANG,
2280 [errprint(__file__:__line__: [$0 has been replaced by AC_SYS_INTERPRETER, taking no arguments
2281 ])m4exit(4)])
2282
2283 AC_DEFUN(AC_SYS_LONG_FILE_NAMES,
2284 [AC_CACHE_CHECK(for long file names, ac_cv_sys_long_file_names,
2285 [ac_cv_sys_long_file_names=yes
2286 # Test for long file names in all the places we know might matter:
2287 #      .                the current directory, where building will happen
2288 #      $prefix/lib      where we will be installing things
2289 #      $exec_prefix/lib likewise
2290 # eval it to expand exec_prefix.
2291 #      $TMPDIR          if set, where it might want to write temporary files
2292 # if $TMPDIR is not set:
2293 #      /tmp             where it might want to write temporary files
2294 #      /var/tmp         likewise
2295 #      /usr/tmp         likewise
2296 if test -n "$TMPDIR" && test -d "$TMPDIR" && test -w "$TMPDIR"; then
2297   ac_tmpdirs="$TMPDIR"
2298 else
2299   ac_tmpdirs='/tmp /var/tmp /usr/tmp'
2300 fi
2301 for ac_dir in  . $ac_tmpdirs `eval echo $prefix/lib $exec_prefix/lib` ; do
2302   test -d $ac_dir || continue
2303   test -w $ac_dir || continue # It is less confusing to not echo anything here.
2304   (echo 1 > $ac_dir/conftest9012345) 2>/dev/null
2305   (echo 2 > $ac_dir/conftest9012346) 2>/dev/null
2306   val=`cat $ac_dir/conftest9012345 2>/dev/null`
2307   if test ! -f $ac_dir/conftest9012345 || test "$val" != 1; then
2308     ac_cv_sys_long_file_names=no
2309     rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null
2310     break
2311   fi
2312   rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null
2313 done])
2314 if test $ac_cv_sys_long_file_names = yes; then
2315   AC_DEFINE(HAVE_LONG_FILE_NAMES)
2316 fi
2317 ])
2318
2319 AC_DEFUN(AC_SYS_RESTARTABLE_SYSCALLS,
2320 [AC_CACHE_CHECK(for restartable system calls, ac_cv_sys_restartable_syscalls,
2321 [AC_TRY_RUN(
2322 [/* Exit 0 (true) if wait returns something other than -1,
2323    i.e. the pid of the child, which means that wait was restarted
2324    after getting the signal.  */
2325 #include <sys/types.h>
2326 #include <signal.h>
2327 ucatch (isig) { }
2328 main () {
2329   int i = fork (), status;
2330   if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); }
2331   signal (SIGINT, ucatch);
2332   status = wait(&i);
2333   if (status == -1) wait(&i);
2334   exit (status == -1);
2335 }
2336 ], ac_cv_sys_restartable_syscalls=yes, ac_cv_sys_restartable_syscalls=no)])
2337 if test $ac_cv_sys_restartable_syscalls = yes; then
2338   AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS)
2339 fi
2340 ])
2341
2342 AC_DEFUN(AC_PATH_X,
2343 [AC_REQUIRE_CPP()dnl Set CPP; we run AC_PATH_X_DIRECT conditionally.
2344 # If we find X, set shell vars x_includes and x_libraries to the
2345 # paths, otherwise set no_x=yes.
2346 # Uses ac_ vars as temps to allow command line to override cache and checks.
2347 # --without-x overrides everything else, but does not touch the cache.
2348 AC_MSG_CHECKING(for X)
2349
2350 AC_ARG_WITH(x, [  --with-x                use the X Window System])
2351 # $have_x is `yes', `no', `disabled', or empty when we do not yet know.
2352 if test "x$with_x" = xno; then
2353   # The user explicitly disabled X.
2354   have_x=disabled
2355 else
2356   if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
2357     # Both variables are already set.
2358     have_x=yes
2359   else
2360 AC_CACHE_VAL(ac_cv_have_x,
2361 [# One or both of the vars are not set, and there is no cached value.
2362 ac_x_includes=NO ac_x_libraries=NO
2363 AC_PATH_X_XMKMF
2364 AC_PATH_X_DIRECT
2365 if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then
2366   # Didn't find X anywhere.  Cache the known absence of X.
2367   ac_cv_have_x="have_x=no"
2368 else
2369   # Record where we found X for the cache.
2370   ac_cv_have_x="have_x=yes \
2371                 ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
2372 fi])dnl
2373   fi
2374   eval "$ac_cv_have_x"
2375 fi # $with_x != no
2376
2377 if test "$have_x" != yes; then
2378   AC_MSG_RESULT($have_x)
2379   no_x=yes
2380 else
2381   # If each of the values was on the command line, it overrides each guess.
2382   test "x$x_includes" = xNONE && x_includes=$ac_x_includes
2383   test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
2384   # Update the cache value to reflect the command line values.
2385   ac_cv_have_x="have_x=yes \
2386                 ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
2387   AC_MSG_RESULT([libraries $x_libraries, headers $x_includes])
2388 fi
2389 ])
2390
2391 dnl Internal subroutine of AC_PATH_X.
2392 dnl Set ac_x_includes and/or ac_x_libraries.
2393 AC_DEFUN(AC_PATH_X_XMKMF,
2394 [rm -fr conftestdir
2395 if mkdir conftestdir; then
2396   cd conftestdir
2397   # Make sure to not put "make" in the Imakefile rules, since we grep it out.
2398   cat > Imakefile <<'EOF'
2399 acfindx:
2400         @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
2401 EOF
2402   if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2403     # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
2404     eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
2405     # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
2406     for ac_extension in a so sl; do
2407       if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
2408         test -f $ac_im_libdir/libX11.$ac_extension; then
2409         ac_im_usrlibdir=$ac_im_libdir; break
2410       fi
2411     done
2412     # Screen out bogus values from the imake configuration.  They are
2413     # bogus both because they are the default anyway, and because
2414     # using them would break gcc on systems where it needs fixed includes.
2415     case "$ac_im_incroot" in
2416         /usr/include) ;;
2417         *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;;
2418     esac
2419     case "$ac_im_usrlibdir" in
2420         /usr/lib | /lib) ;;
2421         *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;;
2422     esac
2423   fi
2424   cd ..
2425   rm -fr conftestdir
2426 fi
2427 ])
2428
2429 dnl Internal subroutine of AC_PATH_X.
2430 dnl Set ac_x_includes and/or ac_x_libraries.
2431 AC_DEFUN(AC_PATH_X_DIRECT,
2432 [if test "$ac_x_includes" = NO; then
2433   # Guess where to find include files, by looking for this one X11 .h file.
2434   test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
2435
2436   # First, try using that file with no special directory specified.
2437 AC_TRY_CPP([#include <$x_direct_test_include>],
2438 [# We can compile using X headers with no special include directory.
2439 ac_x_includes=],
2440 [# Look for the header file in a standard set of common directories.
2441 # Check X11 before X11Rn because it is often a symlink to the current release.
2442   for ac_dir in               \
2443     /usr/X11/include          \
2444     /usr/X11R6/include        \
2445     /usr/X11R5/include        \
2446     /usr/X11R4/include        \
2447                               \
2448     /usr/include/X11          \
2449     /usr/include/X11R6        \
2450     /usr/include/X11R5        \
2451     /usr/include/X11R4        \
2452                               \
2453     /usr/local/X11/include    \
2454     /usr/local/X11R6/include  \
2455     /usr/local/X11R5/include  \
2456     /usr/local/X11R4/include  \
2457                               \
2458     /usr/local/include/X11    \
2459     /usr/local/include/X11R6  \
2460     /usr/local/include/X11R5  \
2461     /usr/local/include/X11R4  \
2462                               \
2463     /usr/X386/include         \
2464     /usr/x386/include         \
2465     /usr/XFree86/include/X11  \
2466                               \
2467     /usr/include              \
2468     /usr/local/include        \
2469     /usr/unsupported/include  \
2470     /usr/athena/include       \
2471     /usr/local/x11r5/include  \
2472     /usr/lpp/Xamples/include  \
2473                               \
2474     /usr/openwin/include      \
2475     /usr/openwin/share/include \
2476     ; \
2477   do
2478     if test -r "$ac_dir/$x_direct_test_include"; then
2479       ac_x_includes=$ac_dir
2480       break
2481     fi
2482   done])
2483 fi # $ac_x_includes = NO
2484
2485 if test "$ac_x_libraries" = NO; then
2486   # Check for the libraries.
2487
2488   test -z "$x_direct_test_library" && x_direct_test_library=Xt
2489   test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc
2490
2491   # See if we find them without any special options.
2492   # Don't add to $LIBS permanently.
2493   ac_save_LIBS="$LIBS"
2494   LIBS="-l$x_direct_test_library $LIBS"
2495 AC_TRY_LINK(, [${x_direct_test_function}()],
2496 [LIBS="$ac_save_LIBS"
2497 # We can link X programs with no special library path.
2498 ac_x_libraries=],
2499 [LIBS="$ac_save_LIBS"
2500 # First see if replacing the include by lib works.
2501 # Check X11 before X11Rn because it is often a symlink to the current release.
2502 for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \
2503     /usr/X11/lib          \
2504     /usr/X11R6/lib        \
2505     /usr/X11R5/lib        \
2506     /usr/X11R4/lib        \
2507                           \
2508     /usr/lib/X11          \
2509     /usr/lib/X11R6        \
2510     /usr/lib/X11R5        \
2511     /usr/lib/X11R4        \
2512                           \
2513     /usr/local/X11/lib    \
2514     /usr/local/X11R6/lib  \
2515     /usr/local/X11R5/lib  \
2516     /usr/local/X11R4/lib  \
2517                           \
2518     /usr/local/lib/X11    \
2519     /usr/local/lib/X11R6  \
2520     /usr/local/lib/X11R5  \
2521     /usr/local/lib/X11R4  \
2522                           \
2523     /usr/X386/lib         \
2524     /usr/x386/lib         \
2525     /usr/XFree86/lib/X11  \
2526                           \
2527     /usr/lib              \
2528     /usr/local/lib        \
2529     /usr/unsupported/lib  \
2530     /usr/athena/lib       \
2531     /usr/local/x11r5/lib  \
2532     /usr/lpp/Xamples/lib  \
2533     /lib/usr/lib/X11      \
2534                           \
2535     /usr/openwin/lib      \
2536     /usr/openwin/share/lib \
2537     ; \
2538 do
2539 dnl Don't even attempt the hair of trying to link an X program!
2540   for ac_extension in a so sl; do
2541     if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
2542       ac_x_libraries=$ac_dir
2543       break 2
2544     fi
2545   done
2546 done])
2547 fi # $ac_x_libraries = NO
2548 ])
2549
2550 dnl Find additional X libraries, magic flags, etc.
2551 AC_DEFUN(AC_PATH_XTRA,
2552 [AC_REQUIRE([AC_PATH_X])dnl
2553 if test "$no_x" = yes; then
2554   # Not all programs may use this symbol, but it does not hurt to define it.
2555   AC_DEFINE(X_DISPLAY_MISSING)
2556   X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
2557 else
2558   if test -n "$x_includes"; then
2559     X_CFLAGS="$X_CFLAGS -I$x_includes"
2560   fi
2561
2562   # It would also be nice to do this for all -L options, not just this one.
2563   if test -n "$x_libraries"; then
2564     X_LIBS="$X_LIBS -L$x_libraries"
2565 dnl FIXME banish uname from this macro!
2566     # For Solaris; some versions of Sun CC require a space after -R and
2567     # others require no space.  Words are not sufficient . . . .
2568     case "`(uname -sr) 2>/dev/null`" in
2569     "SunOS 5"*)
2570       AC_MSG_CHECKING(whether -R must be followed by a space)
2571       ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
2572       AC_TRY_LINK(, , ac_R_nospace=yes, ac_R_nospace=no)
2573       if test $ac_R_nospace = yes; then
2574         AC_MSG_RESULT(no)
2575         X_LIBS="$X_LIBS -R$x_libraries"
2576       else
2577         LIBS="$ac_xsave_LIBS -R $x_libraries"
2578         AC_TRY_LINK(, , ac_R_space=yes, ac_R_space=no)
2579         if test $ac_R_space = yes; then
2580           AC_MSG_RESULT(yes)
2581           X_LIBS="$X_LIBS -R $x_libraries"
2582         else
2583           AC_MSG_RESULT(neither works)
2584         fi
2585       fi
2586       LIBS="$ac_xsave_LIBS"
2587     esac
2588   fi
2589
2590   # Check for system-dependent libraries X programs must link with.
2591   # Do this before checking for the system-independent R6 libraries
2592   # (-lICE), since we may need -lsocket or whatever for X linking.
2593
2594   if test "$ISC" = yes; then
2595     X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
2596   else
2597     # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X
2598     # libraries were built with DECnet support.  And karl@cs.umb.edu says
2599     # the Alpha needs dnet_stub (dnet does not exist).
2600     AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
2601     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
2602       AC_CHECK_LIB(dnet_stub, dnet_ntoa,
2603         [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
2604     fi
2605
2606     # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
2607     # to get the SysV transport functions.
2608     # chad@anasazi.com says the Pyramis MIS-ES running DC/OSx (SVR4)
2609     # needs -lnsl.
2610     # The nsl library prevents programs from opening the X display
2611     # on Irix 5.2, according to dickey@clark.net.
2612     AC_CHECK_FUNC(gethostbyname)
2613     if test $ac_cv_func_gethostbyname = no; then
2614       AC_CHECK_LIB(nsl, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl")
2615     fi
2616
2617     # lieder@skyler.mavd.honeywell.com says without -lsocket,
2618     # socket/setsockopt and other routines are undefined under SCO ODT
2619     # 2.0.  But -lsocket is broken on IRIX 5.2 (and is not necessary
2620     # on later versions), says simon@lia.di.epfl.ch: it contains
2621     # gethostby* variants that don't use the nameserver (or something).
2622     # -lsocket must be given before -lnsl if both are needed.
2623     # We assume that if connect needs -lnsl, so does gethostbyname.
2624     AC_CHECK_FUNC(connect)
2625     if test $ac_cv_func_connect = no; then
2626       AC_CHECK_LIB(socket, connect, X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS", ,
2627         $X_EXTRA_LIBS)
2628     fi
2629
2630     # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
2631     AC_CHECK_FUNC(remove)
2632     if test $ac_cv_func_remove = no; then
2633       AC_CHECK_LIB(posix, remove, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix")
2634     fi
2635
2636     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
2637     AC_CHECK_FUNC(shmat)
2638     if test $ac_cv_func_shmat = no; then
2639       AC_CHECK_LIB(ipc, shmat, X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc")
2640     fi
2641   fi
2642
2643   # Check for libraries that X11R6 Xt/Xaw programs need.
2644   ac_save_LDFLAGS="$LDFLAGS"
2645   test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
2646   # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
2647   # check for ICE first), but we must link in the order -lSM -lICE or
2648   # we get undefined symbols.  So assume we have SM if we have ICE.
2649   # These have to be linked with before -lX11, unlike the other
2650   # libraries we check for below, so use a different variable.
2651   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
2652   AC_CHECK_LIB(ICE, IceConnectionNumber,
2653     [X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"], , $X_EXTRA_LIBS)
2654   LDFLAGS="$ac_save_LDFLAGS"
2655
2656 fi
2657 AC_SUBST(X_CFLAGS)dnl
2658 AC_SUBST(X_PRE_LIBS)dnl
2659 AC_SUBST(X_LIBS)dnl
2660 AC_SUBST(X_EXTRA_LIBS)dnl
2661 ])
2662
2663 dnl The old Cygwin32 macro is deprecated.
2664 AC_DEFUN(AC_CYGWIN32,
2665 [AC_OBSOLETE([$0], [; instead use AC_CYGWIN])dnl
2666 AC_CYGWIN])
2667
2668 dnl Check for Cygwin.  This is a way to set the right value for
2669 dnl EXEEXT.
2670 AC_DEFUN(AC_CYGWIN,
2671 [AC_CACHE_CHECK(for Cygwin environment, ac_cv_cygwin,
2672 [AC_TRY_COMPILE(,[
2673 #ifndef __CYGWIN__
2674 #define __CYGWIN__ __CYGWIN32__
2675 #endif
2676 return __CYGWIN__;],
2677 ac_cv_cygwin=yes, ac_cv_cygwin=no)
2678 rm -f conftest*])
2679 CYGWIN=
2680 test "$ac_cv_cygwin" = yes && CYGWIN=yes])
2681
2682 dnl Check for mingw32.  This is another way to set the right value for
2683 dnl EXEEXT.
2684 AC_DEFUN(AC_MINGW32,
2685 [AC_CACHE_CHECK(for mingw32 environment, ac_cv_mingw32,
2686 [AC_TRY_COMPILE(,[return __MINGW32__;],
2687 ac_cv_mingw32=yes, ac_cv_mingw32=no)
2688 rm -f conftest*])
2689 MINGW32=
2690 test "$ac_cv_mingw32" = yes && MINGW32=yes])
2691
2692 dnl Check for the extension used for executables.  This knows that we
2693 dnl add .exe for Cygwin or mingw32.  Otherwise, it compiles a test
2694 dnl executable.  If this is called, the executable extensions will be
2695 dnl automatically used by link commands run by the configure script.
2696 AC_DEFUN(AC_EXEEXT,
2697 [AC_REQUIRE([AC_CYGWIN])
2698 AC_REQUIRE([AC_MINGW32])
2699 AC_MSG_CHECKING([for executable suffix])
2700 AC_CACHE_VAL(ac_cv_exeext,
2701 [if test "$CYGWIN" = yes || test "$MINGW32" = yes; then
2702   ac_cv_exeext=.exe
2703 else
2704   rm -f conftest*
2705   echo 'int main () { return 0; }' > conftest.$ac_ext
2706   ac_cv_exeext=
2707   if AC_TRY_EVAL(ac_link); then
2708     for file in conftest.*; do
2709       case $file in
2710       *.c | *.o | *.obj) ;;
2711       *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
2712       esac
2713     done
2714   else
2715     AC_MSG_ERROR([installation or configuration problem: compiler cannot create executables.])
2716   fi
2717   rm -f conftest*
2718   test x"${ac_cv_exeext}" = x && ac_cv_exeext=no
2719 fi])
2720 EXEEXT=""
2721 test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext}
2722 AC_MSG_RESULT(${ac_cv_exeext})
2723 dnl Setting ac_exeext will implicitly change the ac_link command.
2724 ac_exeext=$EXEEXT
2725 AC_SUBST(EXEEXT)])
2726
2727
2728 dnl ### Checks for UNIX variants
2729 dnl These are kludges which should be replaced by a single POSIX check.
2730 dnl They aren't cached, to discourage their use.
2731
2732
2733 AC_DEFUN(AC_AIX,
2734 [AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
2735 AC_BEFORE([$0], [AC_TRY_RUN])dnl
2736 AC_MSG_CHECKING(for AIX)
2737 AC_EGREP_CPP(yes,
2738 [#ifdef _AIX
2739   yes
2740 #endif
2741 ], [AC_MSG_RESULT(yes); AC_DEFINE(_ALL_SOURCE)], AC_MSG_RESULT(no))
2742 ])
2743
2744 AC_DEFUN(AC_MINIX,
2745 [AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
2746 AC_BEFORE([$0], [AC_TRY_RUN])dnl
2747 AC_CHECK_HEADER(minix/config.h, MINIX=yes, MINIX=)
2748 if test "$MINIX" = yes; then
2749   AC_DEFINE(_POSIX_SOURCE)
2750   AC_DEFINE(_POSIX_1_SOURCE, 2)
2751   AC_DEFINE(_MINIX)
2752 fi
2753 ])
2754
2755 AC_DEFUN(AC_ISC_POSIX,
2756 [AC_REQUIRE([AC_PROG_CC])dnl
2757 AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
2758 AC_BEFORE([$0], [AC_TRY_RUN])dnl
2759 AC_MSG_CHECKING(for POSIXized ISC)
2760 if test -d /etc/conf/kconfig.d &&
2761   grep _POSIX_VERSION [/usr/include/sys/unistd.h] >/dev/null 2>&1
2762 then
2763   AC_MSG_RESULT(yes)
2764   ISC=yes # If later tests want to check for ISC.
2765   AC_DEFINE(_POSIX_SOURCE)
2766   if test "$GCC" = yes; then
2767     CC="$CC -posix"
2768   else
2769     CC="$CC -Xp"
2770   fi
2771 else
2772   AC_MSG_RESULT(no)
2773   ISC=
2774 fi
2775 ])
2776
2777 AC_DEFUN(AC_XENIX_DIR,
2778 [AC_OBSOLETE([$0], [; instead use AC_HEADER_DIRENT])dnl
2779 AC_REQUIRE([AC_DIR_HEADER])dnl
2780 AC_MSG_CHECKING(for Xenix)
2781 AC_EGREP_CPP(yes,
2782 [#if defined(M_XENIX) && !defined(M_UNIX)
2783   yes
2784 #endif
2785 ], [AC_MSG_RESULT(yes); XENIX=yes], [AC_MSG_RESULT(no); XENIX=])
2786 if test "$XENIX" = yes; then
2787   # Make sure -ldir precedes -lx.
2788   test $ac_header_dirent = dirent.h && LIBS="-ldir $LIBS"
2789   LIBS="$LIBS -lx"
2790 fi
2791 ])
2792
2793 AC_DEFUN(AC_DYNIX_SEQ,
2794 [AC_OBSOLETE([$0], [; instead use AC_FUNC_GETMNTENT])dnl
2795 AC_CHECK_LIB(seq, getmntent, LIBS="-lseq $LIBS")
2796 ])
2797
2798 AC_DEFUN(AC_IRIX_SUN,
2799 [AC_OBSOLETE([$0], [; instead use AC_FUNC_GETMNTENT or AC_CHECK_LIB(sun, getpwnam)])dnl
2800 AC_CHECK_LIB(sun, getmntent, LIBS="-lsun $LIBS")
2801 ])
2802
2803 AC_DEFUN(AC_SCO_INTL,
2804 [AC_OBSOLETE([$0], [; instead use AC_FUNC_STRFTIME])dnl
2805 AC_CHECK_LIB(intl, strftime, LIBS="-lintl $LIBS")
2806 ])