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,
44 [AC_CACHE_CHECK([for gettext in libintl],
45 gt_cv_func_gettext_libintl,
46 [AC_TRY_LINK([], [return (int) gettext ("")],
47 gt_cv_func_gettext_libintl=yes,
48 gt_cv_func_gettext_libintl=no)])])
51 if test "$gt_cv_func_gettext_libc" = "yes" \
52 || test "$gt_cv_func_gettext_libintl" = "yes"; then
53 AC_DEFINE(HAVE_GETTEXT)
54 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
55 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
56 if test "$MSGFMT" != "no"; then
57 AC_CHECK_FUNCS(dcgettext)
58 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
59 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
60 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
61 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
62 return _nl_msg_cat_cntr],
72 if test "$CATOBJEXT" = "NONE"; then
73 AC_MSG_CHECKING([whether catgets can be used])
75 [ --with-catgets use catgets functions if available],
76 nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
77 AC_MSG_RESULT($nls_cv_use_catgets)
79 if test "$nls_cv_use_catgets" = "yes"; then
80 dnl No gettext in C library. Try catgets next.
82 AC_CHECK_FUNC(catgets,
83 [AC_DEFINE(HAVE_CATGETS)
84 INTLOBJS="\$(CATOBJS)"
85 AC_PATH_PROG(GENCAT, gencat, no)dnl
86 if test "$GENCAT" != "no"; then
87 AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
88 if test "$GMSGFMT" = "no"; then
89 AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
90 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
92 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
93 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
94 USE_INCLUDED_LIBINTL=yes
98 INTLDEPS="../intl/libintl.a"
100 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
101 nls_cv_header_intl=intl/libintl.h
102 nls_cv_header_libgt=intl/libgettext.h
107 if test "$CATOBJEXT" = "NONE"; then
108 dnl Neither gettext nor catgets in included in the C library.
109 dnl Fall back on GNU gettext library.
110 nls_cv_use_gnu_gettext=yes
114 if test "$nls_cv_use_gnu_gettext" = "yes"; then
115 dnl Mark actions used to generate GNU NLS library.
116 INTLOBJS="\$(GETTOBJS)"
117 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
118 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
119 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
120 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
121 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
123 USE_INCLUDED_LIBINTL=yes
127 INTLDEPS="../intl/libintl.a"
129 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
130 nls_cv_header_intl=intl/libintl.h
131 nls_cv_header_libgt=intl/libgettext.h
134 dnl Test whether we really found GNU xgettext.
135 if test "$XGETTEXT" != ":"; then
136 dnl If it is no GNU xgettext we define it as : so that the
137 dnl Makefiles still can work.
138 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
142 [found xgettext programs is not GNU xgettext; ignore it])
147 # We need to process the po/ directory.
151 nls_cv_header_intl=intl/libintl.h
152 nls_cv_header_libgt=intl/libgettext.h
155 # If this is used in GNU gettext we have to set USE_NLS to `yes'
156 # because some of the sources are only built for this goal.
157 if test "$PACKAGE" = gettext; then
159 USE_INCLUDED_LIBINTL=yes
162 dnl These rules are solely for the distribution goal. While doing this
163 dnl we only have to keep exactly one list of the available catalogs
165 for lang in $ALL_LINGUAS; do
166 GMOFILES="$GMOFILES $lang.gmo"
167 POFILES="$POFILES $lang.po"
170 dnl Make all variables we use known to autoconf.
171 AC_SUBST(USE_INCLUDED_LIBINTL)
174 AC_SUBST(DATADIRNAME)
184 AC_DEFUN(AM_GNU_GETTEXT,
185 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
186 AC_REQUIRE([AC_PROG_CC])dnl
187 AC_REQUIRE([AC_ISC_POSIX])dnl
188 AC_REQUIRE([AC_PROG_RANLIB])dnl
189 AC_REQUIRE([AC_HEADER_STDC])dnl
190 AC_REQUIRE([AC_C_CONST])dnl
191 AC_REQUIRE([AC_C_INLINE])dnl
192 AC_REQUIRE([AC_TYPE_OFF_T])dnl
193 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
194 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
195 AC_REQUIRE([AC_FUNC_MMAP])dnl
197 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
199 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
200 __argz_count __argz_stringify __argz_next])
202 if test "${ac_cv_func_stpcpy+set}" != "set"; then
203 AC_CHECK_FUNCS(stpcpy)
205 if test "${ac_cv_func_stpcpy}" = "yes"; then
206 AC_DEFINE(HAVE_STPCPY)
212 if test "x$CATOBJEXT" != "x"; then
213 if test "x$ALL_LINGUAS" = "x"; then
216 AC_MSG_CHECKING(for catalogs to be installed)
218 for lang in ${LINGUAS=$ALL_LINGUAS}; do
219 case "$ALL_LINGUAS" in
220 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
224 AC_MSG_RESULT($LINGUAS)
227 dnl Construct list of names of catalog files to be constructed.
228 if test -n "$LINGUAS"; then
229 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
233 dnl Determine which catalog format we have (if any is needed)
234 dnl For now we know about two different formats:
235 dnl Linux libc-5 and the normal X/Open format
236 test -d intl || mkdir intl
237 if test "$CATOBJEXT" = ".cat"; then
238 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
240 dnl Transform the SED scripts while copying because some dumb SEDs
241 dnl cannot handle comments.
242 sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
244 dnl po2tbl.sed is always needed.
245 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
246 $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
248 dnl In the intl/Makefile.in we have a special dependency which makes
249 dnl only sense for gettext. We comment this out for non-gettext
251 if test "$PACKAGE" = "gettext"; then
261 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
262 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
263 dnl Try to locate is.
265 if test $ac_aux_dir; then
266 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
268 if test -z $MKINSTALLDIRS; then
269 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
271 AC_SUBST(MKINSTALLDIRS)
273 dnl Generate list of files to be processed by xgettext which will
274 dnl be included in po/Makefile.
275 test -d po || mkdir po
276 if test "x$srcdir" != "x."; then
277 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
278 posrcprefix="$srcdir/"
280 posrcprefix="../$srcdir/"
285 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
286 < $srcdir/po/POTFILES.in > po/POTFILES