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_DEFINE(ENABLE_NLS, 1, [Define to 1 if NLS is requested])
28 AC_MSG_CHECKING([whether included gettext is requested])
29 AC_ARG_WITH(included-gettext,
30 [ --with-included-gettext use the GNU gettext library included here],
31 nls_cv_force_use_gnu_gettext=$withval,
32 nls_cv_force_use_gnu_gettext=no)
33 AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
35 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
36 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
37 dnl User does not insist on using GNU NLS library. Figure out what
38 dnl to use. If gettext or catgets are available (in this order) we
39 dnl use this. Else we have to fall back to GNU NLS library.
40 dnl catgets is only used if permitted by option --with-catgets.
45 AC_CHECK_HEADER(libintl.h,
46 [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
47 [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
48 gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
50 if test "$gt_cv_func_gettext_libc" != "yes"; then
51 AC_CHECK_LIB(intl, bindtextdomain,
52 [AC_CACHE_CHECK([for gettext in libintl],
53 gt_cv_func_gettext_libintl,
54 [AC_TRY_LINK([], [return (int) gettext ("")],
55 gt_cv_func_gettext_libintl=yes,
56 gt_cv_func_gettext_libintl=no)])])
59 if test "$gt_cv_func_gettext_libc" = "yes" \
60 || test "$gt_cv_func_gettext_libintl" = "yes"; then
61 AC_DEFINE(HAVE_GETTEXT, 1,
62 [Define as 1 if you have gettext and don't want to use GNU gettext.])
63 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
64 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
65 if test "$MSGFMT" != "no"; then
66 AC_CHECK_FUNCS(dcgettext)
67 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
68 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
69 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
70 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
71 return _nl_msg_cat_cntr],
81 dnl In the standard gettext, we would now check for catgets.
82 dnl However, we never want to use catgets for our releases.
84 if test x"$CATOBJEXT" = x && test -d $srcdir/../intl; then
85 # Neither gettext nor catgets in included in the C library.
86 # Fall back on GNU gettext library (assuming it is present).
87 nls_cv_use_gnu_gettext=yes
91 if test "$nls_cv_use_gnu_gettext" = "yes"; then
92 dnl Mark actions used to generate GNU NLS library.
93 INTLOBJS="\$(GETTOBJS)"
94 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
95 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
96 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
97 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
98 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
100 USE_INCLUDED_LIBINTL=yes
104 INTLDEPS='$(top_builddir)/../intl/libintl.a'
106 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
107 nls_cv_header_intl=libintl.h
108 nls_cv_header_libgt=libgettext.h
111 dnl Test whether we really found GNU xgettext.
112 if test "$XGETTEXT" != ":"; then
113 dnl If it is no GNU xgettext we define it as : so that the
114 dnl Makefiles still can work.
115 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
119 [found xgettext programs is not GNU xgettext; ignore it])
124 # We need to process the po/ directory.
128 nls_cv_header_intl=libintl.h
129 nls_cv_header_libgt=libgettext.h
132 # If this is used in GNU gettext we have to set USE_NLS to `yes'
133 # because some of the sources are only built for this goal.
134 if test "$PACKAGE" = gettext; then
136 USE_INCLUDED_LIBINTL=yes
139 dnl These rules are solely for the distribution goal. While doing this
140 dnl we only have to keep exactly one list of the available catalogs
142 for lang in $ALL_LINGUAS; do
143 GMOFILES="$GMOFILES $lang.gmo"
144 POFILES="$POFILES $lang.po"
147 dnl Make all variables we use known to autoconf.
148 AC_SUBST(USE_INCLUDED_LIBINTL)
151 AC_SUBST(DATADIRNAME)
161 AC_DEFUN([CY_GNU_GETTEXT],
162 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
163 AC_REQUIRE([AC_PROG_CC])dnl
164 AC_REQUIRE([AC_PROG_RANLIB])dnl
165 AC_REQUIRE([AC_ISC_POSIX])dnl
166 AC_REQUIRE([AC_HEADER_STDC])dnl
167 AC_REQUIRE([AC_C_CONST])dnl
168 AC_REQUIRE([AC_C_INLINE])dnl
169 AC_REQUIRE([AC_TYPE_OFF_T])dnl
170 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
171 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
172 AC_REQUIRE([AC_FUNC_MMAP])dnl
174 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
175 unistd.h values.h sys/param.h])
176 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
177 __argz_count __argz_stringify __argz_next])
179 if test "${ac_cv_func_stpcpy+set}" != "set"; then
180 AC_CHECK_FUNCS(stpcpy)
182 if test "${ac_cv_func_stpcpy}" = "yes"; then
183 AC_DEFINE(HAVE_STPCPY, 1, [Define if you have the stpcpy function])
189 if test "x$CATOBJEXT" != "x"; then
190 if test "x$ALL_LINGUAS" = "x"; then
193 AC_MSG_CHECKING(for catalogs to be installed)
195 for lang in ${LINGUAS=$ALL_LINGUAS}; do
196 case "$ALL_LINGUAS" in
197 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
201 AC_MSG_RESULT($LINGUAS)
204 dnl Construct list of names of catalog files to be constructed.
205 if test -n "$LINGUAS"; then
206 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
210 dnl The reference to <locale.h> in the installed <libintl.h> file
211 dnl must be resolved because we cannot expect the users of this
212 dnl to define HAVE_LOCALE_H.
213 if test $ac_cv_header_locale_h = yes; then
214 INCLUDE_LOCALE_H="#include <locale.h>"
217 /* The system does not provide the header <locale.h>. Take care yourself. */"
219 AC_SUBST(INCLUDE_LOCALE_H)
221 dnl Determine which catalog format we have (if any is needed)
222 dnl For now we know about two different formats:
223 dnl Linux libc-5 and the normal X/Open format
224 if test -f $srcdir/po2tbl.sed.in; then
225 if test "$CATOBJEXT" = ".cat"; then
226 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
228 dnl Transform the SED scripts while copying because some dumb SEDs
229 dnl cannot handle comments.
230 sed -e '/^#/d' $srcdir/$msgformat-msg.sed > po2msg.sed
232 dnl po2tbl.sed is always needed.
233 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
234 $srcdir/po2tbl.sed.in > po2tbl.sed
237 dnl In the intl/Makefile.in we have a special dependency which makes
238 dnl only sense for gettext. We comment this out for non-gettext
240 if test "$PACKAGE" = "gettext"; then
250 MKINSTALLDIRS="\$(srcdir)/../../mkinstalldirs"
251 AC_SUBST(MKINSTALLDIRS)
253 dnl *** For now the libtool support in intl/Makefile is not for real.
257 dnl Generate list of files to be processed by xgettext which will
258 dnl be included in po/Makefile. But only do this if the po directory
259 dnl exists in srcdir and contains POTFILES.in.
260 if test -f $srcdir/po/POTFILES.in; then
261 test -d po || mkdir po
262 if test "x$srcdir" != "x."; then
263 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
264 posrcprefix="$srcdir/"
266 posrcprefix="../$srcdir/"
272 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
273 < $srcdir/po/POTFILES.in > po/POTFILES
277 # Search path for a program which passes the given test.
278 # Ulrich Drepper <drepper@cygnus.com>, 1996.
280 # This file file be copied and used freely without restrictions. It can
281 # be used in projects which are not available under the GNU Public License
282 # but which still want to provide support for the GNU gettext functionality.
283 # Please note that the actual code is *not* freely available.
287 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
288 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
289 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
290 [# Extract the first word of "$2", so it can be a program name with args.
291 set dummy $2; ac_word=[$]2
292 AC_MSG_CHECKING([for $ac_word])
293 AC_CACHE_VAL(ac_cv_path_$1,
296 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
299 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
300 for ac_dir in ifelse([$5], , $PATH, [$5]); do
301 test -z "$ac_dir" && ac_dir=.
302 if test -f $ac_dir/$ac_word; then
304 ac_cv_path_$1="$ac_dir/$ac_word"
310 dnl If no 4th arg is given, leave the cache variable unset,
311 dnl so AC_PATH_PROGS will keep looking.
312 ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
317 if test -n "[$]$1"; then
325 # Check whether LC_MESSAGES is available in <locale.h>.
326 # Ulrich Drepper <drepper@cygnus.com>, 1995.
328 # This file file be copied and used freely without restrictions. It can
329 # be used in projects which are not available under the GNU Public License
330 # but which still want to provide support for the GNU gettext functionality.
331 # Please note that the actual code is *not* freely available.
335 AC_DEFUN([AM_LC_MESSAGES],
336 [if test $ac_cv_header_locale_h = yes; then
337 AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
338 [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
339 am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
340 if test $am_cv_val_LC_MESSAGES = yes; then
341 AC_DEFINE(HAVE_LC_MESSAGES, 1,
342 [Define if your locale.h file contains LC_MESSAGES.])