Commit | Line | Data |
---|---|---|
d60d9f65 SS |
1 | dnl |
2 | dnl Bash specific tests | |
3 | dnl | |
4 | dnl Some derived from PDKSH 5.1.3 autoconf tests | |
5 | dnl | |
6 | dnl | |
7 | dnl Check if dup2() does not clear the close on exec flag | |
8 | dnl | |
9 | AC_DEFUN(BASH_DUP2_CLOEXEC_CHECK, | |
10 | [AC_MSG_CHECKING(if dup2 fails to clear the close-on-exec flag) | |
11 | AC_CACHE_VAL(bash_cv_dup2_broken, | |
12 | [AC_TRY_RUN([ | |
13 | #include <sys/types.h> | |
14 | #include <fcntl.h> | |
15 | main() | |
16 | { | |
17 | int fd1, fd2, fl; | |
18 | fd1 = open("/dev/null", 2); | |
19 | if (fcntl(fd1, 2, 1) < 0) | |
20 | exit(1); | |
21 | fd2 = dup2(fd1, 1); | |
22 | if (fd2 < 0) | |
23 | exit(2); | |
24 | fl = fcntl(fd2, 1, 0); | |
25 | /* fl will be 1 if dup2 did not reset the close-on-exec flag. */ | |
26 | exit(fl != 1); | |
27 | } | |
28 | ], bash_cv_dup2_broken=yes, bash_cv_dup2_broken=no, | |
29 | [AC_MSG_ERROR(cannot check dup2 if cross compiling -- defaulting to no) | |
30 | bash_cv_dup2_broken=no]) | |
31 | ]) | |
32 | AC_MSG_RESULT($bash_cv_dup2_broken) | |
33 | if test $bash_cv_dup2_broken = yes; then | |
34 | AC_DEFINE(DUP2_BROKEN) | |
35 | fi | |
36 | ]) | |
37 | ||
38 | dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7) | |
39 | AC_DEFUN(BASH_SIGNAL_CHECK, | |
40 | [AC_REQUIRE([AC_TYPE_SIGNAL]) | |
41 | AC_MSG_CHECKING(for type of signal functions) | |
42 | AC_CACHE_VAL(bash_cv_signal_vintage, | |
43 | [ | |
44 | AC_TRY_LINK([#include <signal.h>],[ | |
45 | sigset_t ss; | |
46 | struct sigaction sa; | |
47 | sigemptyset(&ss); sigsuspend(&ss); | |
48 | sigaction(SIGINT, &sa, (struct sigaction *) 0); | |
49 | sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0); | |
50 | ], bash_cv_signal_vintage=posix, | |
51 | [ | |
52 | AC_TRY_LINK([#include <signal.h>], [ | |
53 | int mask = sigmask(SIGINT); | |
54 | sigsetmask(mask); sigblock(mask); sigpause(mask); | |
55 | ], bash_cv_signal_vintage=4.2bsd, | |
56 | [ | |
57 | AC_TRY_LINK([ | |
58 | #include <signal.h> | |
59 | RETSIGTYPE foo() { }], [ | |
60 | int mask = sigmask(SIGINT); | |
61 | sigset(SIGINT, foo); sigrelse(SIGINT); | |
62 | sighold(SIGINT); sigpause(SIGINT); | |
63 | ], bash_cv_signal_vintage=svr3, bash_cv_signal_vintage=v7 | |
64 | )] | |
65 | )] | |
66 | ) | |
67 | ]) | |
68 | AC_MSG_RESULT($bash_cv_signal_vintage) | |
69 | if test "$bash_cv_signal_vintage" = posix; then | |
70 | AC_DEFINE(HAVE_POSIX_SIGNALS) | |
71 | elif test "$bash_cv_signal_vintage" = "4.2bsd"; then | |
72 | AC_DEFINE(HAVE_BSD_SIGNALS) | |
73 | elif test "$bash_cv_signal_vintage" = svr3; then | |
74 | AC_DEFINE(HAVE_USG_SIGHOLD) | |
75 | fi | |
76 | ]) | |
77 | ||
78 | dnl Check if the pgrp of setpgrp() can't be the pid of a zombie process. | |
79 | AC_DEFUN(BASH_PGRP_SYNC, | |
80 | [AC_REQUIRE([AC_FUNC_GETPGRP]) | |
81 | AC_MSG_CHECKING(whether pgrps need synchronization) | |
82 | AC_CACHE_VAL(bash_cv_pgrp_pipe, | |
83 | [AC_TRY_RUN([ | |
84 | #ifdef HAVE_UNISTD_H | |
85 | # include <unistd.h> | |
86 | #endif | |
87 | main() | |
88 | { | |
89 | # ifdef GETPGRP_VOID | |
90 | # define getpgID() getpgrp() | |
91 | # else | |
92 | # define getpgID() getpgrp(0) | |
93 | # define setpgid(x,y) setpgrp(x,y) | |
94 | # endif | |
95 | int pid1, pid2, fds[2]; | |
96 | int status; | |
97 | char ok; | |
98 | ||
99 | switch (pid1 = fork()) { | |
100 | case -1: | |
101 | exit(1); | |
102 | case 0: | |
103 | setpgid(0, getpid()); | |
104 | exit(0); | |
105 | } | |
106 | setpgid(pid1, pid1); | |
107 | ||
108 | sleep(2); /* let first child die */ | |
109 | ||
110 | if (pipe(fds) < 0) | |
111 | exit(2); | |
112 | ||
113 | switch (pid2 = fork()) { | |
114 | case -1: | |
115 | exit(3); | |
116 | case 0: | |
117 | setpgid(0, pid1); | |
118 | ok = getpgID() == pid1; | |
119 | write(fds[1], &ok, 1); | |
120 | exit(0); | |
121 | } | |
122 | setpgid(pid2, pid1); | |
123 | ||
124 | close(fds[1]); | |
125 | if (read(fds[0], &ok, 1) != 1) | |
126 | exit(4); | |
127 | wait(&status); | |
128 | wait(&status); | |
129 | exit(ok ? 0 : 5); | |
130 | } | |
131 | ], bash_cv_pgrp_pipe=no,bash_cv_pgrp_pipe=yes, | |
132 | [AC_MSG_ERROR(cannot check pgrp synchronization if cross compiling -- defaulting to no) | |
133 | bash_cv_pgrp_pipe=no]) | |
134 | ]) | |
135 | AC_MSG_RESULT($bash_cv_pgrp_pipe) | |
136 | if test $bash_cv_pgrp_pipe = yes; then | |
137 | AC_DEFINE(PGRP_PIPE) | |
138 | fi | |
139 | ]) | |
140 | ||
141 | dnl | |
142 | dnl check for typedef'd symbols in header files, but allow the caller to | |
143 | dnl specify the include files to be checked in addition to the default | |
144 | dnl | |
145 | dnl BASH_CHECK_TYPE(TYPE, HEADERS, DEFAULT[, VALUE-IF-FOUND]) | |
146 | AC_DEFUN(BASH_CHECK_TYPE, | |
147 | [AC_REQUIRE([AC_HEADER_STDC])dnl | |
148 | AC_MSG_CHECKING(for $1) | |
149 | AC_CACHE_VAL(bash_cv_type_$1, | |
150 | [AC_EGREP_CPP($1, [#include <sys/types.h> | |
151 | #if STDC_HEADERS | |
152 | #include <stdlib.h> | |
153 | #endif | |
154 | $2 | |
155 | ], bash_cv_type_$1=yes, bash_cv_type_$1=no)]) | |
156 | AC_MSG_RESULT($bash_cv_type_$1) | |
157 | ifelse($#, 4, [if test $bash_cv_type_$1 = yes; then | |
158 | AC_DEFINE($4) | |
159 | fi]) | |
160 | if test $bash_cv_type_$1 = no; then | |
161 | AC_DEFINE($1, $3) | |
162 | fi | |
163 | ]) | |
164 | ||
165 | dnl | |
166 | dnl Type of struct rlimit fields: some systems (OSF/1, NetBSD, RISC/os 5.0) | |
167 | dnl have a rlim_t, others (4.4BSD based systems) use quad_t, others use | |
168 | dnl long and still others use int (HP-UX 9.01, SunOS 4.1.3). To simplify | |
169 | dnl matters, this just checks for rlim_t, quad_t, or long. | |
170 | dnl | |
171 | AC_DEFUN(BASH_RLIMIT_TYPE, | |
172 | [AC_MSG_CHECKING(for size and type of struct rlimit fields) | |
173 | AC_CACHE_VAL(bash_cv_type_rlimit, | |
174 | [AC_TRY_COMPILE([#include <sys/types.h> | |
175 | #include <sys/resource.h>], | |
176 | [rlim_t xxx;], bash_cv_type_rlimit=rlim_t,[ | |
177 | AC_TRY_RUN([ | |
178 | #include <sys/types.h> | |
179 | #include <sys/time.h> | |
180 | #include <sys/resource.h> | |
181 | main() | |
182 | { | |
183 | #ifdef HAVE_QUAD_T | |
184 | struct rlimit rl; | |
185 | if (sizeof(rl.rlim_cur) == sizeof(quad_t)) | |
186 | exit(0); | |
187 | #endif | |
188 | exit(1); | |
189 | }], bash_cv_type_rlimit=quad_t, bash_cv_type_rlimit=long, | |
190 | [AC_MSG_ERROR(cannot check quad_t if cross compiling -- defaulting to long) | |
191 | bash_cv_type_rlimit=long])]) | |
192 | ]) | |
193 | AC_MSG_RESULT($bash_cv_type_rlimit) | |
194 | if test $bash_cv_type_rlimit = quad_t; then | |
195 | AC_DEFINE(RLIMTYPE, quad_t) | |
196 | elif test $bash_cv_type_rlimit = rlim_t; then | |
197 | AC_DEFINE(RLIMTYPE, rlim_t) | |
198 | fi | |
199 | ]) | |
200 | ||
201 | dnl | |
202 | dnl Check for sys_siglist[] or _sys_siglist[] | |
203 | dnl | |
204 | AC_DEFUN(BASH_DECL_UNDER_SYS_SIGLIST, | |
205 | [AC_MSG_CHECKING([for _sys_siglist in signal.h or unistd.h]) | |
206 | AC_CACHE_VAL(bash_cv_decl_under_sys_siglist, | |
207 | [AC_TRY_COMPILE([ | |
208 | #include <sys/types.h> | |
209 | #include <signal.h> | |
210 | #ifdef HAVE_UNISTD_H | |
211 | #include <unistd.h> | |
212 | #endif], [ char *msg = _sys_siglist[2]; ], | |
213 | bash_cv_decl_under_sys_siglist=yes, bash_cv_decl_under_sys_siglist=no, | |
214 | [AC_MSG_ERROR(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)])])dnl | |
215 | AC_MSG_RESULT($bash_cv_decl_under_sys_siglist) | |
216 | if test $bash_cv_decl_under_sys_siglist = yes; then | |
217 | AC_DEFINE(UNDER_SYS_SIGLIST_DECLARED) | |
218 | fi | |
219 | ]) | |
220 | ||
221 | AC_DEFUN(BASH_UNDER_SYS_SIGLIST, | |
222 | [AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST]) | |
223 | AC_MSG_CHECKING([for _sys_siglist in system C library]) | |
224 | AC_CACHE_VAL(bash_cv_under_sys_siglist, | |
225 | [AC_TRY_RUN([ | |
226 | #include <sys/types.h> | |
227 | #include <signal.h> | |
228 | #ifdef HAVE_UNISTD_H | |
229 | #include <unistd.h> | |
230 | #endif | |
231 | #ifndef UNDER_SYS_SIGLIST_DECLARED | |
232 | extern char *_sys_siglist[]; | |
233 | #endif | |
234 | main() | |
235 | { | |
236 | char *msg = (char *)_sys_siglist[2]; | |
237 | exit(msg == 0); | |
238 | }], | |
239 | bash_cv_under_sys_siglist=yes, bash_cv_under_sys_siglist=no, | |
240 | [AC_MSG_ERROR(cannot check for _sys_siglist[] if cross compiling -- defaulting to no) | |
241 | bash_cv_under_sys_siglist=no])]) | |
242 | AC_MSG_RESULT($bash_cv_under_sys_siglist) | |
243 | if test $bash_cv_under_sys_siglist = yes; then | |
244 | AC_DEFINE(HAVE_UNDER_SYS_SIGLIST) | |
245 | fi | |
246 | ]) | |
247 | ||
248 | AC_DEFUN(BASH_SYS_SIGLIST, | |
249 | [AC_REQUIRE([AC_DECL_SYS_SIGLIST]) | |
250 | AC_MSG_CHECKING([for sys_siglist in system C library]) | |
251 | AC_CACHE_VAL(bash_cv_sys_siglist, | |
252 | [AC_TRY_RUN([ | |
253 | #include <sys/types.h> | |
254 | #include <signal.h> | |
255 | #ifdef HAVE_UNISTD_H | |
256 | #include <unistd.h> | |
257 | #endif | |
258 | #ifndef SYS_SIGLIST_DECLARED | |
259 | extern char *sys_siglist[]; | |
260 | #endif | |
261 | main() | |
262 | { | |
263 | char *msg = sys_siglist[2]; | |
264 | exit(msg == 0); | |
265 | }], | |
266 | bash_cv_sys_siglist=yes, bash_cv_sys_siglist=no, | |
267 | [AC_MSG_ERROR(cannot check for sys_siglist if cross compiling -- defaulting to no) | |
268 | bash_cv_sys_siglist=no])]) | |
269 | AC_MSG_RESULT($bash_cv_sys_siglist) | |
270 | if test $bash_cv_sys_siglist = yes; then | |
271 | AC_DEFINE(HAVE_SYS_SIGLIST) | |
272 | fi | |
273 | ]) | |
274 | ||
275 | dnl Check for sys_errlist[] and sys_nerr, check for declaration | |
276 | AC_DEFUN(BASH_SYS_ERRLIST, | |
277 | [AC_MSG_CHECKING([for sys_errlist and sys_nerr]) | |
278 | AC_CACHE_VAL(bash_cv_sys_errlist, | |
279 | [AC_TRY_LINK([#include <errno.h>], | |
280 | [extern char *sys_errlist[]; | |
281 | extern int sys_nerr; | |
282 | char *msg = sys_errlist[sys_nerr - 1];], | |
283 | bash_cv_sys_errlist=yes, bash_cv_sys_errlist=no)])dnl | |
284 | AC_MSG_RESULT($bash_cv_sys_errlist) | |
285 | if test $bash_cv_sys_errlist = yes; then | |
286 | AC_DEFINE(HAVE_SYS_ERRLIST) | |
287 | fi | |
288 | ]) | |
289 | ||
290 | dnl Check to see if opendir will open non-directories (not a nice thing) | |
291 | AC_DEFUN(BASH_FUNC_OPENDIR_CHECK, | |
292 | [AC_REQUIRE([AC_HEADER_DIRENT])dnl | |
293 | AC_MSG_CHECKING(if opendir() opens non-directories) | |
294 | AC_CACHE_VAL(bash_cv_opendir_not_robust, | |
295 | [AC_TRY_RUN([ | |
296 | #include <stdio.h> | |
297 | #include <sys/types.h> | |
298 | #include <fcntl.h> | |
299 | #ifdef HAVE_UNISTD_H | |
300 | # include <unistd.h> | |
301 | #endif /* HAVE_UNISTD_H */ | |
302 | #if defined(HAVE_DIRENT_H) | |
303 | # include <dirent.h> | |
304 | #else | |
305 | # define dirent direct | |
306 | # ifdef HAVE_SYS_NDIR_H | |
307 | # include <sys/ndir.h> | |
308 | # endif /* SYSNDIR */ | |
309 | # ifdef HAVE_SYS_DIR_H | |
310 | # include <sys/dir.h> | |
311 | # endif /* SYSDIR */ | |
312 | # ifdef HAVE_NDIR_H | |
313 | # include <ndir.h> | |
314 | # endif | |
315 | #endif /* HAVE_DIRENT_H */ | |
316 | main() | |
317 | { | |
318 | DIR *dir; | |
319 | int fd; | |
320 | unlink("/tmp/not_a_directory"); | |
321 | fd = open("/tmp/not_a_directory", O_WRONLY|O_CREAT, 0666); | |
322 | write(fd, "\n", 1); | |
323 | close(fd); | |
324 | dir = opendir("/tmp/not_a_directory"); | |
325 | unlink("/tmp/not_a_directory"); | |
326 | exit (dir == 0); | |
327 | }], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no, | |
328 | [AC_MSG_ERROR(cannot check opendir if cross compiling -- defaulting to no) | |
329 | bash_cv_opendir_not_robust=no] | |
330 | )]) | |
331 | AC_MSG_RESULT($bash_cv_opendir_not_robust) | |
332 | if test $bash_cv_opendir_not_robust = yes; then | |
333 | AC_DEFINE(OPENDIR_NOT_ROBUST) | |
334 | fi | |
335 | ]) | |
336 | ||
337 | dnl | |
338 | AC_DEFUN(BASH_TYPE_SIGHANDLER, | |
339 | [AC_MSG_CHECKING([whether signal handlers are of type void]) | |
340 | AC_CACHE_VAL(bash_cv_void_sighandler, | |
341 | [AC_TRY_COMPILE([#include <sys/types.h> | |
342 | #include <signal.h> | |
343 | #ifdef signal | |
344 | #undef signal | |
345 | #endif | |
346 | #ifdef __cplusplus | |
347 | extern "C" | |
348 | #endif | |
349 | void (*signal ()) ();], | |
350 | [int i;], bash_cv_void_sighandler=yes, bash_cv_void_sighandler=no)])dnl | |
351 | AC_MSG_RESULT($bash_cv_void_sighandler) | |
352 | if test $bash_cv_void_sighandler = yes; then | |
353 | AC_DEFINE(VOID_SIGHANDLER) | |
354 | fi | |
355 | ]) | |
356 | ||
357 | AC_DEFUN(BASH_TYPE_INT32_T, | |
358 | [ | |
359 | if test "X$bash_cv_type_int32_t" = "X"; then | |
360 | _bash_needmsg=yes | |
361 | else | |
362 | AC_MSG_CHECKING(which builtin C type is 32 bits wide) | |
363 | _bash_needmsg= | |
364 | fi | |
365 | AC_CACHE_VAL(bash_cv_type_int32_t, | |
366 | [AC_TRY_RUN([ | |
367 | main() | |
368 | { | |
369 | #if SIZEOF_INT == 4 | |
370 | exit (0); | |
371 | #else | |
372 | # if SIZEOF_LONG == 4 | |
373 | exit (1); | |
374 | # else | |
375 | # error cannot find 32 bit type... | |
376 | # endif | |
377 | #endif | |
378 | }], bash_cv_type_int32_t=int, bash_cv_type_int32_t=long, | |
379 | [AC_MSG_ERROR(cannot check type sizes if cross-compiling -- defaulting to int) | |
380 | bash_cv_type_int32_t=int] | |
381 | )]) | |
382 | if test "X$_bash_needmsg" = "Xyes"; then | |
383 | AC_MSG_CHECKING(which builtin C type is 32 bits wide) | |
384 | fi | |
385 | AC_MSG_RESULT($bash_cv_type_int32_t); | |
386 | if test "$bash_cv_type_int32_t" = "int"; then | |
387 | AC_DEFINE(int32_t, int) | |
388 | else | |
389 | AC_DEFINE(int32_t, long) | |
390 | fi | |
391 | ]) | |
392 | ||
393 | AC_DEFUN(BASH_TYPE_U_INT32_T, | |
394 | [ | |
395 | if test "X$bash_cv_type_u_int32_t" = "X"; then | |
396 | _bash_needmsg=yes | |
397 | else | |
398 | AC_MSG_CHECKING(which unsigned builtin C type is 32 bits wide) | |
399 | _bash_needmsg= | |
400 | fi | |
401 | AC_CACHE_VAL(bash_cv_type_u_int32_t, | |
402 | [AC_TRY_RUN([ | |
403 | main() | |
404 | { | |
405 | #if SIZEOF_INT == 4 | |
406 | exit (0); | |
407 | #else | |
408 | # if SIZEOF_LONG == 4 | |
409 | exit (1); | |
410 | # else | |
411 | # error cannot find 32 bit type... | |
412 | # endif | |
413 | #endif | |
414 | }], bash_cv_type_u_int32_t=int, bash_cv_type_u_int32_t=long, | |
415 | [AC_MSG_ERROR(cannot check type sizes if cross-compiling -- defaulting to int) | |
416 | bash_cv_type_u_int32_t=int] | |
417 | )]) | |
418 | if test "X$_bash_needmsg" = "Xyes"; then | |
419 | AC_MSG_CHECKING(which unsigned builtin C type is 32 bits wide) | |
420 | fi | |
421 | AC_MSG_RESULT($bash_cv_type_u_int32_t); | |
422 | if test "$bash_cv_type_u_int32_t" = "int"; then | |
423 | AC_DEFINE(u_int32_t, unsigned int) | |
424 | else | |
425 | AC_DEFINE(u_int32_t, unsigned long) | |
426 | fi | |
427 | ]) | |
428 | ||
429 | AC_DEFUN(BASH_TYPE_PTRDIFF_T, | |
430 | [ | |
431 | if test "X$bash_cv_type_ptrdiff_t" = "X"; then | |
432 | _bash_needmsg=yes | |
433 | else | |
434 | AC_MSG_CHECKING(which builtin C type is correct for ptrdiff_t) | |
435 | _bash_needmsg= | |
436 | fi | |
437 | AC_CACHE_VAL(bash_cv_type_ptrdiff_t, | |
438 | [AC_TRY_RUN([ | |
439 | main() | |
440 | { | |
441 | #if SIZEOF_CHAR_P == SIZEOF_INT | |
442 | exit (0); | |
443 | #else | |
444 | # if SIZEOF_CHAR_P == SIZEOF_LONG | |
445 | exit (1); | |
446 | # else | |
447 | # error cannot find type for pointer arithmetic... | |
448 | # endif | |
449 | #endif | |
450 | }], bash_cv_type_ptrdiff_t=int, bash_cv_type_ptrdiff_t=long, | |
451 | [AC_MSG_ERROR(cannot check type sizes if cross-compiling -- defaulting to int) | |
452 | bash_cv_type_ptrdiff_t=int] | |
453 | )]) | |
454 | if test "X$_bash_needmsg" = "Xyes"; then | |
455 | AC_MSG_CHECKING(which builtin C type is correct for ptrdiff_t) | |
456 | fi | |
457 | AC_MSG_RESULT($bash_cv_type_ptrdiff_t); | |
458 | if test "$bash_cv_type_ptrdiff_t" = "int"; then | |
459 | AC_DEFINE(ptrdiff_t, int) | |
460 | else | |
461 | AC_DEFINE(ptrdiff_t, long) | |
462 | fi | |
463 | ]) | |
464 | ||
465 | AC_DEFUN(BASH_FUNC_STRSIGNAL, | |
466 | [AC_MSG_CHECKING([for the existence of strsignal]) | |
467 | AC_CACHE_VAL(bash_cv_have_strsignal, | |
468 | [AC_TRY_LINK([#include <sys/types.h> | |
469 | #include <signal.h>], | |
470 | [char *s = (char *)strsignal(2);], | |
471 | bash_cv_have_strsignal=yes, bash_cv_have_strsignal=no)]) | |
472 | AC_MSG_RESULT($bash_cv_have_strsignal) | |
473 | if test $bash_cv_have_strsignal = yes; then | |
474 | AC_DEFINE(HAVE_STRSIGNAL) | |
475 | fi | |
476 | ]) | |
477 | ||
478 | AC_DEFUN(BASH_FUNC_LSTAT, | |
479 | [dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an | |
480 | dnl inline function in <sys/stat.h>. | |
481 | AC_CACHE_CHECK([for lstat], bash_cv_func_lstat, | |
482 | [AC_TRY_LINK([ | |
483 | #include <sys/types.h> | |
484 | #include <sys/stat.h> | |
485 | ],[ lstat(".",(struct stat *)0); ], | |
486 | bash_cv_func_lstat=yes, bash_cv_func_lstat=no)]) | |
487 | if test $bash_cv_func_lstat = yes; then | |
488 | AC_DEFINE(HAVE_LSTAT) | |
489 | fi | |
490 | ]) | |
491 | ||
492 | AC_DEFUN(BASH_STRUCT_TERMIOS_LDISC, | |
493 | [AC_MSG_CHECKING([for a c_line member of struct termios]) | |
494 | AC_CACHE_VAL(bash_cv_termios_ldisc, | |
495 | [AC_TRY_COMPILE([#include <sys/types.h> | |
496 | #include <termios.h>],[struct termios t; int i; i = t.c_line;], | |
497 | bash_cv_termios_ldisc=yes, bash_cv_termios_ldisc=no)])dnl | |
498 | AC_MSG_RESULT($bash_cv_termios_ldisc) | |
499 | if test $bash_cv_termios_ldisc = yes; then | |
500 | AC_DEFINE(TERMIOS_LDISC) | |
501 | fi | |
502 | ]) | |
503 | ||
504 | AC_DEFUN(BASH_STRUCT_TERMIO_LDISC, | |
505 | [AC_MSG_CHECKING([for a c_line member of struct termio]) | |
506 | AC_CACHE_VAL(bash_cv_termio_ldisc, | |
507 | [AC_TRY_COMPILE([#include <sys/types.h> | |
508 | #include <termio.h>],[struct termio t; int i; i = t.c_line;], | |
509 | bash_cv_termio_ldisc=yes, bash_cv_termio_ldisc=no)])dnl | |
510 | AC_MSG_RESULT($bash_cv_termio_ldisc) | |
511 | if test $bash_cv_termio_ldisc = yes; then | |
512 | AC_DEFINE(TERMIO_LDISC) | |
513 | fi | |
514 | ]) | |
515 | ||
516 | AC_DEFUN(BASH_FUNC_GETENV, | |
517 | [AC_MSG_CHECKING(to see if getenv can be redefined) | |
518 | AC_CACHE_VAL(bash_cv_getenv_redef, | |
519 | [AC_TRY_RUN([ | |
520 | #ifdef HAVE_UNISTD_H | |
521 | # include <unistd.h> | |
522 | #endif | |
523 | #ifndef __STDC__ | |
524 | # ifndef const | |
525 | # define const | |
526 | # endif | |
527 | #endif | |
528 | char * | |
529 | getenv (name) | |
530 | #if defined (__linux__) || defined (__bsdi__) || defined (convex) | |
531 | const char *name; | |
532 | #else | |
533 | char const *name; | |
534 | #endif /* !__linux__ && !__bsdi__ && !convex */ | |
535 | { | |
536 | return "42"; | |
537 | } | |
538 | main() | |
539 | { | |
540 | char *s; | |
541 | /* The next allows this program to run, but does not allow bash to link | |
542 | when it redefines getenv. I'm not really interested in figuring out | |
543 | why not. */ | |
544 | #if defined (NeXT) | |
545 | exit(1); | |
546 | #endif | |
547 | s = getenv("ABCDE"); | |
548 | exit(s == 0); /* force optimizer to leave getenv in */ | |
549 | } | |
550 | ], bash_cv_getenv_redef=yes, bash_cv_getenv_redef=no, | |
551 | [AC_MSG_ERROR(cannot check getenv redefinition if cross compiling -- defaulting to yes) | |
552 | bash_cv_getenv_redef=yes] | |
553 | )]) | |
554 | AC_MSG_RESULT($bash_cv_getenv_redef) | |
555 | if test $bash_cv_getenv_redef = yes; then | |
556 | AC_DEFINE(CAN_REDEFINE_GETENV) | |
557 | fi | |
558 | ]) | |
559 | ||
560 | AC_DEFUN(BASH_FUNC_PRINTF, | |
561 | [AC_MSG_CHECKING(for declaration of printf in <stdio.h>) | |
562 | AC_CACHE_VAL(bash_cv_printf_declared, | |
563 | [AC_TRY_RUN([ | |
564 | #include <stdio.h> | |
565 | #ifdef __STDC__ | |
566 | typedef int (*_bashfunc)(const char *, ...); | |
567 | #else | |
568 | typedef int (*_bashfunc)(); | |
569 | #endif | |
570 | main() | |
571 | { | |
572 | _bashfunc pf; | |
573 | pf = (_bashfunc) printf; | |
574 | exit(pf == 0); | |
575 | } | |
576 | ], bash_cv_printf_declared=yes, bash_cv_printf_declared=no, | |
577 | [AC_MSG_ERROR(cannot check printf declaration if cross compiling -- defaulting to yes) | |
578 | bash_cv_printf_declared=yes] | |
579 | )]) | |
580 | AC_MSG_RESULT($bash_cv_printf_declared) | |
581 | if test $bash_cv_printf_declared = yes; then | |
582 | AC_DEFINE(PRINTF_DECLARED) | |
583 | fi | |
584 | ]) | |
585 | ||
586 | AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS, | |
587 | [AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize) | |
588 | AC_CACHE_VAL(bash_cv_ulimit_maxfds, | |
589 | [AC_TRY_RUN([ | |
590 | main() | |
591 | { | |
592 | long maxfds = ulimit(4, 0L); | |
593 | exit (maxfds == -1L); | |
594 | } | |
595 | ], bash_cv_ulimit_maxfds=yes, bash_cv_ulimit_maxfds=no, | |
596 | [AC_MSG_ERROR(cannot check ulimit if cross compiling -- defaulting to no) | |
597 | bash_cv_ulimit_maxfds=no] | |
598 | )]) | |
599 | AC_MSG_RESULT($bash_cv_ulimit_maxfds) | |
600 | if test $bash_cv_ulimit_maxfds = yes; then | |
601 | AC_DEFINE(ULIMIT_MAXFDS) | |
602 | fi | |
603 | ]) | |
604 | ||
605 | AC_DEFUN(BASH_CHECK_LIB_TERMCAP, | |
606 | [ | |
607 | if test "X$bash_cv_termcap_lib" = "X"; then | |
608 | _bash_needmsg=yes | |
609 | else | |
610 | AC_MSG_CHECKING(which library has the termcap functions) | |
611 | _bash_needmsg= | |
612 | fi | |
613 | AC_CACHE_VAL(bash_cv_termcap_lib, | |
614 | [AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap, | |
615 | [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses, | |
616 | [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses, | |
617 | bash_cv_termcap_lib=gnutermcap)])])]) | |
618 | if test "X$_bash_needmsg" = "Xyes"; then | |
619 | AC_MSG_CHECKING(which library has the termcap functions) | |
620 | fi | |
621 | AC_MSG_RESULT(using $bash_cv_termcap_lib) | |
622 | if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then | |
623 | LDFLAGS="$LDFLAGS -L./lib/termcap" | |
624 | TERMCAP_LIB="./lib/termcap/libtermcap.a" | |
625 | TERMCAP_DEP="./lib/termcap/libtermcap.a" | |
626 | elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then | |
627 | TERMCAP_LIB=-ltermcap | |
628 | TERMCAP_DEP= | |
629 | elif test $bash_cv_termcap_lib = libncurses; then | |
630 | TERMCAP_LIB=-lncurses | |
631 | TERMCAP_DEP= | |
632 | else | |
633 | TERMCAP_LIB=-lcurses | |
634 | TERMCAP_DEP= | |
635 | fi | |
636 | ]) | |
637 | ||
638 | AC_DEFUN(BASH_FUNC_GETCWD, | |
639 | [AC_MSG_CHECKING([if getcwd() calls popen()]) | |
640 | AC_CACHE_VAL(bash_cv_getcwd_calls_popen, | |
641 | [AC_TRY_RUN([ | |
642 | #include <stdio.h> | |
643 | #ifdef HAVE_UNISTD_H | |
644 | #include <unistd.h> | |
645 | #endif | |
646 | ||
647 | #ifndef __STDC__ | |
648 | #ifndef const | |
649 | #define const | |
650 | #endif | |
651 | #endif | |
652 | ||
653 | int popen_called; | |
654 | ||
655 | FILE * | |
656 | popen(command, type) | |
657 | const char *command; | |
658 | const char *type; | |
659 | { | |
660 | popen_called = 1; | |
661 | return (FILE *)NULL; | |
662 | } | |
663 | ||
664 | FILE *_popen(command, type) | |
665 | const char *command; | |
666 | const char *type; | |
667 | { | |
668 | return (popen (command, type)); | |
669 | } | |
670 | ||
671 | int | |
672 | pclose(stream) | |
673 | FILE *stream; | |
674 | { | |
675 | return 0; | |
676 | } | |
677 | ||
678 | int | |
679 | _pclose(stream) | |
680 | FILE *stream; | |
681 | { | |
682 | return 0; | |
683 | } | |
684 | ||
685 | main() | |
686 | { | |
687 | char lbuf[32]; | |
688 | popen_called = 0; | |
689 | getcwd(lbuf, 32); | |
690 | exit (popen_called); | |
691 | } | |
692 | ], bash_cv_getcwd_calls_popen=no, bash_cv_getcwd_calls_popen=yes, | |
693 | [AC_MSG_ERROR(cannot check whether getcwd calls popen if cross compiling -- defaulting to no) | |
694 | bash_cv_getcwd_calls_popen=no] | |
695 | )]) | |
696 | AC_MSG_RESULT($bash_cv_getcwd_calls_popen) | |
697 | if test $bash_cv_getcwd_calls_popen = yes; then | |
698 | AC_DEFINE(GETCWD_BROKEN) | |
699 | fi | |
700 | ]) | |
701 | ||
702 | AC_DEFUN(BASH_STRUCT_DIRENT_D_INO, | |
703 | [AC_REQUIRE([AC_HEADER_DIRENT]) | |
704 | AC_MSG_CHECKING(if struct dirent has a d_ino member) | |
705 | AC_CACHE_VAL(bash_cv_dirent_has_dino, | |
706 | [AC_TRY_COMPILE([ | |
707 | #include <stdio.h> | |
708 | #include <sys/types.h> | |
709 | #ifdef HAVE_UNISTD_H | |
710 | # include <unistd.h> | |
711 | #endif /* HAVE_UNISTD_H */ | |
712 | #if defined(HAVE_DIRENT_H) | |
713 | # include <dirent.h> | |
714 | #else | |
715 | # define dirent direct | |
716 | # ifdef HAVE_SYS_NDIR_H | |
717 | # include <sys/ndir.h> | |
718 | # endif /* SYSNDIR */ | |
719 | # ifdef HAVE_SYS_DIR_H | |
720 | # include <sys/dir.h> | |
721 | # endif /* SYSDIR */ | |
722 | # ifdef HAVE_NDIR_H | |
723 | # include <ndir.h> | |
724 | # endif | |
725 | #endif /* HAVE_DIRENT_H */ | |
726 | ],[ | |
727 | struct dirent d; int z; z = d.d_ino; | |
728 | ], bash_cv_dirent_has_dino=yes, bash_cv_dirent_has_dino=no)]) | |
729 | AC_MSG_RESULT($bash_cv_dirent_has_dino) | |
730 | if test $bash_cv_dirent_has_dino = yes; then | |
731 | AC_DEFINE(STRUCT_DIRENT_HAS_D_INO) | |
732 | fi | |
733 | ]) | |
734 | ||
735 | AC_DEFUN(BASH_STRUCT_DIRENT_D_FILENO, | |
736 | [AC_REQUIRE([AC_HEADER_DIRENT]) | |
737 | AC_MSG_CHECKING(if struct dirent has a d_fileno member) | |
738 | AC_CACHE_VAL(bash_cv_dirent_has_d_fileno, | |
739 | [AC_TRY_COMPILE([ | |
740 | #include <stdio.h> | |
741 | #include <sys/types.h> | |
742 | #ifdef HAVE_UNISTD_H | |
743 | # include <unistd.h> | |
744 | #endif /* HAVE_UNISTD_H */ | |
745 | #if defined(HAVE_DIRENT_H) | |
746 | # include <dirent.h> | |
747 | #else | |
748 | # define dirent direct | |
749 | # ifdef HAVE_SYS_NDIR_H | |
750 | # include <sys/ndir.h> | |
751 | # endif /* SYSNDIR */ | |
752 | # ifdef HAVE_SYS_DIR_H | |
753 | # include <sys/dir.h> | |
754 | # endif /* SYSDIR */ | |
755 | # ifdef HAVE_NDIR_H | |
756 | # include <ndir.h> | |
757 | # endif | |
758 | #endif /* HAVE_DIRENT_H */ | |
759 | ],[ | |
760 | struct dirent d; int z; z = d.d_fileno; | |
761 | ], bash_cv_dirent_has_d_fileno=yes, bash_cv_dirent_has_d_fileno=no)]) | |
762 | AC_MSG_RESULT($bash_cv_dirent_has_d_fileno) | |
763 | if test $bash_cv_dirent_has_d_fileno = yes; then | |
764 | AC_DEFINE(STRUCT_DIRENT_HAS_D_FILENO) | |
765 | fi | |
766 | ]) | |
767 | ||
768 | AC_DEFUN(BASH_REINSTALL_SIGHANDLERS, | |
769 | [AC_REQUIRE([AC_TYPE_SIGNAL]) | |
770 | AC_REQUIRE([BASH_SIGNAL_CHECK]) | |
771 | AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked]) | |
772 | AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers, | |
773 | [AC_TRY_RUN([ | |
774 | #include <signal.h> | |
775 | #ifdef HAVE_UNISTD_H | |
776 | #include <unistd.h> | |
777 | #endif | |
778 | ||
779 | typedef RETSIGTYPE sigfunc(); | |
780 | ||
781 | int nsigint; | |
782 | ||
783 | #ifdef HAVE_POSIX_SIGNALS | |
784 | sigfunc * | |
785 | set_signal_handler(sig, handler) | |
786 | int sig; | |
787 | sigfunc *handler; | |
788 | { | |
789 | struct sigaction act, oact; | |
790 | act.sa_handler = handler; | |
791 | act.sa_flags = 0; | |
792 | sigemptyset (&act.sa_mask); | |
793 | sigemptyset (&oact.sa_mask); | |
794 | sigaction (sig, &act, &oact); | |
795 | return (oact.sa_handler); | |
796 | } | |
797 | #else | |
798 | #define set_signal_handler(s, h) signal(s, h) | |
799 | #endif | |
800 | ||
801 | RETSIGTYPE | |
802 | sigint(s) | |
803 | int s; | |
804 | { | |
805 | nsigint++; | |
806 | } | |
807 | ||
808 | main() | |
809 | { | |
810 | nsigint = 0; | |
811 | set_signal_handler(SIGINT, sigint); | |
812 | kill((int)getpid(), SIGINT); | |
813 | kill((int)getpid(), SIGINT); | |
814 | exit(nsigint != 2); | |
815 | } | |
816 | ], bash_cv_must_reinstall_sighandlers=no, bash_cv_must_reinstall_sighandlers=yes, | |
817 | [AC_MSG_ERROR(cannot check signal handling if cross compiling -- defaulting to no) | |
818 | bash_cv_must_reinstall_sighandlers=no] | |
819 | )]) | |
820 | AC_MSG_RESULT($bash_cv_must_reinstall_sighandlers) | |
821 | if test $bash_cv_must_reinstall_sighandlers = yes; then | |
822 | AC_DEFINE(MUST_REINSTALL_SIGHANDLERS) | |
823 | fi | |
824 | ]) | |
825 | ||
826 | AC_DEFUN(BASH_FUNC_SBRK_DECLARED, | |
827 | [AC_MSG_CHECKING(for declaration of sbrk in <unistd.h>) | |
828 | AC_CACHE_VAL(bash_cv_sbrk_declared, | |
829 | [AC_EGREP_HEADER(sbrk, unistd.h, | |
830 | bash_cv_sbrk_declared=yes, bash_cv_sbrk_declared=no)]) | |
831 | AC_MSG_RESULT($bash_cv_sbrk_declared) | |
832 | if test $bash_cv_sbrk_declared = yes; then | |
833 | AC_DEFINE(SBRK_DECLARED) | |
834 | fi | |
835 | ]) | |
836 | ||
837 | dnl check that some necessary job control definitions are present | |
838 | AC_DEFUN(BASH_JOB_CONTROL_MISSING, | |
839 | [AC_REQUIRE([BASH_SIGNAL_CHECK]) | |
840 | AC_MSG_CHECKING(for presence of necessary job control definitions) | |
841 | AC_CACHE_VAL(bash_cv_job_control_missing, | |
842 | [AC_TRY_RUN([ | |
843 | #include <sys/types.h> | |
844 | #ifdef HAVE_SYS_WAIT_H | |
845 | #include <sys/wait.h> | |
846 | #endif | |
847 | #ifdef HAVE_UNISTD_H | |
848 | #include <unistd.h> | |
849 | #endif | |
850 | #include <signal.h> | |
851 | ||
852 | /* Add more tests in here as appropriate. */ | |
853 | main() | |
854 | { | |
855 | /* signal type */ | |
856 | #if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS) | |
857 | exit(1); | |
858 | #endif | |
859 | ||
860 | /* signals and tty control. */ | |
861 | #if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT) | |
862 | exit (1); | |
863 | #endif | |
864 | ||
865 | /* process control */ | |
866 | #if !defined (WNOHANG) || !defined (WUNTRACED) | |
867 | exit(1); | |
868 | #endif | |
869 | ||
870 | /* Posix systems have tcgetpgrp and waitpid. */ | |
871 | #if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP) | |
872 | exit(1); | |
873 | #endif | |
874 | ||
875 | #if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID) | |
876 | exit(1); | |
877 | #endif | |
878 | ||
879 | /* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */ | |
880 | #if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3) | |
881 | exit(1); | |
882 | #endif | |
883 | ||
884 | exit(0); | |
885 | }], bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing, | |
886 | [AC_MSG_ERROR(cannot check job control if cross-compiling -- defaulting to missing) | |
887 | bash_cv_job_control_missing=missing] | |
888 | )]) | |
889 | AC_MSG_RESULT($bash_cv_job_control_missing) | |
890 | if test $bash_cv_job_control_missing = missing; then | |
891 | AC_DEFINE(JOB_CONTROL_MISSING) | |
892 | fi | |
893 | ]) | |
894 | ||
895 | dnl check whether named pipes are present | |
896 | dnl this requires a previous check for mkfifo, but that is awkward to specify | |
897 | AC_DEFUN(BASH_SYS_NAMED_PIPES, | |
898 | [AC_MSG_CHECKING(for presence of named pipes) | |
899 | AC_CACHE_VAL(bash_cv_sys_named_pipes, | |
900 | [AC_TRY_RUN([ | |
901 | #include <sys/types.h> | |
902 | #include <sys/stat.h> | |
903 | #ifdef HAVE_UNISTD_H | |
904 | #include <unistd.h> | |
905 | #endif | |
906 | ||
907 | /* Add more tests in here as appropriate. */ | |
908 | main() | |
909 | { | |
910 | int fd; | |
911 | ||
912 | #if defined (HAVE_MKFIFO) | |
913 | exit (0); | |
914 | #endif | |
915 | ||
916 | #if !defined (S_IFIFO) && (defined (_POSIX_VERSION) && !defined (S_ISFIFO)) | |
917 | exit (1); | |
918 | #endif | |
919 | ||
920 | #if defined (NeXT) | |
921 | exit (1); | |
922 | #endif | |
923 | ||
924 | fd = mknod ("/tmp/sh-np-autoconf", 0666 | S_IFIFO, 0); | |
925 | if (fd == -1) | |
926 | exit (1); | |
927 | close(fd); | |
928 | unlink ("/tmp/sh-np-autoconf"); | |
929 | exit(0); | |
930 | }], bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing, | |
931 | [AC_MSG_ERROR(cannot check for named pipes if cross-compiling -- defaulting to missing) | |
932 | bash_cv_sys_named_pipes=missing] | |
933 | )]) | |
934 | AC_MSG_RESULT($bash_cv_sys_named_pipes) | |
935 | if test $bash_cv_sys_named_pipes = missing; then | |
936 | AC_DEFINE(NAMED_PIPES_MISSING) | |
937 | fi | |
938 | ]) | |
939 | ||
940 | AC_DEFUN(BASH_FUNC_POSIX_SETJMP, | |
941 | [AC_REQUIRE([BASH_SIGNAL_CHECK]) | |
942 | AC_MSG_CHECKING(for presence of POSIX-style sigsetjmp/siglongjmp) | |
943 | AC_CACHE_VAL(bash_cv_func_sigsetjmp, | |
944 | [AC_TRY_RUN([ | |
945 | #ifdef HAVE_UNISTD_H | |
946 | #include <unistd.h> | |
947 | #endif | |
948 | #include <sys/types.h> | |
949 | #include <signal.h> | |
950 | #include <setjmp.h> | |
951 | ||
952 | main() | |
953 | { | |
954 | #if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS) | |
955 | exit (1); | |
956 | #else | |
957 | ||
958 | int code; | |
959 | sigset_t set, oset; | |
960 | sigjmp_buf xx; | |
961 | ||
962 | /* get the mask */ | |
963 | sigemptyset(&set); | |
964 | sigemptyset(&oset); | |
965 | sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &set); | |
966 | sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset); | |
967 | ||
968 | /* save it */ | |
969 | code = sigsetjmp(xx, 1); | |
970 | if (code) | |
971 | exit(0); /* could get sigmask and compare to oset here. */ | |
972 | ||
973 | /* change it */ | |
974 | sigaddset(&set, SIGINT); | |
975 | sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL); | |
976 | ||
977 | /* and siglongjmp */ | |
978 | siglongjmp(xx, 10); | |
979 | exit(1); | |
980 | #endif | |
981 | }], bash_cv_func_sigsetjmp=present, bash_cv_func_sigsetjmp=missing, | |
982 | [AC_MSG_ERROR(cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing) | |
983 | bash_cv_func_sigsetjmp=missing] | |
984 | )]) | |
985 | AC_MSG_RESULT($bash_cv_func_sigsetjmp) | |
986 | if test $bash_cv_func_sigsetjmp = present; then | |
987 | AC_DEFINE(HAVE_POSIX_SIGSETJMP) | |
988 | fi | |
989 | ]) | |
990 | ||
991 | AC_DEFUN(BASH_HAVE_TIOCGWINSZ, | |
992 | [AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h) | |
993 | AC_CACHE_VAL(bash_cv_tiocgwinsz_in_ioctl, | |
994 | [AC_TRY_COMPILE([#include <sys/types.h> | |
995 | #include <sys/ioctl.h>], [int x = TIOCGWINSZ;], | |
996 | bash_cv_tiocgwinsz_in_ioctl=yes,bash_cv_tiocgwinsz_in_ioctl=no)]) | |
997 | AC_MSG_RESULT($bash_cv_tiocgwinsz_in_ioctl) | |
998 | if test $bash_cv_tiocgwinsz_in_ioctl = yes; then | |
999 | AC_DEFINE(GWINSZ_IN_SYS_IOCTL) | |
1000 | fi | |
1001 | ]) | |
1002 | ||
1003 | AC_DEFUN(BASH_STRUCT_WINSIZE, | |
1004 | [AC_MSG_CHECKING(for struct winsize in sys/ioctl.h and termios.h) | |
1005 | AC_CACHE_VAL(bash_cv_struct_winsize_header, | |
1006 | [AC_TRY_COMPILE([#include <sys/types.h> | |
1007 | #include <sys/ioctl.h>], [struct winsize x;], | |
1008 | bash_cv_struct_winsize_header=ioctl_h, | |
1009 | [AC_TRY_COMPILE([#include <sys/types.h> | |
1010 | #include <termios.h>], [struct winsize x;], | |
1011 | bash_cv_struct_winsize_header=termios_h, bash_cv_struct_winsize_header=other) | |
1012 | ])]) | |
1013 | if test $bash_cv_struct_winsize_header = ioctl_h; then | |
1014 | AC_MSG_RESULT(sys/ioctl.h) | |
1015 | AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL) | |
1016 | elif test $bash_cv_struct_winsize_header = termios_h; then | |
1017 | AC_MSG_RESULT(termios.h) | |
1018 | AC_DEFINE(STRUCT_WINSIZE_IN_TERMIOS) | |
1019 | else | |
1020 | AC_MSG_RESULT(not found) | |
1021 | fi | |
1022 | ]) | |
1023 | ||
1024 | AC_DEFUN(BASH_HAVE_TIOCSTAT, | |
1025 | [AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h) | |
1026 | AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl, | |
1027 | [AC_TRY_COMPILE([#include <sys/types.h> | |
1028 | #include <sys/ioctl.h>], [int x = TIOCSTAT;], | |
1029 | bash_cv_tiocstat_in_ioctl=yes,bash_cv_tiocstat_in_ioctl=no)]) | |
1030 | AC_MSG_RESULT($bash_cv_tiocstat_in_ioctl) | |
1031 | if test $bash_cv_tiocstat_in_ioctl = yes; then | |
1032 | AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL) | |
1033 | fi | |
1034 | ]) | |
1035 | ||
1036 | AC_DEFUN(BASH_HAVE_FIONREAD, | |
1037 | [AC_MSG_CHECKING(for FIONREAD in sys/ioctl.h) | |
1038 | AC_CACHE_VAL(bash_cv_fionread_in_ioctl, | |
1039 | [AC_TRY_COMPILE([#include <sys/types.h> | |
1040 | #include <sys/ioctl.h>], [int x = FIONREAD;], | |
1041 | bash_cv_fionread_in_ioctl=yes,bash_cv_fionread_in_ioctl=no)]) | |
1042 | AC_MSG_RESULT($bash_cv_fionread_in_ioctl) | |
1043 | if test $bash_cv_fionread_in_ioctl = yes; then | |
1044 | AC_DEFINE(FIONREAD_IN_SYS_IOCTL) | |
1045 | fi | |
1046 | ]) | |
1047 | ||
1048 | dnl | |
1049 | dnl See if speed_t is declared in <sys/types.h>. Some versions of linux | |
1050 | dnl require a definition of speed_t each time <termcap.h> is included, | |
1051 | dnl but you can only get speed_t if you include <termios.h> (on some | |
1052 | dnl versions) or <sys/types.h> (on others). | |
1053 | dnl | |
1054 | AC_DEFUN(BASH_MISC_SPEED_T, | |
1055 | [AC_MSG_CHECKING(for speed_t in sys/types.h) | |
1056 | AC_CACHE_VAL(bash_cv_speed_t_in_sys_types, | |
1057 | [AC_TRY_COMPILE([#include <sys/types.h>], [speed_t x;], | |
1058 | bash_cv_speed_t_in_sys_types=yes,bash_cv_speed_t_in_sys_types=no)]) | |
1059 | AC_MSG_RESULT($bash_cv_speed_t_in_sys_types) | |
1060 | if test $bash_cv_speed_t_in_sys_types = yes; then | |
1061 | AC_DEFINE(SPEED_T_IN_SYS_TYPES) | |
1062 | fi | |
1063 | ]) | |
1064 | ||
1065 | AC_DEFUN(BASH_CHECK_GETPW_FUNCS, | |
1066 | [AC_MSG_CHECKING(whether programs are able to redeclare getpw functions) | |
1067 | AC_CACHE_VAL(bash_cv_can_redecl_getpw, | |
1068 | [AC_TRY_COMPILE([#include <sys/types.h> | |
1069 | #include <pwd.h> | |
1070 | extern struct passwd *getpwent(); | |
1071 | extern struct passwd *getpwuid(); | |
1072 | extern struct passwd *getpwnam();], | |
1073 | [struct passwd *z; z = getpwent(); z = getpwuid(0); z = getpwnam("root");], | |
1074 | bash_cv_can_redecl_getpw=yes,bash_cv_can_redecl_getpw=no)]) | |
1075 | AC_MSG_RESULT($bash_cv_can_redecl_getpw) | |
1076 | if test $bash_cv_can_redecl_getpw = no; then | |
1077 | AC_DEFINE(HAVE_GETPW_DECLS) | |
1078 | fi | |
1079 | ]) | |
1080 | ||
1081 | AC_DEFUN(BASH_CHECK_DEV_FD, | |
1082 | [AC_MSG_CHECKING(whether /dev/fd is available) | |
1083 | AC_CACHE_VAL(bash_cv_dev_fd, | |
1084 | [if test -d /dev/fd && test -r /dev/fd/0; then | |
1085 | bash_cv_dev_fd=standard | |
1086 | elif test -d /proc/self/fd && test -r /proc/self/fd/0; then | |
1087 | bash_cv_dev_fd=whacky | |
1088 | else | |
1089 | bash_cv_dev_fd=absent | |
1090 | fi | |
1091 | ]) | |
1092 | AC_MSG_RESULT($bash_cv_dev_fd) | |
1093 | if test $bash_cv_dev_fd = "standard"; then | |
1094 | AC_DEFINE(HAVE_DEV_FD) | |
1095 | AC_DEFINE(DEV_FD_PREFIX, "/dev/fd/") | |
1096 | elif test $bash_cv_dev_fd = "whacky"; then | |
1097 | AC_DEFINE(HAVE_DEV_FD) | |
1098 | AC_DEFINE(DEV_FD_PREFIX, "/proc/self/fd/") | |
1099 | fi | |
1100 | ]) | |
1101 | ||
1102 | dnl | |
1103 | dnl Check for the presence of getpeername (the only networking function | |
1104 | dnl bash currently requires) in libsocket. If libsocket is present, | |
1105 | dnl check for libnsl and add it to LIBS if it's there, since most | |
1106 | dnl systems with libsocket require linking with libnsl as well. | |
1107 | dnl This should only be called if getpeername was not found in libc. | |
1108 | dnl | |
1109 | AC_DEFUN(BASH_CHECK_SOCKLIB, | |
1110 | [ | |
1111 | if test "X$bash_cv_have_socklib" = "X"; then | |
1112 | _bash_needmsg= | |
1113 | else | |
1114 | AC_MSG_CHECKING(for socket library) | |
1115 | _bash_needmsg=yes | |
1116 | fi | |
1117 | AC_CACHE_VAL(bash_cv_have_socklib, | |
1118 | [AC_CHECK_LIB(socket, getpeername, | |
1119 | bash_cv_have_socklib=yes, bash_cv_have_socklib=no, -lnsl)]) | |
1120 | if test "X$_bash_needmsg" = Xyes; then | |
1121 | AC_MSG_RESULT($bash_cv_have_socklib) | |
1122 | _bash_needmsg= | |
1123 | fi | |
1124 | if test $bash_cv_have_socklib = yes; then | |
1125 | # check for libnsl, add it to LIBS if present | |
1126 | if test "X$bash_cv_have_libnsl" = "X"; then | |
1127 | _bash_needmsg= | |
1128 | else | |
1129 | AC_MSG_CHECKING(for libnsl) | |
1130 | _bash_needmsg=yes | |
1131 | fi | |
1132 | AC_CACHE_VAL(bash_cv_have_libnsl, | |
1133 | [AC_CHECK_LIB(nsl, t_open, | |
1134 | bash_cv_have_libnsl=yes, bash_cv_have_libnsl=no)]) | |
1135 | if test "X$_bash_needmsg" = Xyes; then | |
1136 | AC_MSG_RESULT($bash_cv_have_libnsl) | |
1137 | _bash_needmsg= | |
1138 | fi | |
1139 | if test $bash_cv_have_libnsl = yes; then | |
1140 | LIBS="-lsocket -lnsl $LIBS" | |
1141 | else | |
1142 | LIBS="-lsocket $LIBS" | |
1143 | fi | |
1144 | AC_DEFINE(HAVE_LIBSOCKET) | |
1145 | AC_DEFINE(HAVE_GETPEERNAME) | |
1146 | fi | |
1147 | ]) | |
1148 | ||
1149 | AC_DEFUN(BASH_DEFAULT_MAIL_DIR, | |
1150 | [AC_MSG_CHECKING(for default mail directory) | |
1151 | AC_CACHE_VAL(bash_cv_mail_dir, | |
1152 | [if test -d /var/mail; then | |
1153 | bash_cv_mail_dir=/var/mail | |
1154 | elif test -d /usr/mail; then | |
1155 | bash_cv_mail_dir=/usr/mail | |
1156 | elif test -d /var/spool/mail; then | |
1157 | bash_cv_mail_dir=/var/spool/mail | |
1158 | elif test -d /usr/spool/mail; then | |
1159 | bash_cv_mail_dir=/usr/spool/mail | |
1160 | else | |
1161 | bash_cv_mail_dir=unknown | |
1162 | fi | |
1163 | ]) | |
1164 | AC_MSG_RESULT($bash_cv_mail_dir) | |
1165 | if test $bash_cv_mail_dir = "/var/mail"; then | |
1166 | AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/var/mail") | |
1167 | elif test $bash_cv_mail_dir = "/usr/mail"; then | |
1168 | AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/usr/mail") | |
1169 | elif test $bash_cv_mail_dir = "/var/spool/mail"; then | |
1170 | AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/var/spool/mail") | |
1171 | elif test $bash_cv_mail_dir = "/usr/spool/mail"; then | |
1172 | AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "/usr/spool/mail") | |
1173 | else | |
1174 | AC_DEFINE(DEFAULT_MAIL_DIRECTORY, "unknown") | |
1175 | fi | |
1176 | ]) | |
1177 | ||
1178 | dnl | |
1179 | dnl Check if HPUX needs _KERNEL defined for RLIMIT_* definitions | |
1180 | dnl | |
1181 | AC_DEFUN(BASH_KERNEL_RLIMIT_CHECK, | |
1182 | [AC_MSG_CHECKING([whether $host_os needs _KERNEL for RLIMIT defines]) | |
1183 | AC_CACHE_VAL(bash_cv_kernel_rlimit, | |
1184 | [AC_TRY_COMPILE([ | |
1185 | #include <sys/types.h> | |
1186 | #include <sys/resource.h> | |
1187 | ], | |
1188 | [ | |
1189 | int f; | |
1190 | f = RLIMIT_DATA; | |
1191 | ], bash_cv_kernel_rlimit=no, | |
1192 | [AC_TRY_COMPILE([ | |
1193 | #include <sys/types.h> | |
1194 | #define _KERNEL | |
1195 | #include <sys/resource.h> | |
1196 | #undef _KERNEL | |
1197 | ], | |
1198 | [ | |
1199 | int f; | |
1200 | f = RLIMIT_DATA; | |
1201 | ], bash_cv_kernel_rlimit=yes, bash_cv_kernel_rlimit=no)] | |
1202 | )]) | |
1203 | AC_MSG_RESULT($bash_cv_kernel_rlimit) | |
1204 | if test $bash_cv_kernel_rlimit = yes; then | |
1205 | AC_DEFINE(RLIMIT_NEEDS_KERNEL) | |
1206 | fi | |
1207 | ]) | |
1208 | ||
1209 | AC_DEFUN(BASH_FUNC_STRCOLL, | |
1210 | [ | |
1211 | AC_MSG_CHECKING(whether or not strcoll and strcmp differ) | |
1212 | AC_CACHE_VAL(bash_cv_func_strcoll_broken, | |
1213 | [AC_TRY_RUN([ | |
1214 | #include <stdio.h> | |
1215 | #if defined (HAVE_LOCALE_H) | |
1216 | #include <locale.h> | |
1217 | #endif | |
1218 | ||
1219 | main(c, v) | |
1220 | int c; | |
1221 | char *v[]; | |
1222 | { | |
1223 | int r1, r2; | |
1224 | char *deflocale, *defcoll; | |
1225 | ||
1226 | #ifdef HAVE_SETLOCALE | |
1227 | deflocale = setlocale(LC_ALL, ""); | |
1228 | defcoll = setlocale(LC_COLLATE, ""); | |
1229 | #endif | |
1230 | ||
1231 | #ifdef HAVE_STRCOLL | |
1232 | /* These two values are taken from tests/glob-test. */ | |
1233 | r1 = strcoll("abd", "aXd"); | |
1234 | #else | |
1235 | r1 = 0; | |
1236 | #endif | |
1237 | r2 = strcmp("abd", "aXd"); | |
1238 | ||
1239 | /* These two should both be greater than 0. It is permissible for | |
1240 | a system to return different values, as long as the sign is the | |
1241 | same. */ | |
1242 | ||
1243 | /* Exit with 1 (failure) if these two values are both > 0, since | |
1244 | this tests whether strcoll(3) is broken with respect to strcmp(3) | |
1245 | in the default locale. */ | |
1246 | exit (r1 > 0 && r2 > 0); | |
1247 | } | |
1248 | ], bash_cv_func_strcoll_broken=yes, bash_cv_func_strcoll_broken=no, | |
1249 | [AC_MSG_ERROR(cannot check strcoll if cross compiling -- defaulting to no) | |
1250 | bash_cv_func_strcoll_broken=no] | |
1251 | )]) | |
1252 | AC_MSG_RESULT($bash_cv_func_strcoll_broken) | |
1253 | if test $bash_cv_func_strcoll_broken = yes; then | |
1254 | AC_DEFINE(STRCOLL_BROKEN) | |
1255 | fi | |
1256 | ]) | |
1257 | ||
1258 | dnl | |
1259 | dnl If available, use support for large files unless the user specified | |
1260 | dnl one of the CPPFLAGS, LDFLAGS, or LIBS variables (<eggert@twinsun.com> | |
1261 | dnl via GNU patch 2.5) | |
1262 | dnl | |
1263 | AC_DEFUN(BASH_LARGE_FILE_SUPPORT, | |
1264 | [AC_MSG_CHECKING(whether large file support needs explicit enabling) | |
1265 | ac_getconfs='' | |
1266 | ac_result=yes | |
1267 | ac_set='' | |
1268 | ac_shellvars='CPPFLAGS LDFLAGS LIBS' | |
1269 | for ac_shellvar in $ac_shellvars; do | |
1270 | case $ac_shellvar in | |
1271 | CPPFLAGS) ac_lfsvar=LFS_CFLAGS ac_lfs64var=LFS64_CFLAGS ;; | |
1272 | *) ac_lfsvar=LFS_$ac_shellvar ac_lfs64var=LFS64_$ac_shellvar ;; | |
1273 | esac | |
1274 | eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar | |
1275 | (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; } | |
1276 | ac_getconf=`getconf $ac_lfsvar` | |
1277 | ac_getconf64=`getconf $ac_lfs64var` | |
1278 | ac_getconfs=$ac_getconfs$ac_getconf\ $ac_getconf64 | |
1279 | eval ac_test_$ac_shellvar="\$ac_getconf\ \$ac_getconf64" | |
1280 | done | |
1281 | case "$ac_result$ac_getconfs" in | |
1282 | yes) ac_result=no ;; | |
1283 | esac | |
1284 | case "$ac_result$ac_set" in | |
1285 | yes?*) ac_result="yes, but $ac_set is already set, so use its settings" | |
1286 | esac | |
1287 | AC_MSG_RESULT($ac_result) | |
1288 | case $ac_result in | |
1289 | yes) | |
1290 | for ac_shellvar in $ac_shellvars; do | |
1291 | eval $ac_shellvar=\$ac_test_$ac_shellvar | |
1292 | done ;; | |
1293 | esac | |
1294 | ]) | |
1295 | ||
1296 | dnl | |
1297 | dnl AC_SYS_RESTARTABLE_SYSCALLS tests only for restarted system calls | |
1298 | dnl after a signal handler has been installed with signal(). Since | |
1299 | dnl Bash uses sigaction() if it is available, we need to check whether | |
1300 | dnl or not a signal handler installed with sigaction and SA_RESTART | |
1301 | dnl causes system calls to be restarted after the signal is caught | |
1302 | dnl | |
1303 | AC_DEFUN(BASH_SYS_RESTARTABLE_SYSCALLS, | |
1304 | [AC_REQUIRE([BASH_SIGNAL_CHECK]) | |
1305 | AC_CACHE_CHECK(for restartable system calls with posix sigaction, | |
1306 | bash_cv_sys_restartable_syscalls, | |
1307 | [AC_TRY_RUN( | |
1308 | [/* Exit 0 (true) if wait returns something other than -1, | |
1309 | i.e. the pid of the child, which means that wait was restarted | |
1310 | after getting the signal. */ | |
1311 | #include <sys/types.h> | |
1312 | #include <signal.h> | |
1313 | static int caught = 0; | |
1314 | void ucatch (isig) int isig; { caught = 1; } | |
1315 | main () | |
1316 | { | |
1317 | #if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS) | |
1318 | exit (1); | |
1319 | #else | |
1320 | struct sigaction act, oact; | |
1321 | int i, status; | |
1322 | ||
1323 | act.sa_handler = ucatch; | |
1324 | /* Might want to add SA_RESTART here, but bash's set_signal_handler | |
1325 | does not. */ | |
1326 | act.sa_flags = 0; | |
1327 | sigemptyset(&act.sa_mask); | |
1328 | sigemptyset(&oact.sa_mask); | |
1329 | i = fork (); | |
1330 | /* A possible race condition here, but in practice it never happens. */ | |
1331 | if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); } | |
1332 | sigaction(SIGINT, &act, &oact); | |
1333 | status = wait(&i); | |
1334 | if (status == -1) wait(&i); | |
1335 | exit (status == -1); | |
1336 | #endif | |
1337 | } | |
1338 | ], bash_cv_sys_restartable_syscalls=yes, bash_cv_sys_restartable_syscalls=no, | |
1339 | AC_MSG_ERROR(cannot check restartable syscalls if cross compiling)) | |
1340 | ]) | |
1341 | if test $bash_cv_sys_restartable_syscalls = yes; then | |
1342 | AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS) | |
1343 | fi | |
1344 | ]) |