OSDN Git Service

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