1 # Macro to add for using GNU gettext.
2 # Ulrich Drepper <drepper@cygnus.com>, 1995.
7 [AC_MSG_CHECKING([whether NLS is requested])
8 dnl Default is enabled NLS
10 [ --disable-nls do not use Native Language Support],
11 USE_NLS=$enableval, USE_NLS=yes)
12 AC_MSG_RESULT($USE_NLS)
15 USE_INCLUDED_LIBINTL=no
17 dnl If we use NLS figure out what method
18 if test "$USE_NLS" = "yes"; then
20 AC_MSG_CHECKING([whether included gettext is requested])
21 AC_ARG_WITH(included-gettext,
22 [ --with-included-gettext use the GNU gettext library included here],
23 nls_cv_force_use_gnu_gettext=$withval,
24 nls_cv_force_use_gnu_gettext=no)
25 AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
27 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
28 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
29 dnl User does not insist on using GNU NLS library. Figure out what
30 dnl to use. If gettext or catgets are available (in this order) we
31 dnl use this. Else we have to fall back to GNU NLS library.
32 dnl catgets is only used if permitted by option --with-catgets.
37 AC_CHECK_HEADER(libintl.h,
38 [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
39 [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
40 gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
42 if test "$gt_cv_func_gettext_libc" != "yes"; then
43 AC_CHECK_LIB(intl, bindtextdomain,
45 AC_CACHE_CHECK([for gettext in libintl],
46 gt_cv_func_gettext_libintl,
47 [AC_TRY_LINK([], [return (int) gettext ("")],
48 gt_cv_func_gettext_libintl=yes,
49 gt_cv_func_gettext_libintl=no)])])
52 if test "$gt_cv_func_gettext_libc" = "yes" \
53 || test "$gt_cv_func_gettext_libintl" = "yes"; then
54 AC_DEFINE(HAVE_GETTEXT)
55 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
56 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
57 if test "$MSGFMT" != "no"; then
58 AC_CHECK_FUNCS(dcgettext)
59 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
60 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
61 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
62 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
63 return _nl_msg_cat_cntr],
73 if test "$CATOBJEXT" = "NONE"; then
74 AC_MSG_CHECKING([whether catgets can be used])
76 [ --with-catgets use catgets functions if available],
77 nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
78 AC_MSG_RESULT($nls_cv_use_catgets)
80 if test "$nls_cv_use_catgets" = "yes"; then
81 dnl No gettext in C library. Try catgets next.
83 AC_CHECK_FUNC(catgets,
84 [AC_DEFINE(HAVE_CATGETS)
85 INTLOBJS="\$(CATOBJS)"
86 AC_PATH_PROG(GENCAT, gencat, no)dnl
87 if test "$GENCAT" != "no"; then
88 AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
89 if test "$GMSGFMT" = "no"; then
90 AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
91 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
93 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
94 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
95 USE_INCLUDED_LIBINTL=yes
99 INTLDEPS='$(top_builddir)/intl/libintl.a'
101 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
102 nls_cv_header_intl=intl/libintl.h
103 nls_cv_header_libgt=intl/libgettext.h
108 if test "$CATOBJEXT" = "NONE"; then
109 dnl Neither gettext nor catgets in included in the C library.
110 dnl Fall back on GNU gettext library.
111 nls_cv_use_gnu_gettext=yes
115 if test "$nls_cv_use_gnu_gettext" = "yes"; then
116 dnl Mark actions used to generate GNU NLS library.
117 INTLOBJS="\$(GETTOBJS)"
118 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
119 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
120 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
121 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
122 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
124 USE_INCLUDED_LIBINTL=yes
128 INTLDEPS='$(top_builddir)/intl/libintl.a'
130 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
131 nls_cv_header_intl=intl/libintl.h
132 nls_cv_header_libgt=intl/libgettext.h
135 dnl Test whether we really found GNU xgettext.
136 if test "$XGETTEXT" != ":"; then
137 dnl If it is no GNU xgettext we define it as : so that the
138 dnl Makefiles still can work.
139 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
143 [found xgettext programs is not GNU xgettext; ignore it])
148 # We need to process the po/ directory.
152 nls_cv_header_intl=intl/libintl.h
153 nls_cv_header_libgt=intl/libgettext.h
156 # If this is used in GNU gettext we have to set USE_NLS to `yes'
157 # because some of the sources are only built for this goal.
158 if test "$PACKAGE" = gettext; then
160 USE_INCLUDED_LIBINTL=yes
163 dnl These rules are solely for the distribution goal. While doing this
164 dnl we only have to keep exactly one list of the available catalogs
166 for lang in $ALL_LINGUAS; do
167 GMOFILES="$GMOFILES $lang.gmo"
168 POFILES="$POFILES $lang.po"
171 dnl Make all variables we use known to autoconf.
172 AC_SUBST(USE_INCLUDED_LIBINTL)
175 AC_SUBST(DATADIRNAME)
185 AC_DEFUN(AM_GNU_GETTEXT,
186 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
187 AC_REQUIRE([AC_PROG_CC])dnl
188 AC_REQUIRE([AC_PROG_RANLIB])dnl
189 AC_REQUIRE([AC_ISC_POSIX])dnl
190 AC_REQUIRE([AC_HEADER_STDC])dnl
191 AC_REQUIRE([AC_C_CONST])dnl
192 AC_REQUIRE([AC_C_INLINE])dnl
193 AC_REQUIRE([AC_TYPE_OFF_T])dnl
194 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
195 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
196 AC_REQUIRE([AC_FUNC_MMAP])dnl
198 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
199 unistd.h values.h sys/param.h])
200 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
201 __argz_count __argz_stringify __argz_next])
203 if test "${ac_cv_func_stpcpy+set}" != "set"; then
204 AC_CHECK_FUNCS(stpcpy)
206 if test "${ac_cv_func_stpcpy}" = "yes"; then
207 AC_DEFINE(HAVE_STPCPY)
213 if test "x$CATOBJEXT" != "x"; then
214 if test "x$ALL_LINGUAS" = "x"; then
217 AC_MSG_CHECKING(for catalogs to be installed)
219 for lang in ${LINGUAS=$ALL_LINGUAS}; do
220 case "$ALL_LINGUAS" in
221 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
225 AC_MSG_RESULT($LINGUAS)
228 dnl Construct list of names of catalog files to be constructed.
229 if test -n "$LINGUAS"; then
230 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
234 dnl Determine which catalog format we have (if any is needed)
235 dnl For now we know about two different formats:
236 dnl Linux libc-5 and the normal X/Open format
237 test -d intl || mkdir intl
238 if test "$CATOBJEXT" = ".cat"; then
239 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
241 dnl Transform the SED scripts while copying because some dumb SEDs
242 dnl cannot handle comments.
243 sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
245 dnl po2tbl.sed is always needed.
246 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
247 $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
249 dnl In the intl/Makefile.in we have a special dependency which makes
250 dnl only sense for gettext. We comment this out for non-gettext
252 if test "$PACKAGE" = "gettext"; then
262 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
263 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
264 dnl Try to locate is.
266 if test -n "$ac_aux_dir"; then
267 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
269 if test -z "$MKINSTALLDIRS"; then
270 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
272 AC_SUBST(MKINSTALLDIRS)
274 dnl *** For now the libtool support in intl/Makefile is not for real.
278 dnl Generate list of files to be processed by xgettext which will
279 dnl be included in po/Makefile.
280 test -d po || mkdir po
281 if test "x$srcdir" != "x."; then
282 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
283 posrcprefix="$srcdir/"
285 posrcprefix="../$srcdir/"
291 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
292 < $srcdir/po/POTFILES.in > po/POTFILES