* bootstrap: Redo po file retrieval to match Bison's method,
[debian/tar] / acinclude.m4
1 ## ----------------------------------------- ##
2 ## Find how to suppress newlines with echo.  ##
3 ## ----------------------------------------- ##
4
5 # Once this macro is called, you may output with no echo in a Makefile or
6 # script using:  echo @ECHO_N@ "STRING_TO_OUTPUT@ECHO_C@".
7
8 AC_DEFUN(fp_PROG_ECHO,
9 [AC_MSG_CHECKING(how to suppress newlines using echo)
10 AC_CACHE_VAL(fp_cv_prog_echo_nonl,
11 [if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
12   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
13     fp_cv_prog_echo_nonl=no
14   else
15     fp_cv_prog_echo_nonl=option
16   fi
17 else
18   fp_cv_prog_echo_nonl=escape
19 fi
20 ])
21 AC_MSG_RESULT($fp_cv_prog_echo_nonl)
22 case $fp_cv_prog_echo_nonl in
23   no) ECHO_N= ECHO_C= ;;
24   option) ECHO_N=-n ECHO_C= ;;
25   escape) ECHO_N= ECHO_C='\c' ;;
26 esac
27 AC_SUBST(ECHO_N)dnl
28 AC_SUBST(ECHO_C)dnl
29 ])
30
31 ## ------------------------------------------- ##
32 ## Check if --with-included-malloc was given.  ##
33 ## From Franc,ois Pinard                       ##
34 ## ------------------------------------------- ##
35
36 # In 1992, Michael Bushnell (now Thomas Bushnell <thomas@gnu.ai.mit.edu>)
37 # devised a test for avoiding HP/UX malloc and using GNU malloc instead.
38 # Bruno Haible <haible@ma2s2.mathematik.uni-karlsruhe.de> recycled this
39 # test for CLISP Common LISP and extended it to cover broken mallocs from
40 # Sun and SGI.  I (<pinard@iro.umontreal.ca>) reworked it a little so
41 # it is independent of config.guess, and overridable by the installer.
42
43 # On IRIX 5.2, libc malloc is broken, but the -lmalloc one was usable.
44 # So in my packages, I once unconditionally used -lmalloc if it existed.
45 # This does not do anymore, because the -lmalloc malloc is broken on
46 # Solaris 2.4 to 2.5.1 (alignment is 4 bytes instead of 8 bytes, as
47 # reported by John Wells <john@bitsmart.com>).
48
49 # Bruno also notes: "HP-UX has two different malloc() implementations.
50 # Both are broken.  When used with CLISP, the one in the default libc.a
51 # leads to a SIGSEGV, the one in libmalloc.a leads to a SIGBUS.  The SunOS
52 # 4.1.1 malloc() breaks when used by CLISP's generational GC.  The IRIX
53 # 5.2 malloc() breaks when used by CLISP's generational GC."
54
55 # If the installer does not give a preference, we use the included GNU
56 # malloc if we have the slightest doubt that malloc could be broken, this
57 # includes cross compilation, and *all* HP/UX, SunOS or IRIX systems.
58 # It is crude indeed, but I just do not have enough information for truly
59 # benchmarking malloc in all cases, but want safe packages nevertheless.
60
61 AC_DEFUN(fp_WITH_INCLUDED_MALLOC,
62 [AC_MSG_CHECKING(if included GNU malloc is wanted)
63 AC_ARG_WITH(included-malloc,
64 [  --with-included-malloc  use the GNU malloc which is included here], ,
65 [if test $cross_compiling = yes; then
66   withval=yes
67 else
68   case `uname -s 2> /dev/null` in
69     HP-UX | SunOS | IRIX* ) withval=yes ;;
70     *) withval=no ;;
71   esac
72 fi])
73 test "$withval" = yes && LIBOBJS="$LIBOBJS gmalloc.o"
74 AC_MSG_RESULT($withval)
75 ])
76
77 ## -------------------- ##
78 ## Macros from Ulrich.  ##
79 ## -------------------- ##
80
81 # Search path for a program which passes the given test.
82 # Ulrich Drepper <drepper@cygnus.com>, 1996.
83
84 # serial 1
85
86 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
87 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
88 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
89 [# Extract the first word of "$2", so it can be a program name with args.
90 set dummy $2; ac_word=[$]2
91 AC_MSG_CHECKING([for $ac_word])
92 AC_CACHE_VAL(ac_cv_path_$1,
93 [case "[$]$1" in
94   /*)
95   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
96   ;;
97   *)
98   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
99   for ac_dir in ifelse([$5], , $PATH, [$5]); do
100     test -z "$ac_dir" && ac_dir=.
101     if test -f $ac_dir/$ac_word; then
102       if [$3]; then
103         ac_cv_path_$1="$ac_dir/$ac_word"
104         break
105       fi
106     fi
107   done
108   IFS="$ac_save_ifs"
109 dnl If no 4th arg is given, leave the cache variable unset,
110 dnl so AC_PATH_PROGS will keep looking.
111 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
112 ])dnl
113   ;;
114 esac])dnl
115 $1="$ac_cv_path_$1"
116 if test -n "[$]$1"; then
117   AC_MSG_RESULT([$]$1)
118 else
119   AC_MSG_RESULT(no)
120 fi
121 AC_SUBST($1)dnl
122 ])
123
124 # Check whether LC_MESSAGES is available in <locale.h>.
125 # Ulrich Drepper <drepper@cygnus.com>, 1995.
126
127 # serial 1
128
129 AC_DEFUN(AM_LC_MESSAGES,
130   [if test $ac_cv_header_locale_h = yes; then
131     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
132       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
133        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
134     if test $am_cv_val_LC_MESSAGES = yes; then
135       AC_DEFINE(HAVE_LC_MESSAGES)
136     fi
137   fi])
138
139 # Macro to add for using GNU gettext.
140 # Ulrich Drepper <drepper@cygnus.com>, 1995.
141
142 # serial 1
143
144 AC_DEFUN(AM_WITH_NLS,
145   [AC_MSG_CHECKING([whether NLS is requested])
146     dnl Default is enabled NLS
147     AC_ARG_ENABLE(nls,
148       [  --disable-nls           do not use Native Language Support],
149       USE_NLS=$enableval, USE_NLS=yes)
150     AC_MSG_RESULT($USE_NLS)
151     AC_SUBST(USE_NLS)
152
153     USE_INCLUDED_LIBINTL=no
154
155     dnl If we use NLS figure out what method
156     if test "$USE_NLS" = "yes"; then
157       AC_DEFINE(ENABLE_NLS)
158       AC_MSG_CHECKING([whether included gettext is requested])
159       AC_ARG_WITH(included-gettext,
160         [  --with-included-gettext use the GNU gettext library included here],
161         nls_cv_force_use_gnu_gettext=$withval,
162         nls_cv_force_use_gnu_gettext=no)
163       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
164
165       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
166       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
167         dnl User does not insist on using GNU NLS library.  Figure out what
168         dnl to use.  If gettext or catgets are available (in this order) we
169         dnl use this.  Else we have to fall back to GNU NLS library.
170         dnl catgets is only used if permitted by option --with-catgets.
171         nls_cv_header_intl=
172         nls_cv_header_libgt=
173         CATOBJEXT=NONE
174
175         AC_CHECK_HEADER(libintl.h,
176           [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
177             [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
178                gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
179
180            if test "$gt_cv_func_gettext_libc" != "yes"; then
181              AC_CHECK_LIB(intl, bindtextdomain,
182                [AC_CACHE_CHECK([for gettext in libintl],
183                  gt_cv_func_gettext_libintl,
184                  [AC_TRY_LINK([], [return (int) gettext ("")],
185                  gt_cv_func_gettext_libintl=yes,
186                  gt_cv_func_gettext_libintl=no)])])
187            fi
188
189            if test "$gt_cv_func_gettext_libc" = "yes" \
190               || test "$gt_cv_func_gettext_libintl" = "yes"; then
191               AC_DEFINE(HAVE_GETTEXT)
192               AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
193                 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
194               if test "$MSGFMT" != "no"; then
195                 AC_CHECK_FUNCS(dcgettext)
196                 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
197                 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
198                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
199                 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
200                                return _nl_msg_cat_cntr],
201                   [CATOBJEXT=.gmo
202                    DATADIRNAME=share],
203                   [CATOBJEXT=.mo
204                    DATADIRNAME=lib])
205                 INSTOBJEXT=.mo
206               fi
207             fi
208         ])
209
210         if test "$CATOBJEXT" = "NONE"; then
211           AC_MSG_CHECKING([whether catgets can be used])
212           AC_ARG_WITH(catgets,
213             [  --with-catgets          use catgets functions if available],
214             nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
215           AC_MSG_RESULT($nls_cv_use_catgets)
216
217           if test "$nls_cv_use_catgets" = "yes"; then
218             dnl No gettext in C library.  Try catgets next.
219             AC_CHECK_LIB(i, main)
220             AC_CHECK_FUNC(catgets,
221               [AC_DEFINE(HAVE_CATGETS)
222                INTLOBJS="\$(CATOBJS)"
223                AC_PATH_PROG(GENCAT, gencat, no)dnl
224                if test "$GENCAT" != "no"; then
225                  AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
226                  if test "$GMSGFMT" = "no"; then
227                    AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
228                     [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
229                  fi
230                  AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
231                    [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
232                  USE_INCLUDED_LIBINTL=yes
233                  CATOBJEXT=.cat
234                  INSTOBJEXT=.cat
235                  DATADIRNAME=lib
236                  INTLDEPS="../intl/libintl.a"
237                  INTLLIBS=$INTLDEPS
238                  LIBS=`echo $LIBS | sed -e 's/-lintl//'`
239                  nls_cv_header_intl=intl/libintl.h
240                  nls_cv_header_libgt=intl/libgettext.h
241                fi])
242           fi
243         fi
244
245         if test "$CATOBJEXT" = "NONE"; then
246           dnl Neither gettext nor catgets in included in the C library.
247           dnl Fall back on GNU gettext library.
248           nls_cv_use_gnu_gettext=yes
249         fi
250       fi
251
252       if test "$nls_cv_use_gnu_gettext" = "yes"; then
253         dnl Mark actions used to generate GNU NLS library.
254         INTLOBJS="\$(GETTOBJS)"
255         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
256           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
257         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
258         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
259           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
260         AC_SUBST(MSGFMT)
261         USE_INCLUDED_LIBINTL=yes
262         CATOBJEXT=.gmo
263         INSTOBJEXT=.mo
264         DATADIRNAME=share
265         INTLDEPS="../intl/libintl.a"
266         INTLLIBS=$INTLDEPS
267         LIBS=`echo $LIBS | sed -e 's/-lintl//'`
268         nls_cv_header_intl=intl/libintl.h
269         nls_cv_header_libgt=intl/libgettext.h
270       fi
271
272       dnl Test whether we really found GNU xgettext.
273       if test "$XGETTEXT" != ":"; then
274         dnl If it is no GNU xgettext we define it as : so that the
275         dnl Makefiles still can work.
276         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
277           : ;
278         else
279           AC_MSG_RESULT(
280             [found xgettext programs is not GNU xgettext; ignore it])
281           XGETTEXT=":"
282         fi
283       fi
284
285       # We need to process the po/ directory.
286       POSUB=po
287     else
288       DATADIRNAME=share
289       nls_cv_header_intl=intl/libintl.h
290       nls_cv_header_libgt=intl/libgettext.h
291     fi
292
293     # If this is used in GNU gettext we have to set USE_NLS to `yes'
294     # because some of the sources are only built for this goal.
295     if test "$PACKAGE" = gettext; then
296       USE_NLS=yes
297       USE_INCLUDED_LIBINTL=yes
298     fi
299
300     dnl These rules are solely for the distribution goal.  While doing this
301     dnl we only have to keep exactly one list of the available catalogs
302     dnl in configure.in.
303     for lang in $ALL_LINGUAS; do
304       GMOFILES="$GMOFILES $lang.gmo"
305       POFILES="$POFILES $lang.po"
306     done
307
308     dnl Make all variables we use known to autoconf.
309     AC_SUBST(USE_INCLUDED_LIBINTL)
310     AC_SUBST(CATALOGS)
311     AC_SUBST(CATOBJEXT)
312     AC_SUBST(DATADIRNAME)
313     AC_SUBST(GMOFILES)
314     AC_SUBST(INSTOBJEXT)
315     AC_SUBST(INTLDEPS)
316     AC_SUBST(INTLLIBS)
317     AC_SUBST(INTLOBJS)
318     AC_SUBST(POFILES)
319     AC_SUBST(POSUB)
320   ])
321
322 AC_DEFUN(AM_GNU_GETTEXT,
323   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
324    AC_REQUIRE([AC_PROG_CC])dnl
325    AC_REQUIRE([AC_ISC_POSIX])dnl
326    AC_REQUIRE([AC_PROG_RANLIB])dnl
327    AC_REQUIRE([AC_HEADER_STDC])dnl
328    AC_REQUIRE([AC_C_CONST])dnl
329    AC_REQUIRE([AC_C_INLINE])dnl
330    AC_REQUIRE([AC_TYPE_OFF_T])dnl
331    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
332    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
333    AC_REQUIRE([AC_FUNC_MMAP])dnl
334
335    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
336 unistd.h values.h])
337    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
338 __argz_count __argz_stringify __argz_next])
339
340    if test "${ac_cv_func_stpcpy+set}" != "set"; then
341      AC_CHECK_FUNCS(stpcpy)
342    fi
343    if test "${ac_cv_func_stpcpy}" = "yes"; then
344      AC_DEFINE(HAVE_STPCPY)
345    fi
346
347    AM_LC_MESSAGES
348    AM_WITH_NLS
349
350    if test "x$CATOBJEXT" != "x"; then
351      if test "x$ALL_LINGUAS" = "x"; then
352        LINGUAS=
353      else
354        AC_MSG_CHECKING(for catalogs to be installed)
355        NEW_LINGUAS=
356        for lang in ${LINGUAS=$ALL_LINGUAS}; do
357          case "$ALL_LINGUAS" in
358           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
359          esac
360        done
361        LINGUAS=$NEW_LINGUAS
362        AC_MSG_RESULT($LINGUAS)
363      fi
364
365      dnl Construct list of names of catalog files to be constructed.
366      if test -n "$LINGUAS"; then
367        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
368      fi
369    fi
370
371    dnl Determine which catalog format we have (if any is needed)
372    dnl For now we know about two different formats:
373    dnl   Linux libc-5 and the normal X/Open format
374    test -d intl || mkdir intl
375    if test "$CATOBJEXT" = ".cat"; then
376      AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
377
378      dnl Transform the SED scripts while copying because some dumb SEDs
379      dnl cannot handle comments.
380      sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
381    fi
382    dnl po2tbl.sed is always needed.
383    sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
384      $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
385
386    dnl In the intl/Makefile.in we have a special dependency which makes
387    dnl only sense for gettext.  We comment this out for non-gettext
388    dnl packages.
389    if test "$PACKAGE" = "gettext"; then
390      GT_NO="#NO#"
391      GT_YES=
392    else
393      GT_NO=
394      GT_YES="#YES#"
395    fi
396    AC_SUBST(GT_NO)
397    AC_SUBST(GT_YES)
398
399    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
400    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
401    dnl Try to locate is.
402    MKINSTALLDIRS=
403    if test $ac_aux_dir; then
404      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
405    fi
406    if test -z $MKINSTALLDIRS; then
407      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
408    fi
409    AC_SUBST(MKINSTALLDIRS)
410
411    dnl Generate list of files to be processed by xgettext which will
412    dnl be included in po/Makefile.
413    test -d po || mkdir po
414    if test "x$srcdir" != "x."; then
415      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
416        posrcprefix="$srcdir/"
417      else
418        posrcprefix="../$srcdir/"
419      fi
420    else
421      posrcprefix="../"
422    fi
423    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
424         < $srcdir/po/POTFILES.in > po/POTFILES
425   ])