1 # Macro to add for using GNU gettext.
2 # Ulrich Drepper <drepper@cygnus.com>, 1995.
4 # This file can be copied and used freely without restrictions. It can
5 # be used in projects which are not available under the GNU General Public
6 # License but which still want to provide support for the GNU gettext
8 # Please note that the actual code of GNU gettext is covered by the GNU
9 # General Public License and is *not* in the public domain.
13 dnl Note that we always use own gettext implementation, even if we found
14 dnl working system one. We have some own modifications in our implementation
15 dnl and we rely on them.
17 dnl Usage: AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR]).
18 dnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library
19 dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static,
20 dnl depending on --{enable,disable}-{shared,static} and on the presence of
21 dnl AM-DISABLE-SHARED). Otherwise, a static library
22 dnl $(top_builddir)/intl/libintl.a will be created.
23 dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
24 dnl implementations (in libc or libintl) without the ngettext() function
26 dnl LIBDIR is used to find the intl libraries. If empty,
27 dnl the value `$(top_builddir)/intl/' is used.
29 dnl The result of the configuration is one of three cases:
30 dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
32 dnl Catalog format: GNU --> install in $(datadir)
33 dnl Catalog extension: .mo after installation, .gmo in source tree
34 dnl 2) GNU gettext has been found in the system's C library.
35 dnl Catalog format: GNU --> install in $(datadir)
36 dnl Catalog extension: .mo after installation, .gmo in source tree
37 dnl 3) No internationalization, always use English msgid.
38 dnl Catalog format: none
39 dnl Catalog extension: none
40 dnl The use of .gmo is historical (it was needed to avoid overwriting the
41 dnl GNU format catalogs when building on a platform with an X/Open gettext),
42 dnl but we keep it in order not to force irrelevant filename changes on the
45 AC_DEFUN([AM_WITH_NLS],
46 [AC_MSG_CHECKING([whether NLS is requested])
47 dnl Default is enabled NLS
49 EL_ARG_ENABLE(CONFIG_NLS, nls, [Native Language Support],
50 [ --disable-nls do not use Native Language Support])
52 AC_MSG_RESULT($CONFIG_NLS)
55 AM_CONDITIONAL(CONFIG_NLS, test "$CONFIG_NLS" = "yes")
57 dnl If we use NLS figure out what method
58 if test "$CONFIG_NLS" = "yes"; then
59 AC_DEFINE(CONFIG_NLS, 1,
60 [Define to 1 if translation of program messages to the user's native language
62 dnl AC_MSG_CHECKING([whether included gettext is requested])
63 dnl AC_ARG_WITH(included-gettext,
64 dnl [ --with-included-gettext use the GNU gettext library included here],
65 dnl nls_cv_force_use_gnu_gettext=$withval,
66 dnl nls_cv_force_use_gnu_gettext=no)
67 dnl AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
69 nls_cv_force_use_gnu_gettext=yes
70 nls_cv_use_gnu_gettext=yes
72 dnl Mark actions used to generate GNU NLS library.
73 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
74 [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
75 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
76 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
77 [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
79 LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
80 LIBS="$LIBS $LIBICONV"
82 dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
83 dnl Test whether we really found GNU msgfmt.
84 if test "$GMSGFMT" != ":"; then
85 dnl If it is no GNU msgfmt we define it as : so that the
86 dnl Makefiles still can work.
87 if $GMSGFMT --statistics /dev/null >/dev/null 2>&1; then
91 [found msgfmt program is not GNU msgfmt; ignore it])
96 dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
97 dnl Test whether we really found GNU xgettext.
98 if test "$XGETTEXT" != ":"; then
99 dnl If it is no GNU xgettext we define it as : so that the
100 dnl Makefiles still can work.
101 if $XGETTEXT --omit-header /dev/null >/dev/null 2>&1; then
105 [found xgettext program is not GNU xgettext; ignore it])
112 dnl intl/plural.c is generated from intl/plural.y. It requires bison,
113 dnl because plural.y uses bison specific features. It requires at least
114 dnl bison-1.26 because earlier versions generate a plural.c that doesn't
116 dnl bison is only needed for the maintainer (who touches plural.y). But in
117 dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
118 dnl the rule in general Makefile. Now, some people carelessly touch the
119 dnl files or have a broken "make" program, hence the plural.c rule will
120 dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
121 dnl present or too old.
122 AC_CHECK_PROGS([INTLBISON], [bison])
123 if test -z "$INTLBISON"; then
126 dnl Found it, now check the version.
127 AC_MSG_CHECKING([version of bison])
128 changequote(<<,>>)dnl
129 ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
130 case $ac_prog_version in
131 '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
132 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
134 ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
135 *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
137 AC_MSG_RESULT([$ac_prog_version])
139 if test $ac_verc_fail = yes; then
143 dnl These rules are solely for the distribution goal. While doing this
144 dnl we only have to keep exactly one list of the available catalogs
146 for lang in $ALL_LINGUAS; do
147 GMOFILES="$GMOFILES $lang.gmo"
150 dnl Make all variables we use known to autoconf.
154 dnl For backward compatibility. Some configure.ins may be using this.
159 dnl Usage: Just like AM_WITH_NLS, which see.
160 AC_DEFUN([AM_GNU_GETTEXT],
161 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
162 AC_REQUIRE([AC_PROG_CC])dnl
163 AC_REQUIRE([AC_CANONICAL_HOST])dnl
164 AC_REQUIRE([AC_PROG_RANLIB])dnl
165 AC_REQUIRE([AC_ISC_POSIX])dnl
166 AC_REQUIRE([AC_HEADER_STDC])dnl
167 AC_REQUIRE([AC_C_CONST])dnl
168 AC_REQUIRE([AC_C_INLINE])dnl
169 AC_REQUIRE([AC_TYPE_OFF_T])dnl
170 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
171 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
172 AC_REQUIRE([AC_FUNC_MMAP])dnl
173 AC_REQUIRE([jm_GLIBC21])dnl
175 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
176 stdlib.h string.h unistd.h sys/param.h])
177 AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
178 getgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
179 strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
184 AM_WITH_NLS([$1],[$2],[$3])
186 if test "x$ALL_LINGUAS" = "x"; then
189 AC_MSG_CHECKING(for catalogs to be installed)
191 for presentlang in $ALL_LINGUAS; do
193 for desiredlang in ${LINGUAS-$ALL_LINGUAS}; do
194 # Use the presentlang catalog if desiredlang is
195 # a. equal to presentlang, or
196 # b. a variant of presentlang (because in this case,
197 # presentlang can be used as a fallback for messages
198 # which are not translated in the desiredlang catalog).
199 case "$desiredlang" in
200 "$presentlang"*) useit=yes;;
203 if test $useit = yes; then
204 NEW_LINGUAS="$NEW_LINGUAS $presentlang"
208 AC_MSG_RESULT($LINGUAS)
211 dnl Construct list of names of catalog files to be constructed.
212 if test -n "$LINGUAS"; then
213 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang.gmo"; done
216 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
217 dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
218 dnl Try to locate is.
220 if test -n "$ac_aux_dir"; then
221 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
223 if test -z "$MKINSTALLDIRS"; then
224 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
226 AC_SUBST(MKINSTALLDIRS)
228 dnl Enable libtool support if the surrounding package wishes it.
229 INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
230 AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)