Mercurial > hg > xemacs-beta
comparison lib-autoconf-1/acspecific.m4 @ 48:56c54cf7c5b6 r19-16b90
Import from CVS: tag r19-16b90
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:56:04 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
47:11c6df210d7f | 48:56c54cf7c5b6 |
---|---|
1 dnl Macros that test for specific features. | |
2 dnl This file is part of Autoconf. | |
3 dnl Copyright (C) 1992, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. | |
18 dnl | |
19 dnl Written by David MacKenzie, with help from | |
20 dnl Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor, | |
21 dnl Roland McGrath, and Noah Friedman. | |
22 dnl | |
23 dnl | |
24 dnl checks for programs | |
25 dnl | |
26 dnl | |
27 define(AC_PROG_CC, | |
28 [AC_BEFORE([$0], [AC_PROG_CPP])AC_PROVIDE([$0])AC_PROGRAM_CHECK(CC, gcc, gcc, cc) | |
29 # Find out if we are using GNU C, under whatever name. | |
30 cat > conftest.c <<EOF | |
31 #ifdef __GNUC__ | |
32 yes | |
33 #endif | |
34 EOF | |
35 ${CC-cc} -E conftest.c > conftest.out 2>&1 | |
36 if egrep yes conftest.out >/dev/null 2>&1; then | |
37 GCC=1 # For later tests. | |
38 fi | |
39 rm -f conftest* | |
40 ])dnl | |
41 dnl | |
42 define(AC_PROG_CXX, | |
43 [AC_BEFORE([$0], [AC_PROG_CXXCPP])AC_PROVIDE([$0]) | |
44 AC_PROGRAMS_CHECK(CXX, $CCC c++ g++ gcc CC cxx, gcc) | |
45 # Find out if we are using GNU C++, under whatever name. | |
46 cat > conftest.C <<EOF | |
47 #ifdef __GNUC__ | |
48 yes | |
49 #endif | |
50 EOF | |
51 ${CXX-gcc} -E conftest.C > conftest.out 2>&1 | |
52 if egrep yes conftest.out >/dev/null 2>&1; then | |
53 GXX=1 # For later tests. | |
54 fi | |
55 rm -f conftest* | |
56 ])dnl | |
57 dnl | |
58 define(AC_GCC_TRADITIONAL, | |
59 [AC_REQUIRE([AC_PROG_CC])AC_REQUIRE([AC_PROG_CPP])if test -n "$GCC"; then | |
60 AC_CHECKING(whether -traditional is needed) | |
61 changequote(,)dnl | |
62 ac_pattern="Autoconf.*'x'" | |
63 changequote([,])dnl | |
64 ac_prog='#include <sgtty.h> | |
65 Autoconf TIOCGETP' | |
66 AC_PROGRAM_EGREP($ac_pattern, $ac_prog, ac_need_trad=1) | |
67 | |
68 if test -z "$ac_need_trad"; then | |
69 ac_prog='#include <termio.h> | |
70 Autoconf TCGETA' | |
71 AC_PROGRAM_EGREP($ac_pattern, $ac_prog, ac_need_trad=1) | |
72 fi | |
73 test -n "$ac_need_trad" && CC="$CC -traditional" | |
74 fi | |
75 ])dnl | |
76 dnl | |
77 define(AC_MINUS_C_MINUS_O, | |
78 [AC_CHECKING(whether $CC and cc understand -c and -o together) | |
79 echo 'foo(){}' > conftest.c | |
80 # Make sure it works both with $CC and with simple cc. | |
81 # We do the test twice because some compilers refuse to overwrite an | |
82 # existing .o file with -o, though they will create one. | |
83 if ${CC-cc} -c conftest.c -o conftest.o >/dev/null 2>&1 \ | |
84 && test -f conftest.o && ${CC-cc} -c conftest.c -o conftest.o >/dev/null 2>&1 | |
85 then | |
86 # Test first that cc exists at all. | |
87 if cc -c conftest.c >/dev/null 2>&1 | |
88 then | |
89 if cc -c conftest.c -o conftest2.o >/dev/null 2>&1 && \ | |
90 test -f conftest2.o && cc -c conftest.c -o conftest2.o >/dev/null 2>&1 | |
91 then | |
92 : | |
93 else | |
94 AC_DEFINE(NO_MINUS_C_MINUS_O) | |
95 fi | |
96 fi | |
97 else | |
98 AC_DEFINE(NO_MINUS_C_MINUS_O) | |
99 fi | |
100 rm -f conftest* | |
101 ])dnl | |
102 dnl | |
103 dnl Define SET_MAKE to set ${MAKE} if make doesn't. | |
104 define(AC_SET_MAKE, | |
105 [cat > conftestmake <<'EOF' | |
106 all: | |
107 @echo 'ac_maketemp="${MAKE}"' | |
108 EOF | |
109 changequote(,)dnl | |
110 # GNU make sometimes prints "make[1]: Entering...", which would confuse us. | |
111 eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` | |
112 changequote([,])dnl | |
113 if test -n "$ac_maketemp"; then SET_MAKE= | |
114 else SET_MAKE="MAKE=${MAKE-make}"; fi | |
115 rm -f conftestmake | |
116 AC_SUBST([SET_MAKE])dnl | |
117 ])dnl | |
118 dnl | |
119 define(AC_PROG_RANLIB, [AC_PROGRAM_CHECK(RANLIB, ranlib, ranlib, :)])dnl | |
120 dnl | |
121 define(AC_PROG_AWK, [AC_PROGRAMS_CHECK(AWK, mawk gawk nawk awk,)])dnl | |
122 dnl | |
123 define(AC_PROG_YACC,[AC_PROGRAMS_CHECK(YACC, 'bison -y' byacc, yacc)])dnl | |
124 dnl | |
125 define(AC_PROG_CPP, | |
126 [AC_PROVIDE([$0])AC_CHECKING(how to run the C preprocessor) | |
127 if test -z "$CPP"; then | |
128 # This must be in double quotes, not single quotes, because CPP may get | |
129 # substituted into the Makefile and ``${CC-cc}'' will simply confuse | |
130 # make. It must be expanded now. | |
131 CPP="${CC-cc} -E" | |
132 dnl On the NeXT, cc -E runs the code through the compiler's parser, | |
133 dnl not just through cpp. | |
134 AC_TEST_CPP([#include <stdio.h> | |
135 Syntax Error], , | |
136 CPP="${CC-cc} -E -traditional-cpp" | |
137 AC_TEST_CPP([#include <stdio.h> | |
138 Syntax Error], ,CPP=/lib/cpp)) | |
139 fi | |
140 AC_VERBOSE(setting CPP to $CPP) | |
141 AC_SUBST(CPP)dnl | |
142 ])dnl | |
143 dnl | |
144 define(AC_PROG_CXXCPP, | |
145 [AC_PROVIDE([$0])AC_CHECKING(how to run the C++ preprocessor) | |
146 AC_LANG_SAVE[]dnl | |
147 AC_LANG_CPLUSPLUS[]dnl | |
148 if test -z "$CXXCPP"; then | |
149 CXXCPP="${CXX-c++} -E" | |
150 AC_TEST_CPP([#include <stdlib.h>], , CXXCPP=/lib/cpp) | |
151 fi | |
152 AC_VERBOSE(setting CXXCPP to $CXXCPP) | |
153 AC_LANG_RESTORE[]dnl | |
154 AC_SUBST(CXXCPP)dnl | |
155 ])dnl | |
156 dnl | |
157 dnl Require finding the C or C++ preprocessor, whichever is the | |
158 dnl current language. | |
159 define(AC_REQUIRE_CPP, | |
160 [ifelse(AC_LANG,C,[AC_REQUIRE([AC_PROG_CPP])],[AC_REQUIRE([AC_PROG_CXXCPP])])])dnl | |
161 dnl | |
162 define(AC_PROG_LEX, | |
163 [AC_PROVIDE([$0])AC_PROGRAM_CHECK(LEX, flex, flex, lex) | |
164 if test -z "$LEXLIB" | |
165 then | |
166 case "$LEX" in | |
167 flex*) AC_HAVE_LIBRARY(fl, LEXLIB="-lfl") ;; | |
168 *) LEXLIB="-ll" ;; | |
169 esac | |
170 fi | |
171 AC_VERBOSE(setting LEXLIB to $LEXLIB) | |
172 AC_SUBST(LEXLIB)])dnl | |
173 dnl | |
174 define(AC_YYTEXT_POINTER,[dnl | |
175 AC_REQUIRE_CPP()AC_REQUIRE([AC_PROG_LEX])dnl | |
176 AC_CHECKING(for yytext declaration) | |
177 # POSIX says lex can declare yytext either as a pointer or an array; the | |
178 # default is implementation-dependent. Figure out which it is, since | |
179 # not all implementations provide the %pointer and %array declarations. | |
180 # | |
181 # The minimal lex program is just a single line: %%. But some broken lexes | |
182 # (Solaris, I think it was) want two %% lines, so accommodate them. | |
183 echo '%% | |
184 %%' | ${LEX} | |
185 if test -f lex.yy.c; then | |
186 LEX_OUTPUT_ROOT=lex.yy | |
187 elif test -f lexyy.c; then | |
188 LEX_OUTPUT_ROOT=lexyy | |
189 else | |
190 # Don't know what to do here. | |
191 AC_ERROR(cannot find output from $LEX, giving up on yytext declaration) | |
192 LEX_OUTPUT_ROOT= | |
193 fi | |
194 if test -n "$LEX_OUTPUT_ROOT"; then | |
195 echo 'extern char *yytext; main () { exit (0); }' >>$LEX_OUTPUT_ROOT.c | |
196 ac_save_LIBS="$LIBS" | |
197 LIBS="$LIBS $LEXLIB" | |
198 AC_TEST_PROGRAM(`cat $LEX_OUTPUT_ROOT.c`, AC_DEFINE(YYTEXT_POINTER)) | |
199 LIBS="$ac_save_LIBS" | |
200 rm -f "${LEX_OUTPUT_ROOT}.c" | |
201 fi | |
202 AC_SUBST(LEX_OUTPUT_ROOT)dnl | |
203 ])dnl | |
204 dnl | |
205 define(AC_PROG_INSTALL, | |
206 [# Make sure to not get the incompatible SysV /etc/install and | |
207 # /usr/sbin/install, which might be in PATH before a BSD-like install, | |
208 # or the SunOS /usr/etc/install directory, or the AIX /bin/install, | |
209 # or the AFS install, which mishandles nonexistent args, or | |
210 # /usr/ucb/install on SVR4, which tries to use the nonexistent group | |
211 # `staff', or /sbin/install on IRIX which has incompatible command-line | |
212 # syntax. Sigh. | |
213 # | |
214 # On most BSDish systems install is in /usr/bin, not /usr/ucb | |
215 # anyway. | |
216 # This turns out not to be true, so the mere pathname isn't an indication | |
217 # of whether the program works. What we really need is a set of tests for | |
218 # the install program to see if it actually works in all the required ways. | |
219 # | |
220 # Avoid using ./install, which might have been erroneously created | |
221 # by make from ./install.sh. | |
222 if test -z "${INSTALL}"; then | |
223 AC_CHECKING(for a BSD compatible install) | |
224 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" | |
225 for ac_dir in $PATH; do | |
226 case "$ac_dir" in | |
227 ''|.|/etc|/sbin|/usr/sbin|/usr/etc|/usr/afsws/bin|/usr/ucb) ;; | |
228 *) | |
229 # OSF1 and SCO ODT 3.0 have their own names for install. | |
230 for ac_prog in installbsd scoinst install; do | |
231 if test -f $ac_dir/$ac_prog; then | |
232 if test $ac_prog = install && | |
233 grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then | |
234 # AIX install. It has an incompatible calling convention. | |
235 # OSF/1 installbsd also uses dspmsg, but is usable. | |
236 : | |
237 else | |
238 INSTALL="$ac_dir/$ac_prog -c" | |
239 break 2 | |
240 fi | |
241 fi | |
242 done | |
243 ;; | |
244 esac | |
245 done | |
246 IFS="$ac_save_ifs" | |
247 fi | |
248 | |
249 if test -z "$INSTALL"; then | |
250 # As a last resort, use the slow shell script. | |
251 for ac_dir in ${srcdir} ${srcdir}/.. ${srcdir}/../..; do | |
252 if test -f $ac_dir/install.sh; then | |
253 INSTALL="$ac_dir/install.sh -c"; break | |
254 fi | |
255 done | |
256 fi | |
257 if test -z "$INSTALL"; then | |
258 AC_ERROR([can not find install.sh in ${srcdir} or ${srcdir}/.. or ${srcdir}/../..]) | |
259 fi | |
260 AC_SUBST(INSTALL)dnl | |
261 AC_VERBOSE(setting INSTALL to $INSTALL) | |
262 | |
263 # Use test -z because SunOS4 sh mishandles ${INSTALL_PROGRAM-'${INSTALL}'}. | |
264 # It thinks the first close brace ends the variable substitution. | |
265 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' | |
266 AC_SUBST(INSTALL_PROGRAM)dnl | |
267 AC_VERBOSE(setting INSTALL_PROGRAM to $INSTALL_PROGRAM) | |
268 | |
269 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' | |
270 AC_SUBST(INSTALL_DATA)dnl | |
271 AC_VERBOSE(setting INSTALL_DATA to $INSTALL_DATA) | |
272 ])dnl | |
273 dnl | |
274 define(AC_LN_S, | |
275 [AC_CHECKING(for ln -s) | |
276 rm -f conftestdata | |
277 if ln -s X conftestdata 2>/dev/null | |
278 then | |
279 rm -f conftestdata | |
280 LN_S="ln -s" | |
281 else | |
282 LN_S=ln | |
283 fi | |
284 AC_SUBST(LN_S) | |
285 ])dnl | |
286 dnl | |
287 define(AC_RSH, | |
288 [AC_CHECKING(for remote shell) | |
289 if test -f /usr/ucb/rsh || test -f /usr/bin/remsh || test -f /usr/bin/rsh || | |
290 test -f /usr/bsd/rsh || test -f /usr/bin/nsh; then | |
291 RTAPELIB=rtapelib.o | |
292 else | |
293 AC_HEADER_CHECK(netdb.h, AC_DEFINE(HAVE_NETDB_H) RTAPELIB=rtapelib.o, | |
294 AC_DEFINE(NO_REMOTE)) | |
295 fi | |
296 AC_SUBST(RTAPELIB)dnl | |
297 ])dnl | |
298 dnl | |
299 dnl | |
300 dnl checks for header files | |
301 dnl | |
302 dnl | |
303 define(AC_STDC_HEADERS, | |
304 [AC_REQUIRE_CPP()dnl | |
305 AC_CHECKING(for ANSI C header files) | |
306 AC_TEST_CPP([#include <stdlib.h> | |
307 #include <stdarg.h> | |
308 #include <string.h> | |
309 #include <float.h>], | |
310 [# SunOS 4.x string.h does not declare mem*, contrary to ANSI. | |
311 AC_HEADER_EGREP(memchr, string.h, | |
312 # SGI's /bin/cc from Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. | |
313 AC_TEST_PROGRAM([#include <ctype.h> | |
314 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') | |
315 #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) | |
316 #define XOR(e,f) (((e) && !(f)) || (!(e) && (f))) | |
317 int main () { int i; for (i = 0; i < 256; i++) | |
318 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); | |
319 exit (0); } | |
320 ], | |
321 [# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. | |
322 AC_HEADER_EGREP(free, stdlib.h, AC_DEFINE(STDC_HEADERS))]))]) | |
323 ])dnl | |
324 dnl | |
325 define(AC_UNISTD_H, [AC_OBSOLETE([$0], [; instead use AC_HAVE_HEADERS(unistd.h)])AC_HEADER_CHECK(unistd.h, | |
326 AC_DEFINE(HAVE_UNISTD_H))])dnl | |
327 dnl | |
328 define(AC_USG, | |
329 [AC_OBSOLETE([$0], [; instead use AC_HAVE_HEADERS(string.h) and HAVE_STRING_H])AC_COMPILE_CHECK([BSD string and memory functions], | |
330 [#include <strings.h>], [rindex(0, 0); bzero(0, 0);], , AC_DEFINE(USG))])dnl | |
331 dnl | |
332 dnl | |
333 dnl If memchr and the like aren't declared in <string.h>, include <memory.h>. | |
334 dnl To avoid problems, don't check for gcc2 built-ins. | |
335 define(AC_MEMORY_H, | |
336 [AC_OBSOLETE([$0], [; instead use AC_HAVE_HEADERS(memory.h) and HAVE_MEMORY_H])AC_CHECKING(whether string.h declares mem functions) | |
337 AC_HEADER_EGREP(memchr, string.h, , | |
338 AC_HEADER_CHECK(memory.h, AC_DEFINE(NEED_MEMORY_H)))] | |
339 )dnl | |
340 dnl | |
341 define(AC_MAJOR_HEADER, | |
342 [AC_COMPILE_CHECK([major, minor and makedev header], | |
343 [#include <sys/types.h>], | |
344 [return makedev(0, 0);], ac_makedev=1) | |
345 if test -z "$ac_makedev"; then | |
346 AC_HEADER_CHECK(sys/mkdev.h, AC_DEFINE(MAJOR_IN_MKDEV) ac_makedev=1) | |
347 fi | |
348 if test -z "$ac_makedev"; then | |
349 AC_HEADER_CHECK(sys/sysmacros.h, AC_DEFINE(MAJOR_IN_SYSMACROS)) | |
350 fi] | |
351 )dnl | |
352 dnl | |
353 define(AC_DIR_HEADER, | |
354 [AC_PROVIDE([$0])AC_CHECKING(for directory library header) | |
355 ac_dir_header= | |
356 AC_DIR_HEADER_CHECK(dirent.h, DIRENT) | |
357 AC_DIR_HEADER_CHECK(sys/ndir.h, SYSNDIR) | |
358 AC_DIR_HEADER_CHECK(sys/dir.h, SYSDIR) | |
359 AC_DIR_HEADER_CHECK(ndir.h, NDIR) | |
360 | |
361 AC_CHECKING(for closedir return value) | |
362 AC_TEST_PROGRAM([#include <sys/types.h> | |
363 #include <$ac_dir_header> | |
364 int closedir(); main() { exit(closedir(opendir(".")) != 0); }], , | |
365 AC_DEFINE(VOID_CLOSEDIR)) | |
366 ])dnl | |
367 dnl Subroutine of AC_DIR_HEADER. | |
368 dnl ??? I tried to put this define inside AC_DIR_HEADER, but when I did | |
369 dnl that, $1 and $2 did not get expanded. --roland | |
370 dnl Check if $1 is the winning directory library header file. | |
371 dnl It must not only exist, but also correctly define the `DIR' type. | |
372 dnl If it is really winning, define $2 and set shell var `ac_dir_header' to $1. | |
373 define(AC_DIR_HEADER_CHECK, [dnl | |
374 if test -z "$ac_dir_header"; then | |
375 AC_COMPILE_CHECK($1, [#include <sys/types.h> | |
376 #include <]$1[>], | |
377 [DIR *dirp = 0;], | |
378 AC_DEFINE($2) ac_dir_header=$1)dnl | |
379 fi])dnl | |
380 dnl | |
381 dnl | |
382 dnl checks for typedefs | |
383 dnl | |
384 dnl | |
385 define(AC_GETGROUPS_T, | |
386 [AC_REQUIRE([AC_UID_T])dnl | |
387 AC_CHECKING(for type of array argument to getgroups) | |
388 changequote(,)dnl | |
389 dnl Do not put single quotes in the C program text!! | |
390 ac_prog='/* Thanks to Mike Rendell for this test. */ | |
391 #include <sys/types.h> | |
392 #define NGID 256 | |
393 #undef MAX | |
394 #define MAX(x,y) ((x) > (y) ? (x) : (y)) | |
395 main() | |
396 { | |
397 gid_t gidset[NGID]; | |
398 int i, n; | |
399 union { gid_t gval; long lval; } val; | |
400 | |
401 val.lval = -1; | |
402 for (i = 0; i < NGID; i++) | |
403 gidset[i] = val.gval; | |
404 n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1, | |
405 gidset); | |
406 /* Exit non-zero if getgroups seems to require an array of ints. This | |
407 happens when gid_t is short but getgroups modifies an array of ints. */ | |
408 exit ((n > 0 && gidset[n] != val.gval) ? 1 : 0); | |
409 }' | |
410 changequote([,])dnl | |
411 AC_TEST_PROGRAM([$ac_prog], | |
412 AC_DEFINE(GETGROUPS_T, gid_t), | |
413 AC_DEFINE(GETGROUPS_T, int)) | |
414 ])dnl | |
415 dnl | |
416 define(AC_UID_T, | |
417 [AC_PROVIDE([$0])AC_CHECKING(for uid_t in sys/types.h) | |
418 AC_HEADER_EGREP(uid_t, sys/types.h, , | |
419 AC_DEFINE(uid_t, int) AC_DEFINE(gid_t, int))])dnl | |
420 dnl | |
421 define(AC_SIZE_T, | |
422 [AC_CHECKING(for size_t in sys/types.h) | |
423 AC_HEADER_EGREP(size_t, sys/types.h, , AC_DEFINE(size_t, unsigned))])dnl | |
424 dnl | |
425 define(AC_PID_T, | |
426 [AC_PROVIDE([$0])AC_CHECKING(for pid_t in sys/types.h) | |
427 AC_HEADER_EGREP(pid_t, sys/types.h, , AC_DEFINE(pid_t, int))])dnl | |
428 dnl | |
429 define(AC_OFF_T, | |
430 [AC_PROVIDE([$0])AC_CHECKING(for off_t in sys/types.h) | |
431 AC_HEADER_EGREP(off_t, sys/types.h, , AC_DEFINE(off_t, long))])dnl | |
432 dnl | |
433 define(AC_MODE_T, | |
434 [AC_CHECKING(for mode_t in sys/types.h) | |
435 AC_HEADER_EGREP(mode_t, sys/types.h, , AC_DEFINE(mode_t, int))])dnl | |
436 dnl | |
437 define(AC_RETSIGTYPE, | |
438 [AC_PROVIDE([$0])AC_COMPILE_CHECK([return type of signal handlers], | |
439 [#include <sys/types.h> | |
440 #include <signal.h> | |
441 #ifdef signal | |
442 #undef signal | |
443 #endif | |
444 extern void (*signal ()) ();], | |
445 [int i;], | |
446 [AC_DEFINE(RETSIGTYPE, void)], | |
447 [AC_DEFINE(RETSIGTYPE, int)])] | |
448 )dnl | |
449 dnl | |
450 dnl | |
451 dnl checks for functions | |
452 dnl | |
453 dnl | |
454 define(AC_MMAP, [ | |
455 AC_CHECKING(for working mmap) | |
456 AC_TEST_PROGRAM([/* Thanks to Mike Haertel and Jim Avera for this test. */ | |
457 #include <sys/types.h> | |
458 #include <fcntl.h> | |
459 #include <sys/mman.h> | |
460 | |
461 #ifdef BSD | |
462 #ifndef BSD4_1 | |
463 #define HAVE_GETPAGESIZE | |
464 #endif | |
465 #endif | |
466 #ifndef HAVE_GETPAGESIZE | |
467 #include <sys/param.h> | |
468 #ifdef EXEC_PAGESIZE | |
469 #define getpagesize() EXEC_PAGESIZE | |
470 #else | |
471 #ifdef NBPG | |
472 #define getpagesize() NBPG * CLSIZE | |
473 #ifndef CLSIZE | |
474 #define CLSIZE 1 | |
475 #endif /* no CLSIZE */ | |
476 #else /* no NBPG */ | |
477 #ifdef NBPC | |
478 #define getpagesize() NBPC | |
479 #else /* no NBPC */ | |
480 #define getpagesize() PAGESIZE /* SVR4 */ | |
481 #endif /* no NBPC */ | |
482 #endif /* no NBPG */ | |
483 #endif /* no EXEC_PAGESIZE */ | |
484 #endif /* not HAVE_GETPAGESIZE */ | |
485 | |
486 #ifdef __osf__ | |
487 #define valloc malloc | |
488 #endif | |
489 | |
490 extern char *valloc(); | |
491 extern char *malloc(); | |
492 | |
493 int | |
494 main() | |
495 { | |
496 char *buf1, *buf2, *buf3; | |
497 int i = getpagesize(), j; | |
498 int i2 = getpagesize()*2; | |
499 int fd; | |
500 | |
501 buf1 = valloc(i2); | |
502 buf2 = valloc(i); | |
503 buf3 = malloc(i2); | |
504 for (j = 0; j < i2; ++j) | |
505 *(buf1 + j) = rand(); | |
506 fd = open("conftestmmap", O_CREAT | O_RDWR, 0666); | |
507 write(fd, buf1, i2); | |
508 mmap(buf2, i, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, fd, 0); | |
509 for (j = 0; j < i; ++j) | |
510 if (*(buf1 + j) != *(buf2 + j)) | |
511 exit(1); | |
512 lseek(fd, (long)i, 0); | |
513 read(fd, buf2, i); /* read into mapped memory -- file should not change */ | |
514 /* (it does in i386 SVR4.0 - Jim Avera) */ | |
515 lseek(fd, (long)0, 0); | |
516 read(fd, buf3, i2); | |
517 for (j = 0; j < i2; ++j) | |
518 if (*(buf1 + j) != *(buf3 + j)) | |
519 exit(1); | |
520 exit(0); | |
521 } | |
522 ], AC_DEFINE(HAVE_MMAP)) | |
523 ])dnl | |
524 dnl | |
525 define(AC_VPRINTF, | |
526 [AC_COMPILE_CHECK([vprintf], , [vprintf();], AC_DEFINE(HAVE_VPRINTF), | |
527 ac_vprintf_missing=1) | |
528 if test -n "$ac_vprintf_missing"; then | |
529 AC_COMPILE_CHECK([_doprnt], , [_doprnt();], AC_DEFINE(HAVE_DOPRNT)) | |
530 fi | |
531 ])dnl | |
532 dnl | |
533 define(AC_VFORK, | |
534 [AC_REQUIRE([AC_PID_T])AC_HEADER_CHECK(vfork.h, AC_DEFINE(HAVE_VFORK_H)) | |
535 AC_CHECKING(for working vfork) | |
536 AC_REQUIRE([AC_RETSIGTYPE]) | |
537 AC_TEST_PROGRAM([/* Thanks to Paul Eggert for this test. */ | |
538 #include <stdio.h> | |
539 #include <sys/types.h> | |
540 #include <sys/stat.h> | |
541 #include <signal.h> | |
542 #ifdef HAVE_UNISTD_H | |
543 #include <unistd.h> | |
544 #endif | |
545 #ifdef HAVE_VFORK_H | |
546 #include <vfork.h> | |
547 #endif | |
548 static int signalled; | |
549 static RETSIGTYPE catch (s) int s; { signalled = 1; } | |
550 main() { | |
551 pid_t parent = getpid (); | |
552 pid_t child; | |
553 | |
554 signal (SIGINT, catch); | |
555 | |
556 child = vfork (); | |
557 | |
558 if (child == 0) { | |
559 /* On sparc systems, changes by the child to local and incoming | |
560 argument registers are propagated back to the parent. | |
561 The compiler is told about this with #include <vfork.h>, | |
562 but some compilers (e.g. gcc -O) don't grok <vfork.h>. | |
563 Test for this by using lots of local variables, at least | |
564 as many local variables as main has allocated so far | |
565 including compiler temporaries. 4 locals are enough for | |
566 gcc 1.40.3 on a sparc, but we use 8 to be safe. | |
567 A buggy compiler should reuse the register of parent | |
568 for one of the local variables, since it will think that | |
569 parent can't possibly be used any more in this routine. | |
570 Assigning to the local variable will thus munge parent | |
571 in the parent process. */ | |
572 pid_t | |
573 p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), | |
574 p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); | |
575 /* Convince the compiler that p..p7 are live; otherwise, it might | |
576 use the same hardware register for all 8 local variables. */ | |
577 if (p != p1 || p != p2 || p != p3 || p != p4 | |
578 || p != p5 || p != p6 || p != p7) | |
579 _exit(1); | |
580 | |
581 /* On some systems (e.g. SunOS 5.2), if the parent is catching | |
582 a signal, the child ignores the signal before execing, | |
583 and the parent later receives that signal, the parent dumps core. | |
584 Test for this by ignoring SIGINT in the child. */ | |
585 signal (SIGINT, SIG_IGN); | |
586 | |
587 /* On some systems (e.g. IRIX 3.3), | |
588 vfork doesn't separate parent from child file descriptors. | |
589 If the child closes a descriptor before it execs or exits, | |
590 this munges the parent's descriptor as well. | |
591 Test for this by closing stdout in the child. */ | |
592 _exit(close(fileno(stdout)) != 0); | |
593 } else { | |
594 int status; | |
595 struct stat st; | |
596 | |
597 while (wait(&status) != child) | |
598 ; | |
599 exit( | |
600 /* Was there some problem with vforking? */ | |
601 child < 0 | |
602 | |
603 /* Did the child fail? (This shouldn't happen.) */ | |
604 || status | |
605 | |
606 /* Did the vfork/compiler bug occur? */ | |
607 || parent != getpid() | |
608 | |
609 /* Did the signal handling bug occur? */ | |
610 || kill(parent, SIGINT) != 0 | |
611 || signalled != 1 | |
612 | |
613 /* Did the file descriptor bug occur? */ | |
614 || fstat(fileno(stdout), &st) != 0 | |
615 ); | |
616 } | |
617 }], , AC_DEFINE(vfork, fork)) | |
618 ])dnl | |
619 dnl | |
620 define(AC_WAIT3, | |
621 [AC_CHECKING(for wait3 that fills in rusage) | |
622 AC_TEST_PROGRAM([#include <sys/types.h> | |
623 #include <sys/time.h> | |
624 #include <sys/resource.h> | |
625 #include <stdio.h> | |
626 /* HP-UX has wait3 but does not fill in rusage at all. */ | |
627 main() { | |
628 struct rusage r; | |
629 int i; | |
630 /* Use a field that we can force nonzero -- | |
631 voluntary context switches. | |
632 For systems like NeXT and OSF/1 that don't set it, | |
633 also use the system CPU time. */ | |
634 r.ru_nvcsw = 0; | |
635 r.ru_stime.tv_sec = 0; | |
636 r.ru_stime.tv_usec = 0; | |
637 switch (fork()) { | |
638 case 0: /* Child. */ | |
639 sleep(1); /* Give up the CPU. */ | |
640 _exit(0); | |
641 case -1: _exit(0); /* What can we do? */ | |
642 default: /* Parent. */ | |
643 wait3(&i, 0, &r); | |
644 sleep(1); /* Avoid "text file busy" from rm on fast HP-UX machines. */ | |
645 exit(r.ru_nvcsw == 0 | |
646 && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0); | |
647 } | |
648 }], AC_DEFINE(HAVE_WAIT3)) | |
649 ])dnl | |
650 dnl | |
651 define(AC_ALLOCA, | |
652 [# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works | |
653 # for constant arguments. Useless! | |
654 AC_COMPILE_CHECK(working alloca.h, [#include <alloca.h>], | |
655 [char *p = alloca(2 * sizeof(int));], AC_DEFINE(HAVE_ALLOCA_H)) | |
656 ac_decl="#ifdef __GNUC__ | |
657 #define alloca __builtin_alloca | |
658 #else | |
659 #if HAVE_ALLOCA_H | |
660 #include <alloca.h> | |
661 #else | |
662 #ifdef _AIX | |
663 #pragma alloca | |
664 #else | |
665 char *alloca (); | |
666 #endif | |
667 #endif | |
668 #endif | |
669 " | |
670 AC_COMPILE_CHECK([alloca], $ac_decl, | |
671 [char *p = (char *) alloca(1);], [AC_DEFINE([HAVE_ALLOCA])], [dnl | |
672 ac_alloca_missing=1 | |
673 AC_PROGRAM_EGREP(winnitude, [ | |
674 #if defined(CRAY) && ! defined(CRAY2) | |
675 winnitude | |
676 #else | |
677 lossage | |
678 #endif | |
679 ], | |
680 AC_FUNC_CHECK([_getb67],AC_DEFINE([CRAY_STACKSEG_END],[_getb67]), | |
681 AC_FUNC_CHECK([GETB67],AC_DEFINE([CRAY_STACKSEG_END],[GETB67]), | |
682 AC_FUNC_CHECK([getb67],AC_DEFINE([CRAY_STACKSEG_END],[getb67]))))) | |
683 ]) | |
684 if test -n "$ac_alloca_missing"; then | |
685 # The SVR3 libPW and SVR4 libucb both contain incompatible functions | |
686 # that cause trouble. Some versions do not even contain alloca or | |
687 # contain a buggy version. If you still want to use their alloca, | |
688 # use ar to extract alloca.o from them instead of compiling alloca.c. | |
689 ALLOCA=alloca.o | |
690 AC_DEFINE(C_ALLOCA) | |
691 | |
692 AC_CHECKING(stack direction for C alloca) | |
693 AC_TEST_PROGRAM([find_stack_direction () | |
694 { | |
695 static char *addr = 0; | |
696 auto char dummy; | |
697 if (addr == 0) | |
698 { | |
699 addr = &dummy; | |
700 return find_stack_direction (); | |
701 } | |
702 else | |
703 return (&dummy > addr) ? 1 : -1; | |
704 } | |
705 main () | |
706 { | |
707 exit (find_stack_direction() < 0); | |
708 }], dnl | |
709 AC_DEFINE(STACK_DIRECTION,1), AC_DEFINE(STACK_DIRECTION,-1), dnl | |
710 AC_DEFINE(STACK_DIRECTION,0)) | |
711 fi | |
712 AC_SUBST(ALLOCA)dnl | |
713 ])dnl | |
714 dnl | |
715 define(AC_GETLOADAVG, | |
716 [# Some definitions of getloadavg require that the program be installed setgid. | |
717 AC_SUBST(NEED_SETGID)NEED_SETGID=false | |
718 ac_need_func=true | |
719 | |
720 # Check for the 4.4BSD definition of getloadavg. | |
721 AC_HAVE_LIBRARY(util, LIBS="$LIBS -lutil" ac_need_func=false) | |
722 # Some systems with -lutil have (and need) -lkvm as well, some do not. | |
723 AC_HAVE_LIBRARY(kvm, LIBS="$LIBS -lkvm") | |
724 | |
725 if $ac_need_func; then | |
726 # There is a commonly available library for RS/6000 AIX. | |
727 # Since it is not a standard part of AIX, it might be installed locally. | |
728 LIBS_old="$LIBS" | |
729 LIBS="-L/usr/local/lib $LIBS" | |
730 AC_HAVE_LIBRARY(getloadavg, LIBS="$LIBS -lgetloadavg" ac_need_func=false, | |
731 LIBS="$LIBS_old") | |
732 fi | |
733 | |
734 # Make sure it is really in the library, if we think we found it at all. | |
735 AC_REPLACE_FUNCS(getloadavg) | |
736 | |
737 case "$LIBOBJS" in | |
738 *getloadavg*) | |
739 ac_need_func=true | |
740 AC_HEADER_CHECK(sys/dg_sys_info.h, [dnl | |
741 AC_DEFINE(DGUX) ac_need_func=false | |
742 # Some versions of DGUX need -ldgc for dg_sys_info. | |
743 AC_HAVE_LIBRARY(dgc)]) | |
744 if $ac_need_func; then | |
745 # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it | |
746 # uses stabs), but it's still SVR4. We cannot check for <elf.h> because | |
747 # Irix 4.0.5F has the header but not the library. | |
748 AC_HAVE_LIBRARY(elf, AC_DEFINE(SVR4) LIBS="$LIBS -lelf" ac_need_func=false | |
749 AC_HAVE_LIBRARY(kvm, LIBS="$LIBS -lkvm")) | |
750 fi | |
751 if $ac_need_func; then | |
752 AC_HEADER_CHECK(inq_stats/cpustats.h, AC_DEFINE(UMAX4_3) AC_DEFINE(UMAX) | |
753 ac_need_func=false) | |
754 fi | |
755 if $ac_need_func; then | |
756 AC_HEADER_CHECK(sys/cpustats.h, AC_DEFINE(UMAX) ac_need_func=false) | |
757 fi | |
758 if $ac_need_func; then | |
759 AC_HAVE_HEADERS(mach/mach.h) | |
760 fi | |
761 | |
762 AC_HEADER_CHECK(nlist.h, | |
763 [AC_DEFINE(NLIST_STRUCT) | |
764 AC_COMPILE_CHECK(n_un in struct nlist, [#include <nlist.h>], | |
765 [struct nlist n; n.n_un.n_name = 0;], | |
766 AC_DEFINE(NLIST_NAME_UNION))])dnl | |
767 | |
768 # Figure out whether we will need to install setgid. | |
769 AC_PROGRAM_EGREP([Yowza Am I SETGID yet], [dnl | |
770 #include "${srcdir}/getloadavg.c" | |
771 #ifdef LDAV_PRIVILEGED | |
772 Yowza Am I SETGID yet | |
773 #endif], [AC_DEFINE(GETLOADAVG_PRIVILEGED) NEED_SETGID=true])dnl | |
774 ;; | |
775 | |
776 *) AC_DEFINE(HAVE_GETLOADAVG) ;; | |
777 esac | |
778 | |
779 if $NEED_SETGID; then | |
780 AC_SUBST(KMEM_GROUP)dnl | |
781 # Figure out what group owns /dev/kmem. | |
782 # The installed program will need to be setgid and owned by that group. | |
783 changequote(,)dnl | |
784 # On Solaris, /dev/kmem is a symlink. Get info on the real file. | |
785 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null` | |
786 # If we got an error (system does not support symlinks), try without -L. | |
787 test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem` | |
788 KMEM_GROUP=`echo $ac_ls_output \ | |
789 | sed -ne 's/[ ][ ]*/ /g; | |
790 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/; | |
791 / /s/.* //;p;'` | |
792 changequote([,])dnl | |
793 fi | |
794 ])dnl | |
795 dnl | |
796 define(AC_UTIME_NULL, | |
797 [AC_CHECKING(utime with null argument) | |
798 rm -f conftestdata; > conftestdata | |
799 # Sequent interprets utime(file, 0) to mean use start of epoch. Wrong. | |
800 AC_TEST_PROGRAM([#include <sys/types.h> | |
801 #include <sys/stat.h> | |
802 main() { | |
803 struct stat s, t; | |
804 exit(!(stat ("conftestdata", &s) == 0 && utime("conftestdata", (long *)0) == 0 | |
805 && stat("conftestdata", &t) == 0 && t.st_mtime >= s.st_mtime | |
806 && t.st_mtime - s.st_mtime < 120)); | |
807 }], AC_DEFINE(HAVE_UTIME_NULL)) | |
808 rm -f core | |
809 ])dnl | |
810 dnl | |
811 define(AC_STRCOLL, [AC_CHECKING(for strcoll) | |
812 AC_TEST_PROGRAM([#include <string.h> | |
813 main () | |
814 { | |
815 exit (strcoll ("abc", "def") >= 0 || | |
816 strcoll ("ABC", "DEF") >= 0 || | |
817 strcoll ("123", "456") >= 0); | |
818 }], AC_DEFINE(HAVE_STRCOLL))])dnl | |
819 dnl | |
820 define(AC_SETVBUF_REVERSED, | |
821 [AC_TEST_PROGRAM([#include <stdio.h> | |
822 /* If setvbuf has the reversed format, exit 0. */ | |
823 main () { | |
824 /* This call has the arguments reversed. | |
825 A reversed system may check and see that the address of main | |
826 is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */ | |
827 if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0) | |
828 exit(1); | |
829 putc('\r', stdout); | |
830 exit(0); /* Non-reversed systems segv here. */ | |
831 }], AC_DEFINE(SETVBUF_REVERSED)) | |
832 rm -f core | |
833 ])dnl | |
834 dnl | |
835 dnl | |
836 dnl checks for structure members | |
837 dnl | |
838 dnl | |
839 define(AC_STRUCT_TM, | |
840 [AC_PROVIDE([$0])AC_COMPILE_CHECK([struct tm in time.h], | |
841 [#include <sys/types.h> | |
842 #include <time.h>], | |
843 [struct tm *tp; tp->tm_sec;], , AC_DEFINE(TM_IN_SYS_TIME))])dnl | |
844 dnl | |
845 define(AC_TIME_WITH_SYS_TIME, | |
846 [AC_COMPILE_CHECK([whether time.h and sys/time.h may both be included], | |
847 [#include <sys/types.h> | |
848 #include <sys/time.h> | |
849 #include <time.h>], | |
850 [struct tm *tp;], AC_DEFINE(TIME_WITH_SYS_TIME))])dnl | |
851 dnl | |
852 define(AC_TIMEZONE, | |
853 [AC_REQUIRE([AC_STRUCT_TM])ac_decl='#include <sys/types.h> | |
854 ' | |
855 case "$DEFS" in | |
856 *TM_IN_SYS_TIME*) ac_decl="$ac_decl | |
857 #include <sys/time.h> | |
858 " ;; | |
859 *) ac_decl="$ac_decl | |
860 #include <time.h> | |
861 " ;; | |
862 esac | |
863 AC_COMPILE_CHECK([tm_zone in struct tm], $ac_decl, | |
864 [struct tm tm; tm.tm_zone;], AC_DEFINE(HAVE_TM_ZONE), ac_no_tm_zone=1) | |
865 if test -n "$ac_no_tm_zone"; then | |
866 AC_COMPILE_CHECK(tzname, changequote(<<,>>)dnl | |
867 <<#include <time.h> | |
868 #ifndef tzname /* For SGI. */ | |
869 extern char *tzname[]; /* RS6000 and others want it this way. */ | |
870 #endif>>, changequote([,])dnl | |
871 [atoi(*tzname);], AC_DEFINE(HAVE_TZNAME)) | |
872 fi | |
873 ])dnl | |
874 dnl | |
875 define(AC_ST_BLOCKS, | |
876 [AC_COMPILE_CHECK([st_blocks in struct stat], | |
877 [#include <sys/types.h> | |
878 #include <sys/stat.h>], [struct stat s; s.st_blocks;], | |
879 AC_DEFINE(HAVE_ST_BLOCKS), LIBOBJS="$LIBOBJS fileblocks.o")dnl | |
880 AC_SUBST(LIBOBJS)dnl | |
881 ])dnl | |
882 dnl | |
883 define(AC_ST_BLKSIZE, | |
884 [AC_COMPILE_CHECK([st_blksize in struct stat], | |
885 [#include <sys/types.h> | |
886 #include <sys/stat.h>], [struct stat s; s.st_blksize;], | |
887 AC_DEFINE(HAVE_ST_BLKSIZE))])dnl | |
888 dnl | |
889 define(AC_ST_RDEV, | |
890 [AC_COMPILE_CHECK([st_rdev in struct stat], | |
891 [#include <sys/types.h> | |
892 #include <sys/stat.h>], [struct stat s; s.st_rdev;], | |
893 AC_DEFINE(HAVE_ST_RDEV))])dnl | |
894 dnl | |
895 dnl | |
896 dnl checks for compiler characteristics | |
897 dnl | |
898 dnl | |
899 define(AC_CROSS_CHECK, | |
900 [AC_PROVIDE([$0])AC_CHECKING(whether cross-compiling) | |
901 # If we cannot run a trivial program, we must be cross compiling. | |
902 AC_TEST_PROGRAM([main(){exit(0);}], , cross_compiling=1) | |
903 ])dnl | |
904 dnl | |
905 define(AC_CHAR_UNSIGNED, | |
906 [AC_CHECKING(for unsigned characters) | |
907 AC_TEST_PROGRAM( | |
908 [/* volatile prevents gcc2 from optimizing the test away on sparcs. */ | |
909 #if !__STDC__ | |
910 #define volatile | |
911 #endif | |
912 main() { | |
913 #ifdef __CHAR_UNSIGNED__ | |
914 exit(1); /* No need to redefine it. */ | |
915 #else | |
916 volatile char c = 255; exit(c < 0); | |
917 #endif | |
918 }], AC_DEFINE(__CHAR_UNSIGNED__))] | |
919 )dnl | |
920 dnl | |
921 define(AC_LONG_DOUBLE, | |
922 [AC_REQUIRE([AC_PROG_CC])dnl | |
923 AC_CHECKING(for long double) | |
924 if test -n "$GCC"; then | |
925 AC_DEFINE(HAVE_LONG_DOUBLE) | |
926 else | |
927 AC_TEST_PROGRAM([int main() { | |
928 /* The Stardent Vistra knows sizeof(long double), but does not support it. */ | |
929 long double foo = 0.0; | |
930 /* On Ultrix 4.3 cc, long double is 4 and double is 8. */ | |
931 exit(sizeof(long double) < sizeof(double)); }], | |
932 AC_DEFINE(HAVE_LONG_DOUBLE)) | |
933 fi | |
934 ])dnl | |
935 dnl | |
936 define(AC_INT_16_BITS, | |
937 [AC_OBSOLETE([$0], [; instead use AC_SIZEOF_TYPE(int)]) | |
938 AC_CHECKING(integer size) | |
939 AC_TEST_PROGRAM([main() { exit(sizeof(int) != 2); }], | |
940 AC_DEFINE(INT_16_BITS)) | |
941 ])dnl | |
942 dnl | |
943 define(AC_LONG_64_BITS, | |
944 [AC_OBSOLETE([$0], [; instead use AC_SIZEOF_TYPE(long)]) | |
945 AC_CHECKING(for 64-bit long ints) | |
946 AC_TEST_PROGRAM([main() { exit(sizeof(long int) != 8); }], | |
947 AC_DEFINE(LONG_64_BITS)) | |
948 ])dnl | |
949 dnl | |
950 define(AC_WORDS_BIGENDIAN, | |
951 [AC_CHECKING(byte ordering) | |
952 AC_TEST_PROGRAM([main () { | |
953 /* Are we little or big endian? From Harbison&Steele. */ | |
954 union | |
955 { | |
956 long l; | |
957 char c[sizeof (long)]; | |
958 } u; | |
959 u.l = 1; | |
960 exit (u.c[sizeof (long) - 1] == 1); | |
961 }], , AC_DEFINE(WORDS_BIGENDIAN)) | |
962 ])dnl | |
963 dnl | |
964 define(AC_ARG_ARRAY, | |
965 [AC_CHECKING(whether the address of an argument can be used as an array) | |
966 AC_TEST_PROGRAM([main() { | |
967 /* Return 0 iff arg arrays are ok. */ | |
968 exit(!x(1, 2, 3, 4)); | |
969 } | |
970 x(a, b, c, d) { | |
971 return y(a, &b); | |
972 } | |
973 /* Return 1 iff arg arrays are ok. */ | |
974 y(a, b) int *b; { | |
975 return a == 1 && b[0] == 2 && b[1] == 3 && b[2] == 4; | |
976 }], , AC_DEFINE(NO_ARG_ARRAY)) | |
977 rm -f core | |
978 ])dnl | |
979 dnl | |
980 define(AC_INLINE, | |
981 [AC_REQUIRE([AC_PROG_CC])if test -n "$GCC"; then | |
982 AC_COMPILE_CHECK([inline], , [} inline foo() {], , AC_DEFINE(inline, __inline)) | |
983 fi | |
984 ])dnl | |
985 define(AC_CONST, | |
986 [changequote(,)dnl | |
987 dnl Do not put single quotes in the C program text!! | |
988 ac_prog='/* Ultrix mips cc rejects this. */ | |
989 typedef int charset[2]; const charset x; | |
990 /* SunOS 4.1.1 cc rejects this. */ | |
991 char const *const *ccp; | |
992 char **p; | |
993 /* AIX XL C 1.02.0.0 rejects this. | |
994 It does not let you subtract one const X* pointer from another in an arm | |
995 of an if-expression whose if-part is not a constant expression */ | |
996 const char *g = "string"; | |
997 ccp = &g + (g ? g-g : 0); | |
998 /* HPUX 7.0 cc rejects these. */ | |
999 ++ccp; | |
1000 p = (char**) ccp; | |
1001 ccp = (char const *const *) p; | |
1002 { /* SCO 3.2v4 cc rejects this. */ | |
1003 char *t; | |
1004 char const *s = 0 ? (char *) 0 : (char const *) 0; | |
1005 | |
1006 *t++ = 0; | |
1007 } | |
1008 { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ | |
1009 int x[] = {25,17}; | |
1010 const int *foo = &x[0]; | |
1011 ++foo; | |
1012 } | |
1013 { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ | |
1014 typedef const int *iptr; | |
1015 iptr p = 0; | |
1016 ++p; | |
1017 } | |
1018 { /* AIX XL C 1.02.0.0 rejects this saying | |
1019 "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ | |
1020 struct s { int j; const int *ap[3]; }; | |
1021 struct s *b; b->j = 5; | |
1022 } | |
1023 { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ | |
1024 const int foo = 10; | |
1025 }' | |
1026 changequote([,])dnl | |
1027 AC_COMPILE_CHECK([dnl Do not "break" this again. | |
1028 lack of working const], , [$ac_prog], , AC_DEFINE(const,))])dnl | |
1029 dnl | |
1030 dnl | |
1031 dnl checks for operating system services | |
1032 dnl | |
1033 dnl | |
1034 define(AC_HAVE_POUNDBANG, [dnl | |
1035 AC_CHECKING(whether \`[#]!' works in shell scripts) | |
1036 echo '#!/bin/cat | |
1037 exit 69 | |
1038 ' > conftest | |
1039 chmod u+x conftest | |
1040 (SHELL=/bin/sh; export SHELL; ./conftest > /dev/null) | |
1041 if test $? -ne 69; then | |
1042 :; $1 | |
1043 else | |
1044 :; $2 | |
1045 fi | |
1046 rm -f conftest | |
1047 ])dnl | |
1048 define(AC_REMOTE_TAPE, | |
1049 [AC_CHECKING(for remote tape and socket header files) | |
1050 AC_HEADER_CHECK(sys/mtio.h, AC_DEFINE(HAVE_SYS_MTIO_H) ac_have_mtio_h=1) | |
1051 if test -n "$ac_have_mtio_h"; then | |
1052 AC_TEST_CPP([#include <sgtty.h> | |
1053 #include <sys/socket.h>], PROGS="$PROGS rmt") | |
1054 fi | |
1055 ])dnl | |
1056 dnl | |
1057 define(AC_LONG_FILE_NAMES, | |
1058 [AC_CHECKING(for long file names) | |
1059 ac_some_dir_failed=false | |
1060 # Test for long file names in all the places we know might matter: | |
1061 # . the current directory, where building will happen | |
1062 # /tmp where it might want to write temporary files | |
1063 # /var/tmp likewise | |
1064 # /usr/tmp likewise | |
1065 # $prefix/lib where we will be installing things | |
1066 # $exec_prefix/lib likewise | |
1067 # eval it to expand exec_prefix. | |
1068 for ac_dir in `eval echo . /tmp /var/tmp /usr/tmp $prefix/lib $exec_prefix/lib` ; do | |
1069 test -d $ac_dir || continue | |
1070 test -w $ac_dir || continue # It's less confusing to not echo anything here. | |
1071 (echo 1 > $ac_dir/conftest9012345) 2>/dev/null | |
1072 (echo 2 > $ac_dir/conftest9012346) 2>/dev/null | |
1073 val=`cat $ac_dir/conftest9012345 2>/dev/null` | |
1074 test -f $ac_dir/conftest9012345 && test "$val" = 1 || ac_some_dir_failed=true | |
1075 rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2> /dev/null | |
1076 done | |
1077 $ac_some_dir_failed || AC_DEFINE(HAVE_LONG_FILE_NAMES) | |
1078 ])dnl | |
1079 dnl | |
1080 define(AC_RESTARTABLE_SYSCALLS, | |
1081 [AC_CHECKING(for restartable system calls) | |
1082 AC_TEST_PROGRAM( | |
1083 [/* Exit 0 (true) if wait returns something other than -1, | |
1084 i.e. the pid of the child, which means that wait was restarted | |
1085 after getting the signal. */ | |
1086 #include <sys/types.h> | |
1087 #include <signal.h> | |
1088 ucatch (isig) { } | |
1089 main () { | |
1090 int i = fork (), status; | |
1091 if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); } | |
1092 signal (SIGINT, ucatch); | |
1093 status = wait(&i); | |
1094 if (status == -1) wait(&i); | |
1095 exit (status == -1); | |
1096 } | |
1097 ], AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS)) | |
1098 ])dnl | |
1099 dnl | |
1100 define(AC_FIND_X, | |
1101 [AC_REQUIRE_CPP()dnl Set CPP; we run AC_FIND_X_DIRECT conditionally. | |
1102 AC_PROVIDE([$0])# If we find X, set shell vars x_includes and x_libraries to the paths. | |
1103 no_x=true | |
1104 if test "x$with_x" != xno; then | |
1105 AC_FIND_X_XMKMF | |
1106 if test -z "$ac_im_usrlibdir"; then | |
1107 AC_FIND_X_DIRECT | |
1108 fi | |
1109 test -n "$x_includes" && AC_VERBOSE(X11 headers are in $x_includes) | |
1110 test -n "$x_libraries" && AC_VERBOSE(X11 libraries are in $x_libraries) | |
1111 fi | |
1112 ])dnl | |
1113 dnl | |
1114 dnl Internal subroutine of AC_FIND_X. | |
1115 define(AC_FIND_X_XMKMF, | |
1116 [AC_CHECKING(for X include and library files with xmkmf) | |
1117 rm -fr conftestdir | |
1118 if mkdir conftestdir; then | |
1119 cd conftestdir | |
1120 # Make sure to not put "make" in the Imakefile rules, since we grep it out. | |
1121 cat > Imakefile <<'EOF' | |
1122 acfindx: | |
1123 @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' | |
1124 EOF | |
1125 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then | |
1126 no_x= | |
1127 # GNU make sometimes prints "make[1]: Entering...", which would confuse us. | |
1128 eval `make acfindx 2>/dev/null | grep -v make` | |
1129 # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. | |
1130 if test ! -f $ac_im_usrlibdir/libX11.a && test -f $ac_im_libdir/libX11.a | |
1131 then | |
1132 ac_im_usrlibdir=$ac_im_libdir | |
1133 fi | |
1134 case "$ac_im_incroot" in | |
1135 /usr/include) ;; | |
1136 *) test -z "$x_includes" && x_includes="$ac_im_incroot" ;; | |
1137 esac | |
1138 case "$ac_im_usrlibdir" in | |
1139 /usr/lib | /lib) ;; | |
1140 *) test -z "$x_libraries" && x_libraries="$ac_im_usrlibdir" ;; | |
1141 esac | |
1142 fi | |
1143 cd .. | |
1144 rm -fr conftestdir | |
1145 fi | |
1146 ])dnl | |
1147 dnl | |
1148 dnl Internal subroutine of AC_FIND_X. | |
1149 define(AC_FIND_X_DIRECT, | |
1150 [AC_CHECKING(for X include and library files directly) | |
1151 if test ".$x_direct_test_library" = . ; then | |
1152 x_direct_test_library='Xt' | |
1153 fi | |
1154 if test ".$x_direct_test_include" = . ; then | |
1155 x_direct_test_include='X11/Intrinsic.h' | |
1156 fi | |
1157 AC_TEST_CPP([#include <$x_direct_test_include>], no_x=, | |
1158 for ac_dir in \ | |
1159 /usr/X11R6/include \ | |
1160 /usr/X11R5/include \ | |
1161 /usr/X11R4/include \ | |
1162 \ | |
1163 /usr/include/X11R6 \ | |
1164 /usr/include/X11R5 \ | |
1165 /usr/include/X11R4 \ | |
1166 \ | |
1167 /usr/local/X11R6/include \ | |
1168 /usr/local/X11R5/include \ | |
1169 /usr/local/X11R4/include \ | |
1170 \ | |
1171 /usr/local/include/X11R6 \ | |
1172 /usr/local/include/X11R5 \ | |
1173 /usr/local/include/X11R4 \ | |
1174 \ | |
1175 /usr/X11/include \ | |
1176 /usr/include/X11 \ | |
1177 /usr/local/X11/include \ | |
1178 /usr/local/include/X11 \ | |
1179 \ | |
1180 /usr/X386/include \ | |
1181 /usr/x386/include \ | |
1182 /usr/XFree86/include/X11 \ | |
1183 \ | |
1184 /usr/include \ | |
1185 /usr/local/include \ | |
1186 /usr/unsupported/include \ | |
1187 /usr/athena/include \ | |
1188 /usr/local/x11r5/include \ | |
1189 /usr/lpp/Xamples/include \ | |
1190 \ | |
1191 /usr/openwin/include \ | |
1192 /usr/openwin/share/include \ | |
1193 ; \ | |
1194 do | |
1195 if test -r "$ac_dir/$x_direct_test_include"; then | |
1196 test -z "$x_includes" && x_includes=$ac_dir | |
1197 no_x= | |
1198 break | |
1199 fi | |
1200 done) | |
1201 | |
1202 # Check for the libraries. First see if replacing the `include' by | |
1203 # `lib' works. | |
1204 AC_HAVE_LIBRARY("$x_direct_test_library", no_x=, | |
1205 for ac_dir in `echo "$x_includes" | sed s/include/lib/` \ | |
1206 /usr/X11R6/lib \ | |
1207 /usr/X11R5/lib \ | |
1208 /usr/X11R4/lib \ | |
1209 \ | |
1210 /usr/lib/X11R6 \ | |
1211 /usr/lib/X11R5 \ | |
1212 /usr/lib/X11R4 \ | |
1213 \ | |
1214 /usr/local/X11R6/lib \ | |
1215 /usr/local/X11R5/lib \ | |
1216 /usr/local/X11R4/lib \ | |
1217 \ | |
1218 /usr/local/lib/X11R6 \ | |
1219 /usr/local/lib/X11R5 \ | |
1220 /usr/local/lib/X11R4 \ | |
1221 \ | |
1222 /usr/X11/lib \ | |
1223 /usr/lib/X11 \ | |
1224 /usr/local/X11/lib \ | |
1225 /usr/local/lib/X11 \ | |
1226 \ | |
1227 /usr/X386/lib \ | |
1228 /usr/x386/lib \ | |
1229 /usr/XFree86/lib/X11 \ | |
1230 \ | |
1231 /usr/lib \ | |
1232 /usr/local/lib \ | |
1233 /usr/unsupported/lib \ | |
1234 /usr/athena/lib \ | |
1235 /usr/local/x11r5/lib \ | |
1236 /usr/lpp/Xamples/lib \ | |
1237 \ | |
1238 /usr/openwin/lib \ | |
1239 /usr/openwin/share/lib \ | |
1240 ; \ | |
1241 do | |
1242 for ac_extension in a so sl; do | |
1243 if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then | |
1244 test -z "$x_libraries" && x_libraries=$ac_dir | |
1245 no_x= | |
1246 break 2 | |
1247 fi | |
1248 done | |
1249 done)])dnl | |
1250 dnl | |
1251 dnl Find additional X libraries, magic flags, etc. | |
1252 define(AC_FIND_XTRA, [AC_REQUIRE([AC_ISC_POSIX])AC_REQUIRE([AC_FIND_X]) | |
1253 AC_CHECKING(for additional X libraries and flags) | |
1254 if test -n "$x_includes"; then | |
1255 X_CFLAGS="$X_CFLAGS -I$x_includes" | |
1256 elif test -n "$no_x"; then | |
1257 # Not all programs may use this symbol, but it won't hurt to define it. | |
1258 X_CFLAGS="$X_CFLAGS -DX_DISPLAY_MISSING" | |
1259 fi | |
1260 | |
1261 # It would be nice to have a more robust check for the -R ld option than | |
1262 # just checking for Solaris. | |
1263 # It would also be nice to do this for all -L options, not just this one. | |
1264 if test -n "$x_libraries"; then | |
1265 X_LIBS="$X_LIBS -L$x_libraries" | |
1266 if test "`(uname) 2>/dev/null`" = SunOS \ | |
1267 && uname -r | grep '^5' >/dev/null; then | |
1268 X_LIBS="$X_LIBS -R$x_libraries" | |
1269 fi | |
1270 fi | |
1271 | |
1272 # Check for additional X libraries. | |
1273 | |
1274 if test -n "$ISC"; then | |
1275 X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet" | |
1276 else | |
1277 # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X | |
1278 # libraries were built with DECnet support. And karl@cs.umb.edu's Alpha | |
1279 # needs dnet_stub (dnet doesn't exist). | |
1280 AC_HAVE_LIBRARY(dnet, | |
1281 [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" | |
1282 ac_have_dnet=t]) | |
1283 if test -z "$ac_have_dnet"; then | |
1284 AC_HAVE_LIBRARY(dnet_stub, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"]) | |
1285 fi | |
1286 # lieder@skyler.mavd.honeywell.com says without -lsocket, | |
1287 # socket/setsockopt and other routines are undefined under SCO ODT 2.0. | |
1288 # But -lsocket is broken on IRIX, according to simon@lia.di.epfl.ch. | |
1289 if test "`(uname) 2>/dev/null`" != IRIX; then | |
1290 AC_HAVE_LIBRARY(socket, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lsocket"]) | |
1291 fi | |
1292 fi | |
1293 # | |
1294 AC_VERBOSE(X compiler flags: $X_CFLAGS) | |
1295 AC_VERBOSE(X library flags: $X_LIBS) | |
1296 AC_VERBOSE(extra X libraries: $X_EXTRA_LIBS) | |
1297 AC_SUBST(X_CFLAGS)dnl | |
1298 AC_SUBST(X_LIBS)dnl | |
1299 AC_SUBST(X_EXTRA_LIBS)dnl | |
1300 ])dnl | |
1301 dnl | |
1302 dnl | |
1303 dnl checks for UNIX variants | |
1304 dnl | |
1305 dnl | |
1306 define(AC_AIX, | |
1307 [AC_CHECKING(for AIX) | |
1308 AC_BEFORE([$0], [AC_COMPILE_CHECK])AC_BEFORE([$0], [AC_TEST_PROGRAM])AC_BEFORE([$0], [AC_HEADER_EGREP])AC_BEFORE([$0], [AC_TEST_CPP])AC_PROGRAM_EGREP(yes, | |
1309 [#ifdef _AIX | |
1310 yes | |
1311 #endif | |
1312 ], AC_DEFINE(_ALL_SOURCE)) | |
1313 ])dnl | |
1314 dnl | |
1315 define(AC_MINIX, | |
1316 [AC_BEFORE([$0], [AC_COMPILE_CHECK])AC_BEFORE([$0], [AC_TEST_PROGRAM])AC_BEFORE([$0], [AC_HEADER_EGREP])AC_BEFORE([$0], [AC_TEST_CPP])AC_HEADER_CHECK(minix/config.h, MINIX=1) | |
1317 # The Minix shell can't assign to the same variable on the same line! | |
1318 if test -n "$MINIX"; then | |
1319 AC_DEFINE(_POSIX_SOURCE) | |
1320 AC_DEFINE(_POSIX_1_SOURCE, 2) | |
1321 AC_DEFINE(_MINIX) | |
1322 fi | |
1323 ])dnl | |
1324 dnl | |
1325 define(AC_ISC_POSIX, | |
1326 [AC_PROVIDE([$0])AC_BEFORE([$0], [AC_COMPILE_CHECK])AC_BEFORE([$0], [AC_TEST_PROGRAM])AC_BEFORE([$0], [AC_HEADER_EGREP])AC_BEFORE([$0], [AC_TEST_CPP])AC_CHECKING(for POSIXized ISC) | |
1327 if test -d /etc/conf/kconfig.d && | |
1328 grep _POSIX_VERSION [/usr/include/sys/unistd.h] >/dev/null 2>&1 | |
1329 then | |
1330 ISC=1 # If later tests want to check for ISC. | |
1331 AC_DEFINE(_POSIX_SOURCE) | |
1332 if test -n "$GCC"; then | |
1333 CC="$CC -posix" | |
1334 else | |
1335 CC="$CC -Xp" | |
1336 fi | |
1337 fi | |
1338 ])dnl | |
1339 dnl | |
1340 define(AC_XENIX_DIR, | |
1341 [AC_REQUIRE([AC_DIR_HEADER])AC_CHECKING(for Xenix) | |
1342 AC_PROGRAM_EGREP(yes, | |
1343 [#if defined(M_XENIX) && !defined(M_UNIX) | |
1344 yes | |
1345 #endif | |
1346 ], XENIX=1) | |
1347 if test -n "$XENIX"; then | |
1348 LIBS="$LIBS -lx" | |
1349 case "$DEFS" in | |
1350 *SYSNDIR*) ;; | |
1351 *) LIBS="-ldir $LIBS" ;; # Make sure -ldir precedes any -lx. | |
1352 esac | |
1353 fi | |
1354 ])dnl | |
1355 dnl | |
1356 define(AC_SCO_INTL, | |
1357 [AC_HAVE_LIBRARY(intl, LIBS="$LIBS -lintl") | |
1358 ])dnl | |
1359 dnl | |
1360 define(AC_IRIX_SUN, | |
1361 [AC_HAVE_LIBRARY(sun, LIBS="$LIBS -lsun") | |
1362 ])dnl | |
1363 dnl | |
1364 define(AC_DYNIX_SEQ, | |
1365 [AC_HAVE_LIBRARY(seq, LIBS="$LIBS -lseq") | |
1366 ])dnl | |
1367 dnl | |
1368 define(AC_STAT_MACROS_BROKEN,[AC_CHECKING(for broken stat file mode macros) | |
1369 AC_PROGRAM_EGREP([You lose], [#include <sys/types.h> | |
1370 #include <sys/stat.h> | |
1371 #ifdef S_ISBLK | |
1372 #if S_ISBLK (S_IFDIR) | |
1373 You lose. | |
1374 #endif | |
1375 #ifdef S_IFCHR | |
1376 #if S_ISBLK (S_IFCHR) | |
1377 You lose. | |
1378 #endif | |
1379 #endif /* S_IFCHR */ | |
1380 #endif /* S_ISBLK */ | |
1381 #ifdef S_ISLNK | |
1382 #if S_ISLNK (S_IFREG) | |
1383 You lose. | |
1384 #endif | |
1385 #endif /* S_ISLNK */ | |
1386 #ifdef S_ISSOCK | |
1387 #if S_ISSOCK (S_IFREG) | |
1388 You lose. | |
1389 #endif | |
1390 #endif /* S_ISSOCK */ | |
1391 ], AC_DEFINE(STAT_MACROS_BROKEN))])dnl | |
1392 dnl | |
1393 dnl | |
1394 define(AC_SYS_SIGLIST_DECLARED,[dnl | |
1395 AC_COMPILE_CHECK(sys_siglist declaration in signal.h or unistd.h, | |
1396 [#include <signal.h> | |
1397 /* NetBSD declares sys_siglist in <unistd.h>. */ | |
1398 #ifdef HAVE_UNISTD_H | |
1399 #include <unistd.h> | |
1400 #endif], [char *msg = *(sys_siglist + 1);], | |
1401 AC_DEFINE(SYS_SIGLIST_DECLARED))])dnl | |
1402 dnl |