1 # This file is derived from `gettext.m4'. The difference is that the
2 # included macros assume Cygnus-style source and build trees.
5 dnl This test replaces the one in autoconf.
6 dnl Currently this macro should have the same name as the autoconf macro
7 dnl because gettext's gettext.m4 (distributed in the automake package)
8 dnl still uses it. Otherwise, the use in gettext.m4 makes autoheader
9 dnl give these diagnostics:
10 dnl configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
11 dnl configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
13 undefine([AC_ISC_POSIX])
14 AC_DEFUN(AC_ISC_POSIX,
16 dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
17 AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
21 # Macro to add for using GNU gettext.
22 # Ulrich Drepper <drepper@cygnus.com>, 1995.
24 # This file file be copied and used freely without restrictions. It can
25 # be used in projects which are not available under the GNU Public License
26 # but which still want to provide support for the GNU gettext functionality.
27 # Please note that the actual code is *not* freely available.
32 [AC_MSG_CHECKING([whether NLS is requested])
33 dnl Default is enabled NLS
35 [ --disable-nls do not use Native Language Support],
36 USE_NLS=$enableval, USE_NLS=yes)
37 AC_MSG_RESULT($USE_NLS)
40 USE_INCLUDED_LIBINTL=no
42 dnl If we use NLS figure out what method
43 if test "$USE_NLS" = "yes"; then
44 AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if NLS is requested])
45 AC_MSG_CHECKING([whether included gettext is requested])
46 AC_ARG_WITH(included-gettext,
47 [ --with-included-gettext use the GNU gettext library included here],
48 nls_cv_force_use_gnu_gettext=$withval,
49 nls_cv_force_use_gnu_gettext=no)
50 AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
52 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
53 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
54 dnl User does not insist on using GNU NLS library. Figure out what
55 dnl to use. If gettext or catgets are available (in this order) we
56 dnl use this. Else we have to fall back to GNU NLS library.
57 dnl catgets is only used if permitted by option --with-catgets.
62 AC_CHECK_HEADER(libintl.h,
63 [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
64 [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
65 gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
67 if test "$gt_cv_func_gettext_libc" != "yes"; then
68 AC_CHECK_LIB(intl, bindtextdomain,
69 [AC_CACHE_CHECK([for gettext in libintl],
70 gt_cv_func_gettext_libintl,
71 [AC_TRY_LINK([], [return (int) gettext ("")],
72 gt_cv_func_gettext_libintl=yes,
73 gt_cv_func_gettext_libintl=no)])])
76 if test "$gt_cv_func_gettext_libc" = "yes" \
77 || test "$gt_cv_func_gettext_libintl" = "yes"; then
78 AC_DEFINE(HAVE_GETTEXT, 1,
79 [Define as 1 if you have gettext and don't want to use GNU gettext.])
80 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
81 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
82 if test "$MSGFMT" != "no"; then
83 AC_CHECK_FUNCS(dcgettext)
84 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
85 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
86 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
87 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
88 return _nl_msg_cat_cntr],
98 dnl In the standard gettext, we would now check for catgets.
99 dnl However, we never want to use catgets for our releases.
101 if test "$CATOBJEXT" = "NONE"; then
102 dnl Neither gettext nor catgets in included in the C library.
103 dnl Fall back on GNU gettext library.
104 nls_cv_use_gnu_gettext=yes
108 if test "$nls_cv_use_gnu_gettext" = "yes"; then
109 dnl Mark actions used to generate GNU NLS library.
110 INTLOBJS="\$(GETTOBJS)"
111 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
112 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
113 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
114 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
115 [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=libintl.h
125 nls_cv_header_libgt=libgettext.h
128 dnl Test whether we really found GNU xgettext.
129 if test "$XGETTEXT" != ":"; then
130 dnl If it is no GNU xgettext we define it as : so that the
131 dnl Makefiles still can work.
132 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
136 [found xgettext programs is not GNU xgettext; ignore it])
141 # We need to process the po/ directory.
145 nls_cv_header_intl=libintl.h
146 nls_cv_header_libgt=libgettext.h
149 # If this is used in GNU gettext we have to set USE_NLS to `yes'
150 # because some of the sources are only built for this goal.
151 if test "$PACKAGE" = gettext; then
153 USE_INCLUDED_LIBINTL=yes
156 dnl These rules are solely for the distribution goal. While doing this
157 dnl we only have to keep exactly one list of the available catalogs
159 for lang in $ALL_LINGUAS; do
160 GMOFILES="$GMOFILES $lang.gmo"
161 POFILES="$POFILES $lang.po"
164 dnl Make all variables we use known to autoconf.
165 AC_SUBST(USE_INCLUDED_LIBINTL)
168 AC_SUBST(DATADIRNAME)
178 AC_DEFUN(CY_GNU_GETTEXT,
179 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
180 AC_REQUIRE([AC_PROG_CC])dnl
181 AC_REQUIRE([AC_PROG_RANLIB])dnl
182 AC_REQUIRE([AC_ISC_POSIX])dnl
183 AC_REQUIRE([AC_HEADER_STDC])dnl
184 AC_REQUIRE([AC_C_CONST])dnl
185 AC_REQUIRE([AC_C_INLINE])dnl
186 AC_REQUIRE([AC_TYPE_OFF_T])dnl
187 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
188 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
189 AC_REQUIRE([AC_FUNC_MMAP])dnl
191 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
192 unistd.h values.h sys/param.h])
193 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
194 __argz_count __argz_stringify __argz_next])
196 if test "${ac_cv_func_stpcpy+set}" != "set"; then
197 AC_CHECK_FUNCS(stpcpy)
199 if test "${ac_cv_func_stpcpy}" = "yes"; then
200 AC_DEFINE(HAVE_STPCPY, 1, [Define if you have the stpcpy function])
206 if test "x$CATOBJEXT" != "x"; then
207 if test "x$ALL_LINGUAS" = "x"; then
210 AC_MSG_CHECKING(for catalogs to be installed)
212 for lang in ${LINGUAS=$ALL_LINGUAS}; do
213 case "$ALL_LINGUAS" in
214 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
218 AC_MSG_RESULT($LINGUAS)
221 dnl Construct list of names of catalog files to be constructed.
222 if test -n "$LINGUAS"; then
223 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
227 dnl The reference to <locale.h> in the installed <libintl.h> file
228 dnl must be resolved because we cannot expect the users of this
229 dnl to define HAVE_LOCALE_H.
230 if test $ac_cv_header_locale_h = yes; then
231 INCLUDE_LOCALE_H="#include <locale.h>"
234 /* The system does not provide the header <locale.h>. Take care yourself. */"
236 AC_SUBST(INCLUDE_LOCALE_H)
238 dnl Determine which catalog format we have (if any is needed)
239 dnl For now we know about two different formats:
240 dnl Linux libc-5 and the normal X/Open format
241 if test -f $srcdir/po2tbl.sed.in; then
242 if test "$CATOBJEXT" = ".cat"; then
243 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
245 dnl Transform the SED scripts while copying because some dumb SEDs
246 dnl cannot handle comments.
247 sed -e '/^#/d' $srcdir/$msgformat-msg.sed > po2msg.sed
249 dnl po2tbl.sed is always needed.
250 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
251 $srcdir/po2tbl.sed.in > po2tbl.sed
254 dnl In the intl/Makefile.in we have a special dependency which makes
255 dnl only sense for gettext. We comment this out for non-gettext
257 if test "$PACKAGE" = "gettext"; then
267 MKINSTALLDIRS="\$(srcdir)/../../mkinstalldirs"
268 AC_SUBST(MKINSTALLDIRS)
270 dnl *** For now the libtool support in intl/Makefile is not for real.
274 dnl Generate list of files to be processed by xgettext which will
275 dnl be included in po/Makefile. But only do this if the po directory
276 dnl exists in srcdir and contains POTFILES.in.
277 if test -f $srcdir/po/POTFILES.in; then
278 test -d po || mkdir po
279 if test "x$srcdir" != "x."; then
280 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
281 posrcprefix="$srcdir/"
283 posrcprefix="../$srcdir/"
289 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
290 < $srcdir/po/POTFILES.in > po/POTFILES
294 # Search path for a program which passes the given test.
295 # Ulrich Drepper <drepper@cygnus.com>, 1996.
297 # This file file be copied and used freely without restrictions. It can
298 # be used in projects which are not available under the GNU Public License
299 # but which still want to provide support for the GNU gettext functionality.
300 # Please note that the actual code is *not* freely available.
304 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
305 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
306 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
307 [# Extract the first word of "$2", so it can be a program name with args.
308 set dummy $2; ac_word=[$]2
309 AC_MSG_CHECKING([for $ac_word])
310 AC_CACHE_VAL(ac_cv_path_$1,
313 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
316 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
317 for ac_dir in ifelse([$5], , $PATH, [$5]); do
318 test -z "$ac_dir" && ac_dir=.
319 if test -f $ac_dir/$ac_word; then
321 ac_cv_path_$1="$ac_dir/$ac_word"
327 dnl If no 4th arg is given, leave the cache variable unset,
328 dnl so AC_PATH_PROGS will keep looking.
329 ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
334 if test -n "[$]$1"; then
342 # Check whether LC_MESSAGES is available in <locale.h>.
343 # Ulrich Drepper <drepper@cygnus.com>, 1995.
345 # This file file be copied and used freely without restrictions. It can
346 # be used in projects which are not available under the GNU Public License
347 # but which still want to provide support for the GNU gettext functionality.
348 # Please note that the actual code is *not* freely available.
352 AC_DEFUN(AM_LC_MESSAGES,
353 [if test $ac_cv_header_locale_h = yes; then
354 AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
355 [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
356 am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
357 if test $am_cv_val_LC_MESSAGES = yes; then
358 AC_DEFINE(HAVE_LC_MESSAGES, 1,
359 [Define if your locale.h file contains LC_MESSAGES.])