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