1 # Macro to add for using GNU gettext.
2 # Ulrich Drepper <drepper@cygnus.com>, 1995.
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.
15 AC_DEFUN(AM_GNOME_WITH_NLS,
16 [AC_MSG_CHECKING([whether NLS is requested])
17 dnl Default is enabled NLS
19 [ --disable-nls do not use Native Language Support],
20 USE_NLS=$enableval, USE_NLS=yes)
21 AC_MSG_RESULT($USE_NLS)
24 USE_INCLUDED_LIBINTL=no
26 dnl If we use NLS figure out what method
27 if test "$USE_NLS" = "yes"; then
29 # AC_MSG_CHECKING([whether included gettext is requested])
30 # AC_ARG_WITH(included-gettext,
31 # [ --with-included-gettext use the GNU gettext library included here],
32 # nls_cv_force_use_gnu_gettext=$withval,
33 # nls_cv_force_use_gnu_gettext=no)
34 # AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
35 nls_cv_force_use_gnu_gettext="no"
37 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
38 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
39 dnl User does not insist on using GNU NLS library. Figure out what
40 dnl to use. If gettext or catgets are available (in this order) we
41 dnl use this. Else we have to fall back to GNU NLS library.
42 dnl catgets is only used if permitted by option --with-catgets.
47 AC_CHECK_HEADER(libintl.h,
48 [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
49 [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
50 gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
52 if test "$gt_cv_func_gettext_libc" != "yes"; then
53 AC_CHECK_LIB(intl, bindtextdomain,
54 [AC_CACHE_CHECK([for gettext in libintl],
55 gt_cv_func_gettext_libintl,
56 [AC_CHECK_LIB(intl, gettext,
57 gt_cv_func_gettext_libintl=yes,
58 gt_cv_func_gettext_libintl=no)],
59 gt_cv_func_gettext_libintl=no)])
62 if test "$gt_cv_func_gettext_libc" = "yes" \
63 || test "$gt_cv_func_gettext_libintl" = "yes"; then
64 AC_DEFINE(HAVE_GETTEXT)
65 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
66 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
67 if test "$MSGFMT" != "no"; then
68 AC_CHECK_FUNCS(dcgettext)
69 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
70 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
71 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
72 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
73 return _nl_msg_cat_cntr],
82 # Added by Martin Baulig 12/15/98 for libc5 systems
83 if test "$gt_cv_func_gettext_libc" != "yes" \
84 && test "$gt_cv_func_gettext_libintl" = "yes"; then
86 LIBS=`echo $LIBS | sed -e 's/-lintl//'`
90 if test "$CATOBJEXT" = "NONE"; then
91 AC_MSG_CHECKING([whether catgets can be used])
93 [ --with-catgets use catgets functions if available],
94 nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
95 AC_MSG_RESULT($nls_cv_use_catgets)
97 if test "$nls_cv_use_catgets" = "yes"; then
98 dnl No gettext in C library. Try catgets next.
100 AC_CHECK_FUNC(catgets,
101 [AC_DEFINE(HAVE_CATGETS)
102 INTLOBJS="\$(CATOBJS)"
103 AC_PATH_PROG(GENCAT, gencat, no)dnl
104 # if test "$GENCAT" != "no"; then
105 # AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
106 # if test "$GMSGFMT" = "no"; then
107 # AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
108 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
110 # AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
111 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
112 # USE_INCLUDED_LIBINTL=yes
116 # INTLDEPS='$(top_builddir)/intl/libintl.a'
118 # LIBS=`echo $LIBS | sed -e 's/-lintl//'`
119 # nls_cv_header_intl=intl/libintl.h
120 # nls_cv_header_libgt=intl/libgettext.h
126 if test "$CATOBJEXT" = "NONE"; then
127 dnl Neither gettext nor catgets in included in the C library.
128 dnl Fall back on GNU gettext library.
129 nls_cv_use_gnu_gettext=yes
133 if test "$nls_cv_use_gnu_gettext" != "yes"; then
134 AC_DEFINE(ENABLE_NLS)
136 # Unset this variable since we use the non-zero value as a flag.
138 # dnl Mark actions used to generate GNU NLS library.
139 # INTLOBJS="\$(GETTOBJS)"
140 # AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
141 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
142 # AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
143 # AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
144 # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
146 # USE_INCLUDED_LIBINTL=yes
150 # INTLDEPS='$(top_builddir)/intl/libintl.a'
152 # LIBS=`echo $LIBS | sed -e 's/-lintl//'`
153 # nls_cv_header_intl=intl/libintl.h
154 # nls_cv_header_libgt=intl/libgettext.h
157 dnl Test whether we really found GNU xgettext.
158 if test "$XGETTEXT" != ":"; then
159 dnl If it is no GNU xgettext we define it as : so that the
160 dnl Makefiles still can work.
161 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
165 [found xgettext program is not GNU xgettext; ignore it])
170 # We need to process the po/ directory.
174 nls_cv_header_intl=intl/libintl.h
175 nls_cv_header_libgt=intl/libgettext.h
177 AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
179 [case "$CONFIG_FILES" in *po/Makefile.in*)
180 sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
184 # # If this is used in GNU gettext we have to set USE_NLS to `yes'
185 # # because some of the sources are only built for this goal.
186 # if test "$PACKAGE" = gettext; then
188 # USE_INCLUDED_LIBINTL=yes
191 dnl These rules are solely for the distribution goal. While doing this
192 dnl we only have to keep exactly one list of the available catalogs
194 for lang in $ALL_LINGUAS; do
195 GMOFILES="$GMOFILES $lang.gmo"
196 POFILES="$POFILES $lang.po"
199 dnl Make all variables we use known to autoconf.
200 AC_SUBST(USE_INCLUDED_LIBINTL)
203 AC_SUBST(DATADIRNAME)
213 AC_DEFUN(AM_GNOME_GETTEXT,
214 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
215 AC_REQUIRE([AC_PROG_CC])dnl
216 AC_REQUIRE([AC_PROG_RANLIB])dnl
217 AC_REQUIRE([AC_ISC_POSIX])dnl
218 AC_REQUIRE([AC_HEADER_STDC])dnl
219 AC_REQUIRE([AC_C_CONST])dnl
220 AC_REQUIRE([AC_C_INLINE])dnl
221 AC_REQUIRE([AC_TYPE_OFF_T])dnl
222 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
223 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
224 AC_REQUIRE([AC_FUNC_MMAP])dnl
226 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
227 unistd.h sys/param.h])
228 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
229 strdup __argz_count __argz_stringify __argz_next])
231 if test "${ac_cv_func_stpcpy+set}" != "set"; then
232 AC_CHECK_FUNCS(stpcpy)
234 if test "${ac_cv_func_stpcpy}" = "yes"; then
235 AC_DEFINE(HAVE_STPCPY)
241 if test "x$CATOBJEXT" != "x"; then
242 if test "x$ALL_LINGUAS" = "x"; then
245 AC_MSG_CHECKING(for catalogs to be installed)
247 if test "x$LINGUAS" = "x"; then
250 for lang in $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 The reference to <locale.h> in the installed <libintl.h> file
266 dnl must be resolved because we cannot expect the users of this
267 dnl to define HAVE_LOCALE_H.
268 if test $ac_cv_header_locale_h = yes; then
269 INCLUDE_LOCALE_H="#include <locale.h>"
272 /* The system does not provide the header <locale.h>. Take care yourself. */"
274 AC_SUBST(INCLUDE_LOCALE_H)
276 dnl Determine which catalog format we have (if any is needed)
277 dnl For now we know about two different formats:
278 dnl Linux libc-5 and the normal X/Open format
279 test -d intl || mkdir intl
280 if test "$CATOBJEXT" = ".cat"; then
281 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
283 dnl Transform the SED scripts while copying because some dumb SEDs
284 dnl cannot handle comments.
285 sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
287 dnl po2tbl.sed is always needed.
288 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
289 $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
291 dnl In the intl/Makefile.in we have a special dependency which makes
292 dnl only sense for gettext. We comment this out for non-gettext
294 if test "$PACKAGE" = "gettext"; then
304 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
305 dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
306 dnl Try to locate is.
308 if test -n "$ac_aux_dir"; then
309 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
311 if test -z "$MKINSTALLDIRS"; then
312 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
314 AC_SUBST(MKINSTALLDIRS)
316 dnl *** For now the libtool support in intl/Makefile is not for real.
320 dnl Generate list of files to be processed by xgettext which will
321 dnl be included in po/Makefile.
322 test -d po || mkdir po
323 if test "x$srcdir" != "x."; then
324 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
325 posrcprefix="$srcdir/"
327 posrcprefix="../$srcdir/"
333 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
334 < $srcdir/po/POTFILES.in > po/POTFILES
338 AC_DEFUN(AM_PATH_GNOME,
340 dnl Get the cflags and libraries from the gnome-config script
342 AC_ARG_WITH(gnome-prefix,[ --with-gnome-prefix=PFX Prefix where GNOME is installed (optional)],
343 gnome_config_prefix="$withval", gnome_config_prefix="")
344 AC_ARG_WITH(gnome-exec-prefix,[ --with-gnome-exec-prefix=PFX Exec prefix where GNOME is installed (optional)],
345 gnome_config_exec_prefix="$withval", gnome_config_exec_prefix="")
347 if test x$gnome_config_exec_prefix != x ; then
348 gnome_config_args="$gnome_config_args --exec-prefix=$gnome_config_exec_prefix"
349 if test x${GNOME_CONFIG+set} != xset ; then
350 GNOME_CONFIG=$gnome_config_exec_prefix/bin/gnome-config
353 if test x$gnome_config_prefix != x ; then
354 gnome_config_args="$gnome_config_args --prefix=$gnome_config_prefix"
355 if test x${GNOME_CONFIG+set} != xset ; then
356 GNOME_CONFIG=$gnome_config_prefix/bin/gnome-config
360 AC_PATH_PROG(GNOME_CONFIG, gnome-config, no)
361 min_gnome_version=ifelse([$1], , 1.1.0, $1)
363 AC_MSG_CHECKING(for GNOME - version >= $min_gnome_version)
365 if test "$GNOME_CONFIG" = "no" ; then
368 GNOME_CFLAGS="`$GNOME_CONFIG $gnome_config_args --cflags gnome`"
369 GNOME_LIBS="`$GNOME_CONFIG $gnome_config_args --libs gnome`"
370 GNOMEUI_CFLAGS="`$GNOME_CONFIG $gnome_config_args --cflags gnomeui`"
371 GNOMEUI_LIBS="`$GNOME_CONFIG $gnome_config_args --libs gnomeui`"
373 gnome_config_major_version=`$GNOME_CONFIG $gnome_config_args --version | \
374 sed 's/[[^0-9]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
375 gnome_config_minor_version=`$GNOME_CONFIG $gnome_config_args --version | \
376 sed 's/[[^0-9]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
377 gnome_config_micro_version=`$GNOME_CONFIG $gnome_config_args --version | \
378 sed 's/[[^0-9]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
379 needed_major_version=`echo $min_gnome_version | \
380 sed 's/[[^0-9]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
381 needed_minor_version=`echo $min_gnome_version | \
382 sed 's/[[^0-9]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
383 needed_micro_version=`echo $min_gnome_version | \
384 sed 's/[[^0-9]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
386 if test $gnome_config_major_version -lt $needed_major_version; then
387 ifelse([$3], , :, [$3])
389 elif test $gnome_config_major_version = $needed_major_version; then
390 if test -n "$needed_minor_version" -a $gnome_config_minor_version -lt $needed_minor_version; then
391 ifelse([$3], , :, [$3])
393 elif test -n "$needed_minor_version" -a $gnome_config_minor_version = $needed_minor_version; then
394 if test -n "$needed_micro_version" -a $gnome_config_micro_version -lt $needed_micro_version; then
395 ifelse([$3], , :, [$3])
401 AC_SUBST(GNOME_CFLAGS)
403 AC_SUBST(GNOMEUI_CFLAGS)
404 AC_SUBST(GNOMEUI_LIBS)
406 if test "x$no_gnome" = x ; then
408 ifelse([$2], , :, [$2])
411 if test "$GNOME_CONFIG" = "no" ; then
412 echo "*** The gnome-config script installed by GNOME could not be found"
413 echo "*** If GNOME was installed in PREFIX, make sure PREFIX/bin is in"
414 echo "*** your path, or set the GNOME_CONFIG environment variable to the"
415 echo "*** full path to gnome-config."
421 ifelse([$3], , :, [$3])
424 tmp_gnome_libdir=`$GNOME_CONFIG $gnome_config_args --libdir`
425 if test -n "$4"; then
426 AC_MSG_CHECKING([for additional GNOME modules])
428 for module in $4 ""; do
430 if test "$module" = zvt; then
431 ZVT_LIBS="`$GNOME_CONFIG $gnome_config_args --libs zvt`"
433 elif test "$module" = gtk; then
434 GTK_CFLAGS="`$GNOME_CONFIG $gnome_config_args --cflags gtk`"
435 GTK_LIBS="`$GNOME_CONFIG $gnome_config_args --libs gtk`"
438 elif test "$module" = "glib"; then
439 GLIB_CFLAGS="`$GNOME_CONFIG $gnome_config_args --cflags glib`"
440 GLIB_LIBS="`$GNOME_CONFIG $gnome_config_args --libs glib`"
441 AC_SUBST(GLIB_CFLAGS)
443 elif test "$module" = "oaf"; then
444 OAF_CFLAGS="`$GNOME_CONFIG $gnome_config_args --cflags oaf`"
445 OAF_LIBS="`$GNOME_CONFIG $gnome_config_args --libs oaf`"
448 elif test "$module" = "gnorba"; then
449 GNORBA_CFLAGS="`$GNOME_CONFIG $gnome_config_args --cflags gnorba`"
450 GNORBA_LIBS="`$GNOME_CONFIG $gnome_config_args --libs gnorba`"
451 AC_SUBST(GNORBA_CFLAGS)
452 AC_SUBST(GNORBA_LIBS)
453 elif test -n "$module"; then
454 if $GNOME_CONFIG $gnome_config_args --cflags $module >/dev/null 2>&1; then
455 tmp_bsnom=`echo $module | tr a-z A-Z`
456 eval $tmp_bsnom'_CFLAGS'=\"`$GNOME_CONFIG $gnome_config_args --cflags $module`\"
457 eval $tmp_bsnom'_LIBS'=\"`$GNOME_CONFIG $gnome_config_args --libs $module`\"
459 AC_MSG_RESULT([*** $module library is not installed])
460 ifelse([$3], , :, [$3])
461 gnome_m4_notfound=yes
464 if test "$gnome_m4_notfound" = no; then
465 echo $ac_n " $module" 1>&6
468 if test -n "$4"; then