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
USE_INCLUDED_LIBINTL=no
26
dnl If we use NLS figure out what method
27
if test "$USE_NLS" = "yes"; then
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 gettext in libc], gt_cv_func_gettext_libc,
49
[AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
50
gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
52
if test "$gt_cv_func_gettext_libc" != "yes"; then
53
AC_CHECK_LIB(intl, bindtextdomain,
54
[AC_CACHE_CHECK([for gettext in libintl],
55
gt_cv_func_gettext_libintl,
56
[AC_CHECK_LIB(intl, gettext,
57
gt_cv_func_gettext_libintl=yes,
58
gt_cv_func_gettext_libintl=no)],
59
gt_cv_func_gettext_libintl=no)])
62
if test "$gt_cv_func_gettext_libc" = "yes" \
63
|| test "$gt_cv_func_gettext_libintl" = "yes"; then
64
AC_DEFINE(HAVE_GETTEXT)
65
AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
66
[test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
67
if test "$MSGFMT" != "no"; then
68
AC_CHECK_FUNCS(dcgettext)
69
AC_CHECK_FUNCS(dgettext)
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],
81
echo "You must install msgfmt (part of gettext)."
85
# Added by Martin Baulig 12/15/98 for libc5 systems
86
if test "$gt_cv_func_gettext_libc" != "yes" \
87
&& test "$gt_cv_func_gettext_libintl" = "yes"; then
89
LIBS=`echo $LIBS | sed -e 's/-lintl//'`
93
if test "$CATOBJEXT" = "NONE"; then
94
AC_MSG_CHECKING([whether catgets can be used])
96
[ --with-catgets use catgets functions if available],
97
nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
98
AC_MSG_RESULT($nls_cv_use_catgets)
100
if test "$nls_cv_use_catgets" = "yes"; then
101
dnl No gettext in C library. Try catgets next.
102
AC_CHECK_LIB(i, main)
103
AC_CHECK_FUNC(catgets,
104
[AC_DEFINE(HAVE_CATGETS)
105
INTLOBJS="\$(CATOBJS)"
106
AC_PATH_PROG(GENCAT, gencat, no)dnl
107
# if test "$GENCAT" != "no"; then
108
# AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
109
# if test "$GMSGFMT" = "no"; then
110
# AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
111
# [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
113
# AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
114
# [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
115
# USE_INCLUDED_LIBINTL=yes
119
# INTLDEPS='$(top_builddir)/intl/libintl.a'
121
# LIBS=`echo $LIBS | sed -e 's/-lintl//'`
122
# nls_cv_header_intl=intl/libintl.h
123
# nls_cv_header_libgt=intl/libgettext.h
129
if test "$CATOBJEXT" = "NONE"; then
130
dnl Neither gettext nor catgets in included in the C library.
131
dnl Fall back on GNU gettext library.
132
nls_cv_use_gnu_gettext=yes
136
if test "$nls_cv_use_gnu_gettext" != "yes"; then
137
AC_DEFINE(ENABLE_NLS)
139
# Unset this variable since we use the non-zero value as a flag.
141
# dnl Mark actions used to generate GNU NLS library.
142
# INTLOBJS="\$(GETTOBJS)"
143
# AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
144
# [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
145
# AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
146
# AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
147
# [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
149
# USE_INCLUDED_LIBINTL=yes
153
# INTLDEPS='$(top_builddir)/intl/libintl.a'
155
# LIBS=`echo $LIBS | sed -e 's/-lintl//'`
156
# nls_cv_header_intl=intl/libintl.h
157
# nls_cv_header_libgt=intl/libgettext.h
160
dnl Test whether we really found GNU xgettext.
161
if test "$XGETTEXT" != ":"; then
162
dnl If it is no GNU xgettext we define it as : so that the
163
dnl Makefiles still can work.
164
if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
168
[found xgettext program is not GNU xgettext; ignore it])
173
# We need to process the po/ directory.
177
nls_cv_header_intl=intl/libintl.h
178
nls_cv_header_libgt=intl/libgettext.h
180
AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
182
[case "$CONFIG_FILES" in *po/Makefile.in*)
183
sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
187
# # If this is used in GNU gettext we have to set USE_NLS to `yes'
188
# # because some of the sources are only built for this goal.
189
# if test "$PACKAGE" = gettext; then
191
# USE_INCLUDED_LIBINTL=yes
194
dnl These rules are solely for the distribution goal. While doing this
195
dnl we only have to keep exactly one list of the available catalogs
197
for lang in $ALL_LINGUAS; do
198
GMOFILES="$GMOFILES $lang.gmo"
199
POFILES="$POFILES $lang.po"
202
dnl Make all variables we use known to autoconf.
203
AC_SUBST(USE_INCLUDED_LIBINTL)
206
AC_SUBST(DATADIRNAME)
216
AC_DEFUN(AM_GNOME_GETTEXT,
217
[AC_REQUIRE([AC_PROG_MAKE_SET])dnl
218
AC_REQUIRE([AC_PROG_CC])dnl
219
AC_REQUIRE([AC_PROG_RANLIB])dnl
220
AC_REQUIRE([AC_ISC_POSIX])dnl
221
AC_REQUIRE([AC_HEADER_STDC])dnl
222
AC_REQUIRE([AC_C_CONST])dnl
223
AC_REQUIRE([AC_C_INLINE])dnl
224
AC_REQUIRE([AC_TYPE_OFF_T])dnl
225
AC_REQUIRE([AC_TYPE_SIZE_T])dnl
226
AC_REQUIRE([AC_FUNC_ALLOCA])dnl
227
AC_REQUIRE([AC_FUNC_MMAP])dnl
229
AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
230
unistd.h sys/param.h])
231
AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
232
strdup __argz_count __argz_stringify __argz_next])
234
if test "${ac_cv_func_stpcpy+set}" != "set"; then
235
AC_CHECK_FUNCS(stpcpy)
237
if test "${ac_cv_func_stpcpy}" = "yes"; then
238
AC_DEFINE(HAVE_STPCPY)
244
if test "x$CATOBJEXT" != "x"; then
245
if test "x$ALL_LINGUAS" = "x"; then
248
AC_MSG_CHECKING(for catalogs to be installed)
250
if test "x$LINGUAS" = "x"; then
253
for lang in $LINGUAS; do
254
case "$ALL_LINGUAS" in
255
*$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
259
AC_MSG_RESULT($LINGUAS)
262
dnl Construct list of names of catalog files to be constructed.
263
if test -n "$LINGUAS"; then
264
for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
268
dnl The reference to <locale.h> in the installed <libintl.h> file
269
dnl must be resolved because we cannot expect the users of this
270
dnl to define HAVE_LOCALE_H.
271
if test $ac_cv_header_locale_h = yes; then
272
INCLUDE_LOCALE_H="#include <locale.h>"
275
/* The system does not provide the header <locale.h>. Take care yourself. */"
277
AC_SUBST(INCLUDE_LOCALE_H)
279
dnl Determine which catalog format we have (if any is needed)
280
dnl For now we know about two different formats:
281
dnl Linux libc-5 and the normal X/Open format
282
test -d intl || mkdir intl
283
if test "$CATOBJEXT" = ".cat"; then
284
AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
286
dnl Transform the SED scripts while copying because some dumb SEDs
287
dnl cannot handle comments.
288
sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
290
dnl po2tbl.sed is always needed.
291
sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
292
$srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
294
dnl In the intl/Makefile.in we have a special dependency which makes
295
dnl only sense for gettext. We comment this out for non-gettext
297
if test "$PACKAGE" = "gettext"; then
307
dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
308
dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
309
dnl Try to locate is.
311
if test -n "$ac_aux_dir"; then
312
MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
314
if test -z "$MKINSTALLDIRS"; then
315
MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
317
AC_SUBST(MKINSTALLDIRS)
319
dnl *** For now the libtool support in intl/Makefile is not for real.
323
dnl Generate list of files to be processed by xgettext which will
324
dnl be included in po/Makefile.
325
test -d po || mkdir po
326
if test "x$srcdir" != "x."; then
327
if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
328
posrcprefix="$srcdir/"
330
posrcprefix="../$srcdir/"
336
sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
337
< $srcdir/po/POTFILES.in > po/POTFILES