1 # This file is derived from `gettext.m4'. The difference is that the
2 # included macros assume Cygnus-style source and build trees.
4 # Macro to add for using GNU gettext.
5 # Ulrich Drepper <drepper@cygnus.com>, 1995.
7 # This file file be copied and used freely without restrictions. It can
8 # be used in projects which are not available under the GNU Public License
9 # but which still want to provide support for the GNU gettext functionality.
10 # Please note that the actual code is *not* freely available.
14 AC_DEFUN([CY_WITH_NLS],
15 [AC_MSG_CHECKING([whether NLS is requested])
16 dnl Default is enabled NLS
18 [ --disable-nls do not use Native Language Support],
19 USE_NLS=$enableval, USE_NLS=yes)
20 AC_MSG_RESULT($USE_NLS)
23 USE_INCLUDED_LIBINTL=no
25 dnl If we use NLS figure out what method
26 if test "$USE_NLS" = "yes"; then
27 AC_MSG_CHECKING([whether included gettext is requested])
28 AC_ARG_WITH(included-gettext,
29 [ --with-included-gettext use the GNU gettext library included here],
30 nls_cv_force_use_gnu_gettext=$withval,
31 nls_cv_force_use_gnu_gettext=no)
32 AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
34 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
35 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
36 dnl User does not insist on using GNU NLS library. Figure out what
37 dnl to use. If gettext or catgets are available (in this order) we
38 dnl use this. Else we have to fall back to GNU NLS library.
39 dnl catgets is only used if permitted by option --with-catgets.
44 AC_CHECK_HEADER(libintl.h,
45 [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
46 [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
47 gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
49 if test "$gt_cv_func_gettext_libc" != "yes"; then
50 AC_CHECK_LIB(intl, bindtextdomain,
51 [AC_CACHE_CHECK([for gettext in libintl],
52 gt_cv_func_gettext_libintl,
53 [AC_TRY_LINK([], [return (int) gettext ("")],
54 gt_cv_func_gettext_libintl=yes,
55 gt_cv_func_gettext_libintl=no)])])
58 if test "$gt_cv_func_gettext_libc" = "yes" \
59 || test "$gt_cv_func_gettext_libintl" = "yes"; then
60 AC_DEFINE(HAVE_GETTEXT, 1,
61 [Define as 1 if you have gettext and don't want to use GNU gettext.])
62 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
63 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
64 if test "$MSGFMT" != "no"; then
65 AC_CHECK_FUNCS(dcgettext)
66 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
67 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
68 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
69 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
70 return _nl_msg_cat_cntr],
80 dnl In the standard gettext, we would now check for catgets.
81 dnl However, we never want to use catgets for our releases.
83 if test x"$CATOBJEXT" = x && test -d $srcdir/../intl; then
84 # Neither gettext nor catgets in included in the C library.
85 # Fall back on GNU gettext library (assuming it is present).
86 nls_cv_use_gnu_gettext=yes
90 if test "$nls_cv_use_gnu_gettext" = "yes"; then
91 dnl Mark actions used to generate GNU NLS library.
92 INTLOBJS="\$(GETTOBJS)"
93 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
94 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
95 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
96 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
97 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
99 USE_INCLUDED_LIBINTL=yes
103 INTLDEPS='$(top_builddir)/../intl/libintl.a'
105 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
106 nls_cv_header_intl=libintl.h
107 nls_cv_header_libgt=libgettext.h
110 dnl Test whether we really found GNU xgettext.
111 if test "$XGETTEXT" != ":"; then
112 dnl If it is no GNU xgettext we define it as : so that the
113 dnl Makefiles still can work.
114 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
118 [found xgettext programs is not GNU xgettext; ignore it])
123 # We need to process the po/ directory.
127 nls_cv_header_intl=libintl.h
128 nls_cv_header_libgt=libgettext.h
131 # If this is used in GNU gettext we have to set USE_NLS to `yes'
132 # because some of the sources are only built for this goal.
133 if test "$PACKAGE" = gettext; then
135 USE_INCLUDED_LIBINTL=yes
138 dnl These rules are solely for the distribution goal. While doing this
139 dnl we only have to keep exactly one list of the available catalogs
141 for lang in $ALL_LINGUAS; do
142 GMOFILES="$GMOFILES $lang.gmo"
143 POFILES="$POFILES $lang.po"
146 dnl Make all variables we use known to autoconf.
147 AC_SUBST(USE_INCLUDED_LIBINTL)
150 AC_SUBST(DATADIRNAME)
158 if test "x$CATOBJEXT" != "x"; then
159 AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if NLS is requested])
163 AC_DEFUN([CY_GNU_GETTEXT],
164 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
165 AC_REQUIRE([AC_PROG_CC])dnl
166 AC_REQUIRE([AC_PROG_RANLIB])dnl
167 AC_REQUIRE([AC_ISC_POSIX])dnl
168 AC_REQUIRE([AC_HEADER_STDC])dnl
169 AC_REQUIRE([AC_C_CONST])dnl
170 AC_REQUIRE([AC_C_INLINE])dnl
171 AC_REQUIRE([AC_TYPE_OFF_T])dnl
172 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
173 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
174 AC_REQUIRE([AC_FUNC_MMAP])dnl
176 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
177 unistd.h values.h sys/param.h])
178 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
179 __argz_count __argz_stringify __argz_next])
181 if test "${ac_cv_func_stpcpy+set}" != "set"; then
182 AC_CHECK_FUNCS(stpcpy)
184 if test "${ac_cv_func_stpcpy}" = "yes"; then
185 AC_DEFINE(HAVE_STPCPY, 1, [Define if you have the stpcpy function])
191 if test "x$CATOBJEXT" != "x"; then
192 if test "x$ALL_LINGUAS" = "x"; then
195 AC_MSG_CHECKING(for catalogs to be installed)
197 for lang in ${LINGUAS=$ALL_LINGUAS}; do
198 case "$ALL_LINGUAS" in
199 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
203 AC_MSG_RESULT($LINGUAS)
206 dnl Construct list of names of catalog files to be constructed.
207 if test -n "$LINGUAS"; then
208 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
212 dnl The reference to <locale.h> in the installed <libintl.h> file
213 dnl must be resolved because we cannot expect the users of this
214 dnl to define HAVE_LOCALE_H.
215 if test $ac_cv_header_locale_h = yes; then
216 INCLUDE_LOCALE_H="#include <locale.h>"
219 /* The system does not provide the header <locale.h>. Take care yourself. */"
221 AC_SUBST(INCLUDE_LOCALE_H)
223 dnl Determine which catalog format we have (if any is needed)
224 dnl For now we know about two different formats:
225 dnl Linux libc-5 and the normal X/Open format
226 if test -f $srcdir/po2tbl.sed.in; then
227 if test "$CATOBJEXT" = ".cat"; then
228 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
230 dnl Transform the SED scripts while copying because some dumb SEDs
231 dnl cannot handle comments.
232 sed -e '/^#/d' $srcdir/$msgformat-msg.sed > po2msg.sed
234 dnl po2tbl.sed is always needed.
235 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
236 $srcdir/po2tbl.sed.in > po2tbl.sed
239 dnl In the intl/Makefile.in we have a special dependency which makes
240 dnl only sense for gettext. We comment this out for non-gettext
242 if test "$PACKAGE" = "gettext"; then
252 MKINSTALLDIRS="\$(srcdir)/../../mkinstalldirs"
253 AC_SUBST(MKINSTALLDIRS)
255 dnl *** For now the libtool support in intl/Makefile is not for real.
259 dnl Generate list of files to be processed by xgettext which will
260 dnl be included in po/Makefile. But only do this if the po directory
261 dnl exists in srcdir and contains POTFILES.in.
262 if test -f $srcdir/po/POTFILES.in; then
263 test -d po || mkdir po
264 if test "x$srcdir" != "x."; then
265 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
266 posrcprefix="$srcdir/"
268 posrcprefix="../$srcdir/"
274 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
275 < $srcdir/po/POTFILES.in > po/POTFILES
279 # Search path for a program which passes the given test.
280 # Ulrich Drepper <drepper@cygnus.com>, 1996.
282 # This file file be copied and used freely without restrictions. It can
283 # be used in projects which are not available under the GNU Public License
284 # but which still want to provide support for the GNU gettext functionality.
285 # Please note that the actual code is *not* freely available.
289 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
290 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
291 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
292 [# Extract the first word of "$2", so it can be a program name with args.
293 set dummy $2; ac_word=[$]2
294 AC_MSG_CHECKING([for $ac_word])
295 AC_CACHE_VAL(ac_cv_path_$1,
298 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
301 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
302 for ac_dir in ifelse([$5], , $PATH, [$5]); do
303 test -z "$ac_dir" && ac_dir=.
304 if test -f $ac_dir/$ac_word; then
306 ac_cv_path_$1="$ac_dir/$ac_word"
312 dnl If no 4th arg is given, leave the cache variable unset,
313 dnl so AC_PATH_PROGS will keep looking.
314 ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
319 if test -n "[$]$1"; then
327 # Check whether LC_MESSAGES is available in <locale.h>.
328 # Ulrich Drepper <drepper@cygnus.com>, 1995.
330 # This file file be copied and used freely without restrictions. It can
331 # be used in projects which are not available under the GNU Public License
332 # but which still want to provide support for the GNU gettext functionality.
333 # Please note that the actual code is *not* freely available.
337 AC_DEFUN([AM_LC_MESSAGES],
338 [if test $ac_cv_header_locale_h = yes; then
339 AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
340 [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
341 am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
342 if test $am_cv_val_LC_MESSAGES = yes; then
343 AC_DEFINE(HAVE_LC_MESSAGES, 1,
344 [Define if your locale.h file contains LC_MESSAGES.])