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.
14 # If you make changes to this file, you MUST update the copy in
15 # acinclude.m4. [ aclocal dies on duplicate macros, so if
16 # we run 'aclocal -I macros/' then we'll run into problems
17 # once we've installed glib-gettext.m4 :-( ]
22 AC_DEFUN(AM_GLIB_WITH_NLS,
23 [AC_MSG_CHECKING([whether NLS is requested])
24 dnl Default is enabled NLS
26 [ --disable-nls do not use Native Language Support],
27 USE_NLS=$enableval, USE_NLS=yes)
28 AC_MSG_RESULT($USE_NLS)
31 USE_INCLUDED_LIBINTL=no
33 dnl If we use NLS figure out what method
34 if test "$USE_NLS" = "yes"; then
35 # AC_DEFINE(ENABLE_NLS)
36 # AC_MSG_CHECKING([whether included gettext is requested])
37 # AC_ARG_WITH(included-gettext,
38 # [ --with-included-gettext use the GNU gettext library included here],
39 # nls_cv_force_use_gnu_gettext=$withval,
40 # nls_cv_force_use_gnu_gettext=no)
41 # AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
42 nls_cv_force_use_gnu_gettext="no"
44 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
45 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
46 dnl User does not insist on using GNU NLS library. Figure out what
47 dnl to use. If gettext or catgets are available (in this order) we
48 dnl use this. Else we have to fall back to GNU NLS library.
49 dnl catgets is only used if permitted by option --with-catgets.
54 AC_CHECK_HEADER(libintl.h,
55 [AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc,
56 [AC_TRY_LINK([#include <libintl.h>], [return (int) dgettext ("","")],
57 gt_cv_func_dgettext_libc=yes, gt_cv_func_dgettext_libc=no)])
59 if test "$gt_cv_func_dgettext_libc" != "yes"; then
60 AC_CHECK_LIB(intl, bindtextdomain,
61 [AC_CACHE_CHECK([for dgettext in libintl],
62 gt_cv_func_dgettext_libintl,
63 [AC_CHECK_LIB(intl, dgettext,
64 gt_cv_func_dgettext_libintl=yes,
65 gt_cv_func_dgettext_libintl=no)],
66 gt_cv_func_dgettext_libintl=no)])
69 if test "$gt_cv_func_dgettext_libintl" = "yes"; then
73 if test "$gt_cv_func_dgettext_libc" = "yes" \
74 || test "$gt_cv_func_dgettext_libintl" = "yes"; then
75 AC_DEFINE(HAVE_GETTEXT)
76 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
77 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
78 if test "$MSGFMT" != "no"; then
79 AC_CHECK_FUNCS(dcgettext)
80 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
81 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
82 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
83 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
84 return _nl_msg_cat_cntr],
93 # Added by Martin Baulig 12/15/98 for libc5 systems
94 if test "$gt_cv_func_dgettext_libc" != "yes" \
95 && test "$gt_cv_func_dgettext_libintl" = "yes"; then
97 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
101 # if test "$CATOBJEXT" = "NONE"; then
102 # AC_MSG_CHECKING([whether catgets can be used])
103 # AC_ARG_WITH(catgets,
104 # [ --with-catgets use catgets functions if available],
105 # nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
106 # AC_MSG_RESULT($nls_cv_use_catgets)
108 # if test "$nls_cv_use_catgets" = "yes"; then
109 # dnl No gettext in C library. Try catgets next.
110 # AC_CHECK_LIB(i, main)
111 # AC_CHECK_FUNC(catgets,
112 # [AC_DEFINE(HAVE_CATGETS)
113 # INTLOBJS="\$(CATOBJS)"
114 # AC_PATH_PROG(GENCAT, gencat, no)dnl
115 # if test "$GENCAT" != "no"; then
116 # AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
117 # if test "$GMSGFMT" = "no"; then
118 # AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
119 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
121 # AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
122 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
123 # USE_INCLUDED_LIBINTL=yes
127 # INTLDEPS='$(top_builddir)/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
137 if test "$CATOBJEXT" = "NONE"; then
138 dnl Neither gettext nor catgets in included in the C library.
139 dnl Fall back on GNU gettext library.
140 nls_cv_use_gnu_gettext=yes
144 if test "$nls_cv_use_gnu_gettext" != "yes"; then
145 AC_DEFINE(ENABLE_NLS)
147 dnl Unset this variable since we use the non-zero value as a flag.
149 # dnl Mark actions used to generate GNU NLS library.
150 # INTLOBJS="\$(GETTOBJS)"
151 # AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
152 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
153 # AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
154 # AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
155 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
157 # USE_INCLUDED_LIBINTL=yes
161 # INTLDEPS='$(top_builddir)/intl/libintl.a'
163 # LIBS=`echo $LIBS | sed -e 's/-lintl//'`
164 # nls_cv_header_intl=intl/libintl.h
165 # nls_cv_header_libgt=intl/libgettext.h
168 dnl Test whether we really found GNU xgettext.
169 if test "$XGETTEXT" != ":"; then
170 dnl If it is no GNU xgettext we define it as : so that the
171 dnl Makefiles still can work.
172 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
176 [found xgettext program is not GNU xgettext; ignore it])
181 # We need to process the po/ directory.
185 # nls_cv_header_intl=intl/libintl.h
186 # nls_cv_header_libgt=intl/libgettext.h
188 # AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
190 [case "$CONFIG_FILES" in *po/Makefile.in*)
191 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
195 # # If this is used in GNU gettext we have to set USE_NLS to `yes'
196 # # because some of the sources are only built for this goal.
197 # if test "$PACKAGE" = gettext; then
199 # USE_INCLUDED_LIBINTL=yes
202 dnl These rules are solely for the distribution goal. While doing this
203 dnl we only have to keep exactly one list of the available catalogs
205 for lang in $ALL_LINGUAS; do
206 GMOFILES="$GMOFILES $lang.gmo"
207 POFILES="$POFILES $lang.po"
210 dnl Make all variables we use known to autoconf.
211 AC_SUBST(USE_INCLUDED_LIBINTL)
214 AC_SUBST(DATADIRNAME)
224 AC_DEFUN(AM_GLIB_GNU_GETTEXT,
225 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
226 AC_REQUIRE([AC_PROG_CC])dnl
227 AC_REQUIRE([AC_PROG_RANLIB])dnl
228 # AC_REQUIRE([AC_ISC_POSIX])dnl
229 AC_REQUIRE([AC_HEADER_STDC])dnl
230 AC_REQUIRE([AC_C_CONST])dnl
231 AC_REQUIRE([AC_C_INLINE])dnl
232 AC_REQUIRE([AC_TYPE_OFF_T])dnl
233 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
234 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
235 AC_REQUIRE([AC_FUNC_MMAP])dnl
237 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
238 unistd.h sys/param.h])
239 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
240 strdup __argz_count __argz_stringify __argz_next])
242 # if test "${ac_cv_func_stpcpy+set}" != "set"; then
243 # AC_CHECK_FUNCS(stpcpy)
245 # if test "${ac_cv_func_stpcpy}" = "yes"; then
246 # AC_DEFINE(HAVE_STPCPY)
252 if test "x$CATOBJEXT" != "x"; then
253 if test "x$ALL_LINGUAS" = "x"; then
256 AC_MSG_CHECKING(for catalogs to be installed)
258 for lang in ${LINGUAS=$ALL_LINGUAS}; do
259 case "$ALL_LINGUAS" in
260 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
264 AC_MSG_RESULT($LINGUAS)
267 dnl Construct list of names of catalog files to be constructed.
268 if test -n "$LINGUAS"; then
269 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
273 # dnl The reference to <locale.h> in the installed <libintl.h> file
274 # dnl must be resolved because we cannot expect the users of this
275 # dnl to define HAVE_LOCALE_H.
276 # if test $ac_cv_header_locale_h = yes; then
277 # INCLUDE_LOCALE_H="#include <locale.h>"
279 # INCLUDE_LOCALE_H="\
280 #/* The system does not provide the header <locale.h>. Take care yourself. */"
282 # AC_SUBST(INCLUDE_LOCALE_H)
284 dnl Determine which catalog format we have (if any is needed)
285 dnl For now we know about two different formats:
286 dnl Linux libc-5 and the normal X/Open format
287 test -d po || mkdir po
288 if test "$CATOBJEXT" = ".cat"; then
289 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
291 dnl Transform the SED scripts while copying because some dumb SEDs
292 dnl cannot handle comments.
293 sed -e '/^#/d' $srcdir/po/$msgformat-msg.sed > po/po2msg.sed
295 dnl po2tbl.sed is always needed.
296 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
297 $srcdir/po/po2tbl.sed.in > po/po2tbl.sed
299 # dnl In the intl/Makefile.in we have a special dependency which makes
300 # dnl only sense for gettext. We comment this out for non-gettext
302 # if test "$PACKAGE" = "gettext"; then
312 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
313 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
314 dnl Try to locate is.
316 if test -n "$ac_aux_dir"; then
317 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
319 if test -z "$MKINSTALLDIRS"; then
320 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
322 AC_SUBST(MKINSTALLDIRS)
324 # dnl *** For now the libtool support in intl/Makefile is not for real.
328 dnl Generate list of files to be processed by xgettext which will
329 dnl be included in po/Makefile.
330 test -d po || mkdir po
331 if test "x$srcdir" != "x."; then
332 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
333 posrcprefix="$srcdir/"
335 posrcprefix="../$srcdir/"
341 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
342 < $srcdir/po/POTFILES.in > po/POTFILES