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 dnl We go to great lengths to make sure that aclocal won't
17 dnl try to pull in the installed version of these macros
18 dnl when running aclocal in the glib directory.
20 m4_copy([AC_DEFUN],[glib_DEFUN])
21 m4_copy([AC_REQUIRE],[glib_REQUIRE])
23 dnl At the end, if we're not within glib, we'll define the public
24 dnl definitions in terms of our private definitions.
29 glib_DEFUN([glib_LC_MESSAGES],
30 [AC_CHECK_HEADERS([locale.h])
31 if test $ac_cv_header_locale_h = yes; then
32 AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
33 [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
34 am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
35 if test $am_cv_val_LC_MESSAGES = yes; then
36 AC_DEFINE(HAVE_LC_MESSAGES, 1,
37 [Define if your <locale.h> file defines LC_MESSAGES.])
41 # GLIB_PATH_PROG_WITH_TEST
42 #----------------------------
43 dnl GLIB_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
44 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
45 glib_DEFUN([GLIB_PATH_PROG_WITH_TEST],
46 [# Extract the first word of "$2", so it can be a program name with args.
47 set dummy $2; ac_word=[$]2
48 AC_MSG_CHECKING([for $ac_word])
49 AC_CACHE_VAL(ac_cv_path_$1,
52 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
55 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
56 for ac_dir in ifelse([$5], , $PATH, [$5]); do
57 test -z "$ac_dir" && ac_dir=.
58 if test -f $ac_dir/$ac_word; then
60 ac_cv_path_$1="$ac_dir/$ac_word"
66 dnl If no 4th arg is given, leave the cache variable unset,
67 dnl so AC_PATH_PROGS will keep looking.
68 ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
73 if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
83 glib_DEFUN([GLIB_WITH_NLS],
93 AC_CHECK_HEADER(libintl.h,
94 [gt_cv_func_dgettext_libintl="no"
100 AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc,
104 [return (int) dgettext ("","")],
105 gt_cv_func_dgettext_libc=yes,
106 gt_cv_func_dgettext_libc=no)
109 if test "$gt_cv_func_dgettext_libc" = "yes" ; then
110 AC_CHECK_FUNCS(bind_textdomain_codeset)
114 # If we don't have everything we want, check in libintl
116 if test "$gt_cv_func_dgettext_libc" != "yes" \
117 || test "$ac_cv_func_bind_textdomain_codeset" != "yes" ; then
119 AC_CHECK_LIB(intl, bindtextdomain,
120 [AC_CHECK_LIB(intl, dgettext,
121 gt_cv_func_dgettext_libintl=yes)])
123 if test "$gt_cv_func_dgettext_libintl" != "yes" ; then
124 AC_MSG_CHECKING([if -liconv is needed to use gettext])
126 AC_CHECK_LIB(intl, dcgettext,
127 [gt_cv_func_dgettext_libintl=yes
128 libintl_extra_libs=-liconv],
133 # If we found libintl, then check in it for bind_textdomain_codeset();
134 # we'll prefer libc if neither have bind_textdomain_codeset(),
135 # and both have dgettext
137 if test "$gt_cv_func_dgettext_libintl" = "yes" ; then
138 glib_save_LIBS="$LIBS"
139 LIBS="$LIBS -lintl $libintl_extra_libs"
140 AC_CHECK_FUNCS(bind_textdomain_codeset)
141 LIBS="$glib_save_LIBS"
143 if test "$ac_cv_func_bind_textdomain_codeset" = "yes" ; then
144 gt_cv_func_dgettext_libc=no
146 if test "$gt_cv_func_dgettext_libc" = "yes"; then
147 gt_cv_func_dgettext_libintl=no
153 if test "$gt_cv_func_dgettext_libc" = "yes" \
154 || test "$gt_cv_func_dgettext_libintl" = "yes"; then
155 gt_cv_have_gettext=yes
158 if test "$gt_cv_have_gettext" = "yes"; then
159 AC_DEFINE(HAVE_GETTEXT,1,
160 [Define if the GNU gettext() function is already present or preinstalled.])
161 GLIB_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
162 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
163 if test "$MSGFMT" != "no"; then
164 AC_CHECK_FUNCS(dcgettext)
165 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
166 GLIB_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
167 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
168 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
169 return _nl_msg_cat_cntr],
178 LIBS="$glib_save_LIBS"
181 if test "$gt_cv_have_gettext" = "yes" ; then
182 AC_DEFINE(ENABLE_NLS, 1,
183 [always defined to indicate that i18n is enabled])
186 dnl Test whether we really found GNU xgettext.
187 if test "$XGETTEXT" != ":"; then
188 dnl If it is not GNU xgettext we define it as : so that the
189 dnl Makefiles still can work.
190 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
194 [found xgettext program is not GNU xgettext; ignore it])
199 # We need to process the po/ directory.
203 [case "$CONFIG_FILES" in *po/Makefile.in*)
204 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
207 dnl These rules are solely for the distribution goal. While doing this
208 dnl we only have to keep exactly one list of the available catalogs
210 for lang in $ALL_LINGUAS; do
211 GMOFILES="$GMOFILES $lang.gmo"
212 POFILES="$POFILES $lang.po"
215 dnl Make all variables we use known to autoconf.
221 AC_SUBST(PO_IN_DATADIR_TRUE)
222 AC_SUBST(PO_IN_DATADIR_FALSE)
227 # AM_GLIB_GNU_GETTEXT
228 # -------------------
229 # Do checks necessary for use of gettext. If a suitable implementation
230 # of gettext is found in either in libintl or in the C library,
231 # it will set INTLLIBS to the libraries needed for use of gettext
232 # and AC_DEFINE() HAVE_GETTEXT and ENABLE_NLS. (The shell variable
233 # gt_cv_have_gettext will be set to "yes".) It will also call AC_SUBST()
234 # on various variables needed by the Makefile.in.in installed by
237 glib_DEFUN(GLIB_GNU_GETTEXT,
238 [AC_REQUIRE([AC_PROG_CC])dnl
239 AC_REQUIRE([AC_HEADER_STDC])dnl
244 if test "$gt_cv_have_gettext" = "yes"; then
245 if test "x$ALL_LINGUAS" = "x"; then
248 AC_MSG_CHECKING(for catalogs to be installed)
250 for lang in ${LINGUAS=$ALL_LINGUAS}; do
251 case "$ALL_LINGUAS" in
252 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
256 AC_MSG_RESULT($LINGUAS)
259 dnl Construct list of names of catalog files to be constructed.
260 if test -n "$LINGUAS"; then
261 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
265 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
266 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
267 dnl Try to locate is.
269 if test -n "$ac_aux_dir"; then
270 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
272 if test -z "$MKINSTALLDIRS"; then
273 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
275 AC_SUBST(MKINSTALLDIRS)
277 dnl Generate list of files to be processed by xgettext which will
278 dnl be included in po/Makefile.
279 test -d po || mkdir po
280 if test "x$srcdir" != "x."; then
281 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
282 posrcprefix="$srcdir/"
284 posrcprefix="../$srcdir/"
290 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
291 < $srcdir/po/POTFILES.in > po/POTFILES
294 # AM_GLIB_DEFINE_LOCALEDIR(VARIABLE)
295 # -------------------------------
296 # Define VARIABLE to the location where catalog files will
297 # be installed by po/Makefile.
298 glib_DEFUN(GLIB_DEFINE_LOCALEDIR,
299 [glib_REQUIRE([GLIB_GNU_GETTEXT])dnl
300 glib_save_prefix="$prefix"
301 test "x$prefix" = xNONE && prefix=$ac_default_prefix
302 if test "x$CATOBJEXT" = "x.mo" ; then
303 localedir=`eval echo "${libdir}/locale"`
305 localedir=`eval echo "${datadir}/locale"`
307 prefix="$glib_save_prefix"
308 AC_DEFINE_UNQUOTED($1, "$localedir",
309 [Define the location where the catalogs will be installed])
313 dnl Now the definitions that aclocal will find
315 ifdef(glib_configure_in,[],[
316 AC_DEFUN(AM_GLIB_GNU_GETTEXT,[GLIB_GNU_GETTEXT($@)])
317 AC_DEFUN(AM_GLIB_DEFINE_LOCALEDIR,[GLIB_DEFINE_LOCALEDIR($@)])