]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/aclocal.m4
aclocal.m4 (AC_FUNC_MMAP_ANYWHERE): Completely rewritten.
[thirdparty/gcc.git] / gcc / aclocal.m4
1 Fdnl See whether we can include both string.h and strings.h.
2 AC_DEFUN(gcc_AC_HEADER_STRING,
3 [AC_CACHE_CHECK([whether string.h and strings.h may both be included],
4 gcc_cv_header_string,
5 [AC_TRY_COMPILE([#include <string.h>
6 #include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
7 if test $gcc_cv_header_string = yes; then
8 AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
9 fi
10 ])
11
12 dnl See whether we need a declaration for a function.
13 dnl The result is highly dependent on the INCLUDES passed in, so make sure
14 dnl to use a different cache variable name in this macro if it is invoked
15 dnl in a different context somewhere else.
16 dnl gcc_AC_CHECK_DECL(SYMBOL,
17 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
18 AC_DEFUN(gcc_AC_CHECK_DECL,
19 [AC_MSG_CHECKING([whether $1 is declared])
20 AC_CACHE_VAL(gcc_cv_have_decl_$1,
21 [AC_TRY_COMPILE([$4],
22 [#ifndef $1
23 char *(*pfn) = (char *(*)) $1 ;
24 #endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
25 if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
26 AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
27 else
28 AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
29 fi
30 ])dnl
31
32 dnl Check multiple functions to see whether each needs a declaration.
33 dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
34 dnl gcc_AC_CHECK_DECLS(SYMBOLS,
35 dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
36 AC_DEFUN(gcc_AC_CHECK_DECLS,
37 [for ac_func in $1
38 do
39 changequote(, )dnl
40 ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
41 changequote([, ])dnl
42 gcc_AC_CHECK_DECL($ac_func,
43 [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
44 [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
45 $4
46 )
47 done
48 dnl Automatically generate config.h entries via autoheader.
49 if test x = y ; then
50 patsubst(translit([$1], [a-z], [A-Z]), [\w+],
51 AC_DEFINE([HAVE_DECL_\&], 1,
52 [Define to 1 if we found this declaration otherwise define to 0.]))dnl
53 fi
54 ])
55
56 dnl Check if we have vprintf and possibly _doprnt.
57 dnl Note autoconf checks for vprintf even though we care about vfprintf.
58 AC_DEFUN(gcc_AC_FUNC_VFPRINTF_DOPRNT,
59 [AC_FUNC_VPRINTF
60 vfprintf=
61 doprint=
62 if test $ac_cv_func_vprintf != yes ; then
63 vfprintf=vfprintf.o
64 if test $ac_cv_func__doprnt != yes ; then
65 doprint=doprint.o
66 fi
67 fi
68 AC_SUBST(vfprintf)
69 AC_SUBST(doprint)
70 ])
71
72 dnl See if the printf functions in libc support %p in format strings.
73 AC_DEFUN(gcc_AC_FUNC_PRINTF_PTR,
74 [AC_CACHE_CHECK(whether the printf functions support %p,
75 gcc_cv_func_printf_ptr,
76 [AC_TRY_RUN([#include <stdio.h>
77
78 int main()
79 {
80 char buf[64];
81 char *p = buf, *q = NULL;
82 sprintf(buf, "%p", p);
83 sscanf(buf, "%p", &q);
84 return (p != q);
85 }], gcc_cv_func_printf_ptr=yes, gcc_cv_func_printf_ptr=no,
86 gcc_cv_func_printf_ptr=no)
87 rm -f core core.* *.core])
88 if test $gcc_cv_func_printf_ptr = yes ; then
89 AC_DEFINE(HAVE_PRINTF_PTR, 1, [Define if printf supports "%p".])
90 fi
91 ])
92
93 dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
94 AC_DEFUN(gcc_AC_PROG_LN_S,
95 [AC_MSG_CHECKING(whether ln -s works)
96 AC_CACHE_VAL(gcc_cv_prog_LN_S,
97 [rm -f conftestdata_t
98 echo >conftestdata_f
99 if ln -s conftestdata_f conftestdata_t 2>/dev/null
100 then
101 gcc_cv_prog_LN_S="ln -s"
102 else
103 if ln conftestdata_f conftestdata_t 2>/dev/null
104 then
105 gcc_cv_prog_LN_S=ln
106 else
107 gcc_cv_prog_LN_S=cp
108 fi
109 fi
110 rm -f conftestdata_f conftestdata_t
111 ])dnl
112 LN_S="$gcc_cv_prog_LN_S"
113 if test "$gcc_cv_prog_LN_S" = "ln -s"; then
114 AC_MSG_RESULT(yes)
115 else
116 if test "$gcc_cv_prog_LN_S" = "ln"; then
117 AC_MSG_RESULT([no, using ln])
118 else
119 AC_MSG_RESULT([no, and neither does ln, so using cp])
120 fi
121 fi
122 AC_SUBST(LN_S)dnl
123 ])
124
125 dnl See if hard links work and if not, try to substitute either symbolic links or simple copy.
126 AC_DEFUN(gcc_AC_PROG_LN,
127 [AC_MSG_CHECKING(whether ln works)
128 AC_CACHE_VAL(gcc_cv_prog_LN,
129 [rm -f conftestdata_t
130 echo >conftestdata_f
131 if ln conftestdata_f conftestdata_t 2>/dev/null
132 then
133 gcc_cv_prog_LN="ln"
134 else
135 if ln -s conftestdata_f conftestdata_t 2>/dev/null
136 then
137 gcc_cv_prog_LN="ln -s"
138 else
139 gcc_cv_prog_LN=cp
140 fi
141 fi
142 rm -f conftestdata_f conftestdata_t
143 ])dnl
144 LN="$gcc_cv_prog_LN"
145 if test "$gcc_cv_prog_LN" = "ln"; then
146 AC_MSG_RESULT(yes)
147 else
148 if test "$gcc_cv_prog_LN" = "ln -s"; then
149 AC_MSG_RESULT([no, using ln -s])
150 else
151 AC_MSG_RESULT([no, and neither does ln -s, so using cp])
152 fi
153 fi
154 AC_SUBST(LN)dnl
155 ])
156
157 dnl See whether the stage1 host compiler accepts the volatile keyword.
158 AC_DEFUN(gcc_AC_C_VOLATILE,
159 [AC_CACHE_CHECK([for volatile], gcc_cv_c_volatile,
160 [AC_TRY_COMPILE(, [volatile int foo;],
161 gcc_cv_c_volatile=yes, gcc_cv_c_volatile=no)])
162 if test $gcc_cv_c_volatile = yes ; then
163 AC_DEFINE(HAVE_VOLATILE, 1, [Define if your compiler understands volatile.])
164 fi
165 ])
166
167 dnl Check whether long double is supported. This differs from the
168 dnl built-in autoconf test in that it works for cross compiles.
169 AC_DEFUN(gcc_AC_C_LONG_DOUBLE,
170 [AC_CACHE_CHECK(for long double, gcc_cv_c_long_double,
171 [if test "$GCC" = yes; then
172 gcc_cv_c_long_double=yes
173 else
174 AC_TRY_COMPILE(,
175 [/* The Stardent Vistra knows sizeof(long double), but does not support it. */
176 long double foo = 0.0;
177 /* On Ultrix 4.3 cc, long double is 4 and double is 8. */
178 switch (0) case 0: case (sizeof(long double) >= sizeof(double)):;],
179 gcc_cv_c_long_double=yes, gcc_cv_c_long_double=no)
180 fi])
181 if test $gcc_cv_c_long_double = yes; then
182 AC_DEFINE(HAVE_LONG_DOUBLE)
183 fi
184 ])
185
186 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
187 dnl of the usual 2.
188 AC_DEFUN(gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG,
189 [AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
190 [AC_TRY_COMPILE([
191 #include <sys/types.h>
192 #ifdef HAVE_SYS_STAT_H
193 # include <sys/stat.h>
194 #endif
195 #ifdef HAVE_UNISTD_H
196 # include <unistd.h>
197 #endif
198 #ifdef HAVE_DIRECT_H
199 # include <direct.h>
200 #endif], [mkdir ("foo", 0);],
201 gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
202 if test $gcc_cv_mkdir_takes_one_arg = yes ; then
203 AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
204 fi
205 ])
206
207 AC_DEFUN(gcc_AC_PROG_INSTALL,
208 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
209 # Find a good install program. We prefer a C program (faster),
210 # so one script is as good as another. But avoid the broken or
211 # incompatible versions:
212 # SysV /etc/install, /usr/sbin/install
213 # SunOS /usr/etc/install
214 # IRIX /sbin/install
215 # AIX /bin/install
216 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
217 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
218 # ./install, which can be erroneously created by make from ./install.sh.
219 AC_MSG_CHECKING(for a BSD compatible install)
220 if test -z "$INSTALL"; then
221 AC_CACHE_VAL(ac_cv_path_install,
222 [ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
223 for ac_dir in $PATH; do
224 # Account for people who put trailing slashes in PATH elements.
225 case "$ac_dir/" in
226 /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
227 *)
228 # OSF1 and SCO ODT 3.0 have their own names for install.
229 for ac_prog in ginstall scoinst install; do
230 if test -f $ac_dir/$ac_prog; then
231 if test $ac_prog = install &&
232 grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
233 # AIX install. It has an incompatible calling convention.
234 # OSF/1 installbsd also uses dspmsg, but is usable.
235 :
236 else
237 ac_cv_path_install="$ac_dir/$ac_prog -c"
238 break 2
239 fi
240 fi
241 done
242 ;;
243 esac
244 done
245 IFS="$ac_save_IFS"
246 ])dnl
247 if test "${ac_cv_path_install+set}" = set; then
248 INSTALL="$ac_cv_path_install"
249 else
250 # As a last resort, use the slow shell script. We don't cache a
251 # path for INSTALL within a source directory, because that will
252 # break other packages using the cache if that directory is
253 # removed, or if the path is relative.
254 INSTALL="$ac_install_sh"
255 fi
256 fi
257 dnl We do special magic for INSTALL instead of AC_SUBST, to get
258 dnl relative paths right.
259 AC_MSG_RESULT($INSTALL)
260 AC_SUBST(INSTALL)dnl
261
262 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
263 # It thinks the first close brace ends the variable substitution.
264 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
265 AC_SUBST(INSTALL_PROGRAM)dnl
266
267 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
268 AC_SUBST(INSTALL_DATA)dnl
269 ])
270
271 #serial 1
272 dnl This test replaces the one in autoconf.
273 dnl Currently this macro should have the same name as the autoconf macro
274 dnl because gettext's gettext.m4 (distributed in the automake package)
275 dnl still uses it. Otherwise, the use in gettext.m4 makes autoheader
276 dnl give these diagnostics:
277 dnl configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
278 dnl configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
279
280 undefine([AC_ISC_POSIX])
281 AC_DEFUN(AC_ISC_POSIX,
282 [
283 dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
284 AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
285 ]
286 )
287
288
289 dnl GCC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND [, PATH]])
290 dnl like AC_PATH_PROG but use other cache variables
291 AC_DEFUN(GCC_PATH_PROG,
292 [# Extract the first word of "$2", so it can be a program name with args.
293 set dummy $2; ac_word=[$]2
294 AC_MSG_CHECKING([for $ac_word])
295 AC_CACHE_VAL(gcc_cv_path_$1,
296 [case "[$]$1" in
297 /*)
298 gcc_cv_path_$1="[$]$1" # Let the user override the test with a path.
299 ;;
300 ?:/*)
301 gcc_cv_path_$1="[$]$1" # Let the user override the test with a dos path.
302 ;;
303 *)
304 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
305 dnl $ac_dummy forces splitting on constant user-supplied paths.
306 dnl POSIX.2 word splitting is done only on the output of word expansions,
307 dnl not every word. This closes a longstanding sh security hole.
308 ac_dummy="ifelse([$4], , $PATH, [$4])"
309 for ac_dir in $ac_dummy; do
310 test -z "$ac_dir" && ac_dir=.
311 if test -f $ac_dir/$ac_word; then
312 gcc_cv_path_$1="$ac_dir/$ac_word"
313 break
314 fi
315 done
316 IFS="$ac_save_ifs"
317 dnl If no 3rd arg is given, leave the cache variable unset,
318 dnl so GCC_PATH_PROGS will keep looking.
319 ifelse([$3], , , [ test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$3"
320 ])dnl
321 ;;
322 esac])dnl
323 $1="$gcc_cv_path_$1"
324 if test -n "[$]$1"; then
325 AC_MSG_RESULT([$]$1)
326 else
327 AC_MSG_RESULT(no)
328 fi
329 AC_SUBST($1)dnl
330 ])
331
332
333
334 # Macro to add for using GNU gettext.
335 # Ulrich Drepper <drepper@cygnus.com>, 1995.
336 #
337 # This file can be copied and used freely without restrictions. It can
338 # be used in projects which are not available under the GNU Public License
339 # but which still want to provide support for the GNU gettext functionality.
340 # Please note that the actual code is *not* freely available.
341
342 # serial 5
343
344 AC_DEFUN(AM_WITH_NLS,
345 [AC_MSG_CHECKING([whether NLS is requested])
346 dnl Default is enabled NLS
347 AC_ARG_ENABLE(nls,
348 [ --disable-nls do not use Native Language Support],
349 USE_NLS=$enableval, USE_NLS=yes)
350 AC_MSG_RESULT($USE_NLS)
351 AC_SUBST(USE_NLS)
352
353 USE_INCLUDED_LIBINTL=no
354
355 dnl If we use NLS figure out what method
356 if test "$USE_NLS" = "yes"; then
357 AC_DEFINE(ENABLE_NLS)
358 AC_MSG_CHECKING([whether included gettext is requested])
359 AC_ARG_WITH(included-gettext,
360 [ --with-included-gettext use the GNU gettext library included here],
361 nls_cv_force_use_gnu_gettext=$withval,
362 nls_cv_force_use_gnu_gettext=no)
363 AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
364
365 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
366 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
367 dnl User does not insist on using GNU NLS library. Figure out what
368 dnl to use. If gettext or catgets are available (in this order) we
369 dnl use this. Else we have to fall back to GNU NLS library.
370 dnl catgets is only used if permitted by option --with-catgets.
371 nls_cv_header_intl=
372 nls_cv_header_libgt=
373 CATOBJEXT=NONE
374
375 AC_CHECK_HEADER(libintl.h,
376 [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
377 [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
378 gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
379
380 if test "$gt_cv_func_gettext_libc" != "yes"; then
381 AC_CHECK_LIB(intl, bindtextdomain,
382 [AC_CACHE_CHECK([for gettext in libintl],
383 gt_cv_func_gettext_libintl,
384 [AC_CHECK_LIB(intl, gettext,
385 gt_cv_func_gettext_libintl=yes,
386 gt_cv_func_gettext_libintl=no)],
387 gt_cv_func_gettext_libintl=no)])
388 fi
389
390 if test "$gt_cv_func_gettext_libc" = "yes" \
391 || test "$gt_cv_func_gettext_libintl" = "yes"; then
392 AC_DEFINE(HAVE_GETTEXT)
393 GCC_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
394 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
395 if test "$MSGFMT" != "no"; then
396 AC_CHECK_FUNCS(dcgettext)
397 GCC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
398 GCC_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
399 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
400 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
401 return _nl_msg_cat_cntr],
402 [CATOBJEXT=.gmo
403 DATADIRNAME=share],
404 [CATOBJEXT=.mo
405 DATADIRNAME=lib])
406 INSTOBJEXT=.mo
407 else
408 create_catalogs="no"
409 fi
410 fi
411 ])
412
413 if test "$CATOBJEXT" = "NONE"; then
414 AC_MSG_CHECKING([whether catgets can be used])
415 AC_ARG_WITH(catgets,
416 [ --with-catgets use catgets functions if available],
417 nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
418 AC_MSG_RESULT($nls_cv_use_catgets)
419
420 if test "$nls_cv_use_catgets" = "yes"; then
421 dnl No gettext in C library. Try catgets next.
422 AC_CHECK_LIB(i, main)
423 AC_CHECK_FUNC(catgets,
424 [AC_DEFINE(HAVE_CATGETS)
425 INTLOBJS="\$(CATOBJS)"
426 GCC_PATH_PROG(GENCAT, gencat, no)dnl
427 if test "$GENCAT" != "no"; then
428 GCC_PATH_PROG(GMSGFMT, gmsgfmt, no)
429 if test "$GMSGFMT" = "no"; then
430 GCC_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
431 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
432 if test "$GMSGFMT" = "msgfmt"; then
433 create_catalogs="no"
434 fi
435 fi
436 GCC_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
437 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
438 USE_INCLUDED_LIBINTL=yes
439 CATOBJEXT=.cat
440 INSTOBJEXT=.cat
441 DATADIRNAME=lib
442 INTLDEPS='$(top_builddir)/intl/libintl.a'
443 INTLLIBS=$INTLDEPS
444 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
445 nls_cv_header_intl=intl/libintl.h
446 nls_cv_header_libgt=intl/libgettext.h
447 fi])
448 fi
449 fi
450
451 if test "$CATOBJEXT" = "NONE"; then
452 dnl Neither gettext nor catgets in included in the C library.
453 dnl Fall back on GNU gettext library.
454 nls_cv_use_gnu_gettext=yes
455 fi
456 fi
457
458 if test "$nls_cv_use_gnu_gettext" = "yes"; then
459 dnl Mark actions used to generate GNU NLS library.
460 INTLOBJS="\$(GETTOBJS)"
461 GCC_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
462 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
463 GCC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
464 dnl If we didn't find either msgfmt or gmsgfmt, don't try to
465 dnl create a catalog.
466 if test "$MSGFMT" = "msgfmt" && test "$GMSGFMT" = "msgfmt"; then
467 create_catalogs="no"
468 fi
469 GCC_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
470 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
471 AC_SUBST(MSGFMT)
472 USE_INCLUDED_LIBINTL=yes
473 CATOBJEXT=.gmo
474 INSTOBJEXT=.mo
475 DATADIRNAME=share
476 INTLDEPS='$(top_builddir)/intl/libintl.a'
477 INTLLIBS=$INTLDEPS
478 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
479 nls_cv_header_intl=intl/libintl.h
480 nls_cv_header_libgt=intl/libgettext.h
481 fi
482
483 dnl Test whether we really found GNU xgettext.
484 if test "$XGETTEXT" != ":"; then
485 dnl If it is no GNU xgettext we define it as : so that the
486 dnl Makefiles still can work.
487 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
488 : ;
489 else
490 AC_MSG_RESULT(
491 [found xgettext program is not GNU xgettext; ignore it])
492 XGETTEXT=":"
493 fi
494 fi
495
496
497
498 # We need to process the po/ directory.
499 POSUB=po
500 else
501 DATADIRNAME=share
502 nls_cv_header_intl=intl/libintl.h
503 nls_cv_header_libgt=intl/libgettext.h
504 fi
505 AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
506 AC_OUTPUT_COMMANDS(
507 [case "$CONFIG_FILES" in *po/Makefile.in*)
508 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
509 esac])
510
511
512 # If this is used in GNU gettext we have to set USE_NLS to `yes'
513 # because some of the sources are only built for this goal.
514 if test "$PACKAGE" = gettext; then
515 USE_NLS=yes
516 USE_INCLUDED_LIBINTL=yes
517 fi
518
519 dnl These rules are solely for the distribution goal. While doing this
520 dnl we only have to keep exactly one list of the available catalogs
521 dnl in configure.in.
522 for lang in $ALL_LINGUAS; do
523 GMOFILES="$GMOFILES $lang.gmo"
524 POFILES="$POFILES $lang.po"
525 done
526
527 dnl Make all variables we use known to autoconf.
528 AC_SUBST(USE_INCLUDED_LIBINTL)
529 AC_SUBST(CATALOGS)
530 AC_SUBST(CATOBJEXT)
531 AC_SUBST(DATADIRNAME)
532 AC_SUBST(GMOFILES)
533 AC_SUBST(INSTOBJEXT)
534 AC_SUBST(INTLDEPS)
535 AC_SUBST(INTLLIBS)
536 AC_SUBST(INTLOBJS)
537 AC_SUBST(POFILES)
538 AC_SUBST(POSUB)
539 ])
540
541 AC_DEFUN(AM_GNU_GETTEXT,
542 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
543 AC_REQUIRE([AC_PROG_CC])dnl
544 AC_REQUIRE([AC_PROG_RANLIB])dnl
545 AC_REQUIRE([AC_ISC_POSIX])dnl
546 AC_REQUIRE([AC_HEADER_STDC])dnl
547 AC_REQUIRE([AC_C_CONST])dnl
548 AC_REQUIRE([AC_C_INLINE])dnl
549 AC_REQUIRE([AC_TYPE_OFF_T])dnl
550 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
551 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
552
553 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
554 unistd.h sys/param.h])
555 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
556 strdup __argz_count __argz_stringify __argz_next])
557
558 if test "${ac_cv_func_stpcpy+set}" != "set"; then
559 AC_CHECK_FUNCS(stpcpy)
560 fi
561 if test "${ac_cv_func_stpcpy}" = "yes"; then
562 AC_DEFINE(HAVE_STPCPY)
563 fi
564
565 AM_LC_MESSAGES
566 AM_WITH_NLS
567
568 if test "x$create_catalogs" = "xno"; then
569 AC_MSG_WARN([No program for building catalogs found -> building disabled])
570 fi
571
572 if test "x$CATOBJEXT" != "x" && test "x$create_catalogs" != "xno" ; then
573 if test "x$ALL_LINGUAS" = "x"; then
574 LINGUAS=
575 else
576 AC_MSG_CHECKING(for catalogs to be installed)
577 if test "x$LINGUAS" = "x"; then
578 LINGUAS=$ALL_LINGUAS
579 else
580 NEW_LINGUAS=
581 for lang in $ALL_LINGUAS; do
582 case " $LINGUAS " in
583 *" $lang "*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
584 esac
585 done
586 LINGUAS=$NEW_LINGUAS
587 fi
588 AC_MSG_RESULT($LINGUAS)
589 fi
590
591 dnl Construct list of names of catalog files to be constructed.
592 if test -n "$LINGUAS"; then
593 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
594 fi
595 fi
596
597 dnl The reference to <locale.h> in the installed <libintl.h> file
598 dnl must be resolved because we cannot expect the users of this
599 dnl to define HAVE_LOCALE_H.
600 if test $ac_cv_header_locale_h = yes; then
601 INCLUDE_LOCALE_H="#include <locale.h>"
602 else
603 INCLUDE_LOCALE_H="\
604 /* The system does not provide the header <locale.h>. Take care yourself. */"
605 fi
606 AC_SUBST(INCLUDE_LOCALE_H)
607
608 dnl Determine which catalog format we have (if any is needed)
609 dnl For now we know about two different formats:
610 dnl Linux libc-5 and the normal X/Open format
611 test -d intl || mkdir intl
612 if test "$CATOBJEXT" = ".cat"; then
613 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
614
615 dnl Transform the SED scripts while copying because some dumb SEDs
616 dnl cannot handle comments.
617 sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
618 fi
619 dnl po2tbl.sed is always needed.
620 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
621 $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
622
623 dnl In the intl/Makefile.in we have a special dependency which makes
624 dnl only sense for gettext. We comment this out for non-gettext
625 dnl packages.
626 if test "$PACKAGE" = "gettext"; then
627 GT_NO="#NO#"
628 GT_YES=
629 else
630 GT_NO=
631 GT_YES="#YES#"
632 fi
633 AC_SUBST(GT_NO)
634 AC_SUBST(GT_YES)
635
636 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
637 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
638 dnl Try to locate is.
639 MKINSTALLDIRS=
640 if test -n "$ac_aux_dir"; then
641 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
642 fi
643 if test -z "$MKINSTALLDIRS"; then
644 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
645 fi
646 AC_SUBST(MKINSTALLDIRS)
647
648 dnl *** For now the libtool support in intl/Makefile is not for real.
649 l=
650 AC_SUBST(l)
651
652 dnl Generate list of files to be processed by xgettext which will
653 dnl be included in po/Makefile.
654 test -d po || mkdir po
655 if test "x$srcdir" != "x."; then
656 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
657 posrcprefix="$srcdir/"
658 else
659 posrcprefix="../$srcdir/"
660 fi
661 else
662 posrcprefix="../"
663 fi
664 rm -f po/POTFILES
665 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
666 < $srcdir/po/POTFILES.in > po/POTFILES
667 ])
668
669 # Check whether LC_MESSAGES is available in <locale.h>.
670 # Ulrich Drepper <drepper@cygnus.com>, 1995.
671 #
672 # This file can be copied and used freely without restrictions. It can
673 # be used in projects which are not available under the GNU Public License
674 # but which still want to provide support for the GNU gettext functionality.
675 # Please note that the actual code is *not* freely available.
676
677 # serial 1
678
679 AC_DEFUN(AM_LC_MESSAGES,
680 [if test $ac_cv_header_locale_h = yes; then
681 AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
682 [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
683 am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
684 if test $am_cv_val_LC_MESSAGES = yes; then
685 AC_DEFINE(HAVE_LC_MESSAGES)
686 fi
687 fi])
688
689 # Search path for a program which passes the given test.
690 # Ulrich Drepper <drepper@cygnus.com>, 1996.
691 #
692 # This file can be copied and used freely without restrictions. It can
693 # be used in projects which are not available under the GNU Public License
694 # but which still want to provide support for the GNU gettext functionality.
695 # Please note that the actual code is *not* freely available.
696
697 # serial 1
698
699 dnl GCC_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
700 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
701 AC_DEFUN(GCC_PATH_PROG_WITH_TEST,
702 [# Extract the first word of "$2", so it can be a program name with args.
703 set dummy $2; ac_word=[$]2
704 AC_MSG_CHECKING([for $ac_word])
705 AC_CACHE_VAL(gcc_cv_path_$1,
706 [case "[$]$1" in
707 /*)
708 gcc_cv_path_$1="[$]$1" # Let the user override the test with a path.
709 ;;
710 *)
711 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
712 for ac_dir in ifelse([$5], , $PATH, [$5]); do
713 test -z "$ac_dir" && ac_dir=.
714 if test -f $ac_dir/$ac_word; then
715 if [$3]; then
716 gcc_cv_path_$1="$ac_dir/$ac_word"
717 break
718 fi
719 fi
720 done
721 IFS="$ac_save_ifs"
722 dnl If no 4th arg is given, leave the cache variable unset,
723 dnl so GCC_PATH_PROGS will keep looking.
724 ifelse([$4], , , [ test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$4"
725 ])dnl
726 ;;
727 esac])dnl
728 $1="$gcc_cv_path_$1"
729 if test -n "[$]$1"; then
730 AC_MSG_RESULT([$]$1)
731 else
732 AC_MSG_RESULT(no)
733 fi
734 AC_SUBST($1)dnl
735 ])
736
737 # Check whether mmap can map an arbitrary page from /dev/zero or with
738 # MAP_ANONYMOUS, without MAP_FIXED.
739 AC_DEFUN([AC_FUNC_MMAP_ANYWHERE],
740 [AC_CHECK_FUNCS(getpagesize)
741 # The test program for the next two tests is the same except for one
742 # set of ifdefs.
743 changequote({{{,}}})dnl
744 {{{cat >ct-mmap.inc <<'EOF'
745 #include <sys/types.h>
746 #include <sys/mman.h>
747 #include <fcntl.h>
748 #include <signal.h>
749 #include <setjmp.h>
750 #include <stdio.h>
751
752 #if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
753 # define MAP_ANONYMOUS MAP_ANON
754 #endif
755
756 /* This mess was copied from the GNU getpagesize.h. */
757 #ifndef HAVE_GETPAGESIZE
758 # ifdef HAVE_UNISTD_H
759 # include <unistd.h>
760 # endif
761
762 /* Assume that all systems that can run configure have sys/param.h. */
763 # ifndef HAVE_SYS_PARAM_H
764 # define HAVE_SYS_PARAM_H 1
765 # endif
766
767 # ifdef _SC_PAGESIZE
768 # define getpagesize() sysconf(_SC_PAGESIZE)
769 # else /* no _SC_PAGESIZE */
770 # ifdef HAVE_SYS_PARAM_H
771 # include <sys/param.h>
772 # ifdef EXEC_PAGESIZE
773 # define getpagesize() EXEC_PAGESIZE
774 # else /* no EXEC_PAGESIZE */
775 # ifdef NBPG
776 # define getpagesize() NBPG * CLSIZE
777 # ifndef CLSIZE
778 # define CLSIZE 1
779 # endif /* no CLSIZE */
780 # else /* no NBPG */
781 # ifdef NBPC
782 # define getpagesize() NBPC
783 # else /* no NBPC */
784 # ifdef PAGESIZE
785 # define getpagesize() PAGESIZE
786 # endif /* PAGESIZE */
787 # endif /* no NBPC */
788 # endif /* no NBPG */
789 # endif /* no EXEC_PAGESIZE */
790 # else /* no HAVE_SYS_PARAM_H */
791 # define getpagesize() 8192 /* punt totally */
792 # endif /* no HAVE_SYS_PARAM_H */
793 # endif /* no _SC_PAGESIZE */
794
795 #endif /* no HAVE_GETPAGESIZE */
796
797 #ifndef MAP_FAILED
798 # define MAP_FAILED -1
799 #endif
800
801 #undef perror_exit
802 #define perror_exit(str, val) \
803 do { perror(str); exit(val); } while (0)
804
805 /* Some versions of cygwin mmap require that munmap is called with the
806 same parameters as mmap. GCC expects that this is not the case.
807 Test for various forms of this problem. Warning - icky signal games. */
808
809 static sigset_t unblock_sigsegv;
810 static jmp_buf r;
811 static size_t pg;
812 static int devzero;
813
814 static char *
815 anonmap (size)
816 size_t size;
817 {
818 #ifdef USE_MAP_ANON
819 return (char *) mmap (0, size, PROT_READ|PROT_WRITE,
820 MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
821 #else
822 return (char *) mmap (0, size, PROT_READ|PROT_WRITE,
823 MAP_PRIVATE, devzero, 0);
824 #endif
825 }
826
827 static void
828 sigsegv (unused)
829 int unused;
830 {
831 sigprocmask (SIG_UNBLOCK, &unblock_sigsegv, 0);
832 longjmp (r, 1);
833 }
834
835 /* Basic functionality test. */
836 void
837 test_0 ()
838 {
839 char *x = anonmap (pg);
840 if (x == (char *) MAP_FAILED)
841 perror_exit("test 0 mmap", 2);
842
843 *(int *)x += 1;
844
845 if (munmap(x, pg) < 0)
846 perror_exit("test 0 munmap", 3);
847 }
848
849 /* 1. If we map a 2-page region and unmap its second page, the first page
850 must remain. */
851 static void
852 test_1 ()
853 {
854 char *x = anonmap (pg * 2);
855 if (x == (char *)MAP_FAILED)
856 perror_exit ("test 1 mmap", 4);
857
858 signal (SIGSEGV, sigsegv);
859 if (setjmp (r))
860 perror_exit ("test 1 fault", 5);
861
862 x[0] = 1;
863 x[pg] = 1;
864
865 if (munmap (x + pg, pg) < 0)
866 perror_exit ("test 1 munmap 1", 6);
867 x[0] = 2;
868
869 if (setjmp (r) == 0)
870 {
871 x[pg] = 1;
872 perror_exit ("test 1 no fault", 7);
873 }
874 if (munmap (x, pg) < 0)
875 perror_exit ("test 1 munmap 2", 8);
876 }
877
878 /* 2. If we map a 2-page region and unmap its first page, the second
879 page must remain. */
880 static void
881 test_2 ()
882 {
883 char *x = anonmap (pg * 2);
884 if (x == (char *)MAP_FAILED)
885 perror_exit ("test 2 mmap", 9);
886
887 signal (SIGSEGV, sigsegv);
888 if (setjmp (r))
889 perror_exit ("test 2 fault", 10);
890
891 x[0] = 1;
892 x[pg] = 1;
893
894 if (munmap (x, pg) < 0)
895 perror_exit ("test 2 munmap 1", 11);
896
897 x[pg] = 2;
898
899 if (setjmp (r) == 0)
900 {
901 x[0] = 1;
902 perror_exit ("test 2 no fault", 12);
903 }
904
905 if (munmap (x+pg, pg) < 0)
906 perror_exit ("test 2 munmap 2", 13);
907 }
908
909 /* 3. If we map two adjacent 1-page regions and unmap them both with
910 one munmap, both must go away.
911
912 Getting two adjacent 1-page regions with two mmap calls is slightly
913 tricky. All OS's tested skip over already-allocated blocks; therefore
914 we have been careful to unmap all allocated regions in previous tests.
915 HP/UX allocates pages backward in memory. No OS has yet been observed
916 to be so perverse as to leave unmapped space between consecutive calls
917 to mmap. */
918
919 static void
920 test_3 ()
921 {
922 char *x, *y, *z;
923
924 x = anonmap (pg);
925 if (x == (char *)MAP_FAILED)
926 perror_exit ("test 3 mmap 1", 14);
927 y = anonmap (pg);
928 if (y == (char *)MAP_FAILED)
929 perror_exit ("test 3 mmap 2", 15);
930
931 if (y != x + pg)
932 {
933 if (y == x - pg)
934 z = y, y = x, x = z;
935 else
936 {
937 fprintf (stderr, "test 3 nonconsecutive pages - %lx, %lx\n",
938 (unsigned long)x, (unsigned long)y);
939 exit (16);
940 }
941 }
942
943 signal (SIGSEGV, sigsegv);
944 if (setjmp (r))
945 perror_exit ("test 3 fault", 17);
946
947 x[0] = 1;
948 y[0] = 1;
949
950 if (munmap (x, pg*2) < 0)
951 perror_exit ("test 3 munmap", 18);
952
953 if (setjmp (r) == 0)
954 {
955 x[0] = 1;
956 perror_exit ("test 3 no fault 1", 19);
957 }
958
959 signal (SIGSEGV, sigsegv);
960 if (setjmp (r) == 0)
961 {
962 y[0] = 1;
963 perror_exit ("test 3 no fault 2", 20);
964 }
965 }
966
967 int
968 main ()
969 {
970 sigemptyset (&unblock_sigsegv);
971 sigaddset (&unblock_sigsegv, SIGSEGV);
972 pg = getpagesize ();
973 #ifndef USE_MAP_ANON
974 devzero = open ("/dev/zero", O_RDWR);
975 if (devzero < 0)
976 perror_exit ("open /dev/zero", 1);
977 #endif
978
979 test_0();
980 test_1();
981 test_2();
982 test_3();
983
984 exit(0);
985 }
986 EOF}}}
987 changequote([,])dnl
988
989 AC_CACHE_CHECK(for working mmap from /dev/zero,
990 ac_cv_func_mmap_dev_zero,
991 [AC_TRY_RUN(
992 [#include "ct-mmap.inc"],
993 ac_cv_func_mmap_dev_zero=yes,
994 [if test $? -lt 4
995 then ac_cv_func_mmap_dev_zero=no
996 else ac_cv_func_mmap_dev_zero=buggy
997 fi],
998 # If this is not cygwin, and /dev/zero is a character device, it's probably
999 # safe to assume it works.
1000 [case "$host_os" in
1001 cygwin* | win32 | pe | mingw* ) ac_cv_func_mmap_dev_zero=buggy ;;
1002 * ) if test -c /dev/zero
1003 then ac_cv_func_mmap_dev_zero=yes
1004 else ac_cv_func_mmap_dev_zero=no
1005 fi ;;
1006 esac])
1007 ])
1008 if test $ac_cv_func_mmap_dev_zero = yes; then
1009 AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
1010 [Define if mmap can get us zeroed pages from /dev/zero.])
1011 fi
1012
1013 AC_CACHE_CHECK([for working mmap with MAP_ANON(YMOUS)],
1014 ac_cv_func_mmap_anon,
1015 [AC_TRY_RUN(
1016 [#define USE_MAP_ANON
1017 #include "ct-mmap.inc"],
1018 ac_cv_func_mmap_anon=yes,
1019 [if test $? -lt 4
1020 then ac_cv_func_mmap_anon=no
1021 else ac_cv_func_mmap_anon=buggy
1022 fi],
1023 # Unlike /dev/zero, it is not safe to assume MAP_ANON(YMOUS) works
1024 # just because it's there. Some SCO Un*xen define it but don't implement it.
1025 ac_cv_func_mmap_anon=no)
1026 ])
1027 if test $ac_cv_func_mmap_anon = yes; then
1028 AC_DEFINE(HAVE_MMAP_ANON, 1,
1029 [Define if mmap can get us zeroed pages using MAP_ANON(YMOUS).])
1030 fi
1031 rm -f ct-mmap.inc
1032 ])
1033
1034 # Check whether mmap can map a plain file, without MAP_FIXED.
1035 AC_DEFUN([AC_FUNC_MMAP_FILE],
1036 [AC_CACHE_CHECK(for working mmap of a file, ac_cv_func_mmap_file,
1037 [# Create a file one thousand bytes long.
1038 for i in 1 2 3 4 5 6 7 8 9 0
1039 do for j in 1 2 3 4 5 6 7 8 9 0
1040 do echo $i $j xxxxx
1041 done
1042 done > conftestdata$$
1043
1044 AC_TRY_RUN([
1045 /* Test by Zack Weinberg. Modified from MMAP_ANYWHERE test by
1046 Richard Henderson and Alexandre Oliva.
1047 Check whether read-only mmap of a plain file works. */
1048 #include <sys/types.h>
1049 #include <sys/stat.h>
1050 #include <fcntl.h>
1051 #include <sys/mman.h>
1052
1053 int main()
1054 {
1055 char *x;
1056 int fd;
1057 struct stat st;
1058
1059 fd = open("conftestdata$$", O_RDONLY);
1060 if (fd < 0)
1061 exit(1);
1062
1063 if (fstat (fd, &st))
1064 exit(2);
1065
1066 x = (char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
1067 if (x == (char *) -1)
1068 exit(3);
1069
1070 if (x[0] != '1' || x[1] != ' ' || x[2] != '1' || x[3] != ' ')
1071 exit(4);
1072
1073 if (munmap(x, st.st_size) < 0)
1074 exit(5);
1075
1076 exit(0);
1077 }], ac_cv_func_mmap_file=yes, ac_cv_func_mmap_file=no,
1078 ac_cv_func_mmap_file=no)])
1079 if test $ac_cv_func_mmap_file = yes; then
1080 AC_DEFINE(HAVE_MMAP_FILE, 1,
1081 [Define if read-only mmap of a plain file works.])
1082 fi
1083 ])
1084
1085 dnl Locate a program and check that its version is acceptable.
1086 dnl AC_PROG_CHECK_VER(var, name, version-switch,
1087 dnl version-extract-regexp, version-glob)
1088 AC_DEFUN(gcc_AC_CHECK_PROG_VER,
1089 [AC_CHECK_PROG([$1], [$2], [$2])
1090 if test -n "[$]$1"; then
1091 # Found it, now check the version.
1092 AC_CACHE_CHECK(for modern $2, gcc_cv_prog_$2_modern,
1093 [changequote(<<,>>)dnl
1094 ac_prog_version=`<<$>>$1 $3 2>&1 |
1095 sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'`
1096 echo "configure:__oline__: version of $2 is $ac_prog_version" >&AC_FD_CC
1097 case $ac_prog_version in
1098 '') gcc_cv_prog_$2_modern=no;;
1099 <<$5>>)
1100 gcc_cv_prog_$2_modern=yes;;
1101 *) gcc_cv_prog_$2_modern=no;;
1102 esac
1103 changequote([,])dnl
1104 ])
1105 else
1106 gcc_cv_prog_$2_modern=no
1107 fi
1108 ])