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 unset ac_cv_func_bind_textdomain_codeset
141 AC_CHECK_FUNCS(bind_textdomain_codeset)
142 LIBS="$glib_save_LIBS"
144 if test "$ac_cv_func_bind_textdomain_codeset" = "yes" ; then
145 gt_cv_func_dgettext_libc=no
147 if test "$gt_cv_func_dgettext_libc" = "yes"; then
148 gt_cv_func_dgettext_libintl=no
154 if test "$gt_cv_func_dgettext_libc" = "yes" \
155 || test "$gt_cv_func_dgettext_libintl" = "yes"; then
156 gt_cv_have_gettext=yes
159 if test "$gt_cv_have_gettext" = "yes"; then
160 AC_DEFINE(HAVE_GETTEXT,1,
161 [Define if the GNU gettext() function is already present or preinstalled.])
162 GLIB_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
163 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
164 if test "$MSGFMT" != "no"; then
165 AC_CHECK_FUNCS(dcgettext)
166 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
167 GLIB_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
168 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
169 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
170 return _nl_msg_cat_cntr],
179 LIBS="$glib_save_LIBS"
182 if test "$gt_cv_have_gettext" = "yes" ; then
183 AC_DEFINE(ENABLE_NLS, 1,
184 [always defined to indicate that i18n is enabled])
187 dnl Test whether we really found GNU xgettext.
188 if test "$XGETTEXT" != ":"; then
189 dnl If it is not GNU xgettext we define it as : so that the
190 dnl Makefiles still can work.
191 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
195 [found xgettext program is not GNU xgettext; ignore it])
200 # We need to process the po/ directory.
204 [case "$CONFIG_FILES" in *po/Makefile.in*)
205 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
208 dnl These rules are solely for the distribution goal. While doing this
209 dnl we only have to keep exactly one list of the available catalogs
211 for lang in $ALL_LINGUAS; do
212 GMOFILES="$GMOFILES $lang.gmo"
213 POFILES="$POFILES $lang.po"
216 dnl Make all variables we use known to autoconf.
222 AC_SUBST(PO_IN_DATADIR_TRUE)
223 AC_SUBST(PO_IN_DATADIR_FALSE)
228 # AM_GLIB_GNU_GETTEXT
229 # -------------------
230 # Do checks necessary for use of gettext. If a suitable implementation
231 # of gettext is found in either in libintl or in the C library,
232 # it will set INTLLIBS to the libraries needed for use of gettext
233 # and AC_DEFINE() HAVE_GETTEXT and ENABLE_NLS. (The shell variable
234 # gt_cv_have_gettext will be set to "yes".) It will also call AC_SUBST()
235 # on various variables needed by the Makefile.in.in installed by
238 glib_DEFUN(GLIB_GNU_GETTEXT,
239 [AC_REQUIRE([AC_PROG_CC])dnl
240 AC_REQUIRE([AC_HEADER_STDC])dnl
245 if test "$gt_cv_have_gettext" = "yes"; then
246 if test "x$ALL_LINGUAS" = "x"; then
249 AC_MSG_CHECKING(for catalogs to be installed)
251 for lang in ${LINGUAS=$ALL_LINGUAS}; do
252 case "$ALL_LINGUAS" in
253 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
257 AC_MSG_RESULT($LINGUAS)
260 dnl Construct list of names of catalog files to be constructed.
261 if test -n "$LINGUAS"; then
262 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
266 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
267 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
268 dnl Try to locate is.
270 if test -n "$ac_aux_dir"; then
271 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
273 if test -z "$MKINSTALLDIRS"; then
274 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
276 AC_SUBST(MKINSTALLDIRS)
278 dnl Generate list of files to be processed by xgettext which will
279 dnl be included in po/Makefile.
280 test -d po || mkdir po
281 if test "x$srcdir" != "x."; then
282 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
283 posrcprefix="$srcdir/"
285 posrcprefix="../$srcdir/"
291 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
292 < $srcdir/po/POTFILES.in > po/POTFILES
295 # AM_GLIB_DEFINE_LOCALEDIR(VARIABLE)
296 # -------------------------------
297 # Define VARIABLE to the location where catalog files will
298 # be installed by po/Makefile.
299 glib_DEFUN(GLIB_DEFINE_LOCALEDIR,
300 [glib_REQUIRE([GLIB_GNU_GETTEXT])dnl
301 glib_save_prefix="$prefix"
302 test "x$prefix" = xNONE && prefix=$ac_default_prefix
303 if test "x$CATOBJEXT" = "x.mo" ; then
304 localedir=`eval echo "${libdir}/locale"`
306 localedir=`eval echo "${datadir}/locale"`
308 prefix="$glib_save_prefix"
309 AC_DEFINE_UNQUOTED($1, "$localedir",
310 [Define the location where the catalogs will be installed])
314 dnl Now the definitions that aclocal will find
316 ifdef(glib_configure_in,[],[
317 AC_DEFUN(AM_GLIB_GNU_GETTEXT,[GLIB_GNU_GETTEXT($@)])
318 AC_DEFUN(AM_GLIB_DEFINE_LOCALEDIR,[GLIB_DEFINE_LOCALEDIR($@)])