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