1 # Macro to add for using GNU gettext.
2 # Ulrich Drepper <drepper@cygnus.com>, 1995.
4 # Modified to never use included libintl.
5 # Owen Taylor <otaylor@redhat.com>, 12/15/1998
8 # This file can be copied and used freely without restrictions. It can
9 # be used in projects which are not available under the GNU Public License
10 # but which still want to provide support for the GNU gettext functionality.
11 # Please note that the actual code is *not* freely available.
14 # If you make changes to this file, you MUST update the copy in
15 # acinclude.m4. [ aclocal dies on duplicate macros, so if
16 # we run 'aclocal -I macros/' then we'll run into problems
17 # once we've installed glib-gettext.m4 :-( ]
22 AC_DEFUN(AM_GLIB_WITH_NLS,
23 [AC_MSG_CHECKING([whether NLS is requested])
24 dnl Default is enabled NLS
26 [ --disable-nls do not use Native Language Support],
27 USE_NLS=$enableval, USE_NLS=yes)
28 AC_MSG_RESULT($USE_NLS)
31 USE_INCLUDED_LIBINTL=no
33 dnl If we use NLS figure out what method
34 if test "$USE_NLS" = "yes"; then
35 nls_cv_force_use_gnu_gettext="no"
37 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
38 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
39 dnl User does not insist on using GNU NLS library. Figure out what
40 dnl to use. If gettext or catgets are available (in this order) we
41 dnl use this. Else we have to fall back to GNU NLS library.
42 dnl catgets is only used if permitted by option --with-catgets.
47 AC_CHECK_HEADER(libintl.h,
48 [AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc,
49 [AC_TRY_LINK([#include <libintl.h>], [return (int) dgettext ("","")],
50 gt_cv_func_dgettext_libc=yes, gt_cv_func_dgettext_libc=no)])
52 if test "$gt_cv_func_dgettext_libc" != "yes"; then
53 AC_CHECK_LIB(intl, bindtextdomain,
54 [AC_CACHE_CHECK([for dgettext in libintl],
55 gt_cv_func_dgettext_libintl,
56 [AC_CHECK_LIB(intl, dgettext,
57 gt_cv_func_dgettext_libintl=yes,
58 gt_cv_func_dgettext_libintl=no)],
59 gt_cv_func_dgettext_libintl=no)])
62 if test "$gt_cv_func_dgettext_libintl" = "yes"; then
66 if test "$gt_cv_func_dgettext_libc" = "yes" \
67 || test "$gt_cv_func_dgettext_libintl" = "yes"; then
68 AC_DEFINE(HAVE_GETTEXT)
69 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
70 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
71 if test "$MSGFMT" != "no"; then
72 AC_CHECK_FUNCS(dcgettext)
73 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
74 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
75 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
76 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
77 return _nl_msg_cat_cntr],
86 # Added by Martin Baulig 12/15/98 for libc5 systems
87 if test "$gt_cv_func_dgettext_libc" != "yes" \
88 && test "$gt_cv_func_dgettext_libintl" = "yes"; then
90 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
94 if test "$CATOBJEXT" = "NONE"; then
95 dnl Neither gettext nor catgets in included in the C library.
96 dnl Fall back on GNU gettext library.
97 nls_cv_use_gnu_gettext=yes
101 if test "$nls_cv_use_gnu_gettext" != "yes"; then
102 AC_DEFINE(ENABLE_NLS)
104 dnl Unset this variable since we use the non-zero value as a flag.
108 dnl Test whether we really found GNU xgettext.
109 if test "$XGETTEXT" != ":"; then
110 dnl If it is no GNU xgettext we define it as : so that the
111 dnl Makefiles still can work.
112 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
116 [found xgettext program is not GNU xgettext; ignore it])
121 # We need to process the po/ directory.
127 [case "$CONFIG_FILES" in *po/Makefile.in*)
128 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
131 dnl These rules are solely for the distribution goal. While doing this
132 dnl we only have to keep exactly one list of the available catalogs
134 for lang in $ALL_LINGUAS; do
135 GMOFILES="$GMOFILES $lang.gmo"
136 POFILES="$POFILES $lang.po"
139 dnl Make all variables we use known to autoconf.
140 AC_SUBST(USE_INCLUDED_LIBINTL)
143 AC_SUBST(DATADIRNAME)
153 AC_DEFUN(AM_GLIB_GNU_GETTEXT,
154 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
155 AC_REQUIRE([AC_PROG_CC])dnl
156 AC_REQUIRE([AC_PROG_RANLIB])dnl
157 AC_REQUIRE([AC_HEADER_STDC])dnl
158 AC_REQUIRE([AC_C_CONST])dnl
159 AC_REQUIRE([AC_C_INLINE])dnl
160 AC_REQUIRE([AC_TYPE_OFF_T])dnl
161 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
162 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
163 AC_REQUIRE([AC_FUNC_MMAP])dnl
165 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
166 unistd.h sys/param.h])
167 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
168 strdup __argz_count __argz_stringify __argz_next])
173 if test "x$CATOBJEXT" != "x"; then
174 if test "x$ALL_LINGUAS" = "x"; then
177 AC_MSG_CHECKING(for catalogs to be installed)
179 for lang in ${LINGUAS=$ALL_LINGUAS}; do
180 case "$ALL_LINGUAS" in
181 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
185 AC_MSG_RESULT($LINGUAS)
188 dnl Construct list of names of catalog files to be constructed.
189 if test -n "$LINGUAS"; then
190 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
194 dnl Determine which catalog format we have (if any is needed)
195 dnl For now we know about two different formats:
196 dnl Linux libc-5 and the normal X/Open format
197 test -d po || mkdir po
198 if test "$CATOBJEXT" = ".cat"; then
199 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
201 dnl Transform the SED scripts while copying because some dumb SEDs
202 dnl cannot handle comments.
203 sed -e '/^#/d' $srcdir/po/$msgformat-msg.sed > po/po2msg.sed
205 dnl po2tbl.sed is always needed.
206 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
207 $srcdir/po/po2tbl.sed.in > po/po2tbl.sed
209 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
210 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
211 dnl Try to locate is.
213 if test -n "$ac_aux_dir"; then
214 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
216 if test -z "$MKINSTALLDIRS"; then
217 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
219 AC_SUBST(MKINSTALLDIRS)
221 dnl Generate list of files to be processed by xgettext which will
222 dnl be included in po/Makefile.
223 test -d po || mkdir po
224 if test "x$srcdir" != "x."; then
225 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
226 posrcprefix="$srcdir/"
228 posrcprefix="../$srcdir/"
234 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
235 < $srcdir/po/POTFILES.in > po/POTFILES
238 dnl @synopsis AC_FUNC_VSNPRINTF_C99
240 dnl Check whether there is a vsnprintf() function with C99 semantics installed.
242 AC_DEFUN([AC_FUNC_VSNPRINTF_C99],
243 [AC_CACHE_CHECK(for C99 vsnprintf,
244 ac_cv_func_vsnprintf_c99,
257 r = vsnprintf(buffer, 5, s, args);
271 }], ac_cv_func_vsnprintf_c99=yes, ac_cv_func_vsnprintf_c99=no, ac_cv_func_vsnprintf_c99=no)])
272 dnl Note that the default is to be pessimistic in the case of cross compilation.
273 dnl If you know that the target has a C99 vsnprintf(), you can get around this
274 dnl by setting ac_func_vsnprintf_c99 to yes, as described in the Autoconf manual.
275 if test $ac_cv_func_vsnprintf_c99 = yes; then
276 AC_DEFINE(HAVE_C99_VSNPRINTF, 1,
277 [Define if you have a version of the vsnprintf function
278 with semantics as specified by the ISO C99 standard.])
280 ])# AC_FUNC_VSNPRINTF_C99