]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - m4/package_libcdev.m4
configure: don't check for fsetxattr
[thirdparty/xfsprogs-dev.git] / m4 / package_libcdev.m4
1 #
2 # Check if we have a pwritev2 libc call (Linux)
3 #
4 AC_DEFUN([AC_HAVE_PWRITEV2],
5 [ AC_MSG_CHECKING([for pwritev2])
6 AC_LINK_IFELSE(
7 [ AC_LANG_PROGRAM([[
8 #define _GNU_SOURCE
9 #include <sys/uio.h>
10 ]], [[
11 pwritev2(0, 0, 0, 0, 0);
12 ]])
13 ], have_pwritev2=yes
14 AC_MSG_RESULT(yes),
15 AC_MSG_RESULT(no))
16 AC_SUBST(have_pwritev2)
17 ])
18
19 #
20 # Check if we have a copy_file_range system call (Linux)
21 #
22 AC_DEFUN([AC_HAVE_COPY_FILE_RANGE],
23 [ AC_MSG_CHECKING([for copy_file_range])
24 AC_LINK_IFELSE(
25 [ AC_LANG_PROGRAM([[
26 #define _GNU_SOURCE
27 #include <sys/syscall.h>
28 #include <unistd.h>
29 ]], [[
30 syscall(__NR_copy_file_range, 0, 0, 0, 0, 0, 0);
31 ]])
32 ], have_copy_file_range=yes
33 AC_MSG_RESULT(yes),
34 AC_MSG_RESULT(no))
35 AC_SUBST(have_copy_file_range)
36 ])
37
38 #
39 # Check if we need to override the system struct fsxattr with
40 # the internal definition. This /only/ happens if the system
41 # actually defines struct fsxattr /and/ the system definition
42 # is missing certain fields.
43 #
44 AC_DEFUN([AC_NEED_INTERNAL_FSXATTR],
45 [
46 AC_CHECK_TYPE(struct fsxattr,
47 [
48 AC_CHECK_MEMBER(struct fsxattr.fsx_cowextsize,
49 ,
50 need_internal_fsxattr=yes,
51 [#include <linux/fs.h>]
52 )
53 ],,
54 [#include <linux/fs.h>]
55 )
56 AC_SUBST(need_internal_fsxattr)
57 ])
58
59 #
60 # Check if we need to override the system struct fscrypt_add_key_arg
61 # with the internal definition. This /only/ happens if the system
62 # actually defines struct fscrypt_add_key_arg /and/ the system
63 # definition is missing certain fields.
64 #
65 AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_ADD_KEY_ARG],
66 [
67 AC_CHECK_TYPE(struct fscrypt_add_key_arg,
68 [
69 AC_CHECK_MEMBER(struct fscrypt_add_key_arg.key_id,
70 ,
71 need_internal_fscrypt_add_key_arg=yes,
72 [#include <linux/fs.h>]
73 )
74 ],,
75 [#include <linux/fs.h>]
76 )
77 AC_SUBST(need_internal_fscrypt_add_key_arg)
78 ])
79
80 #
81 # Check if we need to override the system struct fscrypt_policy_v2
82 # with the internal definition. This /only/ happens if the system
83 # actually defines struct fscrypt_policy_v2 /and/ the system
84 # definition is missing certain fields.
85 #
86 AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_POLICY_V2],
87 [
88 AC_CHECK_TYPE(struct fscrypt_policy_v2,
89 [
90 AC_CHECK_MEMBER(struct fscrypt_policy_v2.log2_data_unit_size,
91 ,
92 need_internal_fscrypt_policy_v2=yes,
93 [#include <linux/fs.h>]
94 )
95 ],,
96 [#include <linux/fs.h>]
97 )
98 AC_SUBST(need_internal_fscrypt_policy_v2)
99 ])
100
101 #
102 # Check if we have a FS_IOC_GETFSMAP ioctl (Linux)
103 #
104 AC_DEFUN([AC_HAVE_GETFSMAP],
105 [ AC_MSG_CHECKING([for GETFSMAP])
106 AC_LINK_IFELSE(
107 [ AC_LANG_PROGRAM([[
108 #define _GNU_SOURCE
109 #include <sys/syscall.h>
110 #include <unistd.h>
111 #include <linux/fs.h>
112 #include <linux/fsmap.h>
113 ]], [[
114 unsigned long x = FS_IOC_GETFSMAP;
115 struct fsmap_head fh;
116 ]])
117 ], have_getfsmap=yes
118 AC_MSG_RESULT(yes),
119 AC_MSG_RESULT(no))
120 AC_SUBST(have_getfsmap)
121 ])
122
123 AC_DEFUN([AC_HAVE_STATFS_FLAGS],
124 [
125 AC_CHECK_TYPE(struct statfs,
126 [
127 AC_CHECK_MEMBER(struct statfs.f_flags,
128 have_statfs_flags=yes,,
129 [#include <sys/vfs.h>]
130 )
131 ],,
132 [#include <sys/vfs.h>]
133 )
134 AC_SUBST(have_statfs_flags)
135 ])
136
137 #
138 # Check if we have MAP_SYNC defines (Linux)
139 #
140 AC_DEFUN([AC_HAVE_MAP_SYNC],
141 [ AC_MSG_CHECKING([for MAP_SYNC])
142 AC_COMPILE_IFELSE(
143 [ AC_LANG_PROGRAM([[
144 #include <sys/mman.h>
145 ]], [[
146 int flags = MAP_SYNC | MAP_SHARED_VALIDATE;
147 ]])
148 ], have_map_sync=yes
149 AC_MSG_RESULT(yes),
150 AC_MSG_RESULT(no))
151 AC_SUBST(have_map_sync)
152 ])
153
154 #
155 # Check if we have a mallinfo libc call
156 #
157 AC_DEFUN([AC_HAVE_MALLINFO],
158 [ AC_MSG_CHECKING([for mallinfo ])
159 AC_COMPILE_IFELSE(
160 [ AC_LANG_PROGRAM([[
161 #include <malloc.h>
162 ]], [[
163 struct mallinfo test;
164
165 test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
166 test = mallinfo();
167 ]])
168 ], have_mallinfo=yes
169 AC_MSG_RESULT(yes),
170 AC_MSG_RESULT(no))
171 AC_SUBST(have_mallinfo)
172 ])
173
174 #
175 # Check if we have a mallinfo2 libc call
176 #
177 AC_DEFUN([AC_HAVE_MALLINFO2],
178 [ AC_MSG_CHECKING([for mallinfo2 ])
179 AC_COMPILE_IFELSE(
180 [ AC_LANG_PROGRAM([[
181 #include <malloc.h>
182 ]], [[
183 struct mallinfo2 test;
184
185 test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
186 test = mallinfo2();
187 ]])
188 ], have_mallinfo2=yes
189 AC_MSG_RESULT(yes),
190 AC_MSG_RESULT(no))
191 AC_SUBST(have_mallinfo2)
192 ])
193
194 #
195 # Check if we have a openat call
196 #
197 AC_DEFUN([AC_HAVE_OPENAT],
198 [ AC_CHECK_DECL([openat],
199 have_openat=yes,
200 [],
201 [#include <sys/types.h>
202 #include <sys/stat.h>
203 #include <fcntl.h>]
204 )
205 AC_SUBST(have_openat)
206 ])
207
208 #
209 # Check if we have a fstatat call
210 #
211 AC_DEFUN([AC_HAVE_FSTATAT],
212 [ AC_CHECK_DECL([fstatat],
213 have_fstatat=yes,
214 [],
215 [#define _GNU_SOURCE
216 #include <sys/types.h>
217 #include <sys/stat.h>
218 #include <unistd.h>])
219 AC_SUBST(have_fstatat)
220 ])
221
222 #
223 # Check if we have the SG_IO ioctl
224 #
225 AC_DEFUN([AC_HAVE_SG_IO],
226 [ AC_MSG_CHECKING([for struct sg_io_hdr ])
227 AC_COMPILE_IFELSE(
228 [ AC_LANG_PROGRAM([[
229 #include <scsi/sg.h>
230 #include <sys/ioctl.h>
231 ]], [[
232 struct sg_io_hdr hdr;
233 ioctl(0, SG_IO, &hdr);
234 ]])
235 ], have_sg_io=yes
236 AC_MSG_RESULT(yes),
237 AC_MSG_RESULT(no))
238 AC_SUBST(have_sg_io)
239 ])
240
241 #
242 # Check if we have the HDIO_GETGEO ioctl
243 #
244 AC_DEFUN([AC_HAVE_HDIO_GETGEO],
245 [ AC_MSG_CHECKING([for struct hd_geometry ])
246 AC_COMPILE_IFELSE(
247 [ AC_LANG_PROGRAM([[
248 #include <linux/hdreg.h>
249 #include <sys/ioctl.h>
250 ]], [[
251 struct hd_geometry hdr;
252 ioctl(0, HDIO_GETGEO, &hdr);
253 ]])
254 ], have_hdio_getgeo=yes
255 AC_MSG_RESULT(yes),
256 AC_MSG_RESULT(no))
257 AC_SUBST(have_hdio_getgeo)
258 ])
259
260 AC_DEFUN([AC_PACKAGE_CHECK_LTO],
261 [ AC_MSG_CHECKING([if C compiler supports LTO])
262 OLD_CFLAGS="$CFLAGS"
263 OLD_LDFLAGS="$LDFLAGS"
264 LTO_FLAGS="-flto -ffat-lto-objects"
265 CFLAGS="$CFLAGS $LTO_FLAGS"
266 LDFLAGS="$LDFLAGS $LTO_FLAGS"
267 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
268 [AC_MSG_RESULT([yes])]
269 [lto_cflags=$LTO_FLAGS]
270 [lto_ldflags=$LTO_FLAGS]
271 [AC_PATH_PROG(gcc_ar, gcc-ar,,)]
272 [AC_PATH_PROG(gcc_ranlib, gcc-ranlib,,)],
273 [AC_MSG_RESULT([no])])
274 if test -x "$gcc_ar" && test -x "$gcc_ranlib"; then
275 have_lto=yes
276 fi
277 CFLAGS="${OLD_CFLAGS}"
278 LDFLAGS="${OLD_LDFLAGS}"
279 AC_SUBST(gcc_ar)
280 AC_SUBST(gcc_ranlib)
281 AC_SUBST(have_lto)
282 AC_SUBST(lto_cflags)
283 AC_SUBST(lto_ldflags)
284 ])