1 # Macro to add for using GNU gettext.
2 # Ulrich Drepper <drepper@cygnus.com>, 1995, 1996
4 # Modified to never use included libintl.
5 # Owen Taylor <otaylor@redhat.com>, 12/15/1998
8 # This file can be copied and used freely without restrictions. It can
9 # be used in projects which are not available under the GNU Public License
10 # but which still want to provide support for the GNU gettext functionality.
11 # Please note that the actual code is *not* freely available.
14 # If you make changes to this file, you MUST update the copy in
15 # acinclude.m4. [ aclocal dies on duplicate macros, so if
16 # we run 'aclocal -I macros/' then we'll run into problems
17 # once we've installed glib-gettext.m4 :-( ]
20 AC_DEFUN([AM_GLIB_LC_MESSAGES],
21 [if test $ac_cv_header_locale_h = yes; then
22 AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
23 [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
24 am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
25 if test $am_cv_val_LC_MESSAGES = yes; then
26 AC_DEFINE(HAVE_LC_MESSAGES, 1,
27 [Define if your <locale.h> file defines LC_MESSAGES.])
31 dnl AM_GLIB_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
32 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
33 AC_DEFUN([AM_GLIB_PATH_PROG_WITH_TEST],
34 [# Extract the first word of "$2", so it can be a program name with args.
35 set dummy $2; ac_word=[$]2
36 AC_MSG_CHECKING([for $ac_word])
37 AC_CACHE_VAL(ac_cv_path_$1,
40 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
43 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
44 for ac_dir in ifelse([$5], , $PATH, [$5]); do
45 test -z "$ac_dir" && ac_dir=.
46 if test -f $ac_dir/$ac_word; then
48 ac_cv_path_$1="$ac_dir/$ac_word"
54 dnl If no 4th arg is given, leave the cache variable unset,
55 dnl so AC_PATH_PROGS will keep looking.
56 ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
61 if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
71 AC_DEFUN(AM_GLIB_WITH_NLS,
76 dnl Figure out what method
77 nls_cv_force_use_gnu_gettext="no"
79 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
80 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
81 dnl User does not insist on using GNU NLS library. Figure out what
82 dnl to use. If gettext or catgets are available (in this order) we
83 dnl use this. Else we have to fall back to GNU NLS library.
84 dnl catgets is only used if permitted by option --with-catgets.
90 AC_CHECK_HEADER(libintl.h,
91 [AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc,
92 [AC_TRY_LINK([#include <libintl.h>], [return (int) dgettext ("","")],
93 gt_cv_func_dgettext_libc=yes, gt_cv_func_dgettext_libc=no)])
95 gt_cv_func_dgettext_libintl="no"
98 if test "$gt_cv_func_dgettext_libc" != "yes" ; then
99 AC_CHECK_LIB(intl, bindtextdomain,
100 [AC_CHECK_LIB(intl, dgettext,
101 gt_cv_func_dgettext_libintl=yes)])
103 if test "$gt_cv_func_dgettext_libc" != "yes" ; then
104 AC_MSG_NOTICE([Seeing if -liconv is needed to use gettext])
105 AC_CHECK_LIB(intl, dcgettext,
106 [gt_cv_func_dgettext_libintl=yes
107 libintl_extra_libs=-liconv],
112 if test "$gt_cv_func_dgettext_libintl" = "yes"; then
113 LIBS="$LIBS -lintl $libintl_extra_libs";
116 if test "$gt_cv_func_dgettext_libc" = "yes" \
117 || test "$gt_cv_func_dgettext_libintl" = "yes"; then
118 AC_DEFINE(HAVE_GETTEXT,1,
119 [Define if the GNU gettext() function is already present or preinstalled.])
120 AM_GLIB_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
121 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
122 if test "$MSGFMT" != "no"; then
123 AC_CHECK_FUNCS(dcgettext)
124 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
125 AM_GLIB_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
126 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
127 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
128 return _nl_msg_cat_cntr],
137 # Added by Martin Baulig 12/15/98 for libc5 systems
138 if test "$gt_cv_func_dgettext_libc" != "yes" \
139 && test "$gt_cv_func_dgettext_libintl" = "yes"; then
140 INTLLIBS="-lintl $libintl_extra_libs"
141 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
145 if test "$CATOBJEXT" = "NONE"; then
146 dnl Neither gettext nor catgets in included in the C library.
147 dnl Fall back on GNU gettext library.
148 nls_cv_use_gnu_gettext=yes
152 if test "$nls_cv_use_gnu_gettext" != "yes"; then
153 AC_DEFINE(ENABLE_NLS, 1,
154 [always defined to indicate that i18n is enabled])
156 dnl Unset this variable since we use the non-zero value as a flag.
160 dnl Test whether we really found GNU xgettext.
161 if test "$XGETTEXT" != ":"; then
162 dnl If it is no GNU xgettext we define it as : so that the
163 dnl Makefiles still can work.
164 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
168 [found xgettext program is not GNU xgettext; ignore it])
173 # We need to process the po/ directory.
177 [case "$CONFIG_FILES" in *po/Makefile.in*)
178 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
181 dnl These rules are solely for the distribution goal. While doing this
182 dnl we only have to keep exactly one list of the available catalogs
184 for lang in $ALL_LINGUAS; do
185 GMOFILES="$GMOFILES $lang.gmo"
186 POFILES="$POFILES $lang.po"
189 dnl Make all variables we use known to autoconf.
192 AC_SUBST(DATADIRNAME)
202 AC_DEFUN(AM_GLIB_GNU_GETTEXT,
203 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
204 AC_REQUIRE([AC_PROG_CC])dnl
205 AC_REQUIRE([AC_PROG_RANLIB])dnl
206 AC_REQUIRE([AC_HEADER_STDC])dnl
207 AC_REQUIRE([AC_C_CONST])dnl
208 AC_REQUIRE([AC_C_INLINE])dnl
209 AC_REQUIRE([AC_TYPE_OFF_T])dnl
210 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
211 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
212 AC_REQUIRE([AC_FUNC_MMAP])dnl
214 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
215 unistd.h sys/param.h])
216 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
217 strdup __argz_count __argz_stringify __argz_next])
222 if test "x$CATOBJEXT" != "x"; then
223 if test "x$ALL_LINGUAS" = "x"; then
226 AC_MSG_CHECKING(for catalogs to be installed)
228 for lang in ${LINGUAS=$ALL_LINGUAS}; do
229 case "$ALL_LINGUAS" in
230 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
234 AC_MSG_RESULT($LINGUAS)
237 dnl Construct list of names of catalog files to be constructed.
238 if test -n "$LINGUAS"; then
239 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
243 dnl Determine which catalog format we have (if any is needed)
244 dnl For now we know about two different formats:
245 dnl Linux libc-5 and the normal X/Open format
246 test -d po || mkdir po
247 if test "$CATOBJEXT" = ".cat"; then
248 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
250 dnl Transform the SED scripts while copying because some dumb SEDs
251 dnl cannot handle comments.
252 sed -e '/^#/d' $srcdir/po/$msgformat-msg.sed > po/po2msg.sed
255 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
256 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
257 dnl Try to locate is.
259 if test -n "$ac_aux_dir"; then
260 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
262 if test -z "$MKINSTALLDIRS"; then
263 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
265 AC_SUBST(MKINSTALLDIRS)
267 dnl Generate list of files to be processed by xgettext which will
268 dnl be included in po/Makefile.
269 test -d po || mkdir po
270 if test "x$srcdir" != "x."; then
271 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
272 posrcprefix="$srcdir/"
274 posrcprefix="../$srcdir/"
280 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
281 < $srcdir/po/POTFILES.in > po/POTFILES
285 dnl @synopsis AC_FUNC_VSNPRINTF_C99
287 dnl Check whether there is a vsnprintf() function with C99 semantics installed.
289 AC_DEFUN([AC_FUNC_VSNPRINTF_C99],
290 [AC_CACHE_CHECK(for C99 vsnprintf,
291 ac_cv_func_vsnprintf_c99,
304 r = vsnprintf(buffer, 5, s, args);
318 }], ac_cv_func_vsnprintf_c99=yes, ac_cv_func_vsnprintf_c99=no, ac_cv_func_vsnprintf_c99=no)])
319 dnl Note that the default is to be pessimistic in the case of cross compilation.
320 dnl If you know that the target has a C99 vsnprintf(), you can get around this
321 dnl by setting ac_func_vsnprintf_c99 to yes, as described in the Autoconf manual.
322 if test $ac_cv_func_vsnprintf_c99 = yes; then
323 AC_DEFINE(HAVE_C99_VSNPRINTF, 1,
324 [Define if you have a version of the vsnprintf function
325 with semantics as specified by the ISO C99 standard.])
327 ])# AC_FUNC_VSNPRINTF_C99