]>
Commit | Line | Data |
---|---|---|
705db0b5 AD |
1 | dnl aclocal.m4 generated automatically by aclocal 1.4 |
2 | ||
3 | dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. | |
4 | dnl This file is free software; the Free Software Foundation | |
5 | dnl gives unlimited permission to copy and/or distribute it, | |
6 | dnl with or without modifications, as long as this notice is preserved. | |
7 | ||
8 | dnl This program is distributed in the hope that it will be useful, | |
9 | dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without | |
10 | dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A | |
11 | dnl PARTICULAR PURPOSE. | |
12 | ||
13 | # Do all the work for Automake. This macro actually does too much -- | |
14 | # some checks are only needed if your package does certain things. | |
15 | # But this isn't really a big deal. | |
16 | ||
17 | # serial 1 | |
18 | ||
19 | dnl Usage: | |
20 | dnl AM_INIT_AUTOMAKE(package,version, [no-define]) | |
21 | ||
22 | AC_DEFUN(AM_INIT_AUTOMAKE, | |
23 | [AC_REQUIRE([AC_PROG_INSTALL]) | |
24 | PACKAGE=[$1] | |
25 | AC_SUBST(PACKAGE) | |
26 | VERSION=[$2] | |
27 | AC_SUBST(VERSION) | |
28 | dnl test to see if srcdir already configured | |
29 | if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then | |
30 | AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) | |
31 | fi | |
32 | ifelse([$3],, | |
33 | AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) | |
34 | AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) | |
35 | AC_REQUIRE([AM_SANITY_CHECK]) | |
36 | AC_REQUIRE([AC_ARG_PROGRAM]) | |
37 | dnl FIXME This is truly gross. | |
38 | missing_dir=`cd $ac_aux_dir && pwd` | |
39 | AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) | |
40 | AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) | |
41 | AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) | |
42 | AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) | |
43 | AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) | |
44 | AC_REQUIRE([AC_PROG_MAKE_SET])]) | |
45 | ||
46 | # | |
47 | # Check to make sure that the build environment is sane. | |
48 | # | |
49 | ||
50 | AC_DEFUN(AM_SANITY_CHECK, | |
51 | [AC_MSG_CHECKING([whether build environment is sane]) | |
52 | # Just in case | |
53 | sleep 1 | |
54 | echo timestamp > conftestfile | |
55 | # Do `set' in a subshell so we don't clobber the current shell's | |
56 | # arguments. Must try -L first in case configure is actually a | |
57 | # symlink; some systems play weird games with the mod time of symlinks | |
58 | # (eg FreeBSD returns the mod time of the symlink's containing | |
59 | # directory). | |
60 | if ( | |
61 | set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` | |
62 | if test "[$]*" = "X"; then | |
63 | # -L didn't work. | |
64 | set X `ls -t $srcdir/configure conftestfile` | |
65 | fi | |
66 | if test "[$]*" != "X $srcdir/configure conftestfile" \ | |
67 | && test "[$]*" != "X conftestfile $srcdir/configure"; then | |
68 | ||
69 | # If neither matched, then we have a broken ls. This can happen | |
70 | # if, for instance, CONFIG_SHELL is bash and it inherits a | |
71 | # broken ls alias from the environment. This has actually | |
72 | # happened. Such a system could not be considered "sane". | |
73 | AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken | |
74 | alias in your environment]) | |
75 | fi | |
76 | ||
77 | test "[$]2" = conftestfile | |
78 | ) | |
79 | then | |
80 | # Ok. | |
81 | : | |
82 | else | |
83 | AC_MSG_ERROR([newly created file is older than distributed files! | |
84 | Check your system clock]) | |
85 | fi | |
86 | rm -f conftest* | |
87 | AC_MSG_RESULT(yes)]) | |
88 | ||
89 | dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) | |
90 | dnl The program must properly implement --version. | |
91 | AC_DEFUN(AM_MISSING_PROG, | |
92 | [AC_MSG_CHECKING(for working $2) | |
93 | # Run test in a subshell; some versions of sh will print an error if | |
94 | # an executable is not found, even if stderr is redirected. | |
95 | # Redirect stdin to placate older versions of autoconf. Sigh. | |
96 | if ($2 --version) < /dev/null > /dev/null 2>&1; then | |
97 | $1=$2 | |
98 | AC_MSG_RESULT(found) | |
99 | else | |
100 | $1="$3/missing $2" | |
101 | AC_MSG_RESULT(missing) | |
102 | fi | |
103 | AC_SUBST($1)]) | |
104 | ||
105 | # Like AC_CONFIG_HEADER, but automatically create stamp file. | |
106 | ||
107 | AC_DEFUN(AM_CONFIG_HEADER, | |
108 | [AC_PREREQ([2.12]) | |
109 | AC_CONFIG_HEADER([$1]) | |
110 | dnl When config.status generates a header, we must update the stamp-h file. | |
111 | dnl This file resides in the same directory as the config header | |
112 | dnl that is generated. We must strip everything past the first ":", | |
113 | dnl and everything past the last "/". | |
114 | AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl | |
115 | ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>, | |
116 | <<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, | |
117 | <<am_indx=1 | |
118 | for am_file in <<$1>>; do | |
119 | case " <<$>>CONFIG_HEADERS " in | |
120 | *" <<$>>am_file "*<<)>> | |
121 | echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx | |
122 | ;; | |
123 | esac | |
124 | am_indx=`expr "<<$>>am_indx" + 1` | |
125 | done<<>>dnl>>) | |
126 | changequote([,]))]) | |
127 | ||
128 | ||
129 | # serial 2 | |
130 | ||
131 | # Single argument says where are built sources to test, relative to the | |
132 | # built test directory. Maybe omitted if the same (flat distribution). | |
133 | ||
134 | AC_DEFUN([AT_CONFIG], | |
135 | [AT_TESTPATH=ifelse([$1], [], [.], [$1]) | |
136 | AC_SUBST([AT_TESTPATH]) | |
137 | # Try to be compatible with both Autoconf 2.13 and 2.50. | |
138 | if test -z "$ECHO_C$ECHO_N$ECHO_T"; then | |
139 | ECHO_C="$ac_c" | |
140 | ECHO_N="$ac_n" | |
141 | ECHO_T="$ac_t" | |
142 | AC_SUBST([ECHO_C]) | |
143 | AC_SUBST([ECHO_N]) | |
144 | AC_SUBST([ECHO_T]) | |
145 | fi | |
146 | ]) | |
147 | ||
148 | ||
149 | # serial 1 | |
150 | ||
151 | # @defmac AC_PROG_CC_STDC | |
152 | # @maindex PROG_CC_STDC | |
153 | # @ovindex CC | |
154 | # If the C compiler in not in ANSI C mode by default, try to add an option | |
155 | # to output variable @code{CC} to make it so. This macro tries various | |
156 | # options that select ANSI C on some system or another. It considers the | |
157 | # compiler to be in ANSI C mode if it handles function prototypes correctly. | |
158 | # | |
159 | # If you use this macro, you should check after calling it whether the C | |
160 | # compiler has been set to accept ANSI C; if not, the shell variable | |
161 | # @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source | |
162 | # code in ANSI C, you can make an un-ANSIfied copy of it by using the | |
163 | # program @code{ansi2knr}, which comes with Ghostscript. | |
164 | # @end defmac | |
165 | ||
166 | AC_DEFUN(AM_PROG_CC_STDC, | |
167 | [AC_REQUIRE([AC_PROG_CC]) | |
168 | AC_BEFORE([$0], [AC_C_INLINE]) | |
169 | AC_BEFORE([$0], [AC_C_CONST]) | |
170 | dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require | |
171 | dnl a magic option to avoid problems with ANSI preprocessor commands | |
172 | dnl like #elif. | |
173 | dnl FIXME: can't do this because then AC_AIX won't work due to a | |
174 | dnl circular dependency. | |
175 | dnl AC_BEFORE([$0], [AC_PROG_CPP]) | |
176 | AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) | |
177 | AC_CACHE_VAL(am_cv_prog_cc_stdc, | |
178 | [am_cv_prog_cc_stdc=no | |
179 | ac_save_CC="$CC" | |
180 | # Don't try gcc -ansi; that turns off useful extensions and | |
181 | # breaks some systems' header files. | |
182 | # AIX -qlanglvl=ansi | |
183 | # Ultrix and OSF/1 -std1 | |
184 | # HP-UX -Aa -D_HPUX_SOURCE | |
185 | # SVR4 -Xc -D__EXTENSIONS__ | |
186 | for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" | |
187 | do | |
188 | CC="$ac_save_CC $ac_arg" | |
189 | AC_TRY_COMPILE( | |
190 | [#include <stdarg.h> | |
191 | #include <stdio.h> | |
192 | #include <sys/types.h> | |
193 | #include <sys/stat.h> | |
194 | /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ | |
195 | struct buf { int x; }; | |
196 | FILE * (*rcsopen) (struct buf *, struct stat *, int); | |
197 | static char *e (p, i) | |
198 | char **p; | |
199 | int i; | |
200 | { | |
201 | return p[i]; | |
202 | } | |
203 | static char *f (char * (*g) (char **, int), char **p, ...) | |
204 | { | |
205 | char *s; | |
206 | va_list v; | |
207 | va_start (v,p); | |
208 | s = g (p, va_arg (v,int)); | |
209 | va_end (v); | |
210 | return s; | |
211 | } | |
212 | int test (int i, double x); | |
213 | struct s1 {int (*f) (int a);}; | |
214 | struct s2 {int (*f) (double a);}; | |
215 | int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); | |
216 | int argc; | |
217 | char **argv; | |
218 | ], [ | |
219 | return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; | |
220 | ], | |
221 | [am_cv_prog_cc_stdc="$ac_arg"; break]) | |
222 | done | |
223 | CC="$ac_save_CC" | |
224 | ]) | |
225 | if test -z "$am_cv_prog_cc_stdc"; then | |
226 | AC_MSG_RESULT([none needed]) | |
227 | else | |
228 | AC_MSG_RESULT($am_cv_prog_cc_stdc) | |
229 | fi | |
230 | case "x$am_cv_prog_cc_stdc" in | |
231 | x|xno) ;; | |
232 | *) CC="$CC $am_cv_prog_cc_stdc" ;; | |
233 | esac | |
234 | ]) | |
235 | ||
236 | # serial 1 | |
237 | ||
238 | # BISON_AC_PROG_GNU_M4 | |
239 | # -------------------- | |
240 | # Check for GNU m4, at least 1.3 (supports frozen files). | |
241 | AC_DEFUN([BISON_AC_PROG_GNU_M4], | |
242 | [AC_PATH_PROGS(M4, gm4 gnum4 m4, m4) | |
243 | AC_CACHE_CHECK(whether m4 supports frozen files, ac_cv_prog_gnu_m4, | |
244 | [ac_cv_prog_gnu_m4=no | |
245 | if test x"$M4" != x; then | |
246 | case `$M4 --help < /dev/null 2>&1` in | |
247 | *reload-state*) ac_cv_prog_gnu_m4=yes ;; | |
248 | esac | |
249 | fi])]) | |
250 | ||
251 | AC_DEFUN(BISON_WARNING, | |
252 | [AC_MSG_CHECKING(whether compiler accepts $1) | |
253 | AC_SUBST(WARNING_CFLAGS) | |
254 | ac_save_CFLAGS="$CFLAGS" | |
255 | CFLAGS="$CFLAGS $1" | |
256 | AC_TRY_COMPILE(, | |
257 | [int x;], | |
258 | WARNING_CFLAGS="$WARNING_CFLAGS $1" | |
259 | AC_MSG_RESULT(yes), | |
260 | AC_MSG_RESULT(no)) | |
261 | CFLAGS="$ac_save_CFLAGS"]) | |
262 | ||
263 | ||
264 | # serial 1 | |
265 | ||
266 | AC_DEFUN(AM_C_PROTOTYPES, | |
267 | [AC_REQUIRE([AM_PROG_CC_STDC]) | |
268 | AC_REQUIRE([AC_PROG_CPP]) | |
269 | AC_MSG_CHECKING([for function prototypes]) | |
270 | if test "$am_cv_prog_cc_stdc" != no; then | |
271 | AC_MSG_RESULT(yes) | |
272 | AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes]) | |
273 | U= ANSI2KNR= | |
274 | else | |
275 | AC_MSG_RESULT(no) | |
276 | U=_ ANSI2KNR=./ansi2knr | |
277 | # Ensure some checks needed by ansi2knr itself. | |
278 | AC_HEADER_STDC | |
279 | AC_CHECK_HEADERS(string.h) | |
280 | fi | |
281 | AC_SUBST(U)dnl | |
282 | AC_SUBST(ANSI2KNR)dnl | |
283 | ]) | |
284 | ||
285 | #serial 3 | |
286 | ||
287 | dnl From Jim Meyering. | |
288 | dnl Determine whether malloc accepts 0 as its argument. | |
289 | dnl If it doesn't, arrange to use the replacement function. | |
290 | dnl | |
291 | ||
292 | AC_DEFUN(jm_FUNC_MALLOC, | |
293 | [ | |
294 | dnl xmalloc.c requires that this symbol be defined so it doesn't | |
295 | dnl mistakenly use a broken malloc -- as it might if this test were omitted. | |
296 | AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_MALLOC_CHECK, 1, | |
297 | [Define if the malloc check has been performed. ]) | |
298 | ||
299 | AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc, | |
300 | [AC_TRY_RUN([ | |
301 | char *malloc (); | |
302 | int | |
303 | main () | |
304 | { | |
305 | exit (malloc (0) ? 0 : 1); | |
306 | } | |
307 | ], | |
308 | jm_cv_func_working_malloc=yes, | |
309 | jm_cv_func_working_malloc=no, | |
310 | dnl When crosscompiling, assume malloc is broken. | |
311 | jm_cv_func_working_malloc=no) | |
312 | ]) | |
313 | if test $jm_cv_func_working_malloc = no; then | |
314 | AC_SUBST(LIBOBJS) | |
315 | LIBOBJS="$LIBOBJS malloc.$ac_objext" | |
316 | AC_DEFINE_UNQUOTED(malloc, rpl_malloc, | |
317 | [Define to rpl_malloc if the replacement function should be used.]) | |
318 | fi | |
319 | ]) | |
320 | ||
321 | #serial 3 | |
322 | ||
323 | dnl From Jim Meyering. | |
324 | dnl Determine whether realloc works when both arguments are 0. | |
325 | dnl If it doesn't, arrange to use the replacement function. | |
326 | dnl | |
327 | ||
328 | AC_DEFUN(jm_FUNC_REALLOC, | |
329 | [ | |
330 | dnl xmalloc.c requires that this symbol be defined so it doesn't | |
331 | dnl mistakenly use a broken realloc -- as it might if this test were omitted. | |
332 | AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_REALLOC_CHECK, 1, | |
333 | [Define if the realloc check has been performed. ]) | |
334 | ||
335 | AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc, | |
336 | [AC_TRY_RUN([ | |
337 | char *realloc (); | |
338 | int | |
339 | main () | |
340 | { | |
341 | exit (realloc (0, 0) ? 0 : 1); | |
342 | } | |
343 | ], | |
344 | jm_cv_func_working_realloc=yes, | |
345 | jm_cv_func_working_realloc=no, | |
346 | dnl When crosscompiling, assume realloc is broken. | |
347 | jm_cv_func_working_realloc=no) | |
348 | ]) | |
349 | if test $jm_cv_func_working_realloc = no; then | |
350 | AC_SUBST(LIBOBJS) | |
351 | LIBOBJS="$LIBOBJS realloc.$ac_objext" | |
352 | AC_DEFINE_UNQUOTED(realloc, rpl_realloc, | |
353 | [Define to rpl_realloc if the replacement function should be used.]) | |
354 | fi | |
355 | ]) | |
356 | ||
357 | #serial 1 | |
358 | ||
359 | dnl These are the prerequisite macros for files in the lib/ | |
360 | dnl directories of Bison. | |
361 | ||
362 | AC_DEFUN([jm_PREREQ_QUOTEARG], | |
363 | [ | |
364 | AC_CHECK_FUNCS(isascii iswprint mbrtowc) | |
365 | AC_CHECK_HEADERS(limits.h stdlib.h string.h wchar.h wctype.h) | |
366 | AC_HEADER_STDC | |
367 | AC_C_BACKSLASH_A | |
368 | AC_MBSTATE_T | |
369 | AM_C_PROTOTYPES | |
370 | ]) | |
371 | ||
372 | #serial 3 | |
373 | ||
374 | dnl From Paul Eggert. | |
375 | ||
376 | AC_DEFUN(AC_C_BACKSLASH_A, | |
377 | [ | |
378 | AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a, | |
379 | [AC_TRY_COMPILE([], | |
380 | [ | |
381 | #if '\a' == 'a' | |
382 | syntax error; | |
383 | #endif | |
384 | char buf['\a' == 'a' ? -1 : 1]; | |
385 | buf[0] = '\a'; | |
386 | return buf[0] != "\a"[0]; | |
387 | ], | |
388 | ac_cv_c_backslash_a=yes, | |
389 | ac_cv_c_backslash_a=no)]) | |
390 | if test $ac_cv_c_backslash_a = yes; then | |
391 | AC_DEFINE(HAVE_C_BACKSLASH_A, 1, | |
392 | [Define if backslash-a works in C strings.]) | |
393 | fi | |
394 | ]) | |
395 | ||
396 | # serial 8 | |
397 | ||
398 | # From Paul Eggert. | |
399 | ||
400 | # BeOS 5 has <wchar.h> but does not define mbstate_t, | |
401 | # so you can't declare an object of that type. | |
402 | # Check for this incompatibility with Standard C. | |
403 | ||
404 | # Include stdlib.h first, because otherwise this test would fail on Linux | |
405 | # (at least glibc-2.1.3) because the "_XOPEN_SOURCE 500" definition elicits | |
406 | # a syntax error in wchar.h due to the use of undefined __int32_t. | |
407 | ||
408 | AC_DEFUN(AC_MBSTATE_T, | |
409 | [ | |
410 | AC_CHECK_HEADERS(stdlib.h) | |
411 | ||
412 | AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t, | |
413 | [AC_TRY_COMPILE([ | |
414 | #if HAVE_STDLIB_H | |
415 | # include <stdlib.h> | |
416 | #endif | |
417 | #include <wchar.h>], | |
418 | [mbstate_t x; return sizeof x;], | |
419 | ac_cv_type_mbstate_t=yes, | |
420 | ac_cv_type_mbstate_t=no)]) | |
421 | if test $ac_cv_type_mbstate_t = no; then | |
422 | AC_DEFINE(mbstate_t, int, | |
423 | [Define to a type if <wchar.h> does not define.]) | |
424 | fi]) | |
425 | ||
5141b016 AD |
426 | #serial 1 |
427 | ||
428 | dnl FIXME: put these prerequisite-only *.m4 files in a separate | |
429 | dnl directory -- otherwise, they'll conflict with existing files. | |
430 | ||
431 | dnl These are the prerequisite macros for GNU's error.c file. | |
432 | AC_DEFUN(jm_PREREQ_ERROR, | |
433 | [ | |
434 | AC_CHECK_FUNCS(strerror strerror_r vprintf doprnt) | |
435 | AC_HEADER_STDC | |
436 | AC_FUNC_STRERROR_R | |
437 | ]) | |
438 | ||
439 | #serial 1002 | |
440 | # Experimental replacement for the function in the latest CVS autoconf. | |
441 | # If the compile-test says strerror_r doesn't work, then resort to a | |
442 | # `run'-test that works on BeOS and segfaults on DEC Unix. | |
443 | # Use with the error.c file in ../lib. | |
444 | ||
445 | undefine([AC_FUNC_STRERROR_R]) | |
446 | ||
447 | # AC_FUNC_STRERROR_R | |
448 | # ------------------ | |
449 | AC_DEFUN([AC_FUNC_STRERROR_R], | |
450 | [AC_CHECK_DECLS([strerror_r]) | |
451 | AC_CHECK_FUNCS([strerror_r]) | |
452 | if test $ac_cv_func_strerror_r = yes; then | |
453 | AC_CHECK_HEADERS(string.h) | |
454 | AC_CACHE_CHECK([for working strerror_r], | |
455 | ac_cv_func_strerror_r_works, | |
456 | [ | |
457 | AC_TRY_COMPILE( | |
458 | [ | |
459 | # include <stdio.h> | |
460 | # if HAVE_STRING_H | |
461 | # include <string.h> | |
462 | # endif | |
463 | ], | |
464 | [ | |
465 | char buf[100]; | |
466 | char x = *strerror_r (0, buf, sizeof buf); | |
467 | ], | |
468 | ac_cv_func_strerror_r_works=yes, | |
469 | ac_cv_func_strerror_r_works=no | |
470 | ) | |
471 | if test $ac_cv_func_strerror_r_works = no; then | |
472 | # strerror_r seems not to work, but now we have to choose between | |
473 | # systems that have relatively inaccessible declarations for the | |
474 | # function. BeOS and DEC UNIX 4.0 fall in this category, but the | |
475 | # former has a strerror_r that returns char*, while the latter | |
476 | # has a strerror_r that returns `int'. | |
477 | # This test should segfault on the DEC system. | |
478 | AC_TRY_RUN( | |
479 | [ | |
480 | # include <stdio.h> | |
481 | # include <string.h> | |
482 | # include <ctype.h> | |
483 | ||
484 | extern char *strerror_r (); | |
485 | ||
486 | int | |
487 | main () | |
488 | { | |
489 | char buf[100]; | |
490 | char x = *strerror_r (0, buf, sizeof buf); | |
491 | exit (!isalpha (x)); | |
492 | } | |
493 | ], | |
494 | ac_cv_func_strerror_r_works=yes, | |
495 | ac_cv_func_strerror_r_works=no, | |
496 | ac_cv_func_strerror_r_works=no) | |
497 | fi | |
498 | ]) | |
499 | if test $ac_cv_func_strerror_r_works = yes; then | |
500 | AC_DEFINE_UNQUOTED(HAVE_WORKING_STRERROR_R, 1, | |
501 | [Define to 1 if `strerror_r' returns a string.]) | |
502 | fi | |
503 | fi | |
504 | ])# AC_FUNC_STRERROR_R | |
505 | ||
705db0b5 AD |
506 | # Macro to add for using GNU gettext. |
507 | # Ulrich Drepper <drepper@cygnus.com>, 1995. | |
508 | # | |
509 | # This file can be copied and used freely without restrictions. It can | |
510 | # be used in projects which are not available under the GNU Public License | |
511 | # but which still want to provide support for the GNU gettext functionality. | |
512 | # Please note that the actual code is *not* freely available. | |
513 | ||
514 | # serial 109 | |
515 | ||
516 | AC_PREREQ(2.13) dnl Minimum Autoconf version required. | |
517 | ||
518 | AC_DEFUN(AM_WITH_NLS, | |
519 | [AC_MSG_CHECKING([whether NLS is requested]) | |
520 | dnl Default is enabled NLS | |
521 | AC_ARG_ENABLE(nls, | |
522 | [ --disable-nls do not use Native Language Support], | |
523 | USE_NLS=$enableval, USE_NLS=yes) | |
524 | AC_MSG_RESULT($USE_NLS) | |
525 | AC_SUBST(USE_NLS) | |
526 | ||
527 | USE_INCLUDED_LIBINTL=no | |
528 | ||
529 | dnl If we use NLS figure out what method | |
530 | if test "$USE_NLS" = "yes"; then | |
531 | AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if NLS is requested.]) | |
532 | AC_MSG_CHECKING([whether included gettext is requested]) | |
533 | AC_ARG_WITH(included-gettext, | |
534 | [ --with-included-gettext use the GNU gettext library included here], | |
535 | nls_cv_force_use_gnu_gettext=$withval, | |
536 | nls_cv_force_use_gnu_gettext=no) | |
537 | AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) | |
538 | ||
539 | nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" | |
540 | if test "$nls_cv_force_use_gnu_gettext" != "yes"; then | |
541 | dnl User does not insist on using GNU NLS library. Figure out what | |
542 | dnl to use. If gettext or catgets are available (in this order) we | |
543 | dnl use this. Else we have to fall back to GNU NLS library. | |
544 | dnl catgets is only used if permitted by option --with-catgets. | |
545 | nls_cv_header_intl= | |
546 | nls_cv_header_libgt= | |
547 | CATOBJEXT=NONE | |
548 | ||
549 | AC_CHECK_HEADER(libintl.h, | |
550 | [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc, | |
551 | [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")], | |
552 | gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)]) | |
553 | ||
554 | if test "$gt_cv_func_gettext_libc" != "yes"; then | |
555 | AC_CHECK_LIB(intl, bindtextdomain, | |
556 | [AC_CHECK_LIB(intl, gettext)]) | |
557 | fi | |
558 | ||
559 | if test "$gt_cv_func_gettext_libc" = "yes" \ | |
560 | || test "$ac_cv_lib_intl_gettext" = "yes"; then | |
561 | AC_DEFINE(HAVE_GETTEXT, 1, | |
562 | [Define to 1 if you have gettext and don't want to use GNU gettext.]) | |
563 | AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, | |
564 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl | |
565 | if test "$MSGFMT" != "no"; then | |
566 | AC_CHECK_FUNCS(dcgettext) | |
567 | AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) | |
568 | AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, | |
569 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) | |
570 | AC_TRY_LINK(, [extern int _nl_msg_cat_cntr; | |
571 | return _nl_msg_cat_cntr], | |
572 | [CATOBJEXT=.gmo | |
573 | DATADIRNAME=share], | |
574 | [CATOBJEXT=.mo | |
575 | DATADIRNAME=lib]) | |
576 | INSTOBJEXT=.mo | |
577 | fi | |
578 | fi | |
579 | ]) | |
580 | ||
581 | if test "$CATOBJEXT" = "NONE"; then | |
582 | AC_MSG_CHECKING([whether catgets can be used]) | |
583 | AC_ARG_WITH(catgets, | |
584 | [ --with-catgets use catgets functions if available], | |
585 | nls_cv_use_catgets=$withval, nls_cv_use_catgets=no) | |
586 | AC_MSG_RESULT($nls_cv_use_catgets) | |
587 | ||
588 | if test "$nls_cv_use_catgets" = "yes"; then | |
589 | dnl No gettext in C library. Try catgets next. | |
590 | AC_CHECK_LIB(i, main) | |
591 | AC_CHECK_FUNC(catgets, | |
592 | [AC_DEFINE(HAVE_CATGETS, 1, | |
593 | [Define as 1 if you have \`catgets' and don't want to use GNU gettext.]) | |
594 | INTLOBJS="\$(CATOBJS)" | |
595 | AC_PATH_PROG(GENCAT, gencat, no)dnl | |
596 | if test "$GENCAT" != "no"; then | |
597 | AC_PATH_PROG(GMSGFMT, gmsgfmt, no) | |
598 | if test "$GMSGFMT" = "no"; then | |
599 | AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt, | |
600 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no) | |
601 | fi | |
602 | AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, | |
603 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) | |
604 | USE_INCLUDED_LIBINTL=yes | |
605 | CATOBJEXT=.cat | |
606 | INSTOBJEXT=.cat | |
607 | DATADIRNAME=lib | |
608 | INTLDEPS='$(top_builddir)/intl/libintl.a' | |
609 | INTLLIBS=$INTLDEPS | |
610 | LIBS=`echo $LIBS | sed -e 's/-lintl//'` | |
611 | nls_cv_header_intl=intl/libintl.h | |
612 | nls_cv_header_libgt=intl/libgettext.h | |
613 | fi]) | |
614 | fi | |
615 | fi | |
616 | ||
617 | if test "$CATOBJEXT" = "NONE"; then | |
618 | dnl Neither gettext nor catgets in included in the C library. | |
619 | dnl Fall back on GNU gettext library. | |
620 | nls_cv_use_gnu_gettext=yes | |
621 | fi | |
622 | fi | |
623 | ||
624 | if test "$nls_cv_use_gnu_gettext" = "yes"; then | |
625 | dnl Mark actions used to generate GNU NLS library. | |
626 | INTLOBJS="\$(GETTOBJS)" | |
627 | AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, | |
628 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt) | |
629 | AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) | |
630 | AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, | |
631 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) | |
632 | AC_SUBST(MSGFMT) | |
633 | USE_INCLUDED_LIBINTL=yes | |
634 | CATOBJEXT=.gmo | |
635 | INSTOBJEXT=.mo | |
636 | DATADIRNAME=share | |
637 | INTLDEPS='$(top_builddir)/intl/libintl.a' | |
638 | INTLLIBS=$INTLDEPS | |
639 | LIBS=`echo $LIBS | sed -e 's/-lintl//'` | |
640 | nls_cv_header_intl=intl/libintl.h | |
641 | nls_cv_header_libgt=intl/libgettext.h | |
642 | fi | |
643 | ||
644 | dnl Test whether we really found GNU xgettext. | |
645 | if test "$XGETTEXT" != ":"; then | |
646 | dnl If it is no GNU xgettext we define it as : so that the | |
647 | dnl Makefiles still can work. | |
648 | if $XGETTEXT --omit-header /dev/null 2> /dev/null; then | |
649 | : ; | |
650 | else | |
651 | AC_MSG_RESULT( | |
652 | [found xgettext program is not GNU xgettext; ignore it]) | |
653 | XGETTEXT=":" | |
654 | fi | |
655 | fi | |
656 | ||
657 | # We need to process the po/ directory. | |
658 | POSUB=po | |
659 | else | |
660 | DATADIRNAME=share | |
661 | nls_cv_header_intl=intl/libintl.h | |
662 | nls_cv_header_libgt=intl/libgettext.h | |
663 | fi | |
664 | if test -z "$nls_cv_header_intl"; then | |
665 | # Clean out junk possibly left behind by a previous configuration. | |
666 | rm -f intl/libintl.h | |
667 | fi | |
668 | AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl) | |
669 | AC_OUTPUT_COMMANDS( | |
670 | [case "$CONFIG_FILES" in *po/Makefile.in*) | |
671 | sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile | |
672 | esac]) | |
673 | ||
674 | ||
675 | # If this is used in GNU gettext we have to set USE_NLS to `yes' | |
676 | # because some of the sources are only built for this goal. | |
677 | if test "$PACKAGE" = gettext; then | |
678 | USE_NLS=yes | |
679 | USE_INCLUDED_LIBINTL=yes | |
680 | fi | |
681 | ||
682 | dnl These rules are solely for the distribution goal. While doing this | |
683 | dnl we only have to keep exactly one list of the available catalogs | |
684 | dnl in configure.in. | |
685 | for lang in $ALL_LINGUAS; do | |
686 | GMOFILES="$GMOFILES $lang.gmo" | |
687 | POFILES="$POFILES $lang.po" | |
688 | done | |
689 | ||
690 | dnl Make all variables we use known to autoconf. | |
691 | AC_SUBST(USE_INCLUDED_LIBINTL) | |
692 | AC_SUBST(CATALOGS) | |
693 | AC_SUBST(CATOBJEXT) | |
694 | AC_SUBST(DATADIRNAME) | |
695 | AC_SUBST(GMOFILES) | |
696 | AC_SUBST(INSTOBJEXT) | |
697 | AC_SUBST(INTLDEPS) | |
698 | AC_SUBST(INTLLIBS) | |
699 | AC_SUBST(INTLOBJS) | |
700 | AC_SUBST(POFILES) | |
701 | AC_SUBST(POSUB) | |
702 | ]) | |
703 | ||
704 | AC_DEFUN(AM_GNU_GETTEXT, | |
705 | [AC_REQUIRE([AC_PROG_MAKE_SET])dnl | |
706 | AC_REQUIRE([AC_PROG_CC])dnl | |
707 | AC_REQUIRE([AC_PROG_RANLIB])dnl | |
708 | AC_REQUIRE([AC_ISC_POSIX])dnl | |
709 | AC_REQUIRE([AC_HEADER_STDC])dnl | |
710 | AC_REQUIRE([AC_C_CONST])dnl | |
711 | AC_REQUIRE([AC_C_INLINE])dnl | |
712 | AC_REQUIRE([AC_TYPE_OFF_T])dnl | |
713 | AC_REQUIRE([AC_TYPE_SIZE_T])dnl | |
714 | AC_REQUIRE([AC_FUNC_ALLOCA])dnl | |
715 | AC_REQUIRE([AC_FUNC_MMAP])dnl | |
716 | ||
717 | AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \ | |
718 | unistd.h sys/param.h]) | |
719 | AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \ | |
720 | strdup __argz_count __argz_stringify __argz_next]) | |
721 | ||
722 | if test "${ac_cv_func_stpcpy+set}" != "set"; then | |
723 | AC_CHECK_FUNCS(stpcpy) | |
724 | fi | |
725 | if test "${ac_cv_func_stpcpy}" = "yes"; then | |
726 | AC_DEFINE(HAVE_STPCPY, 1, | |
727 | [Define to 1 if you have the \`stpcpy' function.]) | |
728 | fi | |
729 | ||
730 | AM_LC_MESSAGES | |
731 | AM_WITH_NLS | |
732 | ||
733 | if test "x$CATOBJEXT" != "x"; then | |
734 | if test "x$ALL_LINGUAS" = "x"; then | |
735 | LINGUAS= | |
736 | else | |
737 | AC_MSG_CHECKING(for catalogs to be installed) | |
738 | NEW_LINGUAS= | |
739 | for lang in ${LINGUAS=$ALL_LINGUAS}; do | |
740 | case "$ALL_LINGUAS" in | |
741 | *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;; | |
742 | esac | |
743 | done | |
744 | LINGUAS=$NEW_LINGUAS | |
745 | AC_MSG_RESULT($LINGUAS) | |
746 | fi | |
747 | ||
748 | dnl Construct list of names of catalog files to be constructed. | |
749 | if test -n "$LINGUAS"; then | |
750 | for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done | |
751 | fi | |
752 | fi | |
753 | ||
754 | dnl The reference to <locale.h> in the installed <libintl.h> file | |
755 | dnl must be resolved because we cannot expect the users of this | |
756 | dnl to define HAVE_LOCALE_H. | |
757 | if test $ac_cv_header_locale_h = yes; then | |
758 | INCLUDE_LOCALE_H="#include <locale.h>" | |
759 | else | |
760 | INCLUDE_LOCALE_H="\ | |
761 | /* The system does not provide the header <locale.h>. Take care yourself. */" | |
762 | fi | |
763 | AC_SUBST(INCLUDE_LOCALE_H) | |
764 | ||
765 | dnl Determine which catalog format we have (if any is needed) | |
766 | dnl For now we know about two different formats: | |
767 | dnl Linux libc-5 and the normal X/Open format | |
768 | test -d intl || mkdir intl | |
769 | if test "$CATOBJEXT" = ".cat"; then | |
770 | AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen) | |
771 | ||
772 | dnl Transform the SED scripts while copying because some dumb SEDs | |
773 | dnl cannot handle comments. | |
774 | sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed | |
775 | fi | |
776 | dnl po2tbl.sed is always needed. | |
777 | sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \ | |
778 | $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed | |
779 | ||
780 | dnl In the intl/Makefile.in we have a special dependency which makes | |
781 | dnl only sense for gettext. We comment this out for non-gettext | |
782 | dnl packages. | |
783 | if test "$PACKAGE" = "gettext"; then | |
784 | GT_NO="#NO#" | |
785 | GT_YES= | |
786 | else | |
787 | GT_NO= | |
788 | GT_YES="#YES#" | |
789 | fi | |
790 | AC_SUBST(GT_NO) | |
791 | AC_SUBST(GT_YES) | |
792 | ||
793 | dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly | |
794 | dnl find the mkinstalldirs script in another subdir but ($top_srcdir). | |
795 | dnl Try to locate is. | |
796 | MKINSTALLDIRS= | |
797 | if test -n "$ac_aux_dir"; then | |
798 | MKINSTALLDIRS="\$(top_srcdir)/$ac_aux_dir/mkinstalldirs" | |
799 | fi | |
800 | if test -z "$MKINSTALLDIRS"; then | |
801 | MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" | |
802 | fi | |
803 | AC_SUBST(MKINSTALLDIRS) | |
804 | ||
805 | dnl *** For now the libtool support in intl/Makefile is not for real. | |
806 | l= | |
807 | AC_SUBST(l) | |
808 | ||
809 | dnl Generate list of files to be processed by xgettext which will | |
810 | dnl be included in po/Makefile. | |
811 | test -d po || mkdir po | |
812 | changequote(, )dnl | |
813 | case "$srcdir" in | |
814 | .) | |
815 | posrcprefix="../" ;; | |
816 | /* | [A-Za-z]:*) | |
817 | posrcprefix="$srcdir/" ;; | |
818 | *) | |
819 | posrcprefix="../$srcdir/" ;; | |
820 | esac | |
821 | changequote([, ])dnl | |
822 | rm -f po/POTFILES | |
823 | sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \ | |
824 | < $srcdir/po/POTFILES.in > po/POTFILES | |
825 | ]) | |
826 | ||
827 | # Search path for a program which passes the given test. | |
828 | # Ulrich Drepper <drepper@cygnus.com>, 1996. | |
829 | # | |
830 | # This file can be copied and used freely without restrictions. It can | |
831 | # be used in projects which are not available under the GNU Public License | |
832 | # but which still want to provide support for the GNU gettext functionality. | |
833 | # Please note that the actual code is *not* freely available. | |
834 | ||
835 | # serial 1 | |
836 | ||
837 | dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, | |
838 | dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) | |
839 | AC_DEFUN(AM_PATH_PROG_WITH_TEST, | |
840 | [# Extract the first word of "$2", so it can be a program name with args. | |
841 | set dummy $2; ac_word=[$]2 | |
842 | AC_MSG_CHECKING([for $ac_word]) | |
843 | AC_CACHE_VAL(ac_cv_path_$1, | |
844 | [case "[$]$1" in | |
845 | /*) | |
846 | ac_cv_path_$1="[$]$1" # Let the user override the test with a path. | |
847 | ;; | |
848 | *) | |
849 | IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" | |
850 | for ac_dir in ifelse([$5], , $PATH, [$5]); do | |
851 | test -z "$ac_dir" && ac_dir=. | |
852 | if test -f $ac_dir/$ac_word; then | |
853 | if [$3]; then | |
854 | ac_cv_path_$1="$ac_dir/$ac_word" | |
855 | break | |
856 | fi | |
857 | fi | |
858 | done | |
859 | IFS="$ac_save_ifs" | |
860 | dnl If no 4th arg is given, leave the cache variable unset, | |
861 | dnl so AC_PATH_PROGS will keep looking. | |
862 | ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" | |
863 | ])dnl | |
864 | ;; | |
865 | esac])dnl | |
866 | $1="$ac_cv_path_$1" | |
867 | if test -n "[$]$1"; then | |
868 | AC_MSG_RESULT([$]$1) | |
869 | else | |
870 | AC_MSG_RESULT(no) | |
871 | fi | |
872 | AC_SUBST($1)dnl | |
873 | ]) | |
874 | ||
875 | # Check whether LC_MESSAGES is available in <locale.h>. | |
876 | # Ulrich Drepper <drepper@cygnus.com>, 1995. | |
877 | # | |
878 | # This file can be copied and used freely without restrictions. It can | |
879 | # be used in projects which are not available under the GNU Public License | |
880 | # but which still want to provide support for the GNU gettext functionality. | |
881 | # Please note that the actual code is *not* freely available. | |
882 | ||
883 | # serial 1 | |
884 | ||
885 | AC_DEFUN(AM_LC_MESSAGES, | |
886 | [if test $ac_cv_header_locale_h = yes; then | |
887 | AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, | |
888 | [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES], | |
889 | am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) | |
890 | if test $am_cv_val_LC_MESSAGES = yes; then | |
891 | AC_DEFINE(HAVE_LC_MESSAGES, 1, | |
892 | [Define if your locale.h file contains LC_MESSAGES.]) | |
893 | fi | |
894 | fi]) | |
895 |