1 # autoconf 2.13 / 2.50 compatibility macro
3 # Ulrich Drepper <drepper@cygnus.com>, 1995.
5 # Modified to never use included libintl.
6 # Owen Taylor <otaylor@redhat.com>, 12/15/1998
9 # This file can be copied and used freely without restrictions. It can
10 # be used in projects which are not available under the GNU Public License
11 # but which still want to provide support for the GNU gettext functionality.
12 # Please note that the actual code is *not* freely available.
16 AC_DEFUN(AM_ATK_WITH_NLS,
17 [AC_MSG_CHECKING([whether NLS is requested])
18 dnl Default is enabled NLS
20 [ --disable-nls do not use Native Language Support],
21 USE_NLS=$enableval, USE_NLS=yes)
22 AC_MSG_RESULT($USE_NLS)
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 dgettext in libc], gt_cv_func_dgettext_libc,
50 [AC_TRY_LINK([#include <libintl.h>], [return (int) dgettext ("","")],
51 gt_cv_func_dgettext_libc=yes, gt_cv_func_dgettext_libc=no)])
53 if test "$gt_cv_func_dgettext_libc" != "yes"; then
54 AC_CHECK_LIB(intl, bindtextdomain,
55 [AC_CACHE_CHECK([for dgettext in libintl],
56 gt_cv_func_dgettext_libintl,
57 [AC_CHECK_LIB(intl, dgettext,
58 gt_cv_func_dgettext_libintl=yes,
59 gt_cv_func_dgettext_libintl=no)],
60 gt_cv_func_dgettext_libintl=no)])
63 if test "$gt_cv_func_dgettext_libintl" = "yes"; then
67 if test "$gt_cv_func_dgettext_libc" = "yes" \
68 || test "$gt_cv_func_dgettext_libintl" = "yes"; then
69 AC_DEFINE(HAVE_GETTEXT)
70 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
71 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
72 if test "$MSGFMT" != "no"; then
73 AC_CHECK_FUNCS(dcgettext)
74 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
75 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
76 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
77 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
78 return _nl_msg_cat_cntr],
87 # Added by Martin Baulig 12/15/98 for libc5 systems
88 if test "$gt_cv_func_dgettext_libc" != "yes" \
89 && test "$gt_cv_func_dgettext_libintl" = "yes"; then
91 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
95 if test "$CATOBJEXT" = "NONE"; then
96 AC_MSG_CHECKING([whether catgets can be used])
98 [ --with-catgets use catgets functions if available],
99 nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
100 AC_MSG_RESULT($nls_cv_use_catgets)
102 if test "$nls_cv_use_catgets" = "yes"; then
103 dnl No gettext in C library. Try catgets next.
104 AC_CHECK_LIB(i, main)
105 AC_CHECK_FUNC(catgets,
106 [AC_DEFINE(HAVE_CATGETS)
107 INTLOBJS="\$(CATOBJS)"
108 AC_PATH_PROG(GENCAT, gencat, no)dnl
109 # if test "$GENCAT" != "no"; then
110 # AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
111 # if test "$GMSGFMT" = "no"; then
112 # AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
113 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
115 # AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
116 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
117 # USE_INCLUDED_LIBINTL=yes
121 # INTLDEPS='$(top_builddir)/intl/libintl.a'
123 # LIBS=`echo $LIBS | sed -e 's/-lintl//'`
124 # nls_cv_header_intl=intl/libintl.h
125 # nls_cv_header_libgt=intl/libgettext.h
131 if test "$CATOBJEXT" = "NONE"; then
132 dnl Neither gettext nor catgets in included in the C library.
133 dnl Fall back on GNU gettext library.
134 nls_cv_use_gnu_gettext=yes
138 if test "$nls_cv_use_gnu_gettext" != "yes"; then
139 AC_DEFINE(ENABLE_NLS)
141 # Unset this variable since we use the non-zero value as a flag.
143 # dnl Mark actions used to generate GNU NLS library.
144 # INTLOBJS="\$(GETTOBJS)"
145 # AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
146 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
147 # AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
148 # AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
149 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
151 # USE_INCLUDED_LIBINTL=yes
155 # INTLDEPS='$(top_builddir)/intl/libintl.a'
157 # LIBS=`echo $LIBS | sed -e 's/-lintl//'`
158 # nls_cv_header_intl=intl/libintl.h
159 # nls_cv_header_libgt=intl/libgettext.h
162 dnl Test whether we really found GNU xgettext.
163 if test "$XGETTEXT" != ":"; then
164 dnl If it is no GNU xgettext we define it as : so that the
165 dnl Makefiles still can work.
166 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
170 [found xgettext program is not GNU xgettext; ignore it])
175 # We need to process the po/ directory.
179 nls_cv_header_intl=intl/libintl.h
180 nls_cv_header_libgt=intl/libgettext.h
182 AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
184 [case "$CONFIG_FILES" in *po/Makefile.in*)
185 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
189 # # If this is used in GNU gettext we have to set USE_NLS to `yes'
190 # # because some of the sources are only built for this goal.
191 # if test "$PACKAGE" = gettext; then
193 # USE_INCLUDED_LIBINTL=yes
196 dnl These rules are solely for the distribution goal. While doing this
197 dnl we only have to keep exactly one list of the available catalogs
199 for lang in $ALL_LINGUAS; do
200 GMOFILES="$GMOFILES $lang.gmo"
201 POFILES="$POFILES $lang.po"
204 dnl Make all variables we use known to autoconf.
205 AC_SUBST(USE_INCLUDED_LIBINTL)
208 AC_SUBST(DATADIRNAME)
218 AC_DEFUN(AM_ATK_GNU_GETTEXT,
219 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
220 AC_REQUIRE([AC_PROG_CC])dnl
221 AC_REQUIRE([AC_PROG_RANLIB])dnl
222 AC_REQUIRE([AC_ISC_POSIX])dnl
223 AC_REQUIRE([AC_HEADER_STDC])dnl
224 AC_REQUIRE([AC_C_CONST])dnl
225 AC_REQUIRE([AC_C_INLINE])dnl
226 AC_REQUIRE([AC_TYPE_OFF_T])dnl
227 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
228 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
229 AC_REQUIRE([AC_FUNC_MMAP])dnl
231 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
232 unistd.h sys/param.h])
233 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
234 strdup __argz_count __argz_stringify __argz_next])
236 if test "${ac_cv_func_stpcpy+set}" != "set"; then
237 AC_CHECK_FUNCS(stpcpy)
239 if test "${ac_cv_func_stpcpy}" = "yes"; then
240 AC_DEFINE(HAVE_STPCPY)
246 if test "x$CATOBJEXT" != "x"; then
247 if test "x$ALL_LINGUAS" = "x"; then
250 AC_MSG_CHECKING(for catalogs to be installed)
252 for lang in ${LINGUAS=$ALL_LINGUAS}; do
253 case "$ALL_LINGUAS" in
254 *$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