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