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,
27 dnl Figure out what method
28 nls_cv_force_use_gnu_gettext="no"
30 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
31 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
32 dnl User does not insist on using GNU NLS library. Figure out what
33 dnl to use. If gettext or catgets are available (in this order) we
34 dnl use this. Else we have to fall back to GNU NLS library.
35 dnl catgets is only used if permitted by option --with-catgets.
40 AC_CHECK_HEADER(libintl.h,
41 [AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc,
42 [AC_TRY_LINK([#include <libintl.h>], [return (int) dgettext ("","")],
43 gt_cv_func_dgettext_libc=yes, gt_cv_func_dgettext_libc=no)])
45 if test "$gt_cv_func_dgettext_libc" != "yes"; then
46 AC_CHECK_LIB(intl, bindtextdomain,
47 [AC_CACHE_CHECK([for dgettext in libintl],
48 gt_cv_func_dgettext_libintl,
49 [AC_CHECK_LIB(intl, dgettext,
50 gt_cv_func_dgettext_libintl=yes,
51 gt_cv_func_dgettext_libintl=no)],
52 gt_cv_func_dgettext_libintl=no)])
55 if test "$gt_cv_func_dgettext_libintl" = "yes"; then
59 if test "$gt_cv_func_dgettext_libc" = "yes" \
60 || test "$gt_cv_func_dgettext_libintl" = "yes"; then
61 AC_DEFINE(HAVE_GETTEXT)
62 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
63 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
64 if test "$MSGFMT" != "no"; then
65 AC_CHECK_FUNCS(dcgettext)
66 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
67 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
68 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
69 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
70 return _nl_msg_cat_cntr],
79 # Added by Martin Baulig 12/15/98 for libc5 systems
80 if test "$gt_cv_func_dgettext_libc" != "yes" \
81 && test "$gt_cv_func_dgettext_libintl" = "yes"; then
83 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
87 if test "$CATOBJEXT" = "NONE"; then
88 dnl Neither gettext nor catgets in included in the C library.
89 dnl Fall back on GNU gettext library.
90 nls_cv_use_gnu_gettext=yes
94 if test "$nls_cv_use_gnu_gettext" != "yes"; then
97 dnl Unset this variable since we use the non-zero value as a flag.
101 dnl Test whether we really found GNU xgettext.
102 if test "$XGETTEXT" != ":"; then
103 dnl If it is no GNU xgettext we define it as : so that the
104 dnl Makefiles still can work.
105 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
109 [found xgettext program is not GNU xgettext; ignore it])
114 # We need to process the po/ directory.
118 [case "$CONFIG_FILES" in *po/Makefile.in*)
119 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
122 dnl These rules are solely for the distribution goal. While doing this
123 dnl we only have to keep exactly one list of the available catalogs
125 for lang in $ALL_LINGUAS; do
126 GMOFILES="$GMOFILES $lang.gmo"
127 POFILES="$POFILES $lang.po"
130 dnl Make all variables we use known to autoconf.
133 AC_SUBST(DATADIRNAME)
143 AC_DEFUN(AM_GLIB_GNU_GETTEXT,
144 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
145 AC_REQUIRE([AC_PROG_CC])dnl
146 AC_REQUIRE([AC_PROG_RANLIB])dnl
147 AC_REQUIRE([AC_HEADER_STDC])dnl
148 AC_REQUIRE([AC_C_CONST])dnl
149 AC_REQUIRE([AC_C_INLINE])dnl
150 AC_REQUIRE([AC_TYPE_OFF_T])dnl
151 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
152 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
153 AC_REQUIRE([AC_FUNC_MMAP])dnl
155 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
156 unistd.h sys/param.h])
157 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
158 strdup __argz_count __argz_stringify __argz_next])
163 if test "x$CATOBJEXT" != "x"; then
164 if test "x$ALL_LINGUAS" = "x"; then
167 AC_MSG_CHECKING(for catalogs to be installed)
169 for lang in ${LINGUAS=$ALL_LINGUAS}; do
170 case "$ALL_LINGUAS" in
171 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
175 AC_MSG_RESULT($LINGUAS)
178 dnl Construct list of names of catalog files to be constructed.
179 if test -n "$LINGUAS"; then
180 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
184 dnl Determine which catalog format we have (if any is needed)
185 dnl For now we know about two different formats:
186 dnl Linux libc-5 and the normal X/Open format
187 test -d po || mkdir po
188 if test "$CATOBJEXT" = ".cat"; then
189 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
191 dnl Transform the SED scripts while copying because some dumb SEDs
192 dnl cannot handle comments.
193 sed -e '/^#/d' $srcdir/po/$msgformat-msg.sed > po/po2msg.sed
195 dnl po2tbl.sed is always needed.
196 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
197 $srcdir/po/po2tbl.sed.in > po/po2tbl.sed
199 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
200 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
201 dnl Try to locate is.
203 if test -n "$ac_aux_dir"; then
204 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
206 if test -z "$MKINSTALLDIRS"; then
207 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
209 AC_SUBST(MKINSTALLDIRS)
211 dnl Generate list of files to be processed by xgettext which will
212 dnl be included in po/Makefile.
213 test -d po || mkdir po
214 if test "x$srcdir" != "x."; then
215 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
216 posrcprefix="$srcdir/"
218 posrcprefix="../$srcdir/"
224 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
225 < $srcdir/po/POTFILES.in > po/POTFILES
229 dnl @synopsis AC_FUNC_VSNPRINTF_C99
231 dnl Check whether there is a vsnprintf() function with C99 semantics installed.
233 AC_DEFUN([AC_FUNC_VSNPRINTF_C99],
234 [AC_CACHE_CHECK(for C99 vsnprintf,
235 ac_cv_func_vsnprintf_c99,
248 r = vsnprintf(buffer, 5, s, args);
262 }], ac_cv_func_vsnprintf_c99=yes, ac_cv_func_vsnprintf_c99=no, ac_cv_func_vsnprintf_c99=no)])
263 dnl Note that the default is to be pessimistic in the case of cross compilation.
264 dnl If you know that the target has a C99 vsnprintf(), you can get around this
265 dnl by setting ac_func_vsnprintf_c99 to yes, as described in the Autoconf manual.
266 if test $ac_cv_func_vsnprintf_c99 = yes; then
267 AC_DEFINE(HAVE_C99_VSNPRINTF, 1,
268 [Define if you have a version of the vsnprintf function
269 with semantics as specified by the ISO C99 standard.])
271 ])# AC_FUNC_VSNPRINTF_C99