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_GTK_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 USE_INCLUDED_LIBINTL=no
26 dnl If we use NLS figure out what method
27 if test "$USE_NLS" = "yes"; then
28 # AC_DEFINE(ENABLE_NLS)
29 # AC_MSG_CHECKING([whether included gettext is requested])
30 # AC_ARG_WITH(included-gettext,
31 # [ --with-included-gettext use the GNU gettext library included here],
32 # nls_cv_force_use_gnu_gettext=$withval,
33 # nls_cv_force_use_gnu_gettext=no)
34 # AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
35 nls_cv_force_use_gnu_gettext="no"
37 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
38 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
39 dnl User does not insist on using GNU NLS library. Figure out what
40 dnl to use. If gettext or catgets are available (in this order) we
41 dnl use this. Else we have to fall back to GNU NLS library.
42 dnl catgets is only used if permitted by option --with-catgets.
47 AC_CHECK_HEADER(libintl.h,
48 [AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc,
49 [AC_TRY_LINK([#include <libintl.h>], [return (int) dgettext ("","")],
50 gt_cv_func_dgettext_libc=yes, gt_cv_func_dgettext_libc=no)])
52 if test "$gt_cv_func_dgettext_libc" != "yes"; then
53 AC_CHECK_LIB(intl, bindtextdomain,
54 [AC_CACHE_CHECK([for dgettext in libintl],
55 gt_cv_func_dgettext_libintl,
56 [AC_CHECK_LIB(intl, dgettext,
57 gt_cv_func_dgettext_libintl=yes,
58 gt_cv_func_dgettext_libintl=no)],
59 gt_cv_func_dgettext_libintl=no)])
62 if test "$gt_cv_func_dgettext_libintl" = "yes"; then
66 if test "$gt_cv_func_dgettext_libc" = "yes" \
67 || test "$gt_cv_func_dgettext_libintl" = "yes"; then
68 AC_DEFINE(HAVE_GETTEXT)
69 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
70 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
71 if test "$MSGFMT" != "no"; then
72 AC_CHECK_FUNCS(dcgettext)
73 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
74 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
75 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
76 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
77 return _nl_msg_cat_cntr],
86 # Added by Martin Baulig 12/15/98 for libc5 systems
87 if test "$gt_cv_func_dgettext_libc" != "yes" \
88 && test "$gt_cv_func_dgettext_libintl" = "yes"; then
90 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
94 if test "$CATOBJEXT" = "NONE"; then
95 AC_MSG_CHECKING([whether catgets can be used])
97 [ --with-catgets use catgets functions if available],
98 nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
99 AC_MSG_RESULT($nls_cv_use_catgets)
101 if test "$nls_cv_use_catgets" = "yes"; then
102 dnl No gettext in C library. Try catgets next.
103 AC_CHECK_LIB(i, main)
104 AC_CHECK_FUNC(catgets,
105 [AC_DEFINE(HAVE_CATGETS)
106 INTLOBJS="\$(CATOBJS)"
107 AC_PATH_PROG(GENCAT, gencat, no)dnl
108 # if test "$GENCAT" != "no"; then
109 # AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
110 # if test "$GMSGFMT" = "no"; then
111 # AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
112 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
114 # AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
115 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
116 # USE_INCLUDED_LIBINTL=yes
120 # INTLDEPS='$(top_builddir)/intl/libintl.a'
122 # LIBS=`echo $LIBS | sed -e 's/-lintl//'`
123 # nls_cv_header_intl=intl/libintl.h
124 # nls_cv_header_libgt=intl/libgettext.h
130 if test "$CATOBJEXT" = "NONE"; then
131 dnl Neither gettext nor catgets in included in the C library.
132 dnl Fall back on GNU gettext library.
133 nls_cv_use_gnu_gettext=yes
137 if test "$nls_cv_use_gnu_gettext" != "yes"; then
138 AC_DEFINE(ENABLE_NLS)
140 # Unset this variable since we use the non-zero value as a flag.
142 # dnl Mark actions used to generate GNU NLS library.
143 # INTLOBJS="\$(GETTOBJS)"
144 # AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
145 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
146 # AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
147 # AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
148 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
150 # USE_INCLUDED_LIBINTL=yes
154 # INTLDEPS='$(top_builddir)/intl/libintl.a'
156 # LIBS=`echo $LIBS | sed -e 's/-lintl//'`
157 # nls_cv_header_intl=intl/libintl.h
158 # nls_cv_header_libgt=intl/libgettext.h
161 dnl Test whether we really found GNU xgettext.
162 if test "$XGETTEXT" != ":"; then
163 dnl If it is no GNU xgettext we define it as : so that the
164 dnl Makefiles still can work.
165 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
169 [found xgettext program is not GNU xgettext; ignore it])
174 # We need to process the po/ directory.
178 nls_cv_header_intl=intl/libintl.h
179 nls_cv_header_libgt=intl/libgettext.h
181 AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
183 [case "$CONFIG_FILES" in *po/Makefile.in*)
184 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
188 # # If this is used in GNU gettext we have to set USE_NLS to `yes'
189 # # because some of the sources are only built for this goal.
190 # if test "$PACKAGE" = gettext; then
192 # USE_INCLUDED_LIBINTL=yes
195 dnl These rules are solely for the distribution goal. While doing this
196 dnl we only have to keep exactly one list of the available catalogs
198 for lang in $ALL_LINGUAS; do
199 GMOFILES="$GMOFILES $lang.gmo"
200 POFILES="$POFILES $lang.po"
203 dnl Make all variables we use known to autoconf.
204 AC_SUBST(USE_INCLUDED_LIBINTL)
207 AC_SUBST(DATADIRNAME)
217 AC_DEFUN(AM_GTK_GNU_GETTEXT,
218 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
219 AC_REQUIRE([AC_PROG_CC])dnl
220 AC_REQUIRE([AC_PROG_RANLIB])dnl
221 AC_REQUIRE([AC_ISC_POSIX])dnl
222 AC_REQUIRE([AC_HEADER_STDC])dnl
223 AC_REQUIRE([AC_C_CONST])dnl
224 AC_REQUIRE([AC_C_INLINE])dnl
225 AC_REQUIRE([AC_TYPE_OFF_T])dnl
226 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
227 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
228 AC_REQUIRE([AC_FUNC_MMAP])dnl
230 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
231 unistd.h sys/param.h])
232 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
233 strdup __argz_count __argz_stringify __argz_next])
235 if test "${ac_cv_func_stpcpy+set}" != "set"; then
236 AC_CHECK_FUNCS(stpcpy)
238 if test "${ac_cv_func_stpcpy}" = "yes"; then
239 AC_DEFINE(HAVE_STPCPY)
245 if test "x$CATOBJEXT" != "x"; then
246 if test "x$ALL_LINGUAS" = "x"; then
249 AC_MSG_CHECKING(for catalogs to be installed)
251 for lang in ${LINGUAS=$ALL_LINGUAS}; do
252 case "$ALL_LINGUAS" in
253 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
257 AC_MSG_RESULT($LINGUAS)
260 dnl Construct list of names of catalog files to be constructed.
261 if test -n "$LINGUAS"; then
262 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
266 dnl The reference to <locale.h> in the installed <libintl.h> file
267 dnl must be resolved because we cannot expect the users of this
268 dnl to define HAVE_LOCALE_H.
269 if test $ac_cv_header_locale_h = yes; then
270 INCLUDE_LOCALE_H="#include <locale.h>"
273 /* The system does not provide the header <locale.h>. Take care yourself. */"
275 AC_SUBST(INCLUDE_LOCALE_H)
277 dnl Determine which catalog format we have (if any is needed)
278 dnl For now we know about two different formats:
279 dnl Linux libc-5 and the normal X/Open format
280 test -d intl || mkdir intl
281 if test "$CATOBJEXT" = ".cat"; then
282 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
284 dnl Transform the SED scripts while copying because some dumb SEDs
285 dnl cannot handle comments.
286 sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
288 dnl po2tbl.sed is always needed.
289 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
290 $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
292 dnl In the intl/Makefile.in we have a special dependency which makes
293 dnl only sense for gettext. We comment this out for non-gettext
295 if test "$PACKAGE" = "gettext"; then
305 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
306 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
307 dnl Try to locate is.
309 if test -n "$ac_aux_dir"; then
310 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
312 if test -z "$MKINSTALLDIRS"; then
313 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
315 AC_SUBST(MKINSTALLDIRS)
317 dnl *** For now the libtool support in intl/Makefile is not for real.
321 dnl Generate list of files to be processed by xgettext which will
322 dnl be included in po/Makefile.
323 test -d po || mkdir po
324 if test "x$srcdir" != "x."; then
325 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
326 posrcprefix="$srcdir/"
328 posrcprefix="../$srcdir/"
334 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
335 < $srcdir/po/POTFILES.in > po/POTFILES