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