1dnl
2dnl Bash specific tests
3dnl
4dnl Some derived from PDKSH 5.1.3 autoconf tests
5dnl
6
7AC_DEFUN(BASH_C_LONG_LONG,
8[AC_CACHE_CHECK(for long long, ac_cv_c_long_long,
9[if test "$GCC" = yes; then
10  ac_cv_c_long_long=yes
11else
12AC_TRY_RUN([
13int
14main()
15{
16long long foo = 0;
17exit(sizeof(long long) < sizeof(long));
18}
19], ac_cv_c_long_long=yes, ac_cv_c_long_long=no)
20fi])
21if test $ac_cv_c_long_long = yes; then
22  AC_DEFINE(HAVE_LONG_LONG, 1, [Define if the `long long' type works.])
23fi
24])
25
26dnl
27dnl This is very similar to AC_C_LONG_DOUBLE, with the fix for IRIX
28dnl (< changed to <=) added.
29dnl
30AC_DEFUN(BASH_C_LONG_DOUBLE,
31[AC_CACHE_CHECK(for long double, ac_cv_c_long_double,
32[if test "$GCC" = yes; then
33  ac_cv_c_long_double=yes
34else
35AC_TRY_RUN([
36int
37main()
38{
39  /* The Stardent Vistra knows sizeof(long double), but does not
40     support it. */
41  long double foo = 0.0;
42  /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
43  /* On IRIX 5.3, the compiler converts long double to double with a warning,
44     but compiles this successfully. */
45  exit(sizeof(long double) <= sizeof(double));
46}
47], ac_cv_c_long_double=yes, ac_cv_c_long_double=no)
48fi])
49if test $ac_cv_c_long_double = yes; then
50  AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if the `long double' type works.])
51fi
52])
53
54dnl
55dnl Check for <inttypes.h>.  This is separated out so that it can be
56dnl AC_REQUIREd.
57dnl
58dnl BASH_HEADER_INTTYPES
59AC_DEFUN(BASH_HEADER_INTTYPES,
60[
61 AC_CHECK_HEADERS(inttypes.h)
62])
63
64dnl
65dnl check for typedef'd symbols in header files, but allow the caller to
66dnl specify the include files to be checked in addition to the default
67dnl 
68dnl BASH_CHECK_TYPE(TYPE, HEADERS, DEFAULT[, VALUE-IF-FOUND])
69AC_DEFUN(BASH_CHECK_TYPE,
70[
71AC_REQUIRE([AC_HEADER_STDC])dnl
72AC_REQUIRE([BASH_HEADER_INTTYPES])
73AC_MSG_CHECKING(for $1)
74AC_CACHE_VAL(bash_cv_type_$1,
75[AC_EGREP_CPP($1, [#include <sys/types.h>
76#if STDC_HEADERS
77#include <stdlib.h>
78#include <stddef.h>
79#endif
80#if HAVE_INTTYPES_H
81#include <inttypes.h>
82#endif
83$2
84], bash_cv_type_$1=yes, bash_cv_type_$1=no)])
85AC_MSG_RESULT($bash_cv_type_$1)
86ifelse($#, 4, [if test $bash_cv_type_$1 = yes; then
87	AC_DEFINE($4)
88	fi])
89if test $bash_cv_type_$1 = no; then
90  AC_DEFINE_UNQUOTED($1, $3)
91fi
92])
93
94dnl
95dnl BASH_CHECK_DECL(FUNC)
96dnl
97dnl Check for a declaration of FUNC in stdlib.h and inttypes.h like
98dnl AC_CHECK_DECL
99dnl
100AC_DEFUN(BASH_CHECK_DECL,
101[
102AC_REQUIRE([AC_HEADER_STDC])
103AC_REQUIRE([BASH_HEADER_INTTYPES])
104AC_CACHE_CHECK([for declaration of $1], bash_cv_decl_$1,
105[AC_TRY_LINK(
106[
107#if STDC_HEADERS
108#  include <stdlib.h>
109#endif
110#if HAVE_INTTYPES_H
111#  include <inttypes.h>
112#endif
113],
114[return !$1;],
115bash_cv_decl_$1=yes, bash_cv_decl_$1=no)])
116bash_tr_func=HAVE_DECL_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
117if test $bash_cv_decl_$1 = yes; then
118  AC_DEFINE_UNQUOTED($bash_tr_func, 1)
119else
120  AC_DEFINE_UNQUOTED($bash_tr_func, 0)
121fi
122])
123
124AC_DEFUN(BASH_DECL_PRINTF,
125[AC_MSG_CHECKING(for declaration of printf in <stdio.h>)
126AC_CACHE_VAL(bash_cv_printf_declared,
127[AC_TRY_RUN([
128#include <stdio.h>
129#ifdef __STDC__
130typedef int (*_bashfunc)(const char *, ...);
131#else
132typedef int (*_bashfunc)();
133#endif
134main()
135{
136_bashfunc pf;
137pf = (_bashfunc) printf;
138exit(pf == 0);
139}
140], bash_cv_printf_declared=yes, bash_cv_printf_declared=no,
141   [AC_MSG_WARN(cannot check printf declaration if cross compiling -- defaulting to yes)
142    bash_cv_printf_declared=yes]
143)])
144AC_MSG_RESULT($bash_cv_printf_declared)
145if test $bash_cv_printf_declared = yes; then
146AC_DEFINE(PRINTF_DECLARED)
147fi
148])
149
150AC_DEFUN(BASH_DECL_SBRK,
151[AC_MSG_CHECKING(for declaration of sbrk in <unistd.h>)
152AC_CACHE_VAL(bash_cv_sbrk_declared,
153[AC_EGREP_HEADER(sbrk, unistd.h,
154 bash_cv_sbrk_declared=yes, bash_cv_sbrk_declared=no)])
155AC_MSG_RESULT($bash_cv_sbrk_declared)
156if test $bash_cv_sbrk_declared = yes; then
157AC_DEFINE(SBRK_DECLARED)
158fi
159])
160
161dnl
162dnl Check for sys_siglist[] or _sys_siglist[]
163dnl
164AC_DEFUN(BASH_DECL_UNDER_SYS_SIGLIST,
165[AC_MSG_CHECKING([for _sys_siglist in signal.h or unistd.h])
166AC_CACHE_VAL(bash_cv_decl_under_sys_siglist,
167[AC_TRY_COMPILE([
168#include <sys/types.h>
169#include <signal.h>
170#ifdef HAVE_UNISTD_H
171#include <unistd.h>
172#endif], [ char *msg = _sys_siglist[2]; ],
173  bash_cv_decl_under_sys_siglist=yes, bash_cv_decl_under_sys_siglist=no,
174  [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)])])dnl
175AC_MSG_RESULT($bash_cv_decl_under_sys_siglist)
176if test $bash_cv_decl_under_sys_siglist = yes; then
177AC_DEFINE(UNDER_SYS_SIGLIST_DECLARED)
178fi
179])
180
181AC_DEFUN(BASH_UNDER_SYS_SIGLIST,
182[AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST])
183AC_MSG_CHECKING([for _sys_siglist in system C library])
184AC_CACHE_VAL(bash_cv_under_sys_siglist,
185[AC_TRY_RUN([
186#include <sys/types.h>
187#include <signal.h>
188#ifdef HAVE_UNISTD_H
189#include <unistd.h>
190#endif
191#ifndef UNDER_SYS_SIGLIST_DECLARED
192extern char *_sys_siglist[];
193#endif
194main()
195{
196char *msg = (char *)_sys_siglist[2];
197exit(msg == 0);
198}],
199	bash_cv_under_sys_siglist=yes, bash_cv_under_sys_siglist=no,
200	[AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)
201	 bash_cv_under_sys_siglist=no])])
202AC_MSG_RESULT($bash_cv_under_sys_siglist)
203if test $bash_cv_under_sys_siglist = yes; then
204AC_DEFINE(HAVE_UNDER_SYS_SIGLIST)
205fi
206])
207
208AC_DEFUN(BASH_SYS_SIGLIST,
209[AC_REQUIRE([AC_DECL_SYS_SIGLIST])
210AC_MSG_CHECKING([for sys_siglist in system C library])
211AC_CACHE_VAL(bash_cv_sys_siglist,
212[AC_TRY_RUN([
213#include <sys/types.h>
214#include <signal.h>
215#ifdef HAVE_UNISTD_H
216#include <unistd.h>
217#endif
218#ifndef SYS_SIGLIST_DECLARED
219extern char *sys_siglist[];
220#endif
221main()
222{
223char *msg = sys_siglist[2];
224exit(msg == 0);
225}],
226	bash_cv_sys_siglist=yes, bash_cv_sys_siglist=no,
227	[AC_MSG_WARN(cannot check for sys_siglist if cross compiling -- defaulting to no)
228	 bash_cv_sys_siglist=no])])
229AC_MSG_RESULT($bash_cv_sys_siglist)
230if test $bash_cv_sys_siglist = yes; then
231AC_DEFINE(HAVE_SYS_SIGLIST)
232fi
233])
234
235dnl Check for the various permutations of sys_siglist and make sure we
236dnl compile in siglist.o if they're not defined
237AC_DEFUN(BASH_CHECK_SYS_SIGLIST, [
238AC_REQUIRE([BASH_SYS_SIGLIST])
239AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST])
240AC_REQUIRE([BASH_FUNC_STRSIGNAL])
241if test "$bash_cv_sys_siglist" = no && test "$bash_cv_under_sys_siglist" = no && test "$bash_cv_have_strsignal" = no; then
242  SIGLIST_O=siglist.o
243else
244  SIGLIST_O=
245fi
246AC_SUBST([SIGLIST_O])
247])
248
249dnl Check for sys_errlist[] and sys_nerr, check for declaration
250AC_DEFUN(BASH_SYS_ERRLIST,
251[AC_MSG_CHECKING([for sys_errlist and sys_nerr])
252AC_CACHE_VAL(bash_cv_sys_errlist,
253[AC_TRY_LINK([#include <errno.h>],
254[extern char *sys_errlist[];
255 extern int sys_nerr;
256 char *msg = sys_errlist[sys_nerr - 1];],
257    bash_cv_sys_errlist=yes, bash_cv_sys_errlist=no)])dnl
258AC_MSG_RESULT($bash_cv_sys_errlist)
259if test $bash_cv_sys_errlist = yes; then
260AC_DEFINE(HAVE_SYS_ERRLIST)
261fi
262])
263
264dnl
265dnl Check if dup2() does not clear the close on exec flag
266dnl
267AC_DEFUN(BASH_FUNC_DUP2_CLOEXEC_CHECK,
268[AC_MSG_CHECKING(if dup2 fails to clear the close-on-exec flag)
269AC_CACHE_VAL(bash_cv_dup2_broken,
270[AC_TRY_RUN([
271#include <sys/types.h>
272#include <fcntl.h>
273main()
274{
275  int fd1, fd2, fl;
276  fd1 = open("/dev/null", 2);
277  if (fcntl(fd1, 2, 1) < 0)
278    exit(1);
279  fd2 = dup2(fd1, 1);
280  if (fd2 < 0)
281    exit(2);
282  fl = fcntl(fd2, 1, 0);
283  /* fl will be 1 if dup2 did not reset the close-on-exec flag. */
284  exit(fl != 1);
285}
286], bash_cv_dup2_broken=yes, bash_cv_dup2_broken=no,
287    [AC_MSG_WARN(cannot check dup2 if cross compiling -- defaulting to no)
288     bash_cv_dup2_broken=no])
289])
290AC_MSG_RESULT($bash_cv_dup2_broken)
291if test $bash_cv_dup2_broken = yes; then
292AC_DEFINE(DUP2_BROKEN)
293fi
294])
295
296AC_DEFUN(BASH_FUNC_STRSIGNAL,
297[AC_MSG_CHECKING([for the existence of strsignal])
298AC_CACHE_VAL(bash_cv_have_strsignal,
299[AC_TRY_LINK([#include <sys/types.h>
300#include <signal.h>],
301[char *s = (char *)strsignal(2);],
302 bash_cv_have_strsignal=yes, bash_cv_have_strsignal=no)])
303AC_MSG_RESULT($bash_cv_have_strsignal)
304if test $bash_cv_have_strsignal = yes; then
305AC_DEFINE(HAVE_STRSIGNAL)
306fi
307])
308
309dnl Check to see if opendir will open non-directories (not a nice thing)
310AC_DEFUN(BASH_FUNC_OPENDIR_CHECK,
311[AC_REQUIRE([AC_HEADER_DIRENT])dnl
312AC_MSG_CHECKING(if opendir() opens non-directories)
313AC_CACHE_VAL(bash_cv_opendir_not_robust,
314[AC_TRY_RUN([
315#include <stdio.h>
316#include <sys/types.h>
317#include <fcntl.h>
318#ifdef HAVE_UNISTD_H
319# include <unistd.h>
320#endif /* HAVE_UNISTD_H */
321#if defined(HAVE_DIRENT_H)
322# include <dirent.h>
323#else
324# define dirent direct
325# ifdef HAVE_SYS_NDIR_H
326#  include <sys/ndir.h>
327# endif /* SYSNDIR */
328# ifdef HAVE_SYS_DIR_H
329#  include <sys/dir.h>
330# endif /* SYSDIR */
331# ifdef HAVE_NDIR_H
332#  include <ndir.h>
333# endif
334#endif /* HAVE_DIRENT_H */
335main()
336{
337DIR *dir;
338int fd, err;
339err = mkdir("/tmp/bash-aclocal", 0700);
340if (err < 0) {
341  perror("mkdir");
342  exit(1);
343}
344unlink("/tmp/bash-aclocal/not_a_directory");
345fd = open("/tmp/bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
346write(fd, "\n", 1);
347close(fd);
348dir = opendir("/tmp/bash-aclocal/not_a_directory");
349unlink("/tmp/bash-aclocal/not_a_directory");
350rmdir("/tmp/bash-aclocal");
351exit (dir == 0);
352}], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no,
353    [AC_MSG_WARN(cannot check opendir if cross compiling -- defaulting to no)
354     bash_cv_opendir_not_robust=no]
355)])
356AC_MSG_RESULT($bash_cv_opendir_not_robust)
357if test $bash_cv_opendir_not_robust = yes; then
358AC_DEFINE(OPENDIR_NOT_ROBUST)
359fi
360])
361
362dnl
363AC_DEFUN(BASH_TYPE_SIGHANDLER,
364[AC_MSG_CHECKING([whether signal handlers are of type void])
365AC_CACHE_VAL(bash_cv_void_sighandler,
366[AC_TRY_COMPILE([#include <sys/types.h>
367#include <signal.h>
368#ifdef signal
369#undef signal
370#endif
371#ifdef __cplusplus
372extern "C"
373#endif
374void (*signal ()) ();],
375[int i;], bash_cv_void_sighandler=yes, bash_cv_void_sighandler=no)])dnl
376AC_MSG_RESULT($bash_cv_void_sighandler)
377if test $bash_cv_void_sighandler = yes; then
378AC_DEFINE(VOID_SIGHANDLER)
379fi
380])
381
382dnl
383dnl A signed 16-bit integer quantity
384dnl
385AC_DEFUN(BASH_TYPE_BITS16_T,
386[
387if test "$ac_cv_sizeof_short" = 2; then
388  AC_CHECK_TYPE(bits16_t, short)
389elif test "$ac_cv_sizeof_char" = 2; then
390  AC_CHECK_TYPE(bits16_t, char)
391else
392  AC_CHECK_TYPE(bits16_t, short)
393fi
394])
395
396dnl
397dnl An unsigned 16-bit integer quantity
398dnl
399AC_DEFUN(BASH_TYPE_U_BITS16_T,
400[
401if test "$ac_cv_sizeof_short" = 2; then
402  AC_CHECK_TYPE(u_bits16_t, unsigned short)
403elif test "$ac_cv_sizeof_char" = 2; then
404  AC_CHECK_TYPE(u_bits16_t, unsigned char)
405else
406  AC_CHECK_TYPE(u_bits16_t, unsigned short)
407fi
408])
409
410dnl
411dnl A signed 32-bit integer quantity
412dnl
413AC_DEFUN(BASH_TYPE_BITS32_T,
414[
415if test "$ac_cv_sizeof_int" = 4; then
416  AC_CHECK_TYPE(bits32_t, int)
417elif test "$ac_cv_sizeof_long" = 4; then
418  AC_CHECK_TYPE(bits32_t, long)
419else
420  AC_CHECK_TYPE(bits32_t, int)
421fi
422])
423
424dnl
425dnl An unsigned 32-bit integer quantity
426dnl
427AC_DEFUN(BASH_TYPE_U_BITS32_T,
428[
429if test "$ac_cv_sizeof_int" = 4; then
430  AC_CHECK_TYPE(u_bits32_t, unsigned int)
431elif test "$ac_cv_sizeof_long" = 4; then
432  AC_CHECK_TYPE(u_bits32_t, unsigned long)
433else
434  AC_CHECK_TYPE(u_bits32_t, unsigned int)
435fi
436])
437
438AC_DEFUN(BASH_TYPE_PTRDIFF_T,
439[
440if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_char_p"; then
441  AC_CHECK_TYPE(ptrdiff_t, int)
442elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then
443  AC_CHECK_TYPE(ptrdiff_t, long)
444elif test "$ac_cv_type_long_long" = yes && test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_char_p"; then
445  AC_CHECK_TYPE(ptrdiff_t, [long long])
446else
447  AC_CHECK_TYPE(ptrdiff_t, int)
448fi
449])
450
451dnl
452dnl A signed 64-bit quantity
453dnl
454AC_DEFUN(BASH_TYPE_BITS64_T,
455[
456if test "$ac_cv_sizeof_char_p" = 8; then
457  AC_CHECK_TYPE(bits64_t, char *)
458elif test "$ac_cv_sizeof_double" = 8; then
459  AC_CHECK_TYPE(bits64_t, double)
460elif test -n "$ac_cv_type_long_long" && test "$ac_cv_sizeof_long_long" = 8; then
461  AC_CHECK_TYPE(bits64_t, [long long])
462elif test "$ac_cv_sizeof_long" = 8; then
463  AC_CHECK_TYPE(bits64_t, long)
464else
465  AC_CHECK_TYPE(bits64_t, double)
466fi
467])
468
469AC_DEFUN(BASH_TYPE_LONG_LONG,
470[
471AC_CACHE_CHECK([for long long], bash_cv_type_long_long,
472[AC_TRY_LINK([
473long long ll = 1; int i = 63;],
474[
475long long llm = (long long) -1;
476return ll << i | ll >> i | llm / ll | llm % ll;
477], bash_cv_type_long_long='long long', bash_cv_type_long_long='long')])
478if test "$bash_cv_type_long_long" = 'long long'; then
479  AC_DEFINE(HAVE_LONG_LONG, 1)
480fi
481])
482
483AC_DEFUN(BASH_TYPE_UNSIGNED_LONG_LONG,
484[
485AC_CACHE_CHECK([for unsigned long long], bash_cv_type_unsigned_long_long,
486[AC_TRY_LINK([
487unsigned long long ull = 1; int i = 63;],
488[
489unsigned long long ullmax = (unsigned long long) -1;
490return ull << i | ull >> i | ullmax / ull | ullmax % ull;
491], bash_cv_type_unsigned_long_long='unsigned long long',
492   bash_cv_type_unsigned_long_long='unsigned long')])
493if test "$bash_cv_type_unsigned_long_long" = 'unsigned long long'; then
494  AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1)
495fi
496])
497
498dnl
499dnl Type of struct rlimit fields: some systems (OSF/1, NetBSD, RISC/os 5.0)
500dnl have a rlim_t, others (4.4BSD based systems) use quad_t, others use
501dnl long and still others use int (HP-UX 9.01, SunOS 4.1.3).  To simplify
502dnl matters, this just checks for rlim_t, quad_t, or long.
503dnl
504AC_DEFUN(BASH_TYPE_RLIMIT,
505[AC_MSG_CHECKING(for size and type of struct rlimit fields)
506AC_CACHE_VAL(bash_cv_type_rlimit,
507[AC_TRY_COMPILE([#include <sys/types.h>
508#include <sys/resource.h>],
509[rlim_t xxx;], bash_cv_type_rlimit=rlim_t,[
510AC_TRY_RUN([
511#include <sys/types.h>
512#include <sys/time.h>
513#include <sys/resource.h>
514main()
515{
516#ifdef HAVE_QUAD_T
517  struct rlimit rl;
518  if (sizeof(rl.rlim_cur) == sizeof(quad_t))
519    exit(0);
520#endif
521  exit(1);
522}], bash_cv_type_rlimit=quad_t, bash_cv_type_rlimit=long,
523        [AC_MSG_WARN(cannot check quad_t if cross compiling -- defaulting to long)
524         bash_cv_type_rlimit=long])])
525])
526AC_MSG_RESULT($bash_cv_type_rlimit)
527if test $bash_cv_type_rlimit = quad_t; then
528AC_DEFINE(RLIMTYPE, quad_t)
529elif test $bash_cv_type_rlimit = rlim_t; then
530AC_DEFINE(RLIMTYPE, rlim_t)
531fi
532])
533
534AC_DEFUN(BASH_FUNC_LSTAT,
535[dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an
536dnl inline function in <sys/stat.h>.
537AC_CACHE_CHECK([for lstat], bash_cv_func_lstat,
538[AC_TRY_LINK([
539#include <sys/types.h>
540#include <sys/stat.h>
541],[ lstat(".",(struct stat *)0); ],
542bash_cv_func_lstat=yes, bash_cv_func_lstat=no)])
543if test $bash_cv_func_lstat = yes; then
544  AC_DEFINE(HAVE_LSTAT)
545fi
546])
547
548AC_DEFUN(BASH_FUNC_INET_ATON,
549[
550AC_CACHE_CHECK([for inet_aton], bash_cv_func_inet_aton,
551[AC_TRY_LINK([
552#include <sys/types.h>
553#include <netinet/in.h>
554#include <arpa/inet.h>
555struct in_addr ap;], [ inet_aton("127.0.0.1", &ap); ],
556bash_cv_func_inet_aton=yes, bash_cv_func_inet_aton=no)])
557if test $bash_cv_func_inet_aton = yes; then
558  AC_DEFINE(HAVE_INET_ATON)
559else
560  AC_LIBOBJ(inet_aton)
561fi
562])
563
564AC_DEFUN(BASH_FUNC_GETENV,
565[AC_MSG_CHECKING(to see if getenv can be redefined)
566AC_CACHE_VAL(bash_cv_getenv_redef,
567[AC_TRY_RUN([
568#ifdef HAVE_UNISTD_H
569#  include <unistd.h>
570#endif
571#ifndef __STDC__
572#  ifndef const
573#    define const
574#  endif
575#endif
576char *
577getenv (name)
578#if defined (__linux__) || defined (__bsdi__) || defined (convex)
579     const char *name;
580#else
581     char const *name;
582#endif /* !__linux__ && !__bsdi__ && !convex */
583{
584return "42";
585}
586main()
587{
588char *s;
589/* The next allows this program to run, but does not allow bash to link
590   when it redefines getenv.  I'm not really interested in figuring out
591   why not. */
592#if defined (NeXT)
593exit(1);
594#endif
595s = getenv("ABCDE");
596exit(s == 0);	/* force optimizer to leave getenv in */
597}
598], bash_cv_getenv_redef=yes, bash_cv_getenv_redef=no,
599   [AC_MSG_WARN(cannot check getenv redefinition if cross compiling -- defaulting to yes)
600    bash_cv_getenv_redef=yes]
601)])
602AC_MSG_RESULT($bash_cv_getenv_redef)
603if test $bash_cv_getenv_redef = yes; then
604AC_DEFINE(CAN_REDEFINE_GETENV)
605fi
606])
607
608# We should check for putenv before calling this
609AC_DEFUN(BASH_FUNC_STD_PUTENV,
610[
611AC_REQUIRE([AC_HEADER_STDC])
612AC_REQUIRE([AC_C_PROTOTYPES])
613AC_CACHE_CHECK([for standard-conformant putenv declaration], bash_cv_std_putenv,
614[AC_TRY_LINK([
615#if STDC_HEADERS
616#include <stdlib.h>
617#include <stddef.h>
618#endif
619#ifndef __STDC__
620#  ifndef const
621#    define const
622#  endif
623#endif
624#ifdef PROTOTYPES
625extern int putenv (char *);
626#else
627extern int putenv ();
628#endif
629],
630[return (putenv == 0);],
631bash_cv_std_putenv=yes, bash_cv_std_putenv=no
632)])
633if test $bash_cv_std_putenv = yes; then
634AC_DEFINE(HAVE_STD_PUTENV)
635fi
636])
637
638# We should check for unsetenv before calling this
639AC_DEFUN(BASH_FUNC_STD_UNSETENV,
640[
641AC_REQUIRE([AC_HEADER_STDC])
642AC_REQUIRE([AC_C_PROTOTYPES])
643AC_CACHE_CHECK([for standard-conformant unsetenv declaration], bash_cv_std_unsetenv,
644[AC_TRY_LINK([
645#if STDC_HEADERS
646#include <stdlib.h>
647#include <stddef.h>
648#endif
649#ifndef __STDC__
650#  ifndef const
651#    define const
652#  endif
653#endif
654#ifdef PROTOTYPES
655extern int unsetenv (const char *);
656#else
657extern int unsetenv ();
658#endif
659],
660[return (unsetenv == 0);],
661bash_cv_std_unsetenv=yes, bash_cv_std_unsetenv=no
662)])
663if test $bash_cv_std_unsetenv = yes; then
664AC_DEFINE(HAVE_STD_UNSETENV)
665fi
666])
667
668AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS,
669[AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize)
670AC_CACHE_VAL(bash_cv_ulimit_maxfds,
671[AC_TRY_RUN([
672main()
673{
674long maxfds = ulimit(4, 0L);
675exit (maxfds == -1L);
676}
677], bash_cv_ulimit_maxfds=yes, bash_cv_ulimit_maxfds=no,
678   [AC_MSG_WARN(cannot check ulimit if cross compiling -- defaulting to no)
679    bash_cv_ulimit_maxfds=no]
680)])
681AC_MSG_RESULT($bash_cv_ulimit_maxfds)
682if test $bash_cv_ulimit_maxfds = yes; then
683AC_DEFINE(ULIMIT_MAXFDS)
684fi
685])
686
687AC_DEFUN(BASH_FUNC_GETCWD,
688[AC_MSG_CHECKING([if getcwd() will dynamically allocate memory])
689AC_CACHE_VAL(bash_cv_getcwd_malloc,
690[AC_TRY_RUN([
691#include <stdio.h>
692#ifdef HAVE_UNISTD_H
693#include <unistd.h>
694#endif
695
696main()
697{
698	char	*xpwd;
699	xpwd = getcwd(0, 0);
700	exit (xpwd == 0);
701}
702], bash_cv_getcwd_malloc=yes, bash_cv_getcwd_malloc=no,
703   [AC_MSG_WARN(cannot check whether getcwd allocates memory when cross-compiling -- defaulting to no)
704    bash_cv_getcwd_malloc=no]
705)])
706AC_MSG_RESULT($bash_cv_getcwd_malloc)
707if test $bash_cv_getcwd_malloc = no; then
708AC_DEFINE(GETCWD_BROKEN)
709AC_LIBOBJ(getcwd)
710fi
711])
712
713dnl
714dnl This needs BASH_CHECK_SOCKLIB, but since that's not called on every
715dnl system, we can't use AC_PREREQ
716dnl
717AC_DEFUN(BASH_FUNC_GETHOSTBYNAME,
718[if test "X$bash_cv_have_gethostbyname" = "X"; then
719_bash_needmsg=yes
720else
721AC_MSG_CHECKING(for gethostbyname in socket library)
722_bash_needmsg=
723fi
724AC_CACHE_VAL(bash_cv_have_gethostbyname,
725[AC_TRY_LINK([#include <netdb.h>],
726[ struct hostent *hp;
727  hp = gethostbyname("localhost");
728], bash_cv_have_gethostbyname=yes, bash_cv_have_gethostbyname=no)]
729)
730if test "X$_bash_needmsg" = Xyes; then
731    AC_MSG_CHECKING(for gethostbyname in socket library)
732fi
733AC_MSG_RESULT($bash_cv_have_gethostbyname)
734if test "$bash_cv_have_gethostbyname" = yes; then
735AC_DEFINE(HAVE_GETHOSTBYNAME)
736fi
737])
738
739AC_DEFUN(BASH_FUNC_FNMATCH_EXTMATCH,
740[AC_MSG_CHECKING(if fnmatch does extended pattern matching with FNM_EXTMATCH)
741AC_CACHE_VAL(bash_cv_fnm_extmatch,
742[AC_TRY_RUN([
743#include <fnmatch.h>
744
745main()
746{
747#ifdef FNM_EXTMATCH
748  exit (0);
749#else
750  exit (1);
751#endif
752}
753], bash_cv_fnm_extmatch=yes, bash_cv_fnm_extmatch=no,
754    [AC_MSG_WARN(cannot check FNM_EXTMATCH if cross compiling -- defaulting to no)
755     bash_cv_fnm_extmatch=no])
756])
757AC_MSG_RESULT($bash_cv_fnm_extmatch)
758if test $bash_cv_fnm_extmatch = yes; then
759AC_DEFINE(HAVE_LIBC_FNM_EXTMATCH)
760fi
761])
762
763AC_DEFUN(BASH_FUNC_POSIX_SETJMP,
764[AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
765AC_MSG_CHECKING(for presence of POSIX-style sigsetjmp/siglongjmp)
766AC_CACHE_VAL(bash_cv_func_sigsetjmp,
767[AC_TRY_RUN([
768#ifdef HAVE_UNISTD_H
769#include <unistd.h>
770#endif
771#include <sys/types.h>
772#include <signal.h>
773#include <setjmp.h>
774
775main()
776{
777#if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS)
778exit (1);
779#else
780
781int code;
782sigset_t set, oset;
783sigjmp_buf xx;
784
785/* get the mask */
786sigemptyset(&set);
787sigemptyset(&oset);
788sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &set);
789sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset);
790
791/* save it */
792code = sigsetjmp(xx, 1);
793if (code)
794  exit(0);	/* could get sigmask and compare to oset here. */
795
796/* change it */
797sigaddset(&set, SIGINT);
798sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL);
799
800/* and siglongjmp */
801siglongjmp(xx, 10);
802exit(1);
803#endif
804}], bash_cv_func_sigsetjmp=present, bash_cv_func_sigsetjmp=missing,
805    [AC_MSG_WARN(cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing)
806     bash_cv_func_sigsetjmp=missing]
807)])
808AC_MSG_RESULT($bash_cv_func_sigsetjmp)
809if test $bash_cv_func_sigsetjmp = present; then
810AC_DEFINE(HAVE_POSIX_SIGSETJMP)
811fi
812])
813
814AC_DEFUN(BASH_FUNC_STRCOLL,
815[
816AC_MSG_CHECKING(whether or not strcoll and strcmp differ)
817AC_CACHE_VAL(bash_cv_func_strcoll_broken,
818[AC_TRY_RUN([
819#include <stdio.h>
820#if defined (HAVE_LOCALE_H)
821#include <locale.h>
822#endif
823
824main(c, v)
825int     c;
826char    *v[];
827{
828        int     r1, r2;
829        char    *deflocale, *defcoll;
830
831#ifdef HAVE_SETLOCALE
832        deflocale = setlocale(LC_ALL, "");
833	defcoll = setlocale(LC_COLLATE, "");
834#endif
835
836#ifdef HAVE_STRCOLL
837	/* These two values are taken from tests/glob-test. */
838        r1 = strcoll("abd", "aXd");
839#else
840	r1 = 0;
841#endif
842        r2 = strcmp("abd", "aXd");
843
844	/* These two should both be greater than 0.  It is permissible for
845	   a system to return different values, as long as the sign is the
846	   same. */
847
848        /* Exit with 1 (failure) if these two values are both > 0, since
849	   this tests whether strcoll(3) is broken with respect to strcmp(3)
850	   in the default locale. */
851	exit (r1 > 0 && r2 > 0);
852}
853], bash_cv_func_strcoll_broken=yes, bash_cv_func_strcoll_broken=no,
854   [AC_MSG_WARN(cannot check strcoll if cross compiling -- defaulting to no)
855    bash_cv_func_strcoll_broken=no]
856)])
857AC_MSG_RESULT($bash_cv_func_strcoll_broken)
858if test $bash_cv_func_strcoll_broken = yes; then
859AC_DEFINE(STRCOLL_BROKEN)
860fi
861])
862
863AC_DEFUN(BASH_FUNC_PRINTF_A_FORMAT,
864[AC_MSG_CHECKING([for printf floating point output in hex notation])
865AC_CACHE_VAL(bash_cv_printf_a_format,
866[AC_TRY_RUN([
867#include <stdio.h>
868#include <string.h>
869
870int
871main()
872{
873	double y = 0.0;
874	char abuf[1024];
875
876	sprintf(abuf, "%A", y);
877	exit(strchr(abuf, 'P') == (char *)0);
878}
879], bash_cv_printf_a_format=yes, bash_cv_printf_a_format=no,
880   [AC_MSG_WARN(cannot check printf if cross compiling -- defaulting to no)
881    bash_cv_printf_a_format=no]
882)])
883AC_MSG_RESULT($bash_cv_printf_a_format)
884if test $bash_cv_printf_a_format = yes; then
885AC_DEFINE(HAVE_PRINTF_A_FORMAT)
886fi
887])
888
889AC_DEFUN(BASH_STRUCT_TERMIOS_LDISC,
890[
891AC_CHECK_MEMBER(struct termios.c_line, AC_DEFINE(TERMIOS_LDISC), ,[
892#include <sys/types.h>
893#include <termios.h>
894])
895])
896
897AC_DEFUN(BASH_STRUCT_TERMIO_LDISC,
898[
899AC_CHECK_MEMBER(struct termio.c_line, AC_DEFINE(TERMIO_LDISC), ,[
900#include <sys/types.h>
901#include <termio.h>
902])
903])
904
905dnl
906dnl Like AC_STRUCT_ST_BLOCKS, but doesn't muck with LIBOBJS
907dnl
908dnl sets bash_cv_struct_stat_st_blocks
909dnl
910dnl unused for now; we'll see how AC_CHECK_MEMBERS works
911dnl
912AC_DEFUN(BASH_STRUCT_ST_BLOCKS,
913[
914AC_MSG_CHECKING([for struct stat.st_blocks])
915AC_CACHE_VAL(bash_cv_struct_stat_st_blocks,
916[AC_TRY_COMPILE(
917[
918#include <sys/types.h>
919#include <sys/stat.h>
920],
921[
922main()
923{
924static struct stat a;
925if (a.st_blocks) return 0;
926return 0;
927}
928], bash_cv_struct_stat_st_blocks=yes, bash_cv_struct_stat_st_blocks=no)
929])
930AC_MSG_RESULT($bash_cv_struct_stat_st_blocks)
931if test "$bash_cv_struct_stat_st_blocks" = "yes"; then
932AC_DEFINE(HAVE_STRUCT_STAT_ST_BLOCKS)
933fi
934])
935
936AC_DEFUN([BASH_CHECK_LIB_TERMCAP],
937[
938if test "X$bash_cv_termcap_lib" = "X"; then
939_bash_needmsg=yes
940else
941AC_MSG_CHECKING(which library has the termcap functions)
942_bash_needmsg=
943fi
944AC_CACHE_VAL(bash_cv_termcap_lib,
945[AC_CHECK_FUNC(tgetent, bash_cv_termcap_lib=libc,
946  [AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap,
947    [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
948        [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
949	    [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
950	        bash_cv_termcap_lib=gnutermcap)])])])])])
951if test "X$_bash_needmsg" = "Xyes"; then
952AC_MSG_CHECKING(which library has the termcap functions)
953fi
954AC_MSG_RESULT(using $bash_cv_termcap_lib)
955if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then
956LDFLAGS="$LDFLAGS -L./lib/termcap"
957TERMCAP_LIB="./lib/termcap/libtermcap.a"
958TERMCAP_DEP="./lib/termcap/libtermcap.a"
959elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
960TERMCAP_LIB=-ltermcap
961TERMCAP_DEP=
962elif test $bash_cv_termcap_lib = libtinfo; then
963TERMCAP_LIB=-ltinfo
964TERMCAP_DEP=
965elif test $bash_cv_termcap_lib = libncurses; then
966TERMCAP_LIB=-lncurses
967TERMCAP_DEP=
968elif test $bash_cv_termcap_lib = libc; then
969TERMCAP_LIB=
970TERMCAP_DEP=
971else
972TERMCAP_LIB=-lcurses
973TERMCAP_DEP=
974fi
975])
976
977dnl
978dnl Check for the presence of getpeername in libsocket.
979dnl If libsocket is present, check for libnsl and add it to LIBS if
980dnl it's there, since most systems with libsocket require linking
981dnl with libnsl as well.  This should only be called if getpeername
982dnl was not found in libc.
983dnl
984dnl NOTE: IF WE FIND GETPEERNAME, WE ASSUME THAT WE HAVE BIND/CONNECT
985dnl	  AS WELL
986dnl
987AC_DEFUN(BASH_CHECK_LIB_SOCKET,
988[
989if test "X$bash_cv_have_socklib" = "X"; then
990_bash_needmsg=
991else
992AC_MSG_CHECKING(for socket library)
993_bash_needmsg=yes
994fi
995AC_CACHE_VAL(bash_cv_have_socklib,
996[AC_CHECK_LIB(socket, getpeername,
997        bash_cv_have_socklib=yes, bash_cv_have_socklib=no, -lnsl)])
998if test "X$_bash_needmsg" = Xyes; then
999  AC_MSG_RESULT($bash_cv_have_socklib)
1000  _bash_needmsg=
1001fi
1002if test $bash_cv_have_socklib = yes; then
1003  # check for libnsl, add it to LIBS if present
1004  if test "X$bash_cv_have_libnsl" = "X"; then
1005    _bash_needmsg=
1006  else
1007    AC_MSG_CHECKING(for libnsl)
1008    _bash_needmsg=yes
1009  fi
1010  AC_CACHE_VAL(bash_cv_have_libnsl,
1011	   [AC_CHECK_LIB(nsl, t_open,
1012		 bash_cv_have_libnsl=yes, bash_cv_have_libnsl=no)])
1013  if test "X$_bash_needmsg" = Xyes; then
1014    AC_MSG_RESULT($bash_cv_have_libnsl)
1015    _bash_needmsg=
1016  fi
1017  if test $bash_cv_have_libnsl = yes; then
1018    LIBS="-lsocket -lnsl $LIBS"
1019  else
1020    LIBS="-lsocket $LIBS"
1021  fi
1022  AC_DEFINE(HAVE_LIBSOCKET)
1023  AC_DEFINE(HAVE_GETPEERNAME)
1024fi
1025])
1026
1027AC_DEFUN(BASH_STRUCT_DIRENT_D_INO,
1028[AC_REQUIRE([AC_HEADER_DIRENT])
1029AC_MSG_CHECKING(for struct dirent.d_ino)
1030AC_CACHE_VAL(bash_cv_dirent_has_dino,
1031[AC_TRY_COMPILE([
1032#include <stdio.h>
1033#include <sys/types.h>
1034#ifdef HAVE_UNISTD_H
1035# include <unistd.h>
1036#endif /* HAVE_UNISTD_H */
1037#if defined(HAVE_DIRENT_H)
1038# include <dirent.h>
1039#else
1040# define dirent direct
1041# ifdef HAVE_SYS_NDIR_H
1042#  include <sys/ndir.h>
1043# endif /* SYSNDIR */
1044# ifdef HAVE_SYS_DIR_H
1045#  include <sys/dir.h>
1046# endif /* SYSDIR */
1047# ifdef HAVE_NDIR_H
1048#  include <ndir.h>
1049# endif
1050#endif /* HAVE_DIRENT_H */
1051],[
1052struct dirent d; int z; z = d.d_ino;
1053], bash_cv_dirent_has_dino=yes, bash_cv_dirent_has_dino=no)])
1054AC_MSG_RESULT($bash_cv_dirent_has_dino)
1055if test $bash_cv_dirent_has_dino = yes; then
1056AC_DEFINE(HAVE_STRUCT_DIRENT_D_INO)
1057fi
1058])
1059
1060AC_DEFUN(BASH_STRUCT_DIRENT_D_FILENO,
1061[AC_REQUIRE([AC_HEADER_DIRENT])
1062AC_MSG_CHECKING(for struct dirent.d_fileno)
1063AC_CACHE_VAL(bash_cv_dirent_has_d_fileno,
1064[AC_TRY_COMPILE([
1065#include <stdio.h>
1066#include <sys/types.h>
1067#ifdef HAVE_UNISTD_H
1068# include <unistd.h>
1069#endif /* HAVE_UNISTD_H */
1070#if defined(HAVE_DIRENT_H)
1071# include <dirent.h>
1072#else
1073# define dirent direct
1074# ifdef HAVE_SYS_NDIR_H
1075#  include <sys/ndir.h>
1076# endif /* SYSNDIR */
1077# ifdef HAVE_SYS_DIR_H
1078#  include <sys/dir.h>
1079# endif /* SYSDIR */
1080# ifdef HAVE_NDIR_H
1081#  include <ndir.h>
1082# endif
1083#endif /* HAVE_DIRENT_H */
1084],[
1085struct dirent d; int z; z = d.d_fileno;
1086], bash_cv_dirent_has_d_fileno=yes, bash_cv_dirent_has_d_fileno=no)])
1087AC_MSG_RESULT($bash_cv_dirent_has_d_fileno)
1088if test $bash_cv_dirent_has_d_fileno = yes; then
1089AC_DEFINE(HAVE_STRUCT_DIRENT_D_FILENO)
1090fi
1091])
1092
1093AC_DEFUN(BASH_STRUCT_DIRENT_D_NAMLEN,
1094[AC_REQUIRE([AC_HEADER_DIRENT])
1095AC_MSG_CHECKING(for struct dirent.d_namlen)
1096AC_CACHE_VAL(bash_cv_dirent_has_d_namlen,
1097[AC_TRY_COMPILE([
1098#include <stdio.h>
1099#include <sys/types.h>
1100#ifdef HAVE_UNISTD_H
1101# include <unistd.h>
1102#endif /* HAVE_UNISTD_H */
1103#if defined(HAVE_DIRENT_H)
1104# include <dirent.h>
1105#else
1106# define dirent direct
1107# ifdef HAVE_SYS_NDIR_H
1108#  include <sys/ndir.h>
1109# endif /* SYSNDIR */
1110# ifdef HAVE_SYS_DIR_H
1111#  include <sys/dir.h>
1112# endif /* SYSDIR */
1113# ifdef HAVE_NDIR_H
1114#  include <ndir.h>
1115# endif
1116#endif /* HAVE_DIRENT_H */
1117],[
1118struct dirent d; int z; z = d.d_namlen;
1119], bash_cv_dirent_has_d_namlen=yes, bash_cv_dirent_has_d_namlen=no)])
1120AC_MSG_RESULT($bash_cv_dirent_has_d_namlen)
1121if test $bash_cv_dirent_has_d_namlen = yes; then
1122AC_DEFINE(HAVE_STRUCT_DIRENT_D_NAMLEN)
1123fi
1124])
1125
1126AC_DEFUN(BASH_STRUCT_TIMEVAL,
1127[AC_MSG_CHECKING(for struct timeval in sys/time.h and time.h)
1128AC_CACHE_VAL(bash_cv_struct_timeval,
1129[
1130AC_EGREP_HEADER(struct timeval, sys/time.h,
1131		bash_cv_struct_timeval=yes,
1132		AC_EGREP_HEADER(struct timeval, time.h,
1133			bash_cv_struct_timeval=yes,
1134			bash_cv_struct_timeval=no))
1135])
1136AC_MSG_RESULT($bash_cv_struct_timeval)
1137if test $bash_cv_struct_timeval = yes; then
1138  AC_DEFINE(HAVE_TIMEVAL)
1139fi
1140])
1141
1142AC_DEFUN(BASH_STRUCT_TIMEZONE,
1143[AC_MSG_CHECKING(for struct timezone in sys/time.h and time.h)
1144AC_CACHE_VAL(bash_cv_struct_timezone,
1145[
1146AC_EGREP_HEADER(struct timezone, sys/time.h,
1147		bash_cv_struct_timezone=yes,
1148		AC_EGREP_HEADER(struct timezone, time.h,
1149			bash_cv_struct_timezone=yes,
1150			bash_cv_struct_timezone=no))
1151])
1152AC_MSG_RESULT($bash_cv_struct_timezone)
1153if test $bash_cv_struct_timezone = yes; then
1154  AC_DEFINE(HAVE_STRUCT_TIMEZONE)
1155fi
1156])
1157
1158AC_DEFUN(BASH_STRUCT_WINSIZE,
1159[AC_MSG_CHECKING(for struct winsize in sys/ioctl.h and termios.h)
1160AC_CACHE_VAL(bash_cv_struct_winsize_header,
1161[AC_TRY_COMPILE([#include <sys/types.h>
1162#include <sys/ioctl.h>], [struct winsize x;],
1163  bash_cv_struct_winsize_header=ioctl_h,
1164  [AC_TRY_COMPILE([#include <sys/types.h>
1165#include <termios.h>], [struct winsize x;],
1166  bash_cv_struct_winsize_header=termios_h, bash_cv_struct_winsize_header=other)
1167])])
1168if test $bash_cv_struct_winsize_header = ioctl_h; then
1169  AC_MSG_RESULT(sys/ioctl.h)
1170  AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL)
1171elif test $bash_cv_struct_winsize_header = termios_h; then
1172  AC_MSG_RESULT(termios.h)
1173  AC_DEFINE(STRUCT_WINSIZE_IN_TERMIOS)
1174else
1175  AC_MSG_RESULT(not found)
1176fi
1177])
1178
1179dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)
1180AC_DEFUN(BASH_SYS_SIGNAL_VINTAGE,
1181[AC_REQUIRE([AC_TYPE_SIGNAL])
1182AC_MSG_CHECKING(for type of signal functions)
1183AC_CACHE_VAL(bash_cv_signal_vintage,
1184[
1185  AC_TRY_LINK([#include <signal.h>],[
1186    sigset_t ss;
1187    struct sigaction sa;
1188    sigemptyset(&ss); sigsuspend(&ss);
1189    sigaction(SIGINT, &sa, (struct sigaction *) 0);
1190    sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0);
1191  ], bash_cv_signal_vintage=posix,
1192  [
1193    AC_TRY_LINK([#include <signal.h>], [
1194	int mask = sigmask(SIGINT);
1195	sigsetmask(mask); sigblock(mask); sigpause(mask);
1196    ], bash_cv_signal_vintage=4.2bsd,
1197    [
1198      AC_TRY_LINK([
1199	#include <signal.h>
1200	RETSIGTYPE foo() { }], [
1201		int mask = sigmask(SIGINT);
1202		sigset(SIGINT, foo); sigrelse(SIGINT);
1203		sighold(SIGINT); sigpause(SIGINT);
1204        ], bash_cv_signal_vintage=svr3, bash_cv_signal_vintage=v7
1205    )]
1206  )]
1207)
1208])
1209AC_MSG_RESULT($bash_cv_signal_vintage)
1210if test "$bash_cv_signal_vintage" = posix; then
1211AC_DEFINE(HAVE_POSIX_SIGNALS)
1212elif test "$bash_cv_signal_vintage" = "4.2bsd"; then
1213AC_DEFINE(HAVE_BSD_SIGNALS)
1214elif test "$bash_cv_signal_vintage" = svr3; then
1215AC_DEFINE(HAVE_USG_SIGHOLD)
1216fi
1217])
1218
1219dnl Check if the pgrp of setpgrp() can't be the pid of a zombie process.
1220AC_DEFUN(BASH_SYS_PGRP_SYNC,
1221[AC_REQUIRE([AC_FUNC_GETPGRP])
1222AC_MSG_CHECKING(whether pgrps need synchronization)
1223AC_CACHE_VAL(bash_cv_pgrp_pipe,
1224[AC_TRY_RUN([
1225#ifdef HAVE_UNISTD_H
1226#  include <unistd.h>
1227#endif
1228main()
1229{
1230# ifdef GETPGRP_VOID
1231#  define getpgID()	getpgrp()
1232# else
1233#  define getpgID()	getpgrp(0)
1234#  define setpgid(x,y)	setpgrp(x,y)
1235# endif
1236	int pid1, pid2, fds[2];
1237	int status;
1238	char ok;
1239
1240	switch (pid1 = fork()) {
1241	  case -1:
1242	    exit(1);
1243	  case 0:
1244	    setpgid(0, getpid());
1245	    exit(0);
1246	}
1247	setpgid(pid1, pid1);
1248
1249	sleep(2);	/* let first child die */
1250
1251	if (pipe(fds) < 0)
1252	  exit(2);
1253
1254	switch (pid2 = fork()) {
1255	  case -1:
1256	    exit(3);
1257	  case 0:
1258	    setpgid(0, pid1);
1259	    ok = getpgID() == pid1;
1260	    write(fds[1], &ok, 1);
1261	    exit(0);
1262	}
1263	setpgid(pid2, pid1);
1264
1265	close(fds[1]);
1266	if (read(fds[0], &ok, 1) != 1)
1267	  exit(4);
1268	wait(&status);
1269	wait(&status);
1270	exit(ok ? 0 : 5);
1271}
1272], bash_cv_pgrp_pipe=no,bash_cv_pgrp_pipe=yes,
1273   [AC_MSG_WARN(cannot check pgrp synchronization if cross compiling -- defaulting to no)
1274    bash_cv_pgrp_pipe=no])
1275])
1276AC_MSG_RESULT($bash_cv_pgrp_pipe)
1277if test $bash_cv_pgrp_pipe = yes; then
1278AC_DEFINE(PGRP_PIPE)
1279fi
1280])
1281
1282AC_DEFUN(BASH_SYS_REINSTALL_SIGHANDLERS,
1283[AC_REQUIRE([AC_TYPE_SIGNAL])
1284AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
1285AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked])
1286AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers,
1287[AC_TRY_RUN([
1288#include <signal.h>
1289#ifdef HAVE_UNISTD_H
1290#include <unistd.h>
1291#endif
1292
1293typedef RETSIGTYPE sigfunc();
1294
1295int nsigint;
1296
1297#ifdef HAVE_POSIX_SIGNALS
1298sigfunc *
1299set_signal_handler(sig, handler)
1300     int sig;
1301     sigfunc *handler;
1302{
1303  struct sigaction act, oact;
1304  act.sa_handler = handler;
1305  act.sa_flags = 0;
1306  sigemptyset (&act.sa_mask);
1307  sigemptyset (&oact.sa_mask);
1308  sigaction (sig, &act, &oact);
1309  return (oact.sa_handler);
1310}
1311#else
1312#define set_signal_handler(s, h) signal(s, h)
1313#endif
1314
1315RETSIGTYPE
1316sigint(s)
1317int s;
1318{
1319  nsigint++;
1320}
1321
1322main()
1323{
1324	nsigint = 0;
1325	set_signal_handler(SIGINT, sigint);
1326	kill((int)getpid(), SIGINT);
1327	kill((int)getpid(), SIGINT);
1328	exit(nsigint != 2);
1329}
1330], bash_cv_must_reinstall_sighandlers=no, bash_cv_must_reinstall_sighandlers=yes,
1331   [AC_MSG_WARN(cannot check signal handling if cross compiling -- defaulting to no)
1332    bash_cv_must_reinstall_sighandlers=no]
1333)])
1334AC_MSG_RESULT($bash_cv_must_reinstall_sighandlers)
1335if test $bash_cv_must_reinstall_sighandlers = yes; then
1336AC_DEFINE(MUST_REINSTALL_SIGHANDLERS)
1337fi
1338])
1339
1340dnl check that some necessary job control definitions are present
1341AC_DEFUN(BASH_SYS_JOB_CONTROL_MISSING,
1342[AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
1343AC_MSG_CHECKING(for presence of necessary job control definitions)
1344AC_CACHE_VAL(bash_cv_job_control_missing,
1345[AC_TRY_RUN([
1346#include <sys/types.h>
1347#ifdef HAVE_SYS_WAIT_H
1348#include <sys/wait.h>
1349#endif
1350#ifdef HAVE_UNISTD_H
1351#include <unistd.h>
1352#endif
1353#include <signal.h>
1354
1355/* Add more tests in here as appropriate. */
1356main()
1357{
1358/* signal type */
1359#if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS)
1360exit(1);
1361#endif
1362
1363/* signals and tty control. */
1364#if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT)
1365exit (1);
1366#endif
1367
1368/* process control */
1369#if !defined (WNOHANG) || !defined (WUNTRACED) 
1370exit(1);
1371#endif
1372
1373/* Posix systems have tcgetpgrp and waitpid. */
1374#if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP)
1375exit(1);
1376#endif
1377
1378#if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID)
1379exit(1);
1380#endif
1381
1382/* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */
1383#if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3)
1384exit(1);
1385#endif
1386
1387exit(0);
1388}], bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing,
1389    [AC_MSG_WARN(cannot check job control if cross-compiling -- defaulting to missing)
1390     bash_cv_job_control_missing=missing]
1391)])
1392AC_MSG_RESULT($bash_cv_job_control_missing)
1393if test $bash_cv_job_control_missing = missing; then
1394AC_DEFINE(JOB_CONTROL_MISSING)
1395fi
1396])
1397
1398dnl check whether named pipes are present
1399dnl this requires a previous check for mkfifo, but that is awkward to specify
1400AC_DEFUN(BASH_SYS_NAMED_PIPES,
1401[AC_MSG_CHECKING(for presence of named pipes)
1402AC_CACHE_VAL(bash_cv_sys_named_pipes,
1403[AC_TRY_RUN([
1404#include <sys/types.h>
1405#include <sys/stat.h>
1406#ifdef HAVE_UNISTD_H
1407#include <unistd.h>
1408#endif
1409
1410/* Add more tests in here as appropriate. */
1411main()
1412{
1413int fd, err;
1414
1415#if defined (HAVE_MKFIFO)
1416exit (0);
1417#endif
1418
1419#if !defined (S_IFIFO) && (defined (_POSIX_VERSION) && !defined (S_ISFIFO))
1420exit (1);
1421#endif
1422
1423#if defined (NeXT)
1424exit (1);
1425#endif
1426err = mkdir("/tmp/bash-aclocal", 0700);
1427if (err < 0) {
1428  perror ("mkdir");
1429  exit(1);
1430}
1431fd = mknod ("/tmp/bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
1432if (fd == -1) {
1433  rmdir ("/tmp/bash-aclocal");
1434  exit (1);
1435}
1436close(fd);
1437unlink ("/tmp/bash-aclocal/sh-np-autoconf");
1438rmdir ("/tmp/bash-aclocal");
1439exit(0);
1440}], bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing,
1441    [AC_MSG_WARN(cannot check for named pipes if cross-compiling -- defaulting to missing)
1442     bash_cv_sys_named_pipes=missing]
1443)])
1444AC_MSG_RESULT($bash_cv_sys_named_pipes)
1445if test $bash_cv_sys_named_pipes = missing; then
1446AC_DEFINE(NAMED_PIPES_MISSING)
1447fi
1448])
1449
1450AC_DEFUN(BASH_SYS_DEFAULT_MAIL_DIR,
1451[AC_MSG_CHECKING(for default mail directory)
1452AC_CACHE_VAL(bash_cv_mail_dir,
1453[if test -d /var/mail; then
1454   bash_cv_mail_dir=/var/mail
1455 elif test -d /var/spool/mail; then
1456   bash_cv_mail_dir=/var/spool/mail
1457 elif test -d /usr/mail; then
1458   bash_cv_mail_dir=/usr/mail
1459 elif test -d /usr/spool/mail; then
1460   bash_cv_mail_dir=/usr/spool/mail
1461 else
1462   bash_cv_mail_dir=unknown
1463 fi
1464])
1465AC_MSG_RESULT($bash_cv_mail_dir)
1466AC_DEFINE_UNQUOTED(DEFAULT_MAIL_DIRECTORY, "$bash_cv_mail_dir")
1467])
1468
1469AC_DEFUN(BASH_HAVE_TIOCGWINSZ,
1470[AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h)
1471AC_CACHE_VAL(bash_cv_tiocgwinsz_in_ioctl,
1472[AC_TRY_COMPILE([#include <sys/types.h>
1473#include <sys/ioctl.h>], [int x = TIOCGWINSZ;],
1474  bash_cv_tiocgwinsz_in_ioctl=yes,bash_cv_tiocgwinsz_in_ioctl=no)])
1475AC_MSG_RESULT($bash_cv_tiocgwinsz_in_ioctl)
1476if test $bash_cv_tiocgwinsz_in_ioctl = yes; then   
1477AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
1478fi
1479])
1480
1481AC_DEFUN(BASH_HAVE_TIOCSTAT,
1482[AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h)
1483AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl,
1484[AC_TRY_COMPILE([#include <sys/types.h>
1485#include <sys/ioctl.h>], [int x = TIOCSTAT;],
1486  bash_cv_tiocstat_in_ioctl=yes,bash_cv_tiocstat_in_ioctl=no)])
1487AC_MSG_RESULT($bash_cv_tiocstat_in_ioctl)
1488if test $bash_cv_tiocstat_in_ioctl = yes; then   
1489AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL)
1490fi
1491])
1492
1493AC_DEFUN(BASH_HAVE_FIONREAD,
1494[AC_MSG_CHECKING(for FIONREAD in sys/ioctl.h)
1495AC_CACHE_VAL(bash_cv_fionread_in_ioctl,
1496[AC_TRY_COMPILE([#include <sys/types.h>
1497#include <sys/ioctl.h>], [int x = FIONREAD;],
1498  bash_cv_fionread_in_ioctl=yes,bash_cv_fionread_in_ioctl=no)])
1499AC_MSG_RESULT($bash_cv_fionread_in_ioctl)
1500if test $bash_cv_fionread_in_ioctl = yes; then   
1501AC_DEFINE(FIONREAD_IN_SYS_IOCTL)
1502fi
1503])
1504
1505dnl
1506dnl See if speed_t is declared in <sys/types.h>.  Some versions of linux
1507dnl require a definition of speed_t each time <termcap.h> is included,
1508dnl but you can only get speed_t if you include <termios.h> (on some
1509dnl versions) or <sys/types.h> (on others).
1510dnl
1511AC_DEFUN(BASH_CHECK_SPEED_T,
1512[AC_MSG_CHECKING(for speed_t in sys/types.h)
1513AC_CACHE_VAL(bash_cv_speed_t_in_sys_types,
1514[AC_TRY_COMPILE([#include <sys/types.h>], [speed_t x;],
1515  bash_cv_speed_t_in_sys_types=yes,bash_cv_speed_t_in_sys_types=no)])
1516AC_MSG_RESULT($bash_cv_speed_t_in_sys_types)
1517if test $bash_cv_speed_t_in_sys_types = yes; then   
1518AC_DEFINE(SPEED_T_IN_SYS_TYPES)
1519fi
1520])
1521
1522AC_DEFUN(BASH_CHECK_GETPW_FUNCS,
1523[AC_MSG_CHECKING(whether getpw functions are declared in pwd.h)
1524AC_CACHE_VAL(bash_cv_getpw_declared,
1525[AC_EGREP_CPP(getpwuid,
1526[
1527#include <sys/types.h>
1528#ifdef HAVE_UNISTD_H
1529#  include <unistd.h>
1530#endif
1531#include <pwd.h>
1532],
1533bash_cv_getpw_declared=yes,bash_cv_getpw_declared=no)])
1534AC_MSG_RESULT($bash_cv_getpw_declared)
1535if test $bash_cv_getpw_declared = yes; then
1536AC_DEFINE(HAVE_GETPW_DECLS)
1537fi
1538])
1539
1540AC_DEFUN(BASH_CHECK_DEV_FD,
1541[AC_MSG_CHECKING(whether /dev/fd is available)
1542AC_CACHE_VAL(bash_cv_dev_fd,
1543[bash_cv_dev_fd=""
1544if test -d /dev/fd  && test -r /dev/fd/0 < /dev/null; then
1545# check for systems like FreeBSD 5 that only provide /dev/fd/[012]
1546   exec 3</dev/null
1547   if test -r /dev/fd/3; then
1548     bash_cv_dev_fd=standard
1549   else
1550     bash_cv_dev_fd=absent
1551   fi
1552   exec 3<&-
1553fi
1554if test -z "$bash_cv_dev_fd" ; then 
1555  if test -d /proc/self/fd && test -r /proc/self/fd/0 < /dev/null; then
1556    bash_cv_dev_fd=whacky
1557  else
1558    bash_cv_dev_fd=absent
1559  fi
1560fi
1561])
1562AC_MSG_RESULT($bash_cv_dev_fd)
1563if test $bash_cv_dev_fd = "standard"; then
1564  AC_DEFINE(HAVE_DEV_FD)
1565  AC_DEFINE(DEV_FD_PREFIX, "/dev/fd/")
1566elif test $bash_cv_dev_fd = "whacky"; then
1567  AC_DEFINE(HAVE_DEV_FD)
1568  AC_DEFINE(DEV_FD_PREFIX, "/proc/self/fd/")
1569fi
1570])
1571
1572AC_DEFUN(BASH_CHECK_DEV_STDIN,
1573[AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available)
1574AC_CACHE_VAL(bash_cv_dev_stdin,
1575[if test -d /dev/fd && test -r /dev/stdin < /dev/null; then
1576   bash_cv_dev_stdin=present
1577 elif test -d /proc/self/fd && test -r /dev/stdin < /dev/null; then
1578   bash_cv_dev_stdin=present
1579 else
1580   bash_cv_dev_stdin=absent
1581 fi
1582])
1583AC_MSG_RESULT($bash_cv_dev_stdin)
1584if test $bash_cv_dev_stdin = "present"; then
1585  AC_DEFINE(HAVE_DEV_STDIN)
1586fi
1587])
1588
1589dnl
1590dnl Check if HPUX needs _KERNEL defined for RLIMIT_* definitions
1591dnl
1592AC_DEFUN(BASH_CHECK_KERNEL_RLIMIT,
1593[AC_MSG_CHECKING([whether $host_os needs _KERNEL for RLIMIT defines])
1594AC_CACHE_VAL(bash_cv_kernel_rlimit,
1595[AC_TRY_COMPILE([
1596#include <sys/types.h>
1597#include <sys/resource.h>
1598],
1599[
1600  int f;
1601  f = RLIMIT_DATA;
1602], bash_cv_kernel_rlimit=no,
1603[AC_TRY_COMPILE([
1604#include <sys/types.h>
1605#define _KERNEL
1606#include <sys/resource.h>
1607#undef _KERNEL
1608],
1609[
1610	int f;
1611        f = RLIMIT_DATA;
1612], bash_cv_kernel_rlimit=yes, bash_cv_kernel_rlimit=no)]
1613)])
1614AC_MSG_RESULT($bash_cv_kernel_rlimit)
1615if test $bash_cv_kernel_rlimit = yes; then
1616AC_DEFINE(RLIMIT_NEEDS_KERNEL)
1617fi
1618])
1619
1620dnl
1621dnl Check for 64-bit off_t -- used for malloc alignment
1622dnl
1623dnl C does not allow duplicate case labels, so the compile will fail if
1624dnl sizeof(off_t) is > 4.
1625dnl
1626AC_DEFUN(BASH_CHECK_OFF_T_64,
1627[AC_CACHE_CHECK(for 64-bit off_t, bash_cv_off_t_64,
1628AC_TRY_COMPILE([
1629#ifdef HAVE_UNISTD_H
1630#include <unistd.h>
1631#endif
1632#include <sys/types.h>
1633],[
1634switch (0) case 0: case (sizeof (off_t) <= 4):;
1635], bash_cv_off_t_64=no, bash_cv_off_t_64=yes))
1636if test $bash_cv_off_t_64 = yes; then
1637        AC_DEFINE(HAVE_OFF_T_64)
1638fi])
1639
1640AC_DEFUN(BASH_CHECK_RTSIGS,
1641[AC_MSG_CHECKING(for unusable real-time signals due to large values)
1642AC_CACHE_VAL(bash_cv_unusable_rtsigs,
1643[AC_TRY_RUN([
1644#include <sys/types.h>
1645#include <signal.h>
1646
1647#ifndef NSIG
1648#  define NSIG 64
1649#endif
1650
1651main ()
1652{
1653  int n_sigs = 2 * NSIG;
1654#ifdef SIGRTMIN
1655  int rtmin = SIGRTMIN;
1656#else
1657  int rtmin = 0;
1658#endif
1659
1660  exit(rtmin < n_sigs);
1661}], bash_cv_unusable_rtsigs=yes, bash_cv_unusable_rtsigs=no,
1662    [AC_MSG_WARN(cannot check real-time signals if cross compiling -- defaulting to yes)
1663     bash_cv_unusable_rtsigs=yes]
1664)])
1665AC_MSG_RESULT($bash_cv_unusable_rtsigs)
1666if test $bash_cv_unusable_rtsigs = yes; then
1667AC_DEFINE(UNUSABLE_RT_SIGNALS)
1668fi
1669])
1670
1671dnl
1672dnl check for availability of multibyte characters and functions
1673dnl
1674dnl geez, I wish I didn't have to check for all of this stuff separately
1675dnl
1676AC_DEFUN(BASH_CHECK_MULTIBYTE,
1677[
1678AC_CHECK_HEADERS(wctype.h)
1679AC_CHECK_HEADERS(wchar.h)
1680AC_CHECK_HEADERS(langinfo.h)
1681
1682AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))
1683AC_CHECK_FUNC(mbrlen, AC_DEFINE(HAVE_MBRLEN))
1684
1685AC_CHECK_FUNC(wcrtomb, AC_DEFINE(HAVE_WCRTOMB))
1686AC_CHECK_FUNC(wcscoll, AC_DEFINE(HAVE_WCSCOLL))
1687AC_CHECK_FUNC(wcsdup, AC_DEFINE(HAVE_WCSDUP))
1688AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH))
1689AC_CHECK_FUNC(wctype, AC_DEFINE(HAVE_WCTYPE))
1690
1691dnl checks for both mbrtowc and mbstate_t
1692AC_FUNC_MBRTOWC
1693if test $ac_cv_func_mbrtowc = yes; then
1694	AC_DEFINE(HAVE_MBSTATE_T)
1695fi
1696
1697AC_CHECK_FUNCS(iswlower iswupper towlower towupper iswctype)
1698
1699AC_CACHE_CHECK([for nl_langinfo and CODESET], bash_cv_langinfo_codeset,
1700[AC_TRY_LINK(
1701[#include <langinfo.h>],
1702[char* cs = nl_langinfo(CODESET);],
1703bash_cv_langinfo_codeset=yes, bash_cv_langinfo_codeset=no)])
1704if test $bash_cv_langinfo_codeset = yes; then
1705  AC_DEFINE(HAVE_LANGINFO_CODESET)
1706fi
1707
1708dnl check for wchar_t in <wchar.h>
1709AC_CACHE_CHECK([for wchar_t in wchar.h], bash_cv_type_wchar_t,
1710[AC_TRY_COMPILE(
1711[#include <wchar.h>
1712],
1713[
1714        wchar_t foo;
1715        foo = 0;
1716], bash_cv_type_wchar_t=yes, bash_cv_type_wchar_t=no)])
1717if test $bash_cv_type_wchar_t = yes; then
1718        AC_DEFINE(HAVE_WCHAR_T, 1, [systems should define this type here])
1719fi
1720
1721dnl check for wctype_t in <wctype.h>
1722AC_CACHE_CHECK([for wctype_t in wctype.h], bash_cv_type_wctype_t,
1723[AC_TRY_COMPILE(
1724[#include <wctype.h>],
1725[
1726        wctype_t foo;
1727        foo = 0;
1728], bash_cv_type_wctype_t=yes, bash_cv_type_wctype_t=no)])
1729if test $bash_cv_type_wctype_t = yes; then
1730        AC_DEFINE(HAVE_WCTYPE_T, 1, [systems should define this type here])
1731fi
1732
1733dnl check for wint_t in <wctype.h>
1734AC_CACHE_CHECK([for wint_t in wctype.h], bash_cv_type_wint_t,
1735[AC_TRY_COMPILE(
1736[#include <wctype.h>],
1737[
1738        wint_t foo;
1739        foo = 0;
1740], bash_cv_type_wint_t=yes, bash_cv_type_wint_t=no)])
1741if test $bash_cv_type_wint_t = yes; then
1742        AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here])
1743fi
1744
1745])
1746
1747dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB
1748dnl require:
1749dnl	AC_PROG_CC
1750dnl	BASH_CHECK_LIB_TERMCAP
1751
1752AC_DEFUN([RL_LIB_READLINE_VERSION],
1753[
1754AC_REQUIRE([BASH_CHECK_LIB_TERMCAP])
1755
1756AC_MSG_CHECKING([version of installed readline library])
1757
1758# What a pain in the ass this is.
1759
1760# save cpp and ld options
1761_save_CFLAGS="$CFLAGS"
1762_save_LDFLAGS="$LDFLAGS"
1763_save_LIBS="$LIBS"
1764
1765# Don't set ac_cv_rl_prefix if the caller has already assigned a value.  This
1766# allows the caller to do something like $_rl_prefix=$withval if the user
1767# specifies --with-installed-readline=PREFIX as an argument to configure
1768
1769if test -z "$ac_cv_rl_prefix"; then
1770test "x$prefix" = xNONE && ac_cv_rl_prefix=$ac_default_prefix || ac_cv_rl_prefix=${prefix}
1771fi
1772
1773eval ac_cv_rl_includedir=${ac_cv_rl_prefix}/include
1774eval ac_cv_rl_libdir=${ac_cv_rl_prefix}/lib
1775
1776LIBS="$LIBS -lreadline ${TERMCAP_LIB}"
1777CFLAGS="$CFLAGS -I${ac_cv_rl_includedir}"
1778LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}"
1779
1780AC_CACHE_VAL(ac_cv_rl_version,
1781[AC_TRY_RUN([
1782#include <stdio.h>
1783#include <readline/readline.h>
1784
1785extern int rl_gnu_readline_p;
1786
1787main()
1788{
1789	FILE *fp;
1790	fp = fopen("conftest.rlv", "w");
1791	if (fp == 0)
1792		exit(1);
1793	if (rl_gnu_readline_p != 1)
1794		fprintf(fp, "0.0\n");
1795	else
1796		fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0");
1797	fclose(fp);
1798	exit(0);
1799}
1800],
1801ac_cv_rl_version=`cat conftest.rlv`,
1802ac_cv_rl_version='0.0',
1803ac_cv_rl_version='4.2')])
1804
1805CFLAGS="$_save_CFLAGS"
1806LDFLAGS="$_save_LDFLAGS"
1807LIBS="$_save_LIBS"
1808
1809RL_MAJOR=0
1810RL_MINOR=0
1811
1812# (
1813case "$ac_cv_rl_version" in
18142*|3*|4*|5*|6*|7*|8*|9*)
1815	RL_MAJOR=`echo $ac_cv_rl_version | sed 's:\..*$::'`
1816	RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[[a-zA-Z]]*$::'`
1817	;;
1818esac
1819
1820# (((
1821case $RL_MAJOR in
1822[[0-9][0-9]])	_RL_MAJOR=$RL_MAJOR ;;
1823[[0-9]])	_RL_MAJOR=0$RL_MAJOR ;;
1824*)		_RL_MAJOR=00 ;;
1825esac
1826
1827# (((
1828case $RL_MINOR in
1829[[0-9][0-9]])	_RL_MINOR=$RL_MINOR ;;
1830[[0-9]])	_RL_MINOR=0$RL_MINOR ;;
1831*)		_RL_MINOR=00 ;;
1832esac
1833
1834RL_VERSION="0x${_RL_MAJOR}${_RL_MINOR}"
1835
1836# Readline versions greater than 4.2 have these defines in readline.h
1837
1838if test $ac_cv_rl_version = '0.0' ; then
1839	AC_MSG_WARN([Could not test version of installed readline library.])
1840elif test $RL_MAJOR -gt 4 || { test $RL_MAJOR = 4 && test $RL_MINOR -gt 2 ; } ; then
1841	# set these for use by the caller
1842	RL_PREFIX=$ac_cv_rl_prefix
1843	RL_LIBDIR=$ac_cv_rl_libdir
1844	RL_INCLUDEDIR=$ac_cv_rl_includedir
1845	AC_MSG_RESULT($ac_cv_rl_version)
1846else
1847
1848AC_DEFINE_UNQUOTED(RL_READLINE_VERSION, $RL_VERSION, [encoded version of the installed readline library])
1849AC_DEFINE_UNQUOTED(RL_VERSION_MAJOR, $RL_MAJOR, [major version of installed readline library])
1850AC_DEFINE_UNQUOTED(RL_VERSION_MINOR, $RL_MINOR, [minor version of installed readline library])
1851
1852AC_SUBST(RL_VERSION)
1853AC_SUBST(RL_MAJOR)
1854AC_SUBST(RL_MINOR)
1855
1856# set these for use by the caller
1857RL_PREFIX=$ac_cv_rl_prefix
1858RL_LIBDIR=$ac_cv_rl_libdir
1859RL_INCLUDEDIR=$ac_cv_rl_includedir
1860
1861AC_MSG_RESULT($ac_cv_rl_version)
1862
1863fi
1864])
1865
1866AC_DEFUN(BASH_FUNC_CTYPE_NONASCII,
1867[
1868AC_MSG_CHECKING(whether the ctype macros accept non-ascii characters)
1869AC_CACHE_VAL(bash_cv_func_ctype_nonascii,
1870[AC_TRY_RUN([
1871#ifdef HAVE_LOCALE_H
1872#include <locale.h>
1873#endif
1874#include <stdio.h>
1875#include <ctype.h>
1876
1877main(c, v)
1878int	c;
1879char	*v[];
1880{
1881	char	*deflocale;
1882	unsigned char x;
1883	int	r1, r2;
1884
1885#ifdef HAVE_SETLOCALE
1886	/* We take a shot here.  If that locale is not known, try the
1887	   system default.  We try this one because '\342' (226) is
1888	   known to be a printable character in that locale. */
1889	deflocale = setlocale(LC_ALL, "en_US.ISO8859-1");
1890	if (deflocale == 0)
1891		deflocale = setlocale(LC_ALL, "");
1892#endif
1893
1894	x = '\342';
1895	r1 = isprint(x);
1896	x -= 128;
1897	r2 = isprint(x);
1898	exit (r1 == 0 || r2 == 0);
1899}
1900], bash_cv_func_ctype_nonascii=yes, bash_cv_func_ctype_nonascii=no,
1901   [AC_MSG_WARN(cannot check ctype macros if cross compiling -- defaulting to no)
1902    bash_cv_func_ctype_nonascii=no]
1903)])
1904AC_MSG_RESULT($bash_cv_func_ctype_nonascii)
1905if test $bash_cv_func_ctype_nonascii = yes; then
1906AC_DEFINE(CTYPE_NON_ASCII)
1907fi
1908])
1909
1910AC_DEFUN(BASH_CHECK_WCONTINUED,
1911[
1912AC_MSG_CHECKING(whether WCONTINUED flag to waitpid is unavailable or available but broken)
1913AC_CACHE_VAL(bash_cv_wcontinued_broken,
1914[AC_TRY_RUN([
1915#include <sys/types.h>
1916#include <sys/wait.h>
1917#include <unistd.h>
1918#include <errno.h>
1919
1920#ifndef errno
1921extern int errno;
1922#endif
1923main()
1924{
1925	int	x;
1926
1927	x = waitpid(-1, (int *)0, WNOHANG|WCONTINUED);
1928	if (x == -1 && errno == EINVAL)
1929		exit (1);
1930	else
1931		exit (0);
1932}
1933], bash_cv_wcontinued_broken=no,bash_cv_wcontinued_broken=yes,
1934   [AC_MSG_WARN(cannot check WCONTINUED if cross compiling -- defaulting to no)
1935    bash_cv_wcontinued_broken=no]
1936)])
1937AC_MSG_RESULT($bash_cv_wcontinued_broken)
1938if test $bash_cv_wcontinued_broken = yes; then
1939AC_DEFINE(WCONTINUED_BROKEN)
1940fi
1941])
1942
1943dnl
1944dnl tests added for bashdb
1945dnl
1946
1947
1948AC_DEFUN([AM_PATH_LISPDIR],
1949 [AC_ARG_WITH(lispdir, AC_HELP_STRING([--with-lispdir], [override the default lisp directory]),
1950  [ lispdir="$withval" 
1951    AC_MSG_CHECKING([where .elc files should go])
1952    AC_MSG_RESULT([$lispdir])],
1953  [
1954  # If set to t, that means we are running in a shell under Emacs.
1955  # If you have an Emacs named "t", then use the full path.
1956  test x"$EMACS" = xt && EMACS=
1957  AC_CHECK_PROGS(EMACS, emacs xemacs, no)
1958  if test $EMACS != "no"; then
1959    if test x${lispdir+set} != xset; then
1960      AC_CACHE_CHECK([where .elc files should go], [am_cv_lispdir], [dnl
1961	am_cv_lispdir=`$EMACS -batch -q -eval '(while load-path (princ (concat (car load-path) "\n")) (setq load-path (cdr load-path)))' | sed -n -e 's,/$,,' -e '/.*\/lib\/\(x\?emacs\/site-lisp\)$/{s,,${libdir}/\1,;p;q;}' -e '/.*\/share\/\(x\?emacs\/site-lisp\)$/{s,,${datadir}/\1,;p;q;}'`
1962	if test -z "$am_cv_lispdir"; then
1963	  am_cv_lispdir='${datadir}/emacs/site-lisp'
1964	fi
1965      ])
1966      lispdir="$am_cv_lispdir"
1967    fi
1968  fi
1969 ])
1970 AC_SUBST(lispdir)
1971])
1972
1973dnl
1974dnl tests added for gettext
1975dnl
1976# codeset.m4 serial AM1 (gettext-0.10.40)
1977dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
1978dnl This file is free software, distributed under the terms of the GNU
1979dnl General Public License.  As a special exception to the GNU General
1980dnl Public License, this file may be distributed as part of a program
1981dnl that contains a configuration script generated by Autoconf, under
1982dnl the same distribution terms as the rest of that program.
1983
1984dnl From Bruno Haible.
1985
1986AC_DEFUN([AM_LANGINFO_CODESET],
1987[
1988  AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
1989    [AC_TRY_LINK([#include <langinfo.h>],
1990      [char* cs = nl_langinfo(CODESET);],
1991      am_cv_langinfo_codeset=yes,
1992      am_cv_langinfo_codeset=no)
1993    ])
1994  if test $am_cv_langinfo_codeset = yes; then
1995    AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
1996      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
1997  fi
1998])
1999# gettext.m4 serial 20 (gettext-0.12)
2000dnl Copyright (C) 1995-2003 Free Software Foundation, Inc.
2001dnl This file is free software, distributed under the terms of the GNU
2002dnl General Public License.  As a special exception to the GNU General
2003dnl Public License, this file may be distributed as part of a program
2004dnl that contains a configuration script generated by Autoconf, under
2005dnl the same distribution terms as the rest of that program.
2006dnl
2007dnl This file can can be used in projects which are not available under
2008dnl the GNU General Public License or the GNU Library General Public
2009dnl License but which still want to provide support for the GNU gettext
2010dnl functionality.
2011dnl Please note that the actual code of the GNU gettext library is covered
2012dnl by the GNU Library General Public License, and the rest of the GNU
2013dnl gettext package package is covered by the GNU General Public License.
2014dnl They are *not* in the public domain.
2015
2016dnl Authors:
2017dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
2018dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
2019
2020dnl Macro to add for using GNU gettext.
2021
2022dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
2023dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
2024dnl    default (if it is not specified or empty) is 'no-libtool'.
2025dnl    INTLSYMBOL should be 'external' for packages with no intl directory,
2026dnl    and 'no-libtool' or 'use-libtool' for packages with an intl directory.
2027dnl    If INTLSYMBOL is 'use-libtool', then a libtool library
2028dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
2029dnl    depending on --{enable,disable}-{shared,static} and on the presence of
2030dnl    AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
2031dnl    $(top_builddir)/intl/libintl.a will be created.
2032dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
2033dnl    implementations (in libc or libintl) without the ngettext() function
2034dnl    will be ignored.  If NEEDSYMBOL is specified and is
2035dnl    'need-formatstring-macros', then GNU gettext implementations that don't
2036dnl    support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
2037dnl INTLDIR is used to find the intl libraries.  If empty,
2038dnl    the value `$(top_builddir)/intl/' is used.
2039dnl
2040dnl The result of the configuration is one of three cases:
2041dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
2042dnl    and used.
2043dnl    Catalog format: GNU --> install in $(datadir)
2044dnl    Catalog extension: .mo after installation, .gmo in source tree
2045dnl 2) GNU gettext has been found in the system's C library.
2046dnl    Catalog format: GNU --> install in $(datadir)
2047dnl    Catalog extension: .mo after installation, .gmo in source tree
2048dnl 3) No internationalization, always use English msgid.
2049dnl    Catalog format: none
2050dnl    Catalog extension: none
2051dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
2052dnl The use of .gmo is historical (it was needed to avoid overwriting the
2053dnl GNU format catalogs when building on a platform with an X/Open gettext),
2054dnl but we keep it in order not to force irrelevant filename changes on the
2055dnl maintainers.
2056dnl
2057AC_DEFUN([AM_GNU_GETTEXT],
2058[
2059  dnl Argument checking.
2060  ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
2061    [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
2062])])])])])
2063  ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
2064    [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
2065])])])])
2066  define(gt_included_intl, ifelse([$1], [external], [no], [yes]))
2067  define(gt_libtool_suffix_prefix, ifelse([$1], [use-libtool], [l], []))
2068
2069  AC_REQUIRE([AM_PO_SUBDIRS])dnl
2070  ifelse(gt_included_intl, yes, [
2071    AC_REQUIRE([AM_INTL_SUBDIR])dnl
2072  ])
2073
2074  dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
2075  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
2076  AC_REQUIRE([AC_LIB_RPATH])
2077
2078  dnl Sometimes libintl requires libiconv, so first search for libiconv.
2079  dnl Ideally we would do this search only after the
2080  dnl      if test "$USE_NLS" = "yes"; then
2081  dnl        if test "$gt_cv_func_gnugettext_libc" != "yes"; then
2082  dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
2083  dnl the configure script would need to contain the same shell code
2084  dnl again, outside any 'if'. There are two solutions:
2085  dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
2086  dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
2087  dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
2088  dnl documented, we avoid it.
2089  ifelse(gt_included_intl, yes, , [
2090    AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
2091  ])
2092
2093  dnl Set USE_NLS.
2094  AM_NLS
2095
2096  ifelse(gt_included_intl, yes, [
2097    BUILD_INCLUDED_LIBINTL=no
2098    USE_INCLUDED_LIBINTL=no
2099  ])
2100  LIBINTL=
2101  LTLIBINTL=
2102  POSUB=
2103
2104  dnl If we use NLS figure out what method
2105  if test "$USE_NLS" = "yes"; then
2106    gt_use_preinstalled_gnugettext=no
2107    ifelse(gt_included_intl, yes, [
2108      AC_MSG_CHECKING([whether included gettext is requested])
2109      AC_ARG_WITH(included-gettext,
2110        [  --with-included-gettext use the GNU gettext library included here],
2111        nls_cv_force_use_gnu_gettext=$withval,
2112        nls_cv_force_use_gnu_gettext=no)
2113      AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
2114
2115      nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
2116      if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
2117    ])
2118        dnl User does not insist on using GNU NLS library.  Figure out what
2119        dnl to use.  If GNU gettext is available we use this.  Else we have
2120        dnl to fall back to GNU NLS library.
2121
2122        dnl Add a version number to the cache macros.
2123        define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1)))
2124        define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc])
2125        define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl])
2126
2127        AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
2128         [AC_TRY_LINK([#include <libintl.h>
2129]ifelse([$2], [need-formatstring-macros],
2130[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
2131#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
2132#endif
2133changequote(,)dnl
2134typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
2135changequote([,])dnl
2136], [])[extern int _nl_msg_cat_cntr;
2137extern int *_nl_domain_bindings;],
2138            [bindtextdomain ("", "");
2139return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings],
2140            gt_cv_func_gnugettext_libc=yes,
2141            gt_cv_func_gnugettext_libc=no)])
2142
2143        if test "$gt_cv_func_gnugettext_libc" != "yes"; then
2144          dnl Sometimes libintl requires libiconv, so first search for libiconv.
2145          ifelse(gt_included_intl, yes, , [
2146            AM_ICONV_LINK
2147          ])
2148          dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
2149          dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
2150          dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
2151          dnl even if libiconv doesn't exist.
2152          AC_LIB_LINKFLAGS_BODY([intl])
2153          AC_CACHE_CHECK([for GNU gettext in libintl],
2154            gt_cv_func_gnugettext_libintl,
2155           [gt_save_CPPFLAGS="$CPPFLAGS"
2156            CPPFLAGS="$CPPFLAGS $INCINTL"
2157            gt_save_LIBS="$LIBS"
2158            LIBS="$LIBS $LIBINTL"
2159            dnl Now see whether libintl exists and does not depend on libiconv.
2160            AC_TRY_LINK([#include <libintl.h>
2161]ifelse([$2], [need-formatstring-macros],
2162[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
2163#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
2164#endif
2165changequote(,)dnl
2166typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
2167changequote([,])dnl
2168], [])[extern int _nl_msg_cat_cntr;
2169extern
2170#ifdef __cplusplus
2171"C"
2172#endif
2173const char *_nl_expand_alias ();],
2174              [bindtextdomain ("", "");
2175return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
2176              gt_cv_func_gnugettext_libintl=yes,
2177              gt_cv_func_gnugettext_libintl=no)
2178            dnl Now see whether libintl exists and depends on libiconv.
2179            if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then
2180              LIBS="$LIBS $LIBICONV"
2181              AC_TRY_LINK([#include <libintl.h>
2182]ifelse([$2], [need-formatstring-macros],
2183[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
2184#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
2185#endif
2186changequote(,)dnl
2187typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
2188changequote([,])dnl
2189], [])[extern int _nl_msg_cat_cntr;
2190extern
2191#ifdef __cplusplus
2192"C"
2193#endif
2194const char *_nl_expand_alias ();],
2195                [bindtextdomain ("", "");
2196return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
2197               [LIBINTL="$LIBINTL $LIBICONV"
2198                LTLIBINTL="$LTLIBINTL $LTLIBICONV"
2199                gt_cv_func_gnugettext_libintl=yes
2200               ])
2201            fi
2202            CPPFLAGS="$gt_save_CPPFLAGS"
2203            LIBS="$gt_save_LIBS"])
2204        fi
2205
2206        dnl If an already present or preinstalled GNU gettext() is found,
2207        dnl use it.  But if this macro is used in GNU gettext, and GNU
2208        dnl gettext is already preinstalled in libintl, we update this
2209        dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
2210        if test "$gt_cv_func_gnugettext_libc" = "yes" \
2211           || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
2212                && test "$PACKAGE" != gettext-runtime \
2213                && test "$PACKAGE" != gettext-tools; }; then
2214          gt_use_preinstalled_gnugettext=yes
2215        else
2216          dnl Reset the values set by searching for libintl.
2217          LIBINTL=
2218          LTLIBINTL=
2219          INCINTL=
2220        fi
2221
2222    ifelse(gt_included_intl, yes, [
2223        if test "$gt_use_preinstalled_gnugettext" != "yes"; then
2224          dnl GNU gettext is not found in the C library.
2225          dnl Fall back on included GNU gettext library.
2226          nls_cv_use_gnu_gettext=yes
2227        fi
2228      fi
2229
2230      if test "$nls_cv_use_gnu_gettext" = "yes"; then
2231        dnl Mark actions used to generate GNU NLS library.
2232        BUILD_INCLUDED_LIBINTL=yes
2233        USE_INCLUDED_LIBINTL=yes
2234        LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV"
2235        LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV"
2236        LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
2237      fi
2238
2239      if test "$gt_use_preinstalled_gnugettext" = "yes" \
2240         || test "$nls_cv_use_gnu_gettext" = "yes"; then
2241        dnl Mark actions to use GNU gettext tools.
2242        CATOBJEXT=.gmo
2243      fi
2244    ])
2245
2246    if test "$gt_use_preinstalled_gnugettext" = "yes" \
2247       || test "$nls_cv_use_gnu_gettext" = "yes"; then
2248      AC_DEFINE(ENABLE_NLS, 1,
2249        [Define to 1 if translation of program messages to the user's native language
2250   is requested.])
2251    else
2252      USE_NLS=no
2253    fi
2254  fi
2255
2256  AC_MSG_CHECKING([whether to use NLS])
2257  AC_MSG_RESULT([$USE_NLS])
2258  if test "$USE_NLS" = "yes"; then
2259    AC_MSG_CHECKING([where the gettext function comes from])
2260    if test "$gt_use_preinstalled_gnugettext" = "yes"; then
2261      if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
2262        gt_source="external libintl"
2263      else
2264        gt_source="libc"
2265      fi
2266    else
2267      gt_source="included intl directory"
2268    fi
2269    AC_MSG_RESULT([$gt_source])
2270  fi
2271
2272  if test "$USE_NLS" = "yes"; then
2273
2274    if test "$gt_use_preinstalled_gnugettext" = "yes"; then
2275      if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
2276        AC_MSG_CHECKING([how to link with libintl])
2277        AC_MSG_RESULT([$LIBINTL])
2278        AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
2279      fi
2280
2281      dnl For backward compatibility. Some packages may be using this.
2282      AC_DEFINE(HAVE_GETTEXT, 1,
2283       [Define if the GNU gettext() function is already present or preinstalled.])
2284      AC_DEFINE(HAVE_DCGETTEXT, 1,
2285       [Define if the GNU dcgettext() function is already present or preinstalled.])
2286    fi
2287
2288    dnl We need to process the po/ directory.
2289    POSUB=po
2290  fi
2291
2292  ifelse(gt_included_intl, yes, [
2293    dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
2294    dnl to 'yes' because some of the testsuite requires it.
2295    if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then
2296      BUILD_INCLUDED_LIBINTL=yes
2297    fi
2298
2299    dnl Make all variables we use known to autoconf.
2300    AC_SUBST(BUILD_INCLUDED_LIBINTL)
2301    AC_SUBST(USE_INCLUDED_LIBINTL)
2302    AC_SUBST(CATOBJEXT)
2303
2304    dnl For backward compatibility. Some configure.ins may be using this.
2305    nls_cv_header_intl=
2306    nls_cv_header_libgt=
2307
2308    dnl For backward compatibility. Some Makefiles may be using this.
2309    DATADIRNAME=share
2310    AC_SUBST(DATADIRNAME)
2311
2312    dnl For backward compatibility. Some Makefiles may be using this.
2313    INSTOBJEXT=.mo
2314    AC_SUBST(INSTOBJEXT)
2315
2316    dnl For backward compatibility. Some Makefiles may be using this.
2317    GENCAT=gencat
2318    AC_SUBST(GENCAT)
2319
2320    dnl For backward compatibility. Some Makefiles may be using this.
2321    if test "$USE_INCLUDED_LIBINTL" = yes; then
2322      INTLOBJS="\$(GETTOBJS)"
2323    fi
2324    AC_SUBST(INTLOBJS)
2325
2326    dnl Enable libtool support if the surrounding package wishes it.
2327    INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
2328    AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
2329  ])
2330
2331  dnl For backward compatibility. Some Makefiles may be using this.
2332  INTLLIBS="$LIBINTL"
2333  AC_SUBST(INTLLIBS)
2334
2335  dnl Make all documented variables known to autoconf.
2336  AC_SUBST(LIBINTL)
2337  AC_SUBST(LTLIBINTL)
2338  AC_SUBST(POSUB)
2339])
2340
2341
2342dnl Checks for all prerequisites of the intl subdirectory,
2343dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
2344dnl            USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
2345AC_DEFUN([AM_INTL_SUBDIR],
2346[
2347  AC_REQUIRE([AC_PROG_INSTALL])dnl
2348  AC_REQUIRE([AM_MKINSTALLDIRS])dnl
2349  AC_REQUIRE([AC_PROG_CC])dnl
2350  AC_REQUIRE([AC_CANONICAL_HOST])dnl
2351  AC_REQUIRE([AC_PROG_RANLIB])dnl
2352  AC_REQUIRE([AC_ISC_POSIX])dnl
2353  AC_REQUIRE([AC_HEADER_STDC])dnl
2354  AC_REQUIRE([AC_C_CONST])dnl
2355  AC_REQUIRE([AC_C_INLINE])dnl
2356  AC_REQUIRE([AC_TYPE_OFF_T])dnl
2357  AC_REQUIRE([AC_TYPE_SIZE_T])dnl
2358  AC_REQUIRE([AC_FUNC_ALLOCA])dnl
2359  AC_REQUIRE([AC_FUNC_MMAP])dnl
2360  AC_REQUIRE([jm_GLIBC21])dnl
2361  AC_REQUIRE([gt_INTDIV0])dnl
2362  AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])dnl
2363  AC_REQUIRE([gt_HEADER_INTTYPES_H])dnl
2364  AC_REQUIRE([gt_INTTYPES_PRI])dnl
2365
2366  AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
2367stdlib.h string.h unistd.h sys/param.h])
2368  AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getc_unlocked getcwd getegid \
2369geteuid getgid getuid mempcpy munmap putenv setenv setlocale stpcpy \
2370strcasecmp strdup strtoul tsearch __argz_count __argz_stringify __argz_next \
2371__fsetlocking])
2372
2373  AM_ICONV
2374  AM_LANGINFO_CODESET
2375  if test $ac_cv_header_locale_h = yes; then
2376    AM_LC_MESSAGES
2377  fi
2378
2379  dnl intl/plural.c is generated from intl/plural.y. It requires bison,
2380  dnl because plural.y uses bison specific features. It requires at least
2381  dnl bison-1.26 because earlier versions generate a plural.c that doesn't
2382  dnl compile.
2383  dnl bison is only needed for the maintainer (who touches plural.y). But in
2384  dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
2385  dnl the rule in general Makefile. Now, some people carelessly touch the
2386  dnl files or have a broken "make" program, hence the plural.c rule will
2387  dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
2388  dnl present or too old.
2389  AC_CHECK_PROGS([INTLBISON], [bison])
2390  if test -z "$INTLBISON"; then
2391    ac_verc_fail=yes
2392  else
2393    dnl Found it, now check the version.
2394    AC_MSG_CHECKING([version of bison])
2395changequote(<<,>>)dnl
2396    ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
2397    case $ac_prog_version in
2398      '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
2399      1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
2400changequote([,])dnl
2401         ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
2402      *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
2403    esac
2404    AC_MSG_RESULT([$ac_prog_version])
2405  fi
2406  if test $ac_verc_fail = yes; then
2407    INTLBISON=:
2408  fi
2409])
2410
2411
2412dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
2413AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
2414# glibc21.m4 serial 2 (fileutils-4.1.3, gettext-0.10.40)
2415dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
2416dnl This file is free software, distributed under the terms of the GNU
2417dnl General Public License.  As a special exception to the GNU General
2418dnl Public License, this file may be distributed as part of a program
2419dnl that contains a configuration script generated by Autoconf, under
2420dnl the same distribution terms as the rest of that program.
2421
2422# Test for the GNU C Library, version 2.1 or newer.
2423# From Bruno Haible.
2424
2425AC_DEFUN([jm_GLIBC21],
2426  [
2427    AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
2428      ac_cv_gnu_library_2_1,
2429      [AC_EGREP_CPP([Lucky GNU user],
2430	[
2431#include <features.h>
2432#ifdef __GNU_LIBRARY__
2433 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
2434  Lucky GNU user
2435 #endif
2436#endif
2437	],
2438	ac_cv_gnu_library_2_1=yes,
2439	ac_cv_gnu_library_2_1=no)
2440      ]
2441    )
2442    AC_SUBST(GLIBC21)
2443    GLIBC21="$ac_cv_gnu_library_2_1"
2444  ]
2445)
2446# iconv.m4 serial AM4 (gettext-0.11.3)
2447dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
2448dnl This file is free software, distributed under the terms of the GNU
2449dnl General Public License.  As a special exception to the GNU General
2450dnl Public License, this file may be distributed as part of a program
2451dnl that contains a configuration script generated by Autoconf, under
2452dnl the same distribution terms as the rest of that program.
2453
2454dnl From Bruno Haible.
2455
2456AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
2457[
2458  dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
2459  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
2460  AC_REQUIRE([AC_LIB_RPATH])
2461
2462  dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
2463  dnl accordingly.
2464  AC_LIB_LINKFLAGS_BODY([iconv])
2465])
2466
2467AC_DEFUN([AM_ICONV_LINK],
2468[
2469  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
2470  dnl those with the standalone portable GNU libiconv installed).
2471
2472  dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
2473  dnl accordingly.
2474  AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
2475
2476  dnl Add $INCICONV to CPPFLAGS before performing the following checks,
2477  dnl because if the user has installed libiconv and not disabled its use
2478  dnl via --without-libiconv-prefix, he wants to use it. The first
2479  dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
2480  am_save_CPPFLAGS="$CPPFLAGS"
2481  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
2482
2483  AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
2484    am_cv_func_iconv="no, consider installing GNU libiconv"
2485    am_cv_lib_iconv=no
2486    AC_TRY_LINK([#include <stdlib.h>
2487#include <iconv.h>],
2488      [iconv_t cd = iconv_open("","");
2489       iconv(cd,NULL,NULL,NULL,NULL);
2490       iconv_close(cd);],
2491      am_cv_func_iconv=yes)
2492    if test "$am_cv_func_iconv" != yes; then
2493      am_save_LIBS="$LIBS"
2494      LIBS="$LIBS $LIBICONV"
2495      AC_TRY_LINK([#include <stdlib.h>
2496#include <iconv.h>],
2497        [iconv_t cd = iconv_open("","");
2498         iconv(cd,NULL,NULL,NULL,NULL);
2499         iconv_close(cd);],
2500        am_cv_lib_iconv=yes
2501        am_cv_func_iconv=yes)
2502      LIBS="$am_save_LIBS"
2503    fi
2504  ])
2505  if test "$am_cv_func_iconv" = yes; then
2506    AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
2507  fi
2508  if test "$am_cv_lib_iconv" = yes; then
2509    AC_MSG_CHECKING([how to link with libiconv])
2510    AC_MSG_RESULT([$LIBICONV])
2511  else
2512    dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
2513    dnl either.
2514    CPPFLAGS="$am_save_CPPFLAGS"
2515    LIBICONV=
2516    LTLIBICONV=
2517  fi
2518  AC_SUBST(LIBICONV)
2519  AC_SUBST(LTLIBICONV)
2520])
2521
2522AC_DEFUN([AM_ICONV],
2523[
2524  AM_ICONV_LINK
2525  if test "$am_cv_func_iconv" = yes; then
2526    AC_MSG_CHECKING([for iconv declaration])
2527    AC_CACHE_VAL(am_cv_proto_iconv, [
2528      AC_TRY_COMPILE([
2529#include <stdlib.h>
2530#include <iconv.h>
2531extern
2532#ifdef __cplusplus
2533"C"
2534#endif
2535#if defined(__STDC__) || defined(__cplusplus)
2536size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
2537#else
2538size_t iconv();
2539#endif
2540], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
2541      am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
2542    am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
2543    AC_MSG_RESULT([$]{ac_t:-
2544         }[$]am_cv_proto_iconv)
2545    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
2546      [Define as const if the declaration of iconv() needs const.])
2547  fi
2548])
2549# intdiv0.m4 serial 1 (gettext-0.11.3)
2550dnl Copyright (C) 2002 Free Software Foundation, Inc.
2551dnl This file is free software, distributed under the terms of the GNU
2552dnl General Public License.  As a special exception to the GNU General
2553dnl Public License, this file may be distributed as part of a program
2554dnl that contains a configuration script generated by Autoconf, under
2555dnl the same distribution terms as the rest of that program.
2556
2557dnl From Bruno Haible.
2558
2559AC_DEFUN([gt_INTDIV0],
2560[
2561  AC_REQUIRE([AC_PROG_CC])dnl
2562  AC_REQUIRE([AC_CANONICAL_HOST])dnl
2563
2564  AC_CACHE_CHECK([whether integer division by zero raises SIGFPE],
2565    gt_cv_int_divbyzero_sigfpe,
2566    [
2567      AC_TRY_RUN([
2568#include <stdlib.h>
2569#include <signal.h>
2570
2571static void
2572#ifdef __cplusplus
2573sigfpe_handler (int sig)
2574#else
2575sigfpe_handler (sig) int sig;
2576#endif
2577{
2578  /* Exit with code 0 if SIGFPE, with code 1 if any other signal.  */
2579  exit (sig != SIGFPE);
2580}
2581
2582int x = 1;
2583int y = 0;
2584int z;
2585int nan;
2586
2587int main ()
2588{
2589  signal (SIGFPE, sigfpe_handler);
2590/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP.  */
2591#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
2592  signal (SIGTRAP, sigfpe_handler);
2593#endif
2594/* Linux/SPARC yields signal SIGILL.  */
2595#if defined (__sparc__) && defined (__linux__)
2596  signal (SIGILL, sigfpe_handler);
2597#endif
2598
2599  z = x / y;
2600  nan = y / y;
2601  exit (1);
2602}
2603], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no,
2604        [
2605          # Guess based on the CPU.
2606          case "$host_cpu" in
2607            alpha* | i[34567]86 | m68k | s390*)
2608              gt_cv_int_divbyzero_sigfpe="guessing yes";;
2609            *)
2610              gt_cv_int_divbyzero_sigfpe="guessing no";;
2611          esac
2612        ])
2613    ])
2614  case "$gt_cv_int_divbyzero_sigfpe" in
2615    *yes) value=1;;
2616    *) value=0;;
2617  esac
2618  AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value,
2619    [Define if integer division by zero raises signal SIGFPE.])
2620])
2621# inttypes.m4 serial 1 (gettext-0.11.4)
2622dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
2623dnl This file is free software, distributed under the terms of the GNU
2624dnl General Public License.  As a special exception to the GNU General
2625dnl Public License, this file may be distributed as part of a program
2626dnl that contains a configuration script generated by Autoconf, under
2627dnl the same distribution terms as the rest of that program.
2628
2629dnl From Paul Eggert.
2630
2631# Define HAVE_INTTYPES_H if <inttypes.h> exists and doesn't clash with
2632# <sys/types.h>.
2633
2634AC_DEFUN([gt_HEADER_INTTYPES_H],
2635[
2636  AC_CACHE_CHECK([for inttypes.h], gt_cv_header_inttypes_h,
2637  [
2638    AC_TRY_COMPILE(
2639      [#include <sys/types.h>
2640#include <inttypes.h>],
2641      [], gt_cv_header_inttypes_h=yes, gt_cv_header_inttypes_h=no)
2642  ])
2643  if test $gt_cv_header_inttypes_h = yes; then
2644    AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
2645      [Define if <inttypes.h> exists and doesn't clash with <sys/types.h>.])
2646  fi
2647])
2648# inttypes_h.m4 serial 5 (gettext-0.12)
2649dnl Copyright (C) 1997-2003 Free Software Foundation, Inc.
2650dnl This file is free software, distributed under the terms of the GNU
2651dnl General Public License.  As a special exception to the GNU General
2652dnl Public License, this file may be distributed as part of a program
2653dnl that contains a configuration script generated by Autoconf, under
2654dnl the same distribution terms as the rest of that program.
2655
2656dnl From Paul Eggert.
2657
2658# Define HAVE_INTTYPES_H_WITH_UINTMAX if <inttypes.h> exists,
2659# doesn't clash with <sys/types.h>, and declares uintmax_t.
2660
2661AC_DEFUN([jm_AC_HEADER_INTTYPES_H],
2662[
2663  AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
2664  [AC_TRY_COMPILE(
2665    [#include <sys/types.h>
2666#include <inttypes.h>],
2667    [uintmax_t i = (uintmax_t) -1;],
2668    jm_ac_cv_header_inttypes_h=yes,
2669    jm_ac_cv_header_inttypes_h=no)])
2670  if test $jm_ac_cv_header_inttypes_h = yes; then
2671    AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1,
2672      [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
2673       and declares uintmax_t. ])
2674  fi
2675])
2676# inttypes-pri.m4 serial 1 (gettext-0.11.4)
2677dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
2678dnl This file is free software, distributed under the terms of the GNU
2679dnl General Public License.  As a special exception to the GNU General
2680dnl Public License, this file may be distributed as part of a program
2681dnl that contains a configuration script generated by Autoconf, under
2682dnl the same distribution terms as the rest of that program.
2683
2684dnl From Bruno Haible.
2685
2686# Define PRI_MACROS_BROKEN if <inttypes.h> exists and defines the PRI*
2687# macros to non-string values.  This is the case on AIX 4.3.3.
2688
2689AC_DEFUN([gt_INTTYPES_PRI],
2690[
2691  AC_REQUIRE([gt_HEADER_INTTYPES_H])
2692  if test $gt_cv_header_inttypes_h = yes; then
2693    AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken],
2694      gt_cv_inttypes_pri_broken,
2695      [
2696        AC_TRY_COMPILE([#include <inttypes.h>
2697#ifdef PRId32
2698char *p = PRId32;
2699#endif
2700], [], gt_cv_inttypes_pri_broken=no, gt_cv_inttypes_pri_broken=yes)
2701      ])
2702  fi
2703  if test "$gt_cv_inttypes_pri_broken" = yes; then
2704    AC_DEFINE_UNQUOTED(PRI_MACROS_BROKEN, 1,
2705      [Define if <inttypes.h> exists and defines unusable PRI* macros.])
2706  fi
2707])
2708# isc-posix.m4 serial 2 (gettext-0.11.2)
2709dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
2710dnl This file is free software, distributed under the terms of the GNU
2711dnl General Public License.  As a special exception to the GNU General
2712dnl Public License, this file may be distributed as part of a program
2713dnl that contains a configuration script generated by Autoconf, under
2714dnl the same distribution terms as the rest of that program.
2715
2716# This file is not needed with autoconf-2.53 and newer.  Remove it in 2005.
2717
2718# This test replaces the one in autoconf.
2719# Currently this macro should have the same name as the autoconf macro
2720# because gettext's gettext.m4 (distributed in the automake package)
2721# still uses it.  Otherwise, the use in gettext.m4 makes autoheader
2722# give these diagnostics:
2723#   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
2724#   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
2725
2726undefine([AC_ISC_POSIX])
2727
2728AC_DEFUN([AC_ISC_POSIX],
2729  [
2730    dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
2731    AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
2732  ]
2733)
2734# lcmessage.m4 serial 3 (gettext-0.11.3)
2735dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
2736dnl This file is free software, distributed under the terms of the GNU
2737dnl General Public License.  As a special exception to the GNU General
2738dnl Public License, this file may be distributed as part of a program
2739dnl that contains a configuration script generated by Autoconf, under
2740dnl the same distribution terms as the rest of that program.
2741dnl
2742dnl This file can can be used in projects which are not available under
2743dnl the GNU General Public License or the GNU Library General Public
2744dnl License but which still want to provide support for the GNU gettext
2745dnl functionality.
2746dnl Please note that the actual code of the GNU gettext library is covered
2747dnl by the GNU Library General Public License, and the rest of the GNU
2748dnl gettext package package is covered by the GNU General Public License.
2749dnl They are *not* in the public domain.
2750
2751dnl Authors:
2752dnl   Ulrich Drepper <drepper@cygnus.com>, 1995.
2753
2754# Check whether LC_MESSAGES is available in <locale.h>.
2755
2756AC_DEFUN([AM_LC_MESSAGES],
2757[
2758  AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
2759    [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
2760       am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
2761  if test $am_cv_val_LC_MESSAGES = yes; then
2762    AC_DEFINE(HAVE_LC_MESSAGES, 1,
2763      [Define if your <locale.h> file defines LC_MESSAGES.])
2764  fi
2765])
2766# lib-ld.m4 serial 2 (gettext-0.12)
2767dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
2768dnl This file is free software, distributed under the terms of the GNU
2769dnl General Public License.  As a special exception to the GNU General
2770dnl Public License, this file may be distributed as part of a program
2771dnl that contains a configuration script generated by Autoconf, under
2772dnl the same distribution terms as the rest of that program.
2773
2774dnl Subroutines of libtool.m4,
2775dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
2776dnl with libtool.m4.
2777
2778dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
2779AC_DEFUN([AC_LIB_PROG_LD_GNU],
2780[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
2781[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
2782if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
2783  acl_cv_prog_gnu_ld=yes
2784else
2785  acl_cv_prog_gnu_ld=no
2786fi])
2787with_gnu_ld=$acl_cv_prog_gnu_ld
2788])
2789
2790dnl From libtool-1.4. Sets the variable LD.
2791AC_DEFUN([AC_LIB_PROG_LD],
2792[AC_ARG_WITH(gnu-ld,
2793[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
2794test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
2795AC_REQUIRE([AC_PROG_CC])dnl
2796AC_REQUIRE([AC_CANONICAL_HOST])dnl
2797# Prepare PATH_SEPARATOR.
2798# The user is always right.
2799if test "${PATH_SEPARATOR+set}" != set; then
2800  echo "#! /bin/sh" >conf$$.sh
2801  echo  "exit 0"   >>conf$$.sh
2802  chmod +x conf$$.sh
2803  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
2804    PATH_SEPARATOR=';'
2805  else
2806    PATH_SEPARATOR=:
2807  fi
2808  rm -f conf$$.sh
2809fi
2810ac_prog=ld
2811if test "$GCC" = yes; then
2812  # Check if gcc -print-prog-name=ld gives a path.
2813  AC_MSG_CHECKING([for ld used by GCC])
2814  case $host in
2815  *-*-mingw*)
2816    # gcc leaves a trailing carriage return which upsets mingw
2817    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
2818  *)
2819    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
2820  esac
2821  case $ac_prog in
2822    # Accept absolute paths.
2823    [[\\/]* | [A-Za-z]:[\\/]*)]
2824      [re_direlt='/[^/][^/]*/\.\./']
2825      # Canonicalize the path of ld
2826      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
2827      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
2828	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
2829      done
2830      test -z "$LD" && LD="$ac_prog"
2831      ;;
2832  "")
2833    # If it fails, then pretend we aren't using GCC.
2834    ac_prog=ld
2835    ;;
2836  *)
2837    # If it is relative, then search for the first ld in PATH.
2838    with_gnu_ld=unknown
2839    ;;
2840  esac
2841elif test "$with_gnu_ld" = yes; then
2842  AC_MSG_CHECKING([for GNU ld])
2843else
2844  AC_MSG_CHECKING([for non-GNU ld])
2845fi
2846AC_CACHE_VAL(acl_cv_path_LD,
2847[if test -z "$LD"; then
2848  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
2849  for ac_dir in $PATH; do
2850    test -z "$ac_dir" && ac_dir=.
2851    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
2852      acl_cv_path_LD="$ac_dir/$ac_prog"
2853      # Check to see if the program is GNU ld.  I'd rather use --version,
2854      # but apparently some GNU ld's only accept -v.
2855      # Break only if it was the GNU/non-GNU ld that we prefer.
2856      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
2857	test "$with_gnu_ld" != no && break
2858      else
2859	test "$with_gnu_ld" != yes && break
2860      fi
2861    fi
2862  done
2863  IFS="$ac_save_ifs"
2864else
2865  acl_cv_path_LD="$LD" # Let the user override the test with a path.
2866fi])
2867LD="$acl_cv_path_LD"
2868if test -n "$LD"; then
2869  AC_MSG_RESULT($LD)
2870else
2871  AC_MSG_RESULT(no)
2872fi
2873test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
2874AC_LIB_PROG_LD_GNU
2875])
2876# lib-link.m4 serial 4 (gettext-0.12)
2877dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
2878dnl This file is free software, distributed under the terms of the GNU
2879dnl General Public License.  As a special exception to the GNU General
2880dnl Public License, this file may be distributed as part of a program
2881dnl that contains a configuration script generated by Autoconf, under
2882dnl the same distribution terms as the rest of that program.
2883
2884dnl From Bruno Haible.
2885
2886dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
2887dnl the libraries corresponding to explicit and implicit dependencies.
2888dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
2889dnl augments the CPPFLAGS variable.
2890AC_DEFUN([AC_LIB_LINKFLAGS],
2891[
2892  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
2893  AC_REQUIRE([AC_LIB_RPATH])
2894  define([Name],[translit([$1],[./-], [___])])
2895  define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
2896                               [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
2897  AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
2898    AC_LIB_LINKFLAGS_BODY([$1], [$2])
2899    ac_cv_lib[]Name[]_libs="$LIB[]NAME"
2900    ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
2901    ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
2902  ])
2903  LIB[]NAME="$ac_cv_lib[]Name[]_libs"
2904  LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
2905  INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
2906  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
2907  AC_SUBST([LIB]NAME)
2908  AC_SUBST([LTLIB]NAME)
2909  dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
2910  dnl results of this search when this library appears as a dependency.
2911  HAVE_LIB[]NAME=yes
2912  undefine([Name])
2913  undefine([NAME])
2914])
2915
2916dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
2917dnl searches for libname and the libraries corresponding to explicit and
2918dnl implicit dependencies, together with the specified include files and
2919dnl the ability to compile and link the specified testcode. If found, it
2920dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
2921dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
2922dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
2923dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
2924AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
2925[
2926  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
2927  AC_REQUIRE([AC_LIB_RPATH])
2928  define([Name],[translit([$1],[./-], [___])])
2929  define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
2930                               [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
2931
2932  dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
2933  dnl accordingly.
2934  AC_LIB_LINKFLAGS_BODY([$1], [$2])
2935
2936  dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
2937  dnl because if the user has installed lib[]Name and not disabled its use
2938  dnl via --without-lib[]Name-prefix, he wants to use it.
2939  ac_save_CPPFLAGS="$CPPFLAGS"
2940  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
2941
2942  AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
2943    ac_save_LIBS="$LIBS"
2944    LIBS="$LIBS $LIB[]NAME"
2945    AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
2946    LIBS="$ac_save_LIBS"
2947  ])
2948  if test "$ac_cv_lib[]Name" = yes; then
2949    HAVE_LIB[]NAME=yes
2950    AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
2951    AC_MSG_CHECKING([how to link with lib[]$1])
2952    AC_MSG_RESULT([$LIB[]NAME])
2953  else
2954    HAVE_LIB[]NAME=no
2955    dnl If $LIB[]NAME didn't lead to a usable library, we don't need
2956    dnl $INC[]NAME either.
2957    CPPFLAGS="$ac_save_CPPFLAGS"
2958    LIB[]NAME=
2959    LTLIB[]NAME=
2960  fi
2961  AC_SUBST([HAVE_LIB]NAME)
2962  AC_SUBST([LIB]NAME)
2963  AC_SUBST([LTLIB]NAME)
2964  undefine([Name])
2965  undefine([NAME])
2966])
2967
2968dnl Determine the platform dependent parameters needed to use rpath:
2969dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
2970dnl hardcode_direct, hardcode_minus_L.
2971AC_DEFUN([AC_LIB_RPATH],
2972[
2973  AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
2974  AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
2975  AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
2976  AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
2977  AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
2978    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
2979    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
2980    . ./conftest.sh
2981    rm -f ./conftest.sh
2982    acl_cv_rpath=done
2983  ])
2984  wl="$acl_cv_wl"
2985  libext="$acl_cv_libext"
2986  shlibext="$acl_cv_shlibext"
2987  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
2988  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
2989  hardcode_direct="$acl_cv_hardcode_direct"
2990  hardcode_minus_L="$acl_cv_hardcode_minus_L"
2991  dnl Determine whether the user wants rpath handling at all.
2992  AC_ARG_ENABLE(rpath,
2993    [  --disable-rpath         do not hardcode runtime library paths],
2994    :, enable_rpath=yes)
2995])
2996
2997dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
2998dnl the libraries corresponding to explicit and implicit dependencies.
2999dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
3000AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
3001[
3002  define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
3003                               [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
3004  dnl By default, look in $includedir and $libdir.
3005  use_additional=yes
3006  AC_LIB_WITH_FINAL_PREFIX([
3007    eval additional_includedir=\"$includedir\"
3008    eval additional_libdir=\"$libdir\"
3009  ])
3010  AC_LIB_ARG_WITH([lib$1-prefix],
3011[  --with-lib$1-prefix[=DIR]  search for lib$1 in DIR/include and DIR/lib
3012  --without-lib$1-prefix     don't search for lib$1 in includedir and libdir],
3013[
3014    if test "X$withval" = "Xno"; then
3015      use_additional=no
3016    else
3017      if test "X$withval" = "X"; then
3018        AC_LIB_WITH_FINAL_PREFIX([
3019          eval additional_includedir=\"$includedir\"
3020          eval additional_libdir=\"$libdir\"
3021        ])
3022      else
3023        additional_includedir="$withval/include"
3024        additional_libdir="$withval/lib"
3025      fi
3026    fi
3027])
3028  dnl Search the library and its dependencies in $additional_libdir and
3029  dnl $LDFLAGS. Using breadth-first-seach.
3030  LIB[]NAME=
3031  LTLIB[]NAME=
3032  INC[]NAME=
3033  rpathdirs=
3034  ltrpathdirs=
3035  names_already_handled=
3036  names_next_round='$1 $2'
3037  while test -n "$names_next_round"; do
3038    names_this_round="$names_next_round"
3039    names_next_round=
3040    for name in $names_this_round; do
3041      already_handled=
3042      for n in $names_already_handled; do
3043        if test "$n" = "$name"; then
3044          already_handled=yes
3045          break
3046        fi
3047      done
3048      if test -z "$already_handled"; then
3049        names_already_handled="$names_already_handled $name"
3050        dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
3051        dnl or AC_LIB_HAVE_LINKFLAGS call.
3052        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
3053        eval value=\"\$HAVE_LIB$uppername\"
3054        if test -n "$value"; then
3055          if test "$value" = yes; then
3056            eval value=\"\$LIB$uppername\"
3057            test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
3058            eval value=\"\$LTLIB$uppername\"
3059            test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
3060          else
3061            dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
3062            dnl that this library doesn't exist. So just drop it.
3063            :
3064          fi
3065        else
3066          dnl Search the library lib$name in $additional_libdir and $LDFLAGS
3067          dnl and the already constructed $LIBNAME/$LTLIBNAME.
3068          found_dir=
3069          found_la=
3070          found_so=
3071          found_a=
3072          if test $use_additional = yes; then
3073            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
3074              found_dir="$additional_libdir"
3075              found_so="$additional_libdir/lib$name.$shlibext"
3076              if test -f "$additional_libdir/lib$name.la"; then
3077                found_la="$additional_libdir/lib$name.la"
3078              fi
3079            else
3080              if test -f "$additional_libdir/lib$name.$libext"; then
3081                found_dir="$additional_libdir"
3082                found_a="$additional_libdir/lib$name.$libext"
3083                if test -f "$additional_libdir/lib$name.la"; then
3084                  found_la="$additional_libdir/lib$name.la"
3085                fi
3086              fi
3087            fi
3088          fi
3089          if test "X$found_dir" = "X"; then
3090            for x in $LDFLAGS $LTLIB[]NAME; do
3091              AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3092              case "$x" in
3093                -L*)
3094                  dir=`echo "X$x" | sed -e 's/^X-L//'`
3095                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
3096                    found_dir="$dir"
3097                    found_so="$dir/lib$name.$shlibext"
3098                    if test -f "$dir/lib$name.la"; then
3099                      found_la="$dir/lib$name.la"
3100                    fi
3101                  else
3102                    if test -f "$dir/lib$name.$libext"; then
3103                      found_dir="$dir"
3104                      found_a="$dir/lib$name.$libext"
3105                      if test -f "$dir/lib$name.la"; then
3106                        found_la="$dir/lib$name.la"
3107                      fi
3108                    fi
3109                  fi
3110                  ;;
3111              esac
3112              if test "X$found_dir" != "X"; then
3113                break
3114              fi
3115            done
3116          fi
3117          if test "X$found_dir" != "X"; then
3118            dnl Found the library.
3119            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
3120            if test "X$found_so" != "X"; then
3121              dnl Linking with a shared library. We attempt to hardcode its
3122              dnl directory into the executable's runpath, unless it's the
3123              dnl standard /usr/lib.
3124              if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
3125                dnl No hardcoding is needed.
3126                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
3127              else
3128                dnl Use an explicit option to hardcode DIR into the resulting
3129                dnl binary.
3130                dnl Potentially add DIR to ltrpathdirs.
3131                dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
3132                haveit=
3133                for x in $ltrpathdirs; do
3134                  if test "X$x" = "X$found_dir"; then
3135                    haveit=yes
3136                    break
3137                  fi
3138                done
3139                if test -z "$haveit"; then
3140                  ltrpathdirs="$ltrpathdirs $found_dir"
3141                fi
3142                dnl The hardcoding into $LIBNAME is system dependent.
3143                if test "$hardcode_direct" = yes; then
3144                  dnl Using DIR/libNAME.so during linking hardcodes DIR into the
3145                  dnl resulting binary.
3146                  LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
3147                else
3148                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
3149                    dnl Use an explicit option to hardcode DIR into the resulting
3150                    dnl binary.
3151                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
3152                    dnl Potentially add DIR to rpathdirs.
3153                    dnl The rpathdirs will be appended to $LIBNAME at the end.
3154                    haveit=
3155                    for x in $rpathdirs; do
3156                      if test "X$x" = "X$found_dir"; then
3157                        haveit=yes
3158                        break
3159                      fi
3160                    done
3161                    if test -z "$haveit"; then
3162                      rpathdirs="$rpathdirs $found_dir"
3163                    fi
3164                  else
3165                    dnl Rely on "-L$found_dir".
3166                    dnl But don't add it if it's already contained in the LDFLAGS
3167                    dnl or the already constructed $LIBNAME
3168                    haveit=
3169                    for x in $LDFLAGS $LIB[]NAME; do
3170                      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3171                      if test "X$x" = "X-L$found_dir"; then
3172                        haveit=yes
3173                        break
3174                      fi
3175                    done
3176                    if test -z "$haveit"; then
3177                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
3178                    fi
3179                    if test "$hardcode_minus_L" != no; then
3180                      dnl FIXME: Not sure whether we should use
3181                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
3182                      dnl here.
3183                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
3184                    else
3185                      dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
3186                      dnl here, because this doesn't fit in flags passed to the
3187                      dnl compiler. So give up. No hardcoding. This affects only
3188                      dnl very old systems.
3189                      dnl FIXME: Not sure whether we should use
3190                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
3191                      dnl here.
3192                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
3193                    fi
3194                  fi
3195                fi
3196              fi
3197            else
3198              if test "X$found_a" != "X"; then
3199                dnl Linking with a static library.
3200                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
3201              else
3202                dnl We shouldn't come here, but anyway it's good to have a
3203                dnl fallback.
3204                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
3205              fi
3206            fi
3207            dnl Assume the include files are nearby.
3208            additional_includedir=
3209            case "$found_dir" in
3210              */lib | */lib/)
3211                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
3212                additional_includedir="$basedir/include"
3213                ;;
3214            esac
3215            if test "X$additional_includedir" != "X"; then
3216              dnl Potentially add $additional_includedir to $INCNAME.
3217              dnl But don't add it
3218              dnl   1. if it's the standard /usr/include,
3219              dnl   2. if it's /usr/local/include and we are using GCC on Linux,
3220              dnl   3. if it's already present in $CPPFLAGS or the already
3221              dnl      constructed $INCNAME,
3222              dnl   4. if it doesn't exist as a directory.
3223              if test "X$additional_includedir" != "X/usr/include"; then
3224                haveit=
3225                if test "X$additional_includedir" = "X/usr/local/include"; then
3226                  if test -n "$GCC"; then
3227                    case $host_os in
3228                      linux*) haveit=yes;;
3229                    esac
3230                  fi
3231                fi
3232                if test -z "$haveit"; then
3233                  for x in $CPPFLAGS $INC[]NAME; do
3234                    AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3235                    if test "X$x" = "X-I$additional_includedir"; then
3236                      haveit=yes
3237                      break
3238                    fi
3239                  done
3240                  if test -z "$haveit"; then
3241                    if test -d "$additional_includedir"; then
3242                      dnl Really add $additional_includedir to $INCNAME.
3243                      INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
3244                    fi
3245                  fi
3246                fi
3247              fi
3248            fi
3249            dnl Look for dependencies.
3250            if test -n "$found_la"; then
3251              dnl Read the .la file. It defines the variables
3252              dnl dlname, library_names, old_library, dependency_libs, current,
3253              dnl age, revision, installed, dlopen, dlpreopen, libdir.
3254              save_libdir="$libdir"
3255              case "$found_la" in
3256                */* | *\\*) . "$found_la" ;;
3257                *) . "./$found_la" ;;
3258              esac
3259              libdir="$save_libdir"
3260              dnl We use only dependency_libs.
3261              for dep in $dependency_libs; do
3262                case "$dep" in
3263                  -L*)
3264                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
3265                    dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
3266                    dnl But don't add it
3267                    dnl   1. if it's the standard /usr/lib,
3268                    dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
3269                    dnl   3. if it's already present in $LDFLAGS or the already
3270                    dnl      constructed $LIBNAME,
3271                    dnl   4. if it doesn't exist as a directory.
3272                    if test "X$additional_libdir" != "X/usr/lib"; then
3273                      haveit=
3274                      if test "X$additional_libdir" = "X/usr/local/lib"; then
3275                        if test -n "$GCC"; then
3276                          case $host_os in
3277                            linux*) haveit=yes;;
3278                          esac
3279                        fi
3280                      fi
3281                      if test -z "$haveit"; then
3282                        haveit=
3283                        for x in $LDFLAGS $LIB[]NAME; do
3284                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3285                          if test "X$x" = "X-L$additional_libdir"; then
3286                            haveit=yes
3287                            break
3288                          fi
3289                        done
3290                        if test -z "$haveit"; then
3291                          if test -d "$additional_libdir"; then
3292                            dnl Really add $additional_libdir to $LIBNAME.
3293                            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
3294                          fi
3295                        fi
3296                        haveit=
3297                        for x in $LDFLAGS $LTLIB[]NAME; do
3298                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3299                          if test "X$x" = "X-L$additional_libdir"; then
3300                            haveit=yes
3301                            break
3302                          fi
3303                        done
3304                        if test -z "$haveit"; then
3305                          if test -d "$additional_libdir"; then
3306                            dnl Really add $additional_libdir to $LTLIBNAME.
3307                            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
3308                          fi
3309                        fi
3310                      fi
3311                    fi
3312                    ;;
3313                  -R*)
3314                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
3315                    if test "$enable_rpath" != no; then
3316                      dnl Potentially add DIR to rpathdirs.
3317                      dnl The rpathdirs will be appended to $LIBNAME at the end.
3318                      haveit=
3319                      for x in $rpathdirs; do
3320                        if test "X$x" = "X$dir"; then
3321                          haveit=yes
3322                          break
3323                        fi
3324                      done
3325                      if test -z "$haveit"; then
3326                        rpathdirs="$rpathdirs $dir"
3327                      fi
3328                      dnl Potentially add DIR to ltrpathdirs.
3329                      dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
3330                      haveit=
3331                      for x in $ltrpathdirs; do
3332                        if test "X$x" = "X$dir"; then
3333                          haveit=yes
3334                          break
3335                        fi
3336                      done
3337                      if test -z "$haveit"; then
3338                        ltrpathdirs="$ltrpathdirs $dir"
3339                      fi
3340                    fi
3341                    ;;
3342                  -l*)
3343                    dnl Handle this in the next round.
3344                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
3345                    ;;
3346                  *.la)
3347                    dnl Handle this in the next round. Throw away the .la's
3348                    dnl directory; it is already contained in a preceding -L
3349                    dnl option.
3350                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
3351                    ;;
3352                  *)
3353                    dnl Most likely an immediate library name.
3354                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
3355                    LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
3356                    ;;
3357                esac
3358              done
3359            fi
3360          else
3361            dnl Didn't find the library; assume it is in the system directories
3362            dnl known to the linker and runtime loader. (All the system
3363            dnl directories known to the linker should also be known to the
3364            dnl runtime loader, otherwise the system is severely misconfigured.)
3365            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
3366            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
3367          fi
3368        fi
3369      fi
3370    done
3371  done
3372  if test "X$rpathdirs" != "X"; then
3373    if test -n "$hardcode_libdir_separator"; then
3374      dnl Weird platform: only the last -rpath option counts, the user must
3375      dnl pass all path elements in one option. We can arrange that for a
3376      dnl single library, but not when more than one $LIBNAMEs are used.
3377      alldirs=
3378      for found_dir in $rpathdirs; do
3379        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
3380      done
3381      dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
3382      acl_save_libdir="$libdir"
3383      libdir="$alldirs"
3384      eval flag=\"$hardcode_libdir_flag_spec\"
3385      libdir="$acl_save_libdir"
3386      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
3387    else
3388      dnl The -rpath options are cumulative.
3389      for found_dir in $rpathdirs; do
3390        acl_save_libdir="$libdir"
3391        libdir="$found_dir"
3392        eval flag=\"$hardcode_libdir_flag_spec\"
3393        libdir="$acl_save_libdir"
3394        LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
3395      done
3396    fi
3397  fi
3398  if test "X$ltrpathdirs" != "X"; then
3399    dnl When using libtool, the option that works for both libraries and
3400    dnl executables is -R. The -R options are cumulative.
3401    for found_dir in $ltrpathdirs; do
3402      LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
3403    done
3404  fi
3405])
3406
3407dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
3408dnl unless already present in VAR.
3409dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
3410dnl contains two or three consecutive elements that belong together.
3411AC_DEFUN([AC_LIB_APPENDTOVAR],
3412[
3413  for element in [$2]; do
3414    haveit=
3415    for x in $[$1]; do
3416      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3417      if test "X$x" = "X$element"; then
3418        haveit=yes
3419        break
3420      fi
3421    done
3422    if test -z "$haveit"; then
3423      [$1]="${[$1]}${[$1]:+ }$element"
3424    fi
3425  done
3426])
3427# lib-prefix.m4 serial 2 (gettext-0.12)
3428dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
3429dnl This file is free software, distributed under the terms of the GNU
3430dnl General Public License.  As a special exception to the GNU General
3431dnl Public License, this file may be distributed as part of a program
3432dnl that contains a configuration script generated by Autoconf, under
3433dnl the same distribution terms as the rest of that program.
3434
3435dnl From Bruno Haible.
3436
3437dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
3438dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
3439dnl require excessive bracketing.
3440ifdef([AC_HELP_STRING],
3441[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
3442[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
3443
3444dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
3445dnl to access previously installed libraries. The basic assumption is that
3446dnl a user will want packages to use other packages he previously installed
3447dnl with the same --prefix option.
3448dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
3449dnl libraries, but is otherwise very convenient.
3450AC_DEFUN([AC_LIB_PREFIX],
3451[
3452  AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
3453  AC_REQUIRE([AC_PROG_CC])
3454  AC_REQUIRE([AC_CANONICAL_HOST])
3455  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
3456  dnl By default, look in $includedir and $libdir.
3457  use_additional=yes
3458  AC_LIB_WITH_FINAL_PREFIX([
3459    eval additional_includedir=\"$includedir\"
3460    eval additional_libdir=\"$libdir\"
3461  ])
3462  AC_LIB_ARG_WITH([lib-prefix],
3463[  --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
3464  --without-lib-prefix    don't search for libraries in includedir and libdir],
3465[
3466    if test "X$withval" = "Xno"; then
3467      use_additional=no
3468    else
3469      if test "X$withval" = "X"; then
3470        AC_LIB_WITH_FINAL_PREFIX([
3471          eval additional_includedir=\"$includedir\"
3472          eval additional_libdir=\"$libdir\"
3473        ])
3474      else
3475        additional_includedir="$withval/include"
3476        additional_libdir="$withval/lib"
3477      fi
3478    fi
3479])
3480  if test $use_additional = yes; then
3481    dnl Potentially add $additional_includedir to $CPPFLAGS.
3482    dnl But don't add it
3483    dnl   1. if it's the standard /usr/include,
3484    dnl   2. if it's already present in $CPPFLAGS,
3485    dnl   3. if it's /usr/local/include and we are using GCC on Linux,
3486    dnl   4. if it doesn't exist as a directory.
3487    if test "X$additional_includedir" != "X/usr/include"; then
3488      haveit=
3489      for x in $CPPFLAGS; do
3490        AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3491        if test "X$x" = "X-I$additional_includedir"; then
3492          haveit=yes
3493          break
3494        fi
3495      done
3496      if test -z "$haveit"; then
3497        if test "X$additional_includedir" = "X/usr/local/include"; then
3498          if test -n "$GCC"; then
3499            case $host_os in
3500              linux*) haveit=yes;;
3501            esac
3502          fi
3503        fi
3504        if test -z "$haveit"; then
3505          if test -d "$additional_includedir"; then
3506            dnl Really add $additional_includedir to $CPPFLAGS.
3507            CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
3508          fi
3509        fi
3510      fi
3511    fi
3512    dnl Potentially add $additional_libdir to $LDFLAGS.
3513    dnl But don't add it
3514    dnl   1. if it's the standard /usr/lib,
3515    dnl   2. if it's already present in $LDFLAGS,
3516    dnl   3. if it's /usr/local/lib and we are using GCC on Linux,
3517    dnl   4. if it doesn't exist as a directory.
3518    if test "X$additional_libdir" != "X/usr/lib"; then
3519      haveit=
3520      for x in $LDFLAGS; do
3521        AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3522        if test "X$x" = "X-L$additional_libdir"; then
3523          haveit=yes
3524          break
3525        fi
3526      done
3527      if test -z "$haveit"; then
3528        if test "X$additional_libdir" = "X/usr/local/lib"; then
3529          if test -n "$GCC"; then
3530            case $host_os in
3531              linux*) haveit=yes;;
3532            esac
3533          fi
3534        fi
3535        if test -z "$haveit"; then
3536          if test -d "$additional_libdir"; then
3537            dnl Really add $additional_libdir to $LDFLAGS.
3538            LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
3539          fi
3540        fi
3541      fi
3542    fi
3543  fi
3544])
3545
3546dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
3547dnl acl_final_exec_prefix, containing the values to which $prefix and
3548dnl $exec_prefix will expand at the end of the configure script.
3549AC_DEFUN([AC_LIB_PREPARE_PREFIX],
3550[
3551  dnl Unfortunately, prefix and exec_prefix get only finally determined
3552  dnl at the end of configure.
3553  if test "X$prefix" = "XNONE"; then
3554    acl_final_prefix="$ac_default_prefix"
3555  else
3556    acl_final_prefix="$prefix"
3557  fi
3558  if test "X$exec_prefix" = "XNONE"; then
3559    acl_final_exec_prefix='${prefix}'
3560  else
3561    acl_final_exec_prefix="$exec_prefix"
3562  fi
3563  acl_save_prefix="$prefix"
3564  prefix="$acl_final_prefix"
3565  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
3566  prefix="$acl_save_prefix"
3567])
3568
3569dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
3570dnl variables prefix and exec_prefix bound to the values they will have
3571dnl at the end of the configure script.
3572AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
3573[
3574  acl_save_prefix="$prefix"
3575  prefix="$acl_final_prefix"
3576  acl_save_exec_prefix="$exec_prefix"
3577  exec_prefix="$acl_final_exec_prefix"
3578  $1
3579  exec_prefix="$acl_save_exec_prefix"
3580  prefix="$acl_save_prefix"
3581])
3582# nls.m4 serial 1 (gettext-0.12)
3583dnl Copyright (C) 1995-2003 Free Software Foundation, Inc.
3584dnl This file is free software, distributed under the terms of the GNU
3585dnl General Public License.  As a special exception to the GNU General
3586dnl Public License, this file may be distributed as part of a program
3587dnl that contains a configuration script generated by Autoconf, under
3588dnl the same distribution terms as the rest of that program.
3589dnl
3590dnl This file can can be used in projects which are not available under
3591dnl the GNU General Public License or the GNU Library General Public
3592dnl License but which still want to provide support for the GNU gettext
3593dnl functionality.
3594dnl Please note that the actual code of the GNU gettext library is covered
3595dnl by the GNU Library General Public License, and the rest of the GNU
3596dnl gettext package package is covered by the GNU General Public License.
3597dnl They are *not* in the public domain.
3598
3599dnl Authors:
3600dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
3601dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
3602
3603AC_DEFUN([AM_NLS],
3604[
3605  AC_MSG_CHECKING([whether NLS is requested])
3606  dnl Default is enabled NLS
3607  AC_ARG_ENABLE(nls,
3608    [  --disable-nls           do not use Native Language Support],
3609    USE_NLS=$enableval, USE_NLS=yes)
3610  AC_MSG_RESULT($USE_NLS)
3611  AC_SUBST(USE_NLS)
3612])
3613
3614AC_DEFUN([AM_MKINSTALLDIRS],
3615[
3616  dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
3617  dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
3618  dnl Try to locate it.
3619  MKINSTALLDIRS=
3620  if test -n "$ac_aux_dir"; then
3621    case "$ac_aux_dir" in
3622      /*) MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" ;;
3623      *) MKINSTALLDIRS="\$(top_builddir)/$ac_aux_dir/mkinstalldirs" ;;
3624    esac
3625  fi
3626  if test -z "$MKINSTALLDIRS"; then
3627    MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
3628  fi
3629  AC_SUBST(MKINSTALLDIRS)
3630])
3631# po.m4 serial 1 (gettext-0.12)
3632dnl Copyright (C) 1995-2003 Free Software Foundation, Inc.
3633dnl This file is free software, distributed under the terms of the GNU
3634dnl General Public License.  As a special exception to the GNU General
3635dnl Public License, this file may be distributed as part of a program
3636dnl that contains a configuration script generated by Autoconf, under
3637dnl the same distribution terms as the rest of that program.
3638dnl
3639dnl This file can can be used in projects which are not available under
3640dnl the GNU General Public License or the GNU Library General Public
3641dnl License but which still want to provide support for the GNU gettext
3642dnl functionality.
3643dnl Please note that the actual code of the GNU gettext library is covered
3644dnl by the GNU Library General Public License, and the rest of the GNU
3645dnl gettext package package is covered by the GNU General Public License.
3646dnl They are *not* in the public domain.
3647
3648dnl Authors:
3649dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
3650dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
3651
3652dnl Checks for all prerequisites of the po subdirectory.
3653AC_DEFUN([AM_PO_SUBDIRS],
3654[
3655  AC_REQUIRE([AC_PROG_MAKE_SET])dnl
3656  AC_REQUIRE([AC_PROG_INSTALL])dnl
3657  AC_REQUIRE([AM_MKINSTALLDIRS])dnl
3658  AC_REQUIRE([AM_NLS])dnl
3659
3660  dnl Perform the following tests also if --disable-nls has been given,
3661  dnl because they are needed for "make dist" to work.
3662
3663  dnl Search for GNU msgfmt in the PATH.
3664  dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
3665  dnl The second test excludes FreeBSD msgfmt.
3666  AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
3667    [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 &&
3668     (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
3669    :)
3670  AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
3671
3672  dnl Search for GNU xgettext 0.12 or newer in the PATH.
3673  dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
3674  dnl The second test excludes FreeBSD xgettext.
3675  AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
3676    [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 &&
3677     (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
3678    :)
3679  dnl Remove leftover from FreeBSD xgettext call.
3680  rm -f messages.po
3681
3682  dnl Search for GNU msgmerge 0.11 or newer in the PATH.
3683  AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
3684    [$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1], :)
3685
3686  dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
3687  dnl Test whether we really found GNU msgfmt.
3688  if test "$GMSGFMT" != ":"; then
3689    dnl If it is no GNU msgfmt we define it as : so that the
3690    dnl Makefiles still can work.
3691    if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 &&
3692       (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
3693      : ;
3694    else
3695      GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'`
3696      AC_MSG_RESULT(
3697        [found $GMSGFMT program is not GNU msgfmt; ignore it])
3698      GMSGFMT=":"
3699    fi
3700  fi
3701
3702  dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
3703  dnl Test whether we really found GNU xgettext.
3704  if test "$XGETTEXT" != ":"; then
3705    dnl If it is no GNU xgettext we define it as : so that the
3706    dnl Makefiles still can work.
3707    if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 &&
3708       (if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
3709      : ;
3710    else
3711      AC_MSG_RESULT(
3712        [found xgettext program is not GNU xgettext; ignore it])
3713      XGETTEXT=":"
3714    fi
3715    dnl Remove leftover from FreeBSD xgettext call.
3716    rm -f messages.po
3717  fi
3718
3719  AC_OUTPUT_COMMANDS([
3720    for ac_file in $CONFIG_FILES; do
3721      # Support "outfile[:infile[:infile...]]"
3722      case "$ac_file" in
3723        *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
3724      esac
3725      # PO directories have a Makefile.in generated from Makefile.in.in.
3726      case "$ac_file" in */Makefile.in)
3727        # Adjust a relative srcdir.
3728        ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
3729        ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
3730        ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
3731        # In autoconf-2.13 it is called $ac_given_srcdir.
3732        # In autoconf-2.50 it is called $srcdir.
3733        test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
3734        case "$ac_given_srcdir" in
3735          .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
3736          /*) top_srcdir="$ac_given_srcdir" ;;
3737          *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
3738        esac
3739        if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
3740          rm -f "$ac_dir/POTFILES"
3741          test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
3742          cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ 	]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
3743          POMAKEFILEDEPS="POTFILES.in"
3744          # ALL_LINGUAS, POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES depend
3745          # on $ac_dir but don't depend on user-specified configuration
3746          # parameters.
3747          if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
3748            # The LINGUAS file contains the set of available languages.
3749            if test -n "$OBSOLETE_ALL_LINGUAS"; then
3750              test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
3751            fi
3752            ALL_LINGUAS_=`sed -e "/^#/d" "$ac_given_srcdir/$ac_dir/LINGUAS"`
3753            # Hide the ALL_LINGUAS assigment from automake.
3754            eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
3755            POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
3756          else
3757            # The set of available languages was given in configure.in.
3758            eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS'
3759          fi
3760          case "$ac_given_srcdir" in
3761            .) srcdirpre= ;;
3762            *) srcdirpre='$(srcdir)/' ;;
3763          esac
3764          POFILES=
3765          GMOFILES=
3766          UPDATEPOFILES=
3767          DUMMYPOFILES=
3768          for lang in $ALL_LINGUAS; do
3769            POFILES="$POFILES $srcdirpre$lang.po"
3770            GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
3771            UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
3772            DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
3773          done
3774          # CATALOGS depends on both $ac_dir and the user's LINGUAS
3775          # environment variable.
3776          INST_LINGUAS=
3777          if test -n "$ALL_LINGUAS"; then
3778            for presentlang in $ALL_LINGUAS; do
3779              useit=no
3780              if test "%UNSET%" != "$LINGUAS"; then
3781                desiredlanguages="$LINGUAS"
3782              else
3783                desiredlanguages="$ALL_LINGUAS"
3784              fi
3785              for desiredlang in $desiredlanguages; do
3786                # Use the presentlang catalog if desiredlang is
3787                #   a. equal to presentlang, or
3788                #   b. a variant of presentlang (because in this case,
3789                #      presentlang can be used as a fallback for messages
3790                #      which are not translated in the desiredlang catalog).
3791                case "$desiredlang" in
3792                  "$presentlang"*) useit=yes;;
3793                esac
3794              done
3795              if test $useit = yes; then
3796                INST_LINGUAS="$INST_LINGUAS $presentlang"
3797              fi
3798            done
3799          fi
3800          CATALOGS=
3801          if test -n "$INST_LINGUAS"; then
3802            for lang in $INST_LINGUAS; do
3803              CATALOGS="$CATALOGS $lang.gmo"
3804            done
3805          fi
3806          test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
3807          sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
3808          for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do
3809            if test -f "$f"; then
3810              case "$f" in
3811                *.orig | *.bak | *~) ;;
3812                *) cat "$f" >> "$ac_dir/Makefile" ;;
3813              esac
3814            fi
3815          done
3816        fi
3817        ;;
3818      esac
3819    done],
3820   [# Capture the value of obsolete ALL_LINGUAS because we need it to compute
3821    # POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES, CATALOGS. But hide it
3822    # from automake.
3823    eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"'
3824    # Capture the value of LINGUAS because we need it to compute CATALOGS.
3825    LINGUAS="${LINGUAS-%UNSET%}"
3826   ])
3827])
3828# progtest.m4 serial 3 (gettext-0.12)
3829dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
3830dnl This file is free software, distributed under the terms of the GNU
3831dnl General Public License.  As a special exception to the GNU General
3832dnl Public License, this file may be distributed as part of a program
3833dnl that contains a configuration script generated by Autoconf, under
3834dnl the same distribution terms as the rest of that program.
3835dnl
3836dnl This file can can be used in projects which are not available under
3837dnl the GNU General Public License or the GNU Library General Public
3838dnl License but which still want to provide support for the GNU gettext
3839dnl functionality.
3840dnl Please note that the actual code of the GNU gettext library is covered
3841dnl by the GNU Library General Public License, and the rest of the GNU
3842dnl gettext package package is covered by the GNU General Public License.
3843dnl They are *not* in the public domain.
3844
3845dnl Authors:
3846dnl   Ulrich Drepper <drepper@cygnus.com>, 1996.
3847
3848# Search path for a program which passes the given test.
3849
3850dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
3851dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
3852AC_DEFUN([AM_PATH_PROG_WITH_TEST],
3853[
3854# Prepare PATH_SEPARATOR.
3855# The user is always right.
3856if test "${PATH_SEPARATOR+set}" != set; then
3857  echo "#! /bin/sh" >conf$$.sh
3858  echo  "exit 0"   >>conf$$.sh
3859  chmod +x conf$$.sh
3860  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
3861    PATH_SEPARATOR=';'
3862  else
3863    PATH_SEPARATOR=:
3864  fi
3865  rm -f conf$$.sh
3866fi
3867
3868# Find out how to test for executable files. Don't use a zero-byte file,
3869# as systems may use methods other than mode bits to determine executability.
3870cat >conf$$.file <<_ASEOF
3871#! /bin/sh
3872exit 0
3873_ASEOF
3874chmod +x conf$$.file
3875if test -x conf$$.file >/dev/null 2>&1; then
3876  ac_executable_p="test -x"
3877else
3878  ac_executable_p="test -f"
3879fi
3880rm -f conf$$.file
3881
3882# Extract the first word of "$2", so it can be a program name with args.
3883set dummy $2; ac_word=[$]2
3884AC_MSG_CHECKING([for $ac_word])
3885AC_CACHE_VAL(ac_cv_path_$1,
3886[case "[$]$1" in
3887  [[\\/]]* | ?:[[\\/]]*)
3888    ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
3889    ;;
3890  *)
3891    ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR
3892    for ac_dir in ifelse([$5], , $PATH, [$5]); do
3893      IFS="$ac_save_IFS"
3894      test -z "$ac_dir" && ac_dir=.
3895      for ac_exec_ext in '' $ac_executable_extensions; do
3896        if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then
3897          if [$3]; then
3898            ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext"
3899            break 2
3900          fi
3901        fi
3902      done
3903    done
3904    IFS="$ac_save_IFS"
3905dnl If no 4th arg is given, leave the cache variable unset,
3906dnl so AC_PATH_PROGS will keep looking.
3907ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
3908])dnl
3909    ;;
3910esac])dnl
3911$1="$ac_cv_path_$1"
3912if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
3913  AC_MSG_RESULT([$]$1)
3914else
3915  AC_MSG_RESULT(no)
3916fi
3917AC_SUBST($1)dnl
3918])
3919# stdint_h.m4 serial 3 (gettext-0.12)
3920dnl Copyright (C) 1997-2003 Free Software Foundation, Inc.
3921dnl This file is free software, distributed under the terms of the GNU
3922dnl General Public License.  As a special exception to the GNU General
3923dnl Public License, this file may be distributed as part of a program
3924dnl that contains a configuration script generated by Autoconf, under
3925dnl the same distribution terms as the rest of that program.
3926
3927dnl From Paul Eggert.
3928
3929# Define HAVE_STDINT_H_WITH_UINTMAX if <stdint.h> exists,
3930# doesn't clash with <sys/types.h>, and declares uintmax_t.
3931
3932AC_DEFUN([jm_AC_HEADER_STDINT_H],
3933[
3934  AC_CACHE_CHECK([for stdint.h], jm_ac_cv_header_stdint_h,
3935  [AC_TRY_COMPILE(
3936    [#include <sys/types.h>
3937#include <stdint.h>],
3938    [uintmax_t i = (uintmax_t) -1;],
3939    jm_ac_cv_header_stdint_h=yes,
3940    jm_ac_cv_header_stdint_h=no)])
3941  if test $jm_ac_cv_header_stdint_h = yes; then
3942    AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1,
3943      [Define if <stdint.h> exists, doesn't clash with <sys/types.h>,
3944       and declares uintmax_t. ])
3945  fi
3946])
3947# uintmax_t.m4 serial 7 (gettext-0.12)
3948dnl Copyright (C) 1997-2003 Free Software Foundation, Inc.
3949dnl This file is free software, distributed under the terms of the GNU
3950dnl General Public License.  As a special exception to the GNU General
3951dnl Public License, this file may be distributed as part of a program
3952dnl that contains a configuration script generated by Autoconf, under
3953dnl the same distribution terms as the rest of that program.
3954
3955dnl From Paul Eggert.
3956
3957AC_PREREQ(2.13)
3958
3959# Define uintmax_t to 'unsigned long' or 'unsigned long long'
3960# if it is not already defined in <stdint.h> or <inttypes.h>.
3961
3962AC_DEFUN([jm_AC_TYPE_UINTMAX_T],
3963[
3964  AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
3965  AC_REQUIRE([jm_AC_HEADER_STDINT_H])
3966  if test $jm_ac_cv_header_inttypes_h = no && test $jm_ac_cv_header_stdint_h = no; then
3967    AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
3968    test $ac_cv_type_unsigned_long_long = yes \
3969      && ac_type='unsigned long long' \
3970      || ac_type='unsigned long'
3971    AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
3972      [Define to unsigned long or unsigned long long
3973       if <stdint.h> and <inttypes.h> don't define.])
3974  else
3975    AC_DEFINE(HAVE_UINTMAX_T, 1,
3976      [Define if you have the 'uintmax_t' type in <stdint.h> or <inttypes.h>.])
3977  fi
3978])
3979# ulonglong.m4 serial 2 (fileutils-4.0.32, gettext-0.10.40)
3980dnl Copyright (C) 1999-2002 Free Software Foundation, Inc.
3981dnl This file is free software, distributed under the terms of the GNU
3982dnl General Public License.  As a special exception to the GNU General
3983dnl Public License, this file may be distributed as part of a program
3984dnl that contains a configuration script generated by Autoconf, under
3985dnl the same distribution terms as the rest of that program.
3986
3987dnl From Paul Eggert.
3988
3989AC_DEFUN([jm_AC_TYPE_UNSIGNED_LONG_LONG],
3990[
3991  AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
3992  [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
3993    [unsigned long long ullmax = (unsigned long long) -1;
3994     return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
3995    ac_cv_type_unsigned_long_long=yes,
3996    ac_cv_type_unsigned_long_long=no)])
3997  if test $ac_cv_type_unsigned_long_long = yes; then
3998    AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1,
3999      [Define if you have the unsigned long long type.])
4000  fi
4001])
4002