1 dnl See whether we can include both string.h and strings.h.
2 AC_DEFUN(GCC_HEADER_STRING,
3 [AC_CACHE_CHECK([whether string.h and strings.h may both be included],
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)
12 dnl See whether we need a declaration for a function.
13 dnl GCC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
14 AC_DEFUN(GCC_NEED_DECLARATION,
15 [AC_MSG_CHECKING([whether $1 must be declared])
16 AC_CACHE_VAL(gcc_cv_decl_needed_$1,
19 #ifdef STRING_WITH_STRINGS
26 # ifdef HAVE_STRINGS_H
38 #define rindex strrchr
44 [char *(*pfn) = (char *(*)) $1],
45 eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")])
46 if eval "test \"`echo '$gcc_cv_decl_needed_'$1`\" = yes"; then
48 gcc_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
49 AC_DEFINE_UNQUOTED($gcc_tr_decl)
55 dnl Check multiple functions to see whether each needs a declaration.
56 dnl GCC_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
57 AC_DEFUN(GCC_NEED_DECLARATIONS,
60 GCC_NEED_DECLARATION($ac_func, $2)
64 dnl Use <inttypes.h> only if it exists,
65 dnl doesn't clash with <sys/types.h>, and declares intmax_t.
66 AC_DEFUN(GCC_HEADER_INTTYPES,
67 [AC_MSG_CHECKING(for inttypes.h)
68 AC_CACHE_VAL(gcc_cv_header_inttypes_h,
70 [#include <sys/types.h>
71 #include <inttypes.h>],
73 gcc_cv_header_inttypes_h=yes,
74 gcc_cv_header_inttypes_h=no)])
75 AC_MSG_RESULT($gcc_cv_header_inttypes_h)
76 if test $gcc_cv_header_inttypes_h = yes; then
77 AC_DEFINE(HAVE_INTTYPES_H)
81 dnl See if the system preprocessor understands the ANSI C preprocessor
82 dnl stringification operator.
83 AC_DEFUN(GCC_CHECK_STRINGIFY,
84 [AC_MSG_CHECKING(whether cpp understands the stringify operator)
85 AC_CACHE_VAL(gcc_cv_c_have_stringify,
88 char *test = S(foo);],
89 gcc_cv_c_have_stringify=yes, gcc_cv_c_have_stringify=no)])
90 AC_MSG_RESULT($gcc_cv_c_have_stringify)
91 if test $gcc_cv_c_have_stringify = yes; then
92 AC_DEFINE(HAVE_CPP_STRINGIFY)
96 dnl Check if we have vprintf and possibly _doprnt.
97 dnl Note autoconf checks for vprintf even though we care about vfprintf.
98 AC_DEFUN(GCC_FUNC_VFPRINTF_DOPRNT,
102 if test $ac_cv_func_vprintf != yes ; then
104 if test $ac_cv_func__doprnt != yes ; then
112 dnl See if the printf functions in libc support %p in format strings.
113 AC_DEFUN(GCC_FUNC_PRINTF_PTR,
114 [AC_CACHE_CHECK(whether the printf functions support %p,
115 gcc_cv_func_printf_ptr,
116 [AC_TRY_RUN([#include <stdio.h>
121 char *p = buf, *q = NULL;
122 sprintf(buf, "%p", p);
123 sscanf(buf, "%p", &q);
125 }], gcc_cv_func_printf_ptr=yes, gcc_cv_func_printf_ptr=no,
126 gcc_cv_func_printf_ptr=no)
127 rm -f core core.* *.core])
128 if test $gcc_cv_func_printf_ptr = yes ; then
129 AC_DEFINE(HAVE_PRINTF_PTR)
133 dnl See whether the stage1 host compiler accepts the volatile keyword.
134 AC_DEFUN(GCC_C_VOLATILE,
135 [AC_CACHE_CHECK([for volatile], gcc_cv_c_volatile,
136 [AC_TRY_COMPILE(, [volatile int foo;],
137 gcc_cv_c_volatile=yes, gcc_cv_c_volatile=no)])
138 if test $gcc_cv_c_volatile = yes ; then
139 AC_DEFINE(HAVE_VOLATILE)
144 dnl This test replaces the one in autoconf.
145 dnl Currently this macro should have the same name as the autoconf macro
146 dnl because gettext's gettext.m4 (distributed in the automake package)
147 dnl still uses it. Otherwise, the use in gettext.m4 makes autoheader
148 dnl give these diagnostics:
149 dnl configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
150 dnl configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
152 undefine([AC_ISC_POSIX])
153 AC_DEFUN(AC_ISC_POSIX,
155 dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
156 AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
160 # Macro to add for using GNU gettext.
161 # Ulrich Drepper <drepper@cygnus.com>, 1995.
163 # This file can be copied and used freely without restrictions. It can
164 # be used in projects which are not available under the GNU Public License
165 # but which still want to provide support for the GNU gettext functionality.
166 # Please note that the actual code is *not* freely available.
170 AC_DEFUN(AM_WITH_NLS,
171 [AC_MSG_CHECKING([whether NLS is requested])
172 dnl Default is enabled NLS
174 [ --disable-nls do not use Native Language Support],
175 USE_NLS=$enableval, USE_NLS=yes)
176 AC_MSG_RESULT($USE_NLS)
179 USE_INCLUDED_LIBINTL=no
181 dnl If we use NLS figure out what method
182 if test "$USE_NLS" = "yes"; then
183 AC_DEFINE(ENABLE_NLS)
184 AC_MSG_CHECKING([whether included gettext is requested])
185 AC_ARG_WITH(included-gettext,
186 [ --with-included-gettext use the GNU gettext library included here],
187 nls_cv_force_use_gnu_gettext=$withval,
188 nls_cv_force_use_gnu_gettext=no)
189 AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
191 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
192 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
193 dnl User does not insist on using GNU NLS library. Figure out what
194 dnl to use. If gettext or catgets are available (in this order) we
195 dnl use this. Else we have to fall back to GNU NLS library.
196 dnl catgets is only used if permitted by option --with-catgets.
201 AC_CHECK_HEADER(libintl.h,
202 [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
203 [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
204 gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
206 if test "$gt_cv_func_gettext_libc" != "yes"; then
207 AC_CHECK_LIB(intl, bindtextdomain,
208 [AC_CACHE_CHECK([for gettext in libintl],
209 gt_cv_func_gettext_libintl,
210 [AC_CHECK_LIB(intl, gettext,
211 gt_cv_func_gettext_libintl=yes,
212 gt_cv_func_gettext_libintl=no)],
213 gt_cv_func_gettext_libintl=no)])
216 if test "$gt_cv_func_gettext_libc" = "yes" \
217 || test "$gt_cv_func_gettext_libintl" = "yes"; then
218 AC_DEFINE(HAVE_GETTEXT)
219 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
220 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
221 if test "$MSGFMT" != "no"; then
222 AC_CHECK_FUNCS(dcgettext)
223 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
224 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
225 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
226 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
227 return _nl_msg_cat_cntr],
237 if test "$CATOBJEXT" = "NONE"; then
238 AC_MSG_CHECKING([whether catgets can be used])
240 [ --with-catgets use catgets functions if available],
241 nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
242 AC_MSG_RESULT($nls_cv_use_catgets)
244 if test "$nls_cv_use_catgets" = "yes"; then
245 dnl No gettext in C library. Try catgets next.
246 AC_CHECK_LIB(i, main)
247 AC_CHECK_FUNC(catgets,
248 [AC_DEFINE(HAVE_CATGETS)
249 INTLOBJS="\$(CATOBJS)"
250 AC_PATH_PROG(GENCAT, gencat, no)dnl
251 if test "$GENCAT" != "no"; then
252 AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
253 if test "$GMSGFMT" = "no"; then
254 AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
255 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
257 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
258 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
259 USE_INCLUDED_LIBINTL=yes
263 INTLDEPS='$(top_builddir)/intl/libintl.a'
265 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
266 nls_cv_header_intl=intl/libintl.h
267 nls_cv_header_libgt=intl/libgettext.h
272 if test "$CATOBJEXT" = "NONE"; then
273 dnl Neither gettext nor catgets in included in the C library.
274 dnl Fall back on GNU gettext library.
275 nls_cv_use_gnu_gettext=yes
279 if test "$nls_cv_use_gnu_gettext" = "yes"; then
280 dnl Mark actions used to generate GNU NLS library.
281 INTLOBJS="\$(GETTOBJS)"
282 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
283 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
284 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
285 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
286 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
288 USE_INCLUDED_LIBINTL=yes
292 INTLDEPS='$(top_builddir)/intl/libintl.a'
294 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
295 nls_cv_header_intl=intl/libintl.h
296 nls_cv_header_libgt=intl/libgettext.h
299 dnl Test whether we really found GNU xgettext.
300 if test "$XGETTEXT" != ":"; then
301 dnl If it is no GNU xgettext we define it as : so that the
302 dnl Makefiles still can work.
303 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
307 [found xgettext program is not GNU xgettext; ignore it])
312 # We need to process the po/ directory.
316 nls_cv_header_intl=intl/libintl.h
317 nls_cv_header_libgt=intl/libgettext.h
319 AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
321 [case "$CONFIG_FILES" in *po/Makefile.in*)
322 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
326 # If this is used in GNU gettext we have to set USE_NLS to `yes'
327 # because some of the sources are only built for this goal.
328 if test "$PACKAGE" = gettext; then
330 USE_INCLUDED_LIBINTL=yes
333 dnl These rules are solely for the distribution goal. While doing this
334 dnl we only have to keep exactly one list of the available catalogs
336 for lang in $ALL_LINGUAS; do
337 GMOFILES="$GMOFILES $lang.gmo"
338 POFILES="$POFILES $lang.po"
341 dnl Make all variables we use known to autoconf.
342 AC_SUBST(USE_INCLUDED_LIBINTL)
345 AC_SUBST(DATADIRNAME)
355 AC_DEFUN(AM_GNU_GETTEXT,
356 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
357 AC_REQUIRE([AC_PROG_CC])dnl
358 AC_REQUIRE([AC_PROG_RANLIB])dnl
359 AC_REQUIRE([AC_ISC_POSIX])dnl
360 AC_REQUIRE([AC_HEADER_STDC])dnl
361 AC_REQUIRE([AC_C_CONST])dnl
362 AC_REQUIRE([AC_C_INLINE])dnl
363 AC_REQUIRE([AC_TYPE_OFF_T])dnl
364 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
365 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
366 AC_REQUIRE([AC_FUNC_MMAP])dnl
368 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
369 unistd.h sys/param.h])
370 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
371 strdup __argz_count __argz_stringify __argz_next])
373 if test "${ac_cv_func_stpcpy+set}" != "set"; then
374 AC_CHECK_FUNCS(stpcpy)
376 if test "${ac_cv_func_stpcpy}" = "yes"; then
377 AC_DEFINE(HAVE_STPCPY)
383 if test "x$CATOBJEXT" != "x"; then
384 if test "x$ALL_LINGUAS" = "x"; then
387 AC_MSG_CHECKING(for catalogs to be installed)
389 for lang in ${LINGUAS=$ALL_LINGUAS}; do
390 case "$ALL_LINGUAS" in
391 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
395 AC_MSG_RESULT($LINGUAS)
398 dnl Construct list of names of catalog files to be constructed.
399 if test -n "$LINGUAS"; then
400 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
404 dnl The reference to <locale.h> in the installed <libintl.h> file
405 dnl must be resolved because we cannot expect the users of this
406 dnl to define HAVE_LOCALE_H.
407 if test $ac_cv_header_locale_h = yes; then
408 INCLUDE_LOCALE_H="#include <locale.h>"
411 /* The system does not provide the header <locale.h>. Take care yourself. */"
413 AC_SUBST(INCLUDE_LOCALE_H)
415 dnl Determine which catalog format we have (if any is needed)
416 dnl For now we know about two different formats:
417 dnl Linux libc-5 and the normal X/Open format
418 test -d intl || mkdir intl
419 if test "$CATOBJEXT" = ".cat"; then
420 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
422 dnl Transform the SED scripts while copying because some dumb SEDs
423 dnl cannot handle comments.
424 sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
426 dnl po2tbl.sed is always needed.
427 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
428 $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
430 dnl In the intl/Makefile.in we have a special dependency which makes
431 dnl only sense for gettext. We comment this out for non-gettext
433 if test "$PACKAGE" = "gettext"; then
443 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
444 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
445 dnl Try to locate is.
447 if test -n "$ac_aux_dir"; then
448 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
450 if test -z "$MKINSTALLDIRS"; then
451 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
453 AC_SUBST(MKINSTALLDIRS)
455 dnl *** For now the libtool support in intl/Makefile is not for real.
459 dnl Generate list of files to be processed by xgettext which will
460 dnl be included in po/Makefile.
461 test -d po || mkdir po
462 if test "x$srcdir" != "x."; then
463 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
464 posrcprefix="$srcdir/"
466 posrcprefix="../$srcdir/"
472 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
473 < $srcdir/po/POTFILES.in > po/POTFILES
476 # Check whether LC_MESSAGES is available in <locale.h>.
477 # Ulrich Drepper <drepper@cygnus.com>, 1995.
479 # This file can be copied and used freely without restrictions. It can
480 # be used in projects which are not available under the GNU Public License
481 # but which still want to provide support for the GNU gettext functionality.
482 # Please note that the actual code is *not* freely available.
486 AC_DEFUN(AM_LC_MESSAGES,
487 [if test $ac_cv_header_locale_h = yes; then
488 AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
489 [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
490 am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
491 if test $am_cv_val_LC_MESSAGES = yes; then
492 AC_DEFINE(HAVE_LC_MESSAGES)
496 # Search path for a program which passes the given test.
497 # Ulrich Drepper <drepper@cygnus.com>, 1996.
499 # This file can be copied and used freely without restrictions. It can
500 # be used in projects which are not available under the GNU Public License
501 # but which still want to provide support for the GNU gettext functionality.
502 # Please note that the actual code is *not* freely available.
506 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
507 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
508 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
509 [# Extract the first word of "$2", so it can be a program name with args.
510 set dummy $2; ac_word=[$]2
511 AC_MSG_CHECKING([for $ac_word])
512 AC_CACHE_VAL(ac_cv_path_$1,
515 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
518 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
519 for ac_dir in ifelse([$5], , $PATH, [$5]); do
520 test -z "$ac_dir" && ac_dir=.
521 if test -f $ac_dir/$ac_word; then
523 ac_cv_path_$1="$ac_dir/$ac_word"
529 dnl If no 4th arg is given, leave the cache variable unset,
530 dnl so AC_PATH_PROGS will keep looking.
531 ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
536 if test -n "[$]$1"; then