Imported Upstream version 3.2.0
[debian/amanda] / config / gnulib / ftruncate.m4
1 # serial 15
2
3 # See if we need to emulate a missing ftruncate function using fcntl or chsize.
4
5 # Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc.
6 # This file is free software; the Free Software Foundation
7 # gives unlimited permission to copy and/or distribute it,
8 # with or without modifications, as long as this notice is preserved.
9
10 # FIXME: remove this macro, along with all uses of HAVE_FTRUNCATE in 2012,
11 # if the check below provokes no more reports.  So far, the only report
12 # arose from a test build of this gnulib module, cross-compiling to mingw:
13 # <http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/9203>
14 # Now (in 2010), MSVC has been raised as a possible target:
15 # <http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/21394/focus=21396>
16
17 AC_DEFUN([gl_FUNC_FTRUNCATE],
18 [
19   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
20   AC_REQUIRE([AC_CANONICAL_HOST])
21   AC_CHECK_FUNCS_ONCE([ftruncate])
22   if test $ac_cv_func_ftruncate = no; then
23     HAVE_FTRUNCATE=0
24     AC_LIBOBJ([ftruncate])
25     gl_PREREQ_FTRUNCATE
26     case "$host_os" in
27       mingw*)
28         # Yes, we know mingw lacks ftruncate.
29         ;;
30       *)
31         # If someone lacks ftruncate, make configure fail, and request
32         # a bug report to inform us about it.
33         if test x"$SKIP_FTRUNCATE_CHECK" != xyes; then
34           AC_MSG_FAILURE([Your system lacks the ftruncate function.
35               Please report this, along with the output of "uname -a", to the
36               bug-coreutils@gnu.org mailing list.  To continue past this point,
37               rerun configure with SKIP_FTRUNCATE_CHECK=yes.
38               E.g., ./configure SKIP_FTRUNCATE_CHECK=yes])
39         fi
40     esac
41   fi
42 ])
43
44 # Prerequisites of lib/ftruncate.c.
45 AC_DEFUN([gl_PREREQ_FTRUNCATE],
46 [
47   AC_CHECK_FUNCS([chsize])
48 ])