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
7 # Major rework to remove unused code
8 # Owen Taylor <otaylor@redhat.com>, 12/11/2002
10 # This file can be copied and used freely without restrictions. It can
11 # be used in projects which are not available under the GNU Public License
12 # but which still want to provide support for the GNU gettext functionality.
16 # We need this here as well, since someone might use autoconf-2.5x
17 # to configure GLib then an older version to configure a package
18 # using AM_GLIB_GNU_GETTEXT
22 dnl We go to great lengths to make sure that aclocal won't
23 dnl try to pull in the installed version of these macros
24 dnl when running aclocal in the glib directory.
26 m4_copy([AC_DEFUN],[glib_DEFUN])
27 m4_copy([AC_REQUIRE],[glib_REQUIRE])
29 dnl At the end, if we're not within glib, we'll define the public
30 dnl definitions in terms of our private definitions.
35 glib_DEFUN([GLIB_LC_MESSAGES],
36 [AC_CHECK_HEADERS([locale.h])
37 if test $ac_cv_header_locale_h = yes; then
38 AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
39 [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
40 am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
41 if test $am_cv_val_LC_MESSAGES = yes; then
42 AC_DEFINE(HAVE_LC_MESSAGES, 1,
43 [Define if your <locale.h> file defines LC_MESSAGES.])
47 # GLIB_PATH_PROG_WITH_TEST
48 #----------------------------
49 dnl GLIB_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
50 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
51 glib_DEFUN([GLIB_PATH_PROG_WITH_TEST],
52 [# Extract the first word of "$2", so it can be a program name with args.
53 set dummy $2; ac_word=[$]2
54 AC_MSG_CHECKING([for $ac_word])
55 AC_CACHE_VAL(ac_cv_path_$1,
58 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
61 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
62 for ac_dir in ifelse([$5], , $PATH, [$5]); do
63 test -z "$ac_dir" && ac_dir=.
64 if test -f $ac_dir/$ac_word; then
66 ac_cv_path_$1="$ac_dir/$ac_word"
72 dnl If no 4th arg is given, leave the cache variable unset,
73 dnl so AC_PATH_PROGS will keep looking.
74 ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
79 if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
89 glib_DEFUN([GLIB_WITH_NLS],
99 AC_CHECK_HEADER(libintl.h,
100 [gt_cv_func_dgettext_libintl="no"
101 libintl_extra_libs=""
104 # First check in libc
106 AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc,
110 [return (int) dgettext ("","")],
111 gt_cv_func_dgettext_libc=yes,
112 gt_cv_func_dgettext_libc=no)
115 if test "$gt_cv_func_dgettext_libc" = "yes" ; then
116 AC_CHECK_FUNCS(bind_textdomain_codeset)
120 # If we don't have everything we want, check in libintl
122 if test "$gt_cv_func_dgettext_libc" != "yes" \
123 || test "$ac_cv_func_bind_textdomain_codeset" != "yes" ; then
125 AC_CHECK_LIB(intl, bindtextdomain,
126 [AC_CHECK_LIB(intl, dgettext,
127 gt_cv_func_dgettext_libintl=yes)])
129 if test "$gt_cv_func_dgettext_libintl" != "yes" ; then
130 AC_MSG_CHECKING([if -liconv is needed to use gettext])
132 AC_CHECK_LIB(intl, dcgettext,
133 [gt_cv_func_dgettext_libintl=yes
134 libintl_extra_libs=-liconv],
139 # If we found libintl, then check in it for bind_textdomain_codeset();
140 # we'll prefer libc if neither have bind_textdomain_codeset(),
141 # and both have dgettext
143 if test "$gt_cv_func_dgettext_libintl" = "yes" ; then
144 glib_save_LIBS="$LIBS"
145 LIBS="$LIBS -lintl $libintl_extra_libs"
146 unset ac_cv_func_bind_textdomain_codeset
147 AC_CHECK_FUNCS(bind_textdomain_codeset)
148 LIBS="$glib_save_LIBS"
150 if test "$ac_cv_func_bind_textdomain_codeset" = "yes" ; then
151 gt_cv_func_dgettext_libc=no
153 if test "$gt_cv_func_dgettext_libc" = "yes"; then
154 gt_cv_func_dgettext_libintl=no
160 if test "$gt_cv_func_dgettext_libc" = "yes" \
161 || test "$gt_cv_func_dgettext_libintl" = "yes"; then
162 gt_cv_have_gettext=yes
165 if test "$gt_cv_have_gettext" = "yes"; then
166 AC_DEFINE(HAVE_GETTEXT,1,
167 [Define if the GNU gettext() function is already present or preinstalled.])
168 GLIB_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
169 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
170 if test "$MSGFMT" != "no"; then
171 AC_CHECK_FUNCS(dcgettext)
172 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
173 GLIB_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
174 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
175 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
176 return _nl_msg_cat_cntr],
185 LIBS="$glib_save_LIBS"
188 if test "$gt_cv_have_gettext" = "yes" ; then
189 AC_DEFINE(ENABLE_NLS, 1,
190 [always defined to indicate that i18n is enabled])
193 dnl Test whether we really found GNU xgettext.
194 if test "$XGETTEXT" != ":"; then
195 dnl If it is not GNU xgettext we define it as : so that the
196 dnl Makefiles still can work.
197 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
201 [found xgettext program is not GNU xgettext; ignore it])
206 # We need to process the po/ directory.
210 [case "$CONFIG_FILES" in *po/Makefile.in*)
211 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
214 dnl These rules are solely for the distribution goal. While doing this
215 dnl we only have to keep exactly one list of the available catalogs
217 for lang in $ALL_LINGUAS; do
218 GMOFILES="$GMOFILES $lang.gmo"
219 POFILES="$POFILES $lang.po"
222 dnl Make all variables we use known to autoconf.
228 AC_SUBST(PO_IN_DATADIR_TRUE)
229 AC_SUBST(PO_IN_DATADIR_FALSE)
234 # AM_GLIB_GNU_GETTEXT
235 # -------------------
236 # Do checks necessary for use of gettext. If a suitable implementation
237 # of gettext is found in either in libintl or in the C library,
238 # it will set INTLLIBS to the libraries needed for use of gettext
239 # and AC_DEFINE() HAVE_GETTEXT and ENABLE_NLS. (The shell variable
240 # gt_cv_have_gettext will be set to "yes".) It will also call AC_SUBST()
241 # on various variables needed by the Makefile.in.in installed by
244 glib_DEFUN(GLIB_GNU_GETTEXT,
245 [AC_REQUIRE([AC_PROG_CC])dnl
246 AC_REQUIRE([AC_HEADER_STDC])dnl
251 if test "$gt_cv_have_gettext" = "yes"; then
252 if test "x$ALL_LINGUAS" = "x"; then
255 AC_MSG_CHECKING(for catalogs to be installed)
257 for lang in ${LINGUAS=$ALL_LINGUAS}; do
258 case "$ALL_LINGUAS" in
259 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
263 AC_MSG_RESULT($LINGUAS)
266 dnl Construct list of names of catalog files to be constructed.
267 if test -n "$LINGUAS"; then
268 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
272 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
273 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
274 dnl Try to locate is.
276 if test -n "$ac_aux_dir"; then
277 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
279 if test -z "$MKINSTALLDIRS"; then
280 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
282 AC_SUBST(MKINSTALLDIRS)
284 dnl Generate list of files to be processed by xgettext which will
285 dnl be included in po/Makefile.
286 test -d po || mkdir po
287 if test "x$srcdir" != "x."; then
288 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
289 posrcprefix="$srcdir/"
291 posrcprefix="../$srcdir/"
297 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
298 < $srcdir/po/POTFILES.in > po/POTFILES
301 # AM_GLIB_DEFINE_LOCALEDIR(VARIABLE)
302 # -------------------------------
303 # Define VARIABLE to the location where catalog files will
304 # be installed by po/Makefile.
305 glib_DEFUN(GLIB_DEFINE_LOCALEDIR,
306 [glib_REQUIRE([GLIB_GNU_GETTEXT])dnl
307 glib_save_prefix="$prefix"
308 test "x$prefix" = xNONE && prefix=$ac_default_prefix
309 if test "x$CATOBJEXT" = "x.mo" ; then
310 localedir=`eval echo "${libdir}/locale"`
312 localedir=`eval echo "${datadir}/locale"`
314 prefix="$glib_save_prefix"
315 AC_DEFINE_UNQUOTED($1, "$localedir",
316 [Define the location where the catalogs will be installed])
320 dnl Now the definitions that aclocal will find
322 ifdef(glib_configure_in,[],[
323 AC_DEFUN(AM_GLIB_GNU_GETTEXT,[GLIB_GNU_GETTEXT($@)])
324 AC_DEFUN(AM_GLIB_DEFINE_LOCALEDIR,[GLIB_DEFINE_LOCALEDIR($@)])