source: trunk/third/GConf2/acinclude.m4 @ 18253

Revision 18253, 10.9 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18252, which included commits to RCS files with non-trunk default branches.
Line 
1
2# Macro to add for using GNU gettext.
3# Ulrich Drepper <drepper@cygnus.com>, 1995.
4#
5# Modified to never use included libintl.
6# Owen Taylor <otaylor@redhat.com>, 12/15/1998
7#
8#
9# This file can be copied and used freely without restrictions.  It can
10# be used in projects which are not available under the GNU Public License
11# but which still want to provide support for the GNU gettext functionality.
12# Please note that the actual code is *not* freely available.
13
14# serial 5
15
16AC_DEFUN(AM_GCONF_WITH_NLS,
17  [AC_MSG_CHECKING([whether NLS is requested])
18    dnl Default is enabled NLS
19    AC_ARG_ENABLE(nls,
20      [  --disable-nls           do not use Native Language Support],
21      USE_NLS=$enableval, USE_NLS=yes)
22    AC_MSG_RESULT($USE_NLS)
23    AC_SUBST(USE_NLS)
24
25    BUILD_INCLUDED_LIBINTL=no
26    USE_INCLUDED_LIBINTL=no
27
28    dnl If we use NLS figure out what method
29    if test "$USE_NLS" = "yes"; then
30#      AC_DEFINE(ENABLE_NLS)
31#      AC_MSG_CHECKING([whether included gettext is requested])
32#      AC_ARG_WITH(included-gettext,
33#        [  --with-included-gettext use the GNU gettext library included here],
34#        nls_cv_force_use_gnu_gettext=$withval,
35#        nls_cv_force_use_gnu_gettext=no)
36#      AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
37      nls_cv_force_use_gnu_gettext="no"
38
39      nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
40      if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
41        dnl User does not insist on using GNU NLS library.  Figure out what
42        dnl to use.  If gettext or catgets are available (in this order) we
43        dnl use this.  Else we have to fall back to GNU NLS library.
44        dnl catgets is only used if permitted by option --with-catgets.
45        nls_cv_header_intl=
46        nls_cv_header_libgt=
47        CATOBJEXT=NONE
48
49        AC_CHECK_HEADER(libintl.h,
50          [AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc,
51            [AC_TRY_LINK([#include <libintl.h>], [return (int) dgettext ("","")],
52               gt_cv_func_dgettext_libc=yes, gt_cv_func_dgettext_libc=no)])
53
54           if test "$gt_cv_func_dgettext_libc" != "yes"; then
55             AC_CHECK_LIB(intl, bindtextdomain,
56               [AC_CACHE_CHECK([for dgettext in libintl],
57                 gt_cv_func_dgettext_libintl,
58                 [AC_CHECK_LIB(intl, dgettext,
59                  gt_cv_func_dgettext_libintl=yes,
60                  gt_cv_func_dgettext_libintl=no)],
61                 gt_cv_func_dgettext_libintl=no)])
62           fi
63
64           if test "$gt_cv_func_dgettext_libintl" = "yes"; then
65             LIBS="$LIBS -lintl";
66           fi
67
68           if test "$gt_cv_func_dgettext_libc" = "yes" \
69              || test "$gt_cv_func_dgettext_libintl" = "yes"; then
70              AC_DEFINE(HAVE_GETTEXT)
71              AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
72                [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
73              if test "$MSGFMT" != "no"; then
74                AC_CHECK_FUNCS(dcgettext)
75                AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
76                AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
77                  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
78                AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
79                               return _nl_msg_cat_cntr],
80                  [CATOBJEXT=.gmo
81                   DATADIRNAME=share],
82                  [CATOBJEXT=.mo
83                   DATADIRNAME=lib])
84                INSTOBJEXT=.mo
85              fi
86            fi
87
88            # Added by Martin Baulig 12/15/98 for libc5 systems
89            if test "$gt_cv_func_dgettext_libc" != "yes" \
90               && test "$gt_cv_func_dgettext_libintl" = "yes"; then
91               INTLLIBS=-lintl
92               LIBS=`echo $LIBS | sed -e 's/-lintl//'`
93            fi
94        ])
95
96        if test "$CATOBJEXT" = "NONE"; then
97          AC_MSG_CHECKING([whether catgets can be used])
98          AC_ARG_WITH(catgets,
99            [  --with-catgets          use catgets functions if available],
100            nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
101          AC_MSG_RESULT($nls_cv_use_catgets)
102
103          if test "$nls_cv_use_catgets" = "yes"; then
104            dnl No gettext in C library.  Try catgets next.
105            AC_CHECK_LIB(i, main)
106            AC_CHECK_FUNC(catgets,
107              [AC_DEFINE(HAVE_CATGETS)
108               INTLOBJS="\$(CATOBJS)"
109               AC_PATH_PROG(GENCAT, gencat, no)dnl
110#              if test "$GENCAT" != "no"; then
111#                AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
112#                if test "$GMSGFMT" = "no"; then
113#                  AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
114#                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
115#                fi
116#                AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
117#                  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
118#                USE_INCLUDED_LIBINTL=yes
119#                CATOBJEXT=.cat
120#                INSTOBJEXT=.cat
121#                DATADIRNAME=lib
122#                INTLDEPS='$(top_builddir)/intl/libintl.a'
123#                INTLLIBS=$INTLDEPS
124#                LIBS=`echo $LIBS | sed -e 's/-lintl//'`
125#                nls_cv_header_intl=intl/libintl.h
126#                nls_cv_header_libgt=intl/libgettext.h
127#              fi
128            ])
129          fi
130        fi
131
132        if test "$CATOBJEXT" = "NONE"; then
133          dnl Neither gettext nor catgets in included in the C library.
134          dnl Fall back on GNU gettext library.
135          nls_cv_use_gnu_gettext=yes
136        fi
137      fi
138
139      if test "$nls_cv_use_gnu_gettext" != "yes"; then
140        AC_DEFINE(ENABLE_NLS)
141      else
142         # Unset this variable since we use the non-zero value as a flag.
143         CATOBJEXT=
144#        dnl Mark actions used to generate GNU NLS library.
145#        INTLOBJS="\$(GETTOBJS)"
146#        AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
147#         [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
148#        AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
149#        AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
150#         [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
151#        AC_SUBST(MSGFMT)
152#       USE_INCLUDED_LIBINTL=yes
153#        CATOBJEXT=.gmo
154#        INSTOBJEXT=.mo
155#        DATADIRNAME=share
156#       INTLDEPS='$(top_builddir)/intl/libintl.a'
157#       INTLLIBS=$INTLDEPS
158#       LIBS=`echo $LIBS | sed -e 's/-lintl//'`
159#        nls_cv_header_intl=intl/libintl.h
160#        nls_cv_header_libgt=intl/libgettext.h
161      fi
162
163      dnl Test whether we really found GNU xgettext.
164      if test "$XGETTEXT" != ":"; then
165        dnl If it is no GNU xgettext we define it as : so that the
166        dnl Makefiles still can work.
167        if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
168          : ;
169        else
170          AC_MSG_RESULT(
171            [found xgettext program is not GNU xgettext; ignore it])
172          XGETTEXT=":"
173        fi
174      fi
175
176      # We need to process the po/ directory.
177      POSUB=po
178    else
179      DATADIRNAME=share
180      nls_cv_header_intl=intl/libintl.h
181      nls_cv_header_libgt=intl/libgettext.h
182    fi
183    AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
184    AC_OUTPUT_COMMANDS(
185     [case "$CONFIG_FILES" in *po/Makefile.in*)
186        sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
187      esac])
188
189
190#    # If this is used in GNU gettext we have to set USE_NLS to `yes'
191#    # because some of the sources are only built for this goal.
192#    if test "$PACKAGE" = gettext; then
193#      USE_NLS=yes
194#      USE_INCLUDED_LIBINTL=yes
195#    fi
196
197    dnl These rules are solely for the distribution goal.  While doing this
198    dnl we only have to keep exactly one list of the available catalogs
199    dnl in configure.in.
200    for lang in $ALL_LINGUAS; do
201      GMOFILES="$GMOFILES $lang.gmo"
202      POFILES="$POFILES $lang.po"
203    done
204
205    dnl Make all variables we use known to autoconf.
206    AC_SUBST(BUILD_INCLUDED_LIBINTL)
207    AC_SUBST(USE_INCLUDED_LIBINTL)
208    AC_SUBST(CATALOGS)
209    AC_SUBST(CATOBJEXT)
210    AC_SUBST(DATADIRNAME)
211    AC_SUBST(GMOFILES)
212    AC_SUBST(INSTOBJEXT)
213    AC_SUBST(INTLDEPS)
214    AC_SUBST(INTLLIBS)
215    AC_SUBST(INTLOBJS)
216    AC_SUBST(POFILES)
217    AC_SUBST(POSUB)
218  ])
219
220AC_DEFUN(AM_GCONF_GNU_GETTEXT,
221  [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
222   AC_REQUIRE([AC_PROG_CC])dnl
223   AC_REQUIRE([AC_PROG_RANLIB])dnl
224   AC_REQUIRE([AC_ISC_POSIX])dnl
225   AC_REQUIRE([AC_HEADER_STDC])dnl
226   AC_REQUIRE([AC_C_CONST])dnl
227   AC_REQUIRE([AC_C_INLINE])dnl
228   AC_REQUIRE([AC_TYPE_OFF_T])dnl
229   AC_REQUIRE([AC_TYPE_SIZE_T])dnl
230   AC_REQUIRE([AC_FUNC_ALLOCA])dnl
231   AC_REQUIRE([AC_FUNC_MMAP])dnl
232
233   AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
234unistd.h sys/param.h])
235   AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
236strdup __argz_count __argz_stringify __argz_next])
237
238   if test "${ac_cv_func_stpcpy+set}" != "set"; then
239     AC_CHECK_FUNCS(stpcpy)
240   fi
241   if test "${ac_cv_func_stpcpy}" = "yes"; then
242     AC_DEFINE(HAVE_STPCPY)
243   fi
244
245   AM_LC_MESSAGES
246   AM_GCONF_WITH_NLS
247
248   if test "x$CATOBJEXT" != "x"; then
249     if test "x$ALL_LINGUAS" = "x"; then
250       LINGUAS=
251     else
252       AC_MSG_CHECKING(for catalogs to be installed)
253       NEW_LINGUAS=
254       for lang in ${LINGUAS=$ALL_LINGUAS}; do
255         case "$ALL_LINGUAS" in
256          *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
257         esac
258       done
259       LINGUAS=$NEW_LINGUAS
260       AC_MSG_RESULT($LINGUAS)
261     fi
262
263     dnl Construct list of names of catalog files to be constructed.
264     if test -n "$LINGUAS"; then
265       for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
266     fi
267   fi
268
269   dnl The reference to <locale.h> in the installed <libintl.h> file
270   dnl must be resolved because we cannot expect the users of this
271   dnl to define HAVE_LOCALE_H.
272   if test $ac_cv_header_locale_h = yes; then
273     INCLUDE_LOCALE_H="#include <locale.h>"
274   else
275     INCLUDE_LOCALE_H="\
276/* The system does not provide the header <locale.h>.  Take care yourself.  */"
277   fi
278   AC_SUBST(INCLUDE_LOCALE_H)
279
280   dnl Determine which catalog format we have (if any is needed)
281   dnl For now we know about two different formats:
282   dnl   Linux libc-5 and the normal X/Open format
283   test -d intl || mkdir intl
284   if test "$CATOBJEXT" = ".cat"; then
285     AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
286
287     dnl Transform the SED scripts while copying because some dumb SEDs
288     dnl cannot handle comments.
289     sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
290   fi
291   dnl po2tbl.sed is always needed.
292   sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
293     $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
294
295   dnl In the intl/Makefile.in we have a special dependency which makes
296   dnl only sense for gettext.  We comment this out for non-gettext
297   dnl packages.
298   if test "$PACKAGE" = "gettext"; then
299     GT_NO="#NO#"
300     GT_YES=
301   else
302     GT_NO=
303     GT_YES="#YES#"
304   fi
305   AC_SUBST(GT_NO)
306   AC_SUBST(GT_YES)
307
308   dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
309   dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
310   dnl Try to locate is.
311   MKINSTALLDIRS=
312   if test -n "$ac_aux_dir"; then
313     MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
314   fi
315   if test -z "$MKINSTALLDIRS"; then
316     MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
317   fi
318   AC_SUBST(MKINSTALLDIRS)
319
320   dnl *** For now the libtool support in intl/Makefile is not for real.
321   l=
322   AC_SUBST(l)
323
324   dnl Generate list of files to be processed by xgettext which will
325   dnl be included in po/Makefile.
326   test -d po || mkdir po
327   if test "x$srcdir" != "x."; then
328     if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
329       posrcprefix="$srcdir/"
330     else
331       posrcprefix="../$srcdir/"
332     fi
333   else
334     posrcprefix="../"
335   fi
336   rm -f po/POTFILES
337   sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
338        < $srcdir/po/POTFILES.in > po/POTFILES
339  ])
Note: See TracBrowser for help on using the repository browser.