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
196 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
197 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
198 dnl Try to locate is.
200 if test -n "$ac_aux_dir"; then
201 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
203 if test -z "$MKINSTALLDIRS"; then
204 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
206 AC_SUBST(MKINSTALLDIRS)
208 dnl Generate list of files to be processed by xgettext which will
209 dnl be included in po/Makefile.
210 test -d po || mkdir po
211 if test "x$srcdir" != "x."; then
212 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
213 posrcprefix="$srcdir/"
215 posrcprefix="../$srcdir/"
221 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
222 < $srcdir/po/POTFILES.in > po/POTFILES