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,1,
62 [Define if the GNU gettext() function is already present or preinstalled.])
63 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
64 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
65 if test "$MSGFMT" != "no"; then
66 AC_CHECK_FUNCS(dcgettext)
67 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
68 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
69 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
70 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
71 return _nl_msg_cat_cntr],
80 # Added by Martin Baulig 12/15/98 for libc5 systems
81 if test "$gt_cv_func_dgettext_libc" != "yes" \
82 && test "$gt_cv_func_dgettext_libintl" = "yes"; then
84 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
88 if test "$CATOBJEXT" = "NONE"; then
89 dnl Neither gettext nor catgets in included in the C library.
90 dnl Fall back on GNU gettext library.
91 nls_cv_use_gnu_gettext=yes
95 if test "$nls_cv_use_gnu_gettext" != "yes"; then
96 AC_DEFINE(ENABLE_NLS, 1,
97 [always defined to indicate that i18n is enabled])
99 dnl Unset this variable since we use the non-zero value as a flag.
103 dnl Test whether we really found GNU xgettext.
104 if test "$XGETTEXT" != ":"; then
105 dnl If it is no GNU xgettext we define it as : so that the
106 dnl Makefiles still can work.
107 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
111 [found xgettext program is not GNU xgettext; ignore it])
116 # We need to process the po/ directory.
120 [case "$CONFIG_FILES" in *po/Makefile.in*)
121 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
124 dnl These rules are solely for the distribution goal. While doing this
125 dnl we only have to keep exactly one list of the available catalogs
127 for lang in $ALL_LINGUAS; do
128 GMOFILES="$GMOFILES $lang.gmo"
129 POFILES="$POFILES $lang.po"
132 dnl Make all variables we use known to autoconf.
135 AC_SUBST(DATADIRNAME)
145 AC_DEFUN(AM_GLIB_GNU_GETTEXT,
146 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
147 AC_REQUIRE([AC_PROG_CC])dnl
148 AC_REQUIRE([AC_PROG_RANLIB])dnl
149 AC_REQUIRE([AC_HEADER_STDC])dnl
150 AC_REQUIRE([AC_C_CONST])dnl
151 AC_REQUIRE([AC_C_INLINE])dnl
152 AC_REQUIRE([AC_TYPE_OFF_T])dnl
153 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
154 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
155 AC_REQUIRE([AC_FUNC_MMAP])dnl
157 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
158 unistd.h sys/param.h])
159 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
160 strdup __argz_count __argz_stringify __argz_next])
165 if test "x$CATOBJEXT" != "x"; then
166 if test "x$ALL_LINGUAS" = "x"; then
169 AC_MSG_CHECKING(for catalogs to be installed)
171 for lang in ${LINGUAS=$ALL_LINGUAS}; do
172 case "$ALL_LINGUAS" in
173 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
177 AC_MSG_RESULT($LINGUAS)
180 dnl Construct list of names of catalog files to be constructed.
181 if test -n "$LINGUAS"; then
182 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
186 dnl Determine which catalog format we have (if any is needed)
187 dnl For now we know about two different formats:
188 dnl Linux libc-5 and the normal X/Open format
189 test -d po || mkdir po
190 if test "$CATOBJEXT" = ".cat"; then
191 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
193 dnl Transform the SED scripts while copying because some dumb SEDs
194 dnl cannot handle comments.
195 sed -e '/^#/d' $srcdir/po/$msgformat-msg.sed > po/po2msg.sed
198 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
199 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
200 dnl Try to locate is.
202 if test -n "$ac_aux_dir"; then
203 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
205 if test -z "$MKINSTALLDIRS"; then
206 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
208 AC_SUBST(MKINSTALLDIRS)
210 dnl Generate list of files to be processed by xgettext which will
211 dnl be included in po/Makefile.
212 test -d po || mkdir po
213 if test "x$srcdir" != "x."; then
214 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
215 posrcprefix="$srcdir/"
217 posrcprefix="../$srcdir/"
223 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
224 < $srcdir/po/POTFILES.in > po/POTFILES