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