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.
15 AC_DEFUN([AM_GNOME_WITH_NLS],
16 [AC_MSG_CHECKING([whether NLS is requested])
17 dnl Default is enabled NLS
19 [ --disable-nls do not use Native Language Support],
20 USE_NLS=$enableval, USE_NLS=yes)
21 AC_MSG_RESULT($USE_NLS)
24 BUILD_INCLUDED_LIBINTL=no
25 USE_INCLUDED_LIBINTL=no
27 dnl If we use NLS figure out what method
28 if test "$USE_NLS" = "yes"; then
29 # AC_DEFINE(ENABLE_NLS)
30 # AC_MSG_CHECKING([whether included gettext is requested])
31 # AC_ARG_WITH(included-gettext,
32 # [ --with-included-gettext use the GNU gettext library included here],
33 # nls_cv_force_use_gnu_gettext=$withval,
34 # nls_cv_force_use_gnu_gettext=no)
35 # AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
36 nls_cv_force_use_gnu_gettext="no"
38 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
39 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
40 dnl User does not insist on using GNU NLS library. Figure out what
41 dnl to use. If gettext or catgets are available (in this order) we
42 dnl use this. Else we have to fall back to GNU NLS library.
43 dnl catgets is only used if permitted by option --with-catgets.
48 AC_CHECK_HEADER(libintl.h,
49 [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
50 [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
51 gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
53 if test "$gt_cv_func_gettext_libc" != "yes"; then
54 AC_CHECK_LIB(intl, bindtextdomain,
55 [AC_CACHE_CHECK([for gettext in libintl],
56 gt_cv_func_gettext_libintl,
57 [AC_CHECK_LIB(intl, gettext,
58 gt_cv_func_gettext_libintl=yes,
59 gt_cv_func_gettext_libintl=no)],
60 gt_cv_func_gettext_libintl=no)])
63 if test "$gt_cv_func_gettext_libc" = "yes" \
64 || test "$gt_cv_func_gettext_libintl" = "yes"; then
65 AC_DEFINE(HAVE_GETTEXT)
66 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
67 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
68 if test "$MSGFMT" != "no"; then
69 AC_CHECK_FUNCS(dcgettext)
70 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
71 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
72 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
73 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
74 return _nl_msg_cat_cntr],
83 # Added by Martin Baulig 12/15/98 for libc5 systems
84 if test "$gt_cv_func_gettext_libc" != "yes" \
85 && test "$gt_cv_func_gettext_libintl" = "yes"; then
87 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
91 if test "$CATOBJEXT" = "NONE"; then
92 AC_MSG_CHECKING([whether catgets can be used])
94 [ --with-catgets use catgets functions if available],
95 nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
96 AC_MSG_RESULT($nls_cv_use_catgets)
98 if test "$nls_cv_use_catgets" = "yes"; then
99 dnl No gettext in C library. Try catgets next.
100 AC_CHECK_LIB(i, main)
101 AC_CHECK_FUNC(catgets,
102 [AC_DEFINE(HAVE_CATGETS)
103 INTLOBJS="\$(CATOBJS)"
104 AC_PATH_PROG(GENCAT, gencat, no)dnl
105 # if test "$GENCAT" != "no"; then
106 # AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
107 # if test "$GMSGFMT" = "no"; then
108 # AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
109 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
111 # AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
112 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
113 # USE_INCLUDED_LIBINTL=yes
117 # INTLDEPS='$(top_builddir)/intl/libintl.a'
119 # LIBS=`echo $LIBS | sed -e 's/-lintl//'`
120 # nls_cv_header_intl=intl/libintl.h
121 # nls_cv_header_libgt=intl/libgettext.h
127 if test "$CATOBJEXT" = "NONE"; then
128 dnl Neither gettext nor catgets in included in the C library.
129 dnl Fall back on GNU gettext library.
130 nls_cv_use_gnu_gettext=yes
134 if test "$nls_cv_use_gnu_gettext" != "yes"; then
135 AC_DEFINE(ENABLE_NLS)
137 # Unset this variable since we use the non-zero value as a flag.
139 # dnl Mark actions used to generate GNU NLS library.
140 # INTLOBJS="\$(GETTOBJS)"
141 # AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
142 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
143 # AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
144 # AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
145 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
147 # USE_INCLUDED_LIBINTL=yes
151 # INTLDEPS='$(top_builddir)/intl/libintl.a'
153 # LIBS=`echo $LIBS | sed -e 's/-lintl//'`
154 # nls_cv_header_intl=intl/libintl.h
155 # nls_cv_header_libgt=intl/libgettext.h
158 dnl Test whether we really found GNU xgettext.
159 if test "$XGETTEXT" != ":"; then
160 dnl If it is no GNU xgettext we define it as : so that the
161 dnl Makefiles still can work.
162 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
166 [found xgettext program is not GNU xgettext; ignore it])
171 # We need to process the po/ directory.
175 nls_cv_header_intl=intl/libintl.h
176 nls_cv_header_libgt=intl/libgettext.h
178 AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
180 [case "$CONFIG_FILES" in *po/Makefile.in*)
181 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
185 # # If this is used in GNU gettext we have to set USE_NLS to `yes'
186 # # because some of the sources are only built for this goal.
187 # if test "$PACKAGE" = gettext; then
189 # USE_INCLUDED_LIBINTL=yes
192 dnl These rules are solely for the distribution goal. While doing this
193 dnl we only have to keep exactly one list of the available catalogs
195 for lang in $ALL_LINGUAS; do
196 GMOFILES="$GMOFILES $lang.gmo"
197 POFILES="$POFILES $lang.po"
200 dnl Make all variables we use known to autoconf.
201 AC_SUBST(BUILD_INCLUDED_LIBINTL)
202 AC_SUBST(USE_INCLUDED_LIBINTL)
205 AC_SUBST(DATADIRNAME)
215 AC_DEFUN([AM_GNOME_GETTEXT],
216 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
217 AC_REQUIRE([AC_PROG_CC])dnl
218 AC_REQUIRE([AC_PROG_RANLIB])dnl
219 AC_REQUIRE([AC_ISC_POSIX])dnl
220 AC_REQUIRE([AC_HEADER_STDC])dnl
221 AC_REQUIRE([AC_C_CONST])dnl
222 AC_REQUIRE([AC_C_INLINE])dnl
223 AC_REQUIRE([AC_TYPE_OFF_T])dnl
224 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
225 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
226 AC_REQUIRE([AC_FUNC_MMAP])dnl
228 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
229 unistd.h sys/param.h])
230 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
231 strdup __argz_count __argz_stringify __argz_next])
233 if test "${ac_cv_func_stpcpy+set}" != "set"; then
234 AC_CHECK_FUNCS(stpcpy)
236 if test "${ac_cv_func_stpcpy}" = "yes"; then
237 AC_DEFINE(HAVE_STPCPY)
243 if test "x$CATOBJEXT" != "x"; then
244 if test "x$ALL_LINGUAS" = "x"; then
247 AC_MSG_CHECKING(for catalogs to be installed)
249 if test "x$LINGUAS" = "x"; then
252 for lang in $LINGUAS; do
253 case "$ALL_LINGUAS" in
254 *\ $lang\ *|$lang\ *|*\ $lang) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
258 AC_MSG_RESULT($LINGUAS)
261 dnl Construct list of names of catalog files to be constructed.
262 if test -n "$LINGUAS"; then
263 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
267 dnl The reference to <locale.h> in the installed <libintl.h> file
268 dnl must be resolved because we cannot expect the users of this
269 dnl to define HAVE_LOCALE_H.
270 if test $ac_cv_header_locale_h = yes; then
271 INCLUDE_LOCALE_H="#include <locale.h>"
274 /* The system does not provide the header <locale.h>. Take care yourself. */"
276 AC_SUBST(INCLUDE_LOCALE_H)
278 dnl Determine which catalog format we have (if any is needed)
279 dnl For now we know about two different formats:
280 dnl Linux libc-5 and the normal X/Open format
281 test -d intl || mkdir intl
282 if test "$CATOBJEXT" = ".cat"; then
283 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
285 dnl Transform the SED scripts while copying because some dumb SEDs
286 dnl cannot handle comments.
287 sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
289 dnl po2tbl.sed is always needed.
290 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
291 $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
293 dnl In the intl/Makefile.in we have a special dependency which makes
294 dnl only sense for gettext. We comment this out for non-gettext
296 if test "$PACKAGE" = "gettext"; then
306 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
307 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
308 dnl Try to locate is.
310 if test -n "$ac_aux_dir"; then
311 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
313 if test -z "$MKINSTALLDIRS"; then
314 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
316 AC_SUBST(MKINSTALLDIRS)
318 dnl *** For now the libtool support in intl/Makefile is not for real.
322 dnl Generate list of files to be processed by xgettext which will
323 dnl be included in po/Makefile.
324 test -d po || mkdir po
325 if test "x$srcdir" != "x."; then
326 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
327 posrcprefix="$srcdir/"
329 posrcprefix="../$srcdir/"
335 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
336 < $srcdir/po/POTFILES.in > po/POTFILES