473fde210f602b95d9e0cb36ca4862bcf531f827
[gnulib.git] / m4 / ftruncate.m4
1 #serial 2
2
3 # See if we need to emulate a missing ftruncate function using fcntl.
4
5 AC_DEFUN(jm_FUNC_FTRUNCATE,
6 [
7   AC_CHECK_FUNCS(ftruncate, , [ftruncate_missing=yes])
8
9   if test "$ftruncate_missing" = yes; then
10     AC_CHECK_HEADERS(unistd.h)
11     AC_MSG_CHECKING([fcntl emulation of ftruncate])
12     AC_CACHE_VAL(fu_cv_sys_ftruncate_emulation,
13     [AC_TRY_LINK([
14 #include <sys/types.h>
15 #include <fcntl.h>], [
16 #if !defined(F_CHSIZE) && !defined(F_FREESP)
17   chsize();
18 #endif
19   ],
20       fu_cv_sys_ftruncate_emulation=yes,
21       fu_cv_sys_ftruncate_emulation=no)])
22     AC_MSG_RESULT($fu_cv_sys_ftruncate_emulation)
23     if test $fu_cv_sys_ftruncate_emulation = yes; then
24       AC_LIBOBJ([ftruncate])
25     fi
26   fi
27 ])