Installed a new French translation (resolves Debian Bug #106720)
[make.git] / acinclude.m4
blob3822e74174b78c2c74ba699e400b3a65c6eb5627
1 dnl acinclude.m4 -- Extra macros needed for GNU make.
2 dnl
3 dnl Automake will incorporate this into its generated aclocal.m4.
5 dnl ---------------------------------------------------------------------------
6 dnl Got this from the lynx 2.8 distribution.
7 dnl by T.E.Dickey <dickey@clark.net>
8 dnl and Jim Spath <jspath@mail.bcpl.lib.md.us>
9 dnl and Philippe De Muyter <phdm@macqel.be>
10 dnl
11 dnl Created: 1997/1/28
12 dnl Updated: 1997/12/23
13 dnl ---------------------------------------------------------------------------
14 dnl After checking for functions in the default $LIBS, make a further check
15 dnl for the functions that are netlib-related (these aren't always in the
16 dnl libc, etc., and have to be handled specially because there are conflicting
17 dnl and broken implementations.
18 dnl Common library requirements (in order):
19 dnl     -lresolv -lsocket -lnsl
20 dnl     -lnsl -lsocket
21 dnl     -lsocket
22 dnl     -lbsd
23 AC_DEFUN([CF_NETLIBS],[
24 cf_test_netlibs=no
25 AC_MSG_CHECKING(for network libraries)
26 AC_CACHE_VAL(cf_cv_netlibs,[
27 AC_MSG_RESULT(working...)
28 cf_cv_netlibs=""
29 cf_test_netlibs=yes
30 AC_CHECK_FUNCS(gethostname,,[
31         CF_RECHECK_FUNC(gethostname,nsl,cf_cv_netlibs,[
32                 CF_RECHECK_FUNC(gethostname,socket,cf_cv_netlibs)])])
34 # FIXME:  sequent needs this library (i.e., -lsocket -linet -lnsl), but
35 # I don't know the entrypoints - 97/7/22 TD
36 AC_CHECK_LIB(inet,main,cf_cv_netlibs="-linet $cf_cv_netlibs")
38 if test "$ac_cv_func_lsocket" != no ; then
39 AC_CHECK_FUNCS(socket,,[
40         CF_RECHECK_FUNC(socket,socket,cf_cv_netlibs,[
41                 CF_RECHECK_FUNC(socket,bsd,cf_cv_netlibs)])])
44 AC_CHECK_FUNCS(gethostbyname,,[
45         CF_RECHECK_FUNC(gethostbyname,nsl,cf_cv_netlibs)])
47 AC_CHECK_FUNCS(strcasecmp,,[
48         CF_RECHECK_FUNC(strcasecmp,resolv,cf_cv_netlibs)])
50 LIBS="$LIBS $cf_cv_netlibs"
51 test $cf_test_netlibs = no && echo "$cf_cv_netlibs" >&AC_FD_MSG
52 ])dnl
53 dnl ---------------------------------------------------------------------------
54 dnl Re-check on a function to see if we can pick it up by adding a library.
55 dnl     $1 = function to check
56 dnl     $2 = library to check in
57 dnl     $3 = environment to update (e.g., $LIBS)
58 dnl     $4 = what to do if this fails
59 dnl
60 dnl This uses 'unset' if the shell happens to support it, but leaves the
61 dnl configuration variable set to 'unknown' if not.  This is a little better
62 dnl than the normal autoconf test, which gives misleading results if a test
63 dnl for the function is made (e.g., with AC_CHECK_FUNC) after this macro is
64 dnl used (autoconf does not distinguish between a null token and one that is
65 dnl set to 'no').
66 AC_DEFUN([CF_RECHECK_FUNC],[
67 AC_CHECK_LIB($2,$1,[
68         CF_UPPER(cf_tr_func,$1)
69         AC_DEFINE_UNQUOTED(HAVE_$cf_tr_func)
70         ac_cv_func_$1=yes
71         $3="-l$2 [$]$3"],[
72         ac_cv_func_$1=unknown
73         unset ac_cv_func_$1 2>/dev/null
74         $4],
75         [[$]$3])
76 ])dnl
77 dnl ---------------------------------------------------------------------------
78 dnl Make an uppercase version of a variable
79 dnl $1=uppercase($2)
80 AC_DEFUN([CF_UPPER],
82 changequote(,)dnl
83 $1=`echo $2 | tr '[a-z]' '[A-Z]'`
84 changequote([,])dnl
85 ])dnl
87 dnl ---------------------------------------------------------------------------
88 dnl Got this from the GNU tar 1.13.11 distribution
89 dnl by Paul Eggert <eggert@twinsun.com>
90 dnl ---------------------------------------------------------------------------
92 dnl By default, many hosts won't let programs access large files;
93 dnl one must use special compiler options to get large-file access to work.
94 dnl For more details about this brain damage please see:
95 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
97 dnl Written by Paul Eggert <eggert@twinsun.com>.
99 dnl Internal subroutine of AC_SYS_LARGEFILE.
100 dnl AC_SYS_LARGEFILE_FLAGS(FLAGSNAME)
101 AC_DEFUN(AC_SYS_LARGEFILE_FLAGS,
102   [AC_CACHE_CHECK([for $1 value to request large file support],
103      ac_cv_sys_largefile_$1,
104      [if ($GETCONF LFS_$1) >conftest.1 2>conftest.2 && test ! -s conftest.2
105       then
106         ac_cv_sys_largefile_$1=`cat conftest.1`
107       else
108         ac_cv_sys_largefile_$1=no
109         ifelse($1, CFLAGS,
110           [case "$host_os" in
111            # HP-UX 10.20 requires -D__STDC_EXT__ with gcc 2.95.1.
112 changequote(, )dnl
113            hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
114 changequote([, ])dnl
115              if test "$GCC" = yes; then
116                ac_cv_sys_largefile_CFLAGS=-D__STDC_EXT__
117              fi
118              ;;
119            # IRIX 6.2 and later require cc -n32.
120 changequote(, )dnl
121            irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*)
122 changequote([, ])dnl
123              if test "$GCC" != yes; then
124                ac_cv_sys_largefile_CFLAGS=-n32
125              fi
126            esac
127            if test "$ac_cv_sys_largefile_CFLAGS" != no; then
128              ac_save_CC="$CC"
129              CC="$CC $ac_cv_sys_largefile_CFLAGS"
130              AC_TRY_LINK(, , , ac_cv_sys_largefile_CFLAGS=no)
131              CC="$ac_save_CC"
132            fi])
133       fi
134       rm -f conftest*])])
136 dnl Internal subroutine of AC_SYS_LARGEFILE.
137 dnl AC_SYS_LARGEFILE_SPACE_APPEND(VAR, VAL)
138 AC_DEFUN(AC_SYS_LARGEFILE_SPACE_APPEND,
139   [case $2 in
140    no) ;;
141    ?*)
142      case "[$]$1" in
143      '') $1=$2 ;;
144      *) $1=[$]$1' '$2 ;;
145      esac ;;
146    esac])
148 dnl Internal subroutine of AC_SYS_LARGEFILE.
149 dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
150 AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
151   [AC_CACHE_CHECK([for $1], $2,
152      [$2=no
153 changequote(, )dnl
154       $4
155       for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
156         case "$ac_flag" in
157         -D$1)
158           $2=1 ;;
159         -D$1=*)
160           $2=`expr " $ac_flag" : '[^=]*=\(.*\)'` ;;
161         esac
162       done
163 changequote([, ])dnl
164       ])
165    if test "[$]$2" != no; then
166      AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
167    fi])
169 AC_DEFUN(AC_SYS_LARGEFILE,
170   [AC_REQUIRE([AC_CANONICAL_HOST])
171    AC_ARG_ENABLE(largefile,
172      [  --disable-largefile     omit support for large files])
173    if test "$enable_largefile" != no; then
174      AC_CHECK_TOOL(GETCONF, getconf)
175      AC_SYS_LARGEFILE_FLAGS(CFLAGS)
176      AC_SYS_LARGEFILE_FLAGS(LDFLAGS)
177      AC_SYS_LARGEFILE_FLAGS(LIBS)
179      for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
180        case "$ac_flag" in
181        no) ;;
182        -D_FILE_OFFSET_BITS=*) ;;
183        -D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
184        -D_LARGE_FILES | -D_LARGE_FILES=*) ;;
185        -D?* | -I?*)
186          AC_SYS_LARGEFILE_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
187        *)
188          AC_SYS_LARGEFILE_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
189        esac
190      done
191      AC_SYS_LARGEFILE_SPACE_APPEND(LDFLAGS, "$ac_cv_sys_largefile_LDFLAGS")
192      AC_SYS_LARGEFILE_SPACE_APPEND(LIBS, "$ac_cv_sys_largefile_LIBS")
193      AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS,
194        ac_cv_sys_file_offset_bits,
195        [Number of bits in a file offset, on hosts where this is settable.],
196        [case "$host_os" in
197         # HP-UX 10.20 and later
198         hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
199           ac_cv_sys_file_offset_bits=64 ;;
200         esac])
201      AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE,
202        ac_cv_sys_largefile_source,
203        [Define to make fseeko etc. visible, on some hosts.],
204        [case "$host_os" in
205         # HP-UX 10.20 and later
206         hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
207           ac_cv_sys_largefile_source=1 ;;
208         esac])
209      AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
210        ac_cv_sys_large_files,
211        [Define for large files, on AIX-style hosts.],
212        [case "$host_os" in
213         # AIX 4.2 and later
214         aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)
215           ac_cv_sys_large_files=1 ;;
216         esac])
217    fi
218   ])
221 dnl ---------------------------------------------------------------------------
222 dnl From Paul Eggert <eggert@twinsun.com>
224 dnl Define HAVE_INTTYPES_H if <inttypes.h> exists,
225 dnl doesn't clash with <sys/types.h>, and declares uintmax_t.
227 AC_DEFUN(jm_AC_HEADER_INTTYPES_H,
229   if test x = y; then
230     dnl This code is deliberately never run via ./configure.
231     dnl FIXME: this is a gross hack to make autoheader put an entry
232     dnl for `HAVE_INTTYPES_H' in config.h.in.
233     AC_CHECK_FUNCS(INTTYPES_H)
234   fi
235   AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
236   [AC_TRY_COMPILE(
237     [#include <sys/types.h>
238 #include <inttypes.h>],
239     [uintmax_t i = (uintmax_t) -1;],
240     jm_ac_cv_header_inttypes_h=yes,
241     jm_ac_cv_header_inttypes_h=no)])
242   if test $jm_ac_cv_header_inttypes_h = yes; then
243     ac_kludge=HAVE_INTTYPES_H
244     AC_DEFINE_UNQUOTED($ac_kludge)
245   fi
249 dnl ---------------------------------------------------------------------------
250 dnl From Paul Eggert <eggert@twinsun.com>
252 AC_DEFUN(AC_STRUCT_ST_MTIM_NSEC,
253  [AC_CACHE_CHECK([for nanoseconds member of struct stat.st_mtim],
254    ac_cv_struct_st_mtim_nsec,
255    [ac_save_CPPFLAGS="$CPPFLAGS"
256     ac_cv_struct_st_mtim_nsec=no
257     # tv_nsec -- the usual case
258     # _tv_nsec -- Solaris 2.6, if
259     #   (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
260     #    && !defined __EXTENSIONS__)
261     # st__tim.tv_nsec -- UnixWare 2.1.2
262     for ac_val in tv_nsec _tv_nsec st__tim.tv_nsec; do
263       CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
264       AC_TRY_COMPILE([#include <sys/types.h>
265 #include <sys/stat.h>], [struct stat s; s.st_mtim.ST_MTIM_NSEC;],
266         [ac_cv_struct_st_mtim_nsec=$ac_val; break])
267     done
268     CPPFLAGS="$ac_save_CPPFLAGS"])
270   if test $ac_cv_struct_st_mtim_nsec != no; then
271     AC_DEFINE_UNQUOTED(ST_MTIM_NSEC, $ac_cv_struct_st_mtim_nsec)
272   fi
276 dnl ---------------------------------------------------------------------------
277 dnl From Paul Eggert <eggert@twinsun.com>
279 dnl Define uintmax_t to `unsigned long' or `unsigned long long'
280 dnl if <inttypes.h> does not exist.
282 AC_DEFUN(jm_AC_TYPE_UINTMAX_T,
284   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
285   if test $jm_ac_cv_header_inttypes_h = no; then
286     AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
287     [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
288       [unsigned long long ullmax = (unsigned long long) -1;
289        return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
290       ac_cv_type_unsigned_long_long=yes,
291       ac_cv_type_unsigned_long_long=no)])
292     if test $ac_cv_type_unsigned_long_long = yes; then
293       AC_DEFINE(uintmax_t, unsigned long long)
294     else
295       AC_DEFINE(uintmax_t, unsigned long)
296     fi
297   fi
301 # The following is taken from automake 1.4,
302 # except that it prefers the compiler option -Ae to "-Aa -D_HPUX_SOURCE"
303 # because only the former supports 64-bit integral types on HP-UX 10.20.
305 ## ----------------------------------------- ##
306 ## ANSIfy the C compiler whenever possible.  ##
307 ## From Franc,ois Pinard                     ##
308 ## ----------------------------------------- ##
310 # serial 2
312 # @defmac AC_PROG_CC_STDC
313 # @maindex PROG_CC_STDC
314 # @ovindex CC
315 # If the C compiler in not in ANSI C mode by default, try to add an option
316 # to output variable @code{CC} to make it so.  This macro tries various
317 # options that select ANSI C on some system or another.  It considers the
318 # compiler to be in ANSI C mode if it handles function prototypes correctly.
320 # If you use this macro, you should check after calling it whether the C
321 # compiler has been set to accept ANSI C; if not, the shell variable
322 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
323 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
324 # program @code{ansi2knr}, which comes with Ghostscript.
325 # @end defmac
327 AC_DEFUN(AM_PROG_CC_STDC,
328 [AC_REQUIRE([AC_PROG_CC])
329 AC_BEFORE([$0], [AC_C_INLINE])
330 AC_BEFORE([$0], [AC_C_CONST])
331 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
332 dnl a magic option to avoid problems with ANSI preprocessor commands
333 dnl like #elif.
334 dnl FIXME: can't do this because then AC_AIX won't work due to a
335 dnl circular dependency.
336 dnl AC_BEFORE([$0], [AC_PROG_CPP])
337 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
338 AC_CACHE_VAL(am_cv_prog_cc_stdc,
339 [am_cv_prog_cc_stdc=no
340 ac_save_CC="$CC"
341 # Don't try gcc -ansi; that turns off useful extensions and
342 # breaks some systems' header files.
343 # AIX                   -qlanglvl=ansi
344 # Ultrix and OSF/1      -std1
345 # HP-UX                 -Aa -D_HPUX_SOURCE
346 # SVR4                  -Xc -D__EXTENSIONS__
347 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
349   CC="$ac_save_CC $ac_arg"
350   AC_TRY_COMPILE(
351 [#include <stdarg.h>
352 #include <stdio.h>
353 #include <sys/types.h>
354 #include <sys/stat.h>
355 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
356 struct buf { int x; };
357 FILE * (*rcsopen) (struct buf *, struct stat *, int);
358 static char *e (p, i)
359      char **p;
360      int i;
362   return p[i];
364 static char *f (char * (*g) (char **, int), char **p, ...)
366   char *s;
367   va_list v;
368   va_start (v,p);
369   s = g (p, va_arg (v,int));
370   va_end (v);
371   return s;
373 int test (int i, double x);
374 struct s1 {int (*f) (int a);};
375 struct s2 {int (*f) (double a);};
376 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
377 int argc;
378 char **argv;
379 ], [
380 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
382 [am_cv_prog_cc_stdc="$ac_arg"; break])
383 done
384 CC="$ac_save_CC"
386 if test -z "$am_cv_prog_cc_stdc"; then
387   AC_MSG_RESULT([none needed])
388 else
389   AC_MSG_RESULT($am_cv_prog_cc_stdc)
391 case "x$am_cv_prog_cc_stdc" in
392   x|xno) ;;
393   *) CC="$CC $am_cv_prog_cc_stdc" ;;
394 esac
397 dnl ---------------------------------------------------------------------------
398 dnl Enable internationalization support for GNU make.
399 dnl Original obtained from the libit 0.7 distribution
400 dnl Rewritten by Paul D. Smith <psmith@gnu.org>
401 dnl This version is much more straightforward than the original (I think);
402 dnl If the user doesn't disable NLS, check whether she asked for the
403 dnl included gettext.  If so, we use that.  If not, test to see if the
404 dnl system gettext is GNU.  If not, use the included gettext.  If so,
405 dnl use the system gettext.  We are very strict about testing for GNU
406 dnl gettext; not only must the library be GNU gettext, but the libintl.h
407 dnl file must also be GNU.
409 AC_DEFUN(pds_CHECK_SYSTEM_GETTEXT, [
411   # OK.  What we're going to do is see if the system gettext is really
412   # GNU gettext, and we're going to make _sure_ (as we can) that if
413   # it's not we'll use the included gettext.
415   pds_keep_LIBS="$LIBS"
417   # Look around for gettext() and libintl.h on the system
418   AC_CHECK_HEADERS(locale.h)
419   AC_SEARCH_LIBS(gettext, intl)
420   if test "$ac_cv_search_gettext" = no; then
421     with_included_gettext=yes
423   else
424     # We only want to deal with GNU's gettext; if we don't have that
425     # we'll just use our own, thanks very much.
426     AC_CACHE_CHECK([whether the system has GNU gettext],
427                    pds_cv_system_gnu_gettext, [
428       AC_TRY_LINK([
429 #include <libintl.h>
430 #ifdef HAVE_LOCALE_H
431 #include <locale.h>
432 #endif
433 ], [
434 #if __USE_GNU_GETTEXT
435   extern int _nl_msg_cat_cntr;
436   return _nl_msg_cat_cntr;
437 #else
438 not GNU gettext
439 #endif
441         pds_cv_system_gnu_gettext=yes, pds_cv_system_gnu_gettext=no)])
443     if test "x$pds_cv_system_gnu_gettext" = xyes; then
444       with_included_gettext=no
445       AC_DEFINE(HAVE_LIBINTL_H, 1, [Define if you have <libintl.h>.])
446     else
447       with_included_gettext=yes
448       LIBS="$pds_keep_LIBS"
449     fi
450   fi
454 AC_DEFUN(pds_WITH_GETTEXT, [
456   AC_MSG_CHECKING(whether NLS is wanted)
457   AC_ARG_ENABLE(nls,
458     [  --disable-nls           disallow Native Language Support],
459     enable_nls=$enableval, enable_nls=yes)
460   AC_MSG_RESULT($enable_nls)
461   use_nls=$enable_nls
462   AM_CONDITIONAL(USE_NLS, test $use_nls = yes)
464   if test $enable_nls = yes; then
465     AC_DEFINE(ENABLE_NLS, 1, [Define if NLS is requested.])
467     # We don't support catgets at all
468     if test "x$with_catgets" != x; then
469       AC_MSG_WARN([catgets not supported; --with-catgets ignored])
470     fi
472     # Find out what the user wants.
474     AC_ARG_WITH(included-gettext,
475       [  --with-included-gettext use the GNU gettext library included here],
476       with_included_gettext=yes,
477       with_included_gettext=maybe)
479     if test "x$with_included_gettext" != xyes; then
480       pds_CHECK_SYSTEM_GETTEXT
481     fi
483     AC_MSG_CHECKING([whether to use included gettext])
484     AC_MSG_RESULT($with_included_gettext)
486     if test "$with_included_gettext" = yes; then
487       LIBOBJS="$LIBOBJS gettext.o"
488     fi
490     AC_DEFINE(HAVE_GETTEXT, 1, [Define if you have the gettext function.])
491     AC_DEFINE(HAVE_DCGETTEXT, 1, [Define if you have the dcgettext function.])
493     AC_CHECK_FUNCS(getcwd setlocale stpcpy)
495     if test -z "$ALL_LINGUAS"; then
496       AC_MSG_WARN(This package does not install translations yet.)
497     else
498       ac_items="$ALL_LINGUAS"
499       for ac_item in $ac_items; do
500         ALL_POFILES="$ALL_POFILES $ac_item.po"
501         ALL_MOFILES="$ALL_MOFILES $ac_item.mo"
502       done
503     fi
504     AC_SUBST(ALL_LINGUAS)
505     AC_SUBST(ALL_POFILES)
506     AC_SUBST(ALL_MOFILES)
508     AC_MSG_CHECKING(which translations to install)
509     if test -z "$LINGUAS"; then
510       ac_print="$ALL_LINGUAS"
511       MOFILES="$ALL_MOFILES"
512     else
513       ac_items="$LINGUAS"
514       for ac_item in $ac_items; do
515         case "$ALL_LINGUAS" in
516           *$ac_item*)
517             ac_print="$ac_print $ac_item"
518             MOFILES="$MOFILES $ac_item.mo"
519             ;;
520         esac
521       done
522     fi
523     AC_SUBST(MOFILES)
524     if test -z "$ac_print"; then
525       AC_MSG_RESULT(none)
526     else
527       AC_MSG_RESULT($ac_print)
528     fi
530     if test "x$prefix" = xNONE; then
531       AC_DEFINE_UNQUOTED(LOCALEDIR, "$ac_default_prefix/share/locale")
532     else
533       AC_DEFINE_UNQUOTED(LOCALEDIR, "$prefix/share/locale")
534     fi
535   fi])