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 Public License
6 # but which still want to provide support for the GNU gettext functionality.
7 # Please note that the actual code is *not* freely available.
11 AC_PREREQ(2.13) dnl Minimum Autoconf version required.
14 [AC_MSG_CHECKING([whether NLS is requested])
15 dnl Default is enabled NLS
17 [ --disable-nls do not use Native Language Support],
18 USE_NLS=$enableval, USE_NLS=yes)
19 AC_MSG_RESULT($USE_NLS)
22 USE_INCLUDED_LIBINTL=no
24 AC_ARG_WITH(locale-dir,
25 [ --with-locale-dir=DIR specify locale directory],
27 test -z "$LOCALE_DIR" && LOCALE_DIR='$(datadir)/locale'
30 AC_ARG_WITH(gnu-locale-dir,
31 [ --with-gnu-locale-dir=DIR specify GNU locale directory],
32 GNU_LOCALE_DIR=$withval)
33 test -z "$GNU_LOCALE_DIR" && GNU_LOCALE_DIR='$(prefix)/share/locale'
34 AC_SUBST(GNU_LOCALE_DIR)
36 dnl If we use NLS figure out what method
37 if test "$USE_NLS" = "yes"; then
38 AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if NLS is requested.])
39 AC_MSG_CHECKING([whether included gettext is requested])
40 AC_ARG_WITH(included-gettext,
41 [ --with-included-gettext use the GNU gettext library included here],
42 nls_cv_force_use_gnu_gettext=$withval,
43 nls_cv_force_use_gnu_gettext=no)
44 AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
46 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
47 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
48 dnl User does not insist on using GNU NLS library. Figure out what
49 dnl to use. If gettext or catgets are available (in this order) we
50 dnl use this. Else we have to fall back to GNU NLS library.
51 dnl catgets is only used if permitted by option --with-catgets.
56 AC_CHECK_HEADER(libintl.h,
57 [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
58 [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
59 gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
61 if test "$gt_cv_func_gettext_libc" != "yes"; then
62 AC_CHECK_LIB(intl, bindtextdomain,
63 [AC_CHECK_LIB(intl, gettext)])
66 if test "$gt_cv_func_gettext_libc" = "yes" \
67 || test "$ac_cv_lib_intl_gettext" = "yes"; then
68 AC_DEFINE(HAVE_GETTEXT, 1,
69 [Define to 1 if you have gettext and don't want to use GNU 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],
88 if test "$CATOBJEXT" = "NONE"; then
89 AC_MSG_CHECKING([whether catgets can be used])
91 [ --with-catgets use catgets functions if available],
92 nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
93 AC_MSG_RESULT($nls_cv_use_catgets)
95 if test "$nls_cv_use_catgets" = "yes"; then
96 dnl No gettext in C library. Try catgets next.
98 AC_CHECK_FUNC(catgets,
99 [AC_DEFINE(HAVE_CATGETS, 1,
100 [Define as 1 if you have catgets and don't want to use GNU gettext.])
101 INTLOBJS="\$(CATOBJS)"
102 AC_PATH_PROG(GENCAT, gencat, no)dnl
103 if test "$GENCAT" != "no"; then
104 AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
105 if test "$GMSGFMT" = "no"; then
106 AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
107 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
109 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
110 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
111 USE_INCLUDED_LIBINTL=yes
115 INTLDEPS='$(top_builddir)/intl/libintl.a'
117 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
118 nls_cv_header_intl=intl/libintl.h
119 nls_cv_header_libgt=intl/libgettext.h
124 if test "$CATOBJEXT" = "NONE"; then
125 dnl Neither gettext nor catgets in included in the C library.
126 dnl Fall back on GNU gettext library.
127 nls_cv_use_gnu_gettext=yes
131 if test "$nls_cv_use_gnu_gettext" = "yes"; then
132 dnl Mark actions used to generate GNU NLS library.
133 INTLOBJS="\$(GETTOBJS)"
134 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
135 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
136 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
137 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
138 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
140 USE_INCLUDED_LIBINTL=yes
144 INTLDEPS='$(top_builddir)/intl/libintl.a'
146 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
147 nls_cv_header_intl=intl/libintl.h
148 nls_cv_header_libgt=intl/libgettext.h
151 dnl Test whether we really found GNU xgettext.
152 if test "$XGETTEXT" != ":"; then
153 dnl If it is no GNU xgettext we define it as : so that the
154 dnl Makefiles still can work.
155 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
159 [found xgettext program is not GNU xgettext; ignore it])
164 # We need to process the po/ directory.
168 nls_cv_header_intl=intl/libintl.h
169 nls_cv_header_libgt=intl/libgettext.h
171 if test -z "$nls_cv_header_intl"; then
172 # Clean out junk possibly left behind by a previous configuration.
175 AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
177 [case "$CONFIG_FILES" in *po/Makefile.in*)
178 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
182 # If this is used in GNU gettext we have to set USE_NLS to `yes'
183 # because some of the sources are only built for this goal.
184 if test "$PACKAGE" = gettext; then
186 USE_INCLUDED_LIBINTL=yes
189 dnl These rules are solely for the distribution goal. While doing this
190 dnl we only have to keep exactly one list of the available catalogs
192 for lang in $ALL_LINGUAS; do
193 GMOFILES="$GMOFILES $lang.gmo"
194 POFILES="$POFILES $lang.po"
197 dnl Make all variables we use known to autoconf.
198 AC_SUBST(USE_INCLUDED_LIBINTL)
201 AC_SUBST(DATADIRNAME)
211 AC_DEFUN(AM_GNU_GETTEXT,
212 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
213 AC_REQUIRE([AC_PROG_CC])dnl
214 AC_REQUIRE([AC_PROG_RANLIB])dnl
215 AC_REQUIRE([AC_ISC_POSIX])dnl
216 AC_REQUIRE([AC_HEADER_STDC])dnl
217 AC_REQUIRE([AC_C_CONST])dnl
218 AC_REQUIRE([AC_C_INLINE])dnl
219 AC_REQUIRE([AC_TYPE_OFF_T])dnl
220 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
221 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
222 AC_REQUIRE([AC_FUNC_MMAP])dnl
224 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
225 unistd.h sys/param.h])
226 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
227 strdup __argz_count __argz_stringify __argz_next])
229 if test "${ac_cv_func_stpcpy+set}" != "set"; then
230 AC_CHECK_FUNCS(stpcpy)
232 if test "${ac_cv_func_stpcpy}" = "yes"; then
233 AC_DEFINE(HAVE_STPCPY, 1, [Define to 1 if you have the stpcpy function.])
239 if test "x$CATOBJEXT" != "x"; then
240 if test "x$ALL_LINGUAS" = "x"; then
243 AC_MSG_CHECKING(for catalogs to be installed)
245 for lang in ${LINGUAS=$ALL_LINGUAS}; do
246 case "$ALL_LINGUAS" in
247 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
251 AC_MSG_RESULT($LINGUAS)
254 dnl Construct list of names of catalog files to be constructed.
255 if test -n "$LINGUAS"; then
256 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
260 dnl The reference to <locale.h> in the installed <libintl.h> file
261 dnl must be resolved because we cannot expect the users of this
262 dnl to define HAVE_LOCALE_H.
263 if test $ac_cv_header_locale_h = yes; then
264 INCLUDE_LOCALE_H="#include <locale.h>"
267 /* The system does not provide the header <locale.h>. Take care yourself. */"
269 AC_SUBST(INCLUDE_LOCALE_H)
271 dnl Determine which catalog format we have (if any is needed)
272 dnl For now we know about two different formats:
273 dnl Linux libc-5 and the normal X/Open format
274 test -d intl || mkdir intl
275 if test "$CATOBJEXT" = ".cat"; then
276 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
278 dnl Transform the SED scripts while copying because some dumb SEDs
279 dnl cannot handle comments.
280 sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
282 dnl po2tbl.sed is always needed.
283 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
284 $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
286 dnl In the intl/Makefile.in we have a special dependency which makes
287 dnl only sense for gettext. We comment this out for non-gettext
289 if test "$PACKAGE" = "gettext"; then
299 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
300 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
301 dnl Try to locate is.
303 if test -n "$ac_aux_dir"; then
304 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
306 if test -z "$MKINSTALLDIRS"; then
307 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
309 AC_SUBST(MKINSTALLDIRS)
311 dnl *** For now the libtool support in intl/Makefile is not for real.
315 dnl Generate list of files to be processed by xgettext which will
316 dnl be included in po/Makefile.
317 test -d po || mkdir po
322 posrcprefix="$srcdir/" ;;
324 posrcprefix="../$srcdir/" ;;
327 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
328 < $srcdir/po/POTFILES.in > po/POTFILES