* build-aux/gendocs.sh: Restore lost x bit.
[pspp] / m4 / fcntl_h.m4
1 # Configure fcntl.h.
2 dnl Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 dnl Written by Paul Eggert.
8
9 AC_DEFUN([gl_FCNTL_H],
10 [
11   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
12   AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
13   AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
14     [AC_RUN_IFELSE(
15        [AC_LANG_PROGRAM(
16           [[#include <sys/types.h>
17            #include <sys/stat.h>
18            #include <unistd.h>
19            #include <fcntl.h>
20            #ifndef O_NOATIME
21             #define O_NOATIME 0
22            #endif
23            #ifndef O_NOFOLLOW
24             #define O_NOFOLLOW 0
25            #endif
26            static int const constants[] =
27             {
28               O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
29               O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
30             };
31           ]],
32           [[
33             int status = !constants;
34             {
35               static char const sym[] = "conftest.sym";
36               if (symlink (".", sym) != 0
37                   || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
38                 status |= 32;
39             }
40             {
41               static char const file[] = "confdefs.h";
42               int fd = open (file, O_RDONLY | O_NOATIME);
43               char c;
44               struct stat st0, st1;
45               if (fd < 0
46                   || fstat (fd, &st0) != 0
47                   || sleep (1) != 0
48                   || read (fd, &c, 1) != 1
49                   || close (fd) != 0
50                   || stat (file, &st1) != 0
51                   || st0.st_atime != st1.st_atime)
52                 status |= 64;
53             }
54             return status;]])],
55        [gl_cv_header_working_fcntl_h=yes],
56        [case $? in #(
57         32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
58         64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
59         96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
60          *) gl_cv_header_working_fcntl_h='no';;
61         esac],
62        [gl_cv_header_working_fcntl_h=cross-compiling])])
63
64   case $gl_cv_header_working_fcntl_h in #(
65   *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
66   *) ac_val=1;;
67   esac
68   AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
69     [Define to 1 if O_NOATIME works.])
70
71   case $gl_cv_header_working_fcntl_h in #(
72   *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
73   *) ac_val=1;;
74   esac
75   AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
76     [Define to 1 if O_NOFOLLOW works.])
77
78   gl_CHECK_NEXT_HEADERS([fcntl.h])
79   FCNTL_H='fcntl.h'
80   AC_SUBST([FCNTL_H])
81 ])
82
83 AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],
84 [
85   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
86   AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
87   GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
88 ])
89
90 AC_DEFUN([gl_FCNTL_H_DEFAULTS],
91 [
92   GNULIB_OPEN=0;  AC_SUBST([GNULIB_OPEN])
93   dnl Assume proper GNU behavior unless another module says otherwise.
94   REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
95 ])