]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - m4/package_libcdev.m4
configure: don't check for fallocate
[thirdparty/xfsprogs-dev.git] / m4 / package_libcdev.m4
CommitLineData
197d5828
ES
1#
2# Check if we have a preadv libc call (Linux)
3#
4AC_DEFUN([AC_HAVE_PREADV],
5 [ AC_MSG_CHECKING([for preadv])
69d66277
DC
6 AC_LINK_IFELSE(
7 [ AC_LANG_PROGRAM([[
197d5828 8#define _BSD_SOURCE
c1436573 9#define _DEFAULT_SOURCE
197d5828 10#include <sys/uio.h>
69d66277
DC
11 ]], [[
12preadv(0, 0, 0, 0);
13 ]])
197d5828
ES
14 ], have_preadv=yes
15 AC_MSG_RESULT(yes),
16 AC_MSG_RESULT(no))
17 AC_SUBST(have_preadv)
18 ])
19
c5deeac9
GR
20#
21# Check if we have a pwritev2 libc call (Linux)
22#
23AC_DEFUN([AC_HAVE_PWRITEV2],
24 [ AC_MSG_CHECKING([for pwritev2])
69d66277
DC
25 AC_LINK_IFELSE(
26 [ AC_LANG_PROGRAM([[
d6642ab8 27#define _GNU_SOURCE
c5deeac9 28#include <sys/uio.h>
69d66277
DC
29 ]], [[
30pwritev2(0, 0, 0, 0, 0);
31 ]])
c5deeac9
GR
32 ], have_pwritev2=yes
33 AC_MSG_RESULT(yes),
34 AC_MSG_RESULT(no))
35 AC_SUBST(have_pwritev2)
36 ])
37
628e112a
AS
38#
39# Check if we have a copy_file_range system call (Linux)
40#
41AC_DEFUN([AC_HAVE_COPY_FILE_RANGE],
42 [ AC_MSG_CHECKING([for copy_file_range])
69d66277
DC
43 AC_LINK_IFELSE(
44 [ AC_LANG_PROGRAM([[
628e112a
AS
45#define _GNU_SOURCE
46#include <sys/syscall.h>
47#include <unistd.h>
69d66277
DC
48 ]], [[
49syscall(__NR_copy_file_range, 0, 0, 0, 0, 0, 0);
50 ]])
628e112a
AS
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
c7dd81c7
ES
57#
58# Check if we have a syncfs libc call (Linux)
59#
60AC_DEFUN([AC_HAVE_SYNCFS],
61 [ AC_MSG_CHECKING([for syncfs])
69d66277
DC
62 AC_LINK_IFELSE(
63 [ AC_LANG_PROGRAM([[
c7dd81c7 64#define _GNU_SOURCE
c7dd81c7 65#include <unistd.h>
69d66277
DC
66 ]], [[
67syncfs(0);
68 ]])
eb24bcff 69 ], have_syncfs=yes
c7dd81c7
ES
70 AC_MSG_RESULT(yes),
71 AC_MSG_RESULT(no))
72 AC_SUBST(have_syncfs)
73 ])
74
c14c7b79 75#
f5629402 76# Check if we have a fsetxattr call
c14c7b79
JT
77#
78AC_DEFUN([AC_HAVE_FSETXATTR],
79 [ AC_CHECK_DECL([fsetxattr],
80 have_fsetxattr=yes,
81 [],
82 [#include <sys/types.h>
f5629402 83 #include <sys/xattr.h>]
c14c7b79
JT
84 )
85 AC_SUBST(have_fsetxattr)
86 ])
87
a49984b3
JT
88#
89# Check if we have a mremap call (not on Mac OS X)
90#
91AC_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 ])
6529e656
DW
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#
107AC_DEFUN([AC_NEED_INTERNAL_FSXATTR],
108 [
1e51132f
DW
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 )
6529e656
DW
119 AC_SUBST(need_internal_fsxattr)
120 ])
71956d72 121
dfe209d8
EB
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#
128AC_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
e97caf71
EB
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#
149AC_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
71956d72
DW
164#
165# Check if we have a FS_IOC_GETFSMAP ioctl (Linux)
166#
167AC_DEFUN([AC_HAVE_GETFSMAP],
168 [ AC_MSG_CHECKING([for GETFSMAP])
69d66277
DC
169 AC_LINK_IFELSE(
170 [ AC_LANG_PROGRAM([[
71956d72
DW
171#define _GNU_SOURCE
172#include <sys/syscall.h>
173#include <unistd.h>
174#include <linux/fs.h>
175#include <linux/fsmap.h>
69d66277
DC
176 ]], [[
177unsigned long x = FS_IOC_GETFSMAP;
178struct fsmap_head fh;
179 ]])
71956d72
DW
180 ], have_getfsmap=yes
181 AC_MSG_RESULT(yes),
182 AC_MSG_RESULT(no))
183 AC_SUBST(have_getfsmap)
184 ])
ce9adab0
JM
185
186AC_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 ])
dad79683
RZ
199
200#
201# Check if we have MAP_SYNC defines (Linux)
202#
203AC_DEFUN([AC_HAVE_MAP_SYNC],
204 [ AC_MSG_CHECKING([for MAP_SYNC])
69d66277
DC
205 AC_COMPILE_IFELSE(
206 [ AC_LANG_PROGRAM([[
28965957 207#include <sys/mman.h>
69d66277
DC
208 ]], [[
209int flags = MAP_SYNC | MAP_SHARED_VALIDATE;
210 ]])
dad79683
RZ
211 ], have_map_sync=yes
212 AC_MSG_RESULT(yes),
213 AC_MSG_RESULT(no))
214 AC_SUBST(have_map_sync)
215 ])
173a0283
DW
216
217#
218# Check if we have a mallinfo libc call
219#
220AC_DEFUN([AC_HAVE_MALLINFO],
221 [ AC_MSG_CHECKING([for mallinfo ])
69d66277
DC
222 AC_COMPILE_IFELSE(
223 [ AC_LANG_PROGRAM([[
173a0283 224#include <malloc.h>
69d66277
DC
225 ]], [[
226struct mallinfo test;
173a0283 227
69d66277
DC
228test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
229test = mallinfo();
230 ]])
173a0283
DW
231 ], have_mallinfo=yes
232 AC_MSG_RESULT(yes),
233 AC_MSG_RESULT(no))
234 AC_SUBST(have_mallinfo)
235 ])
b364a9c0 236
c74f0468
DW
237#
238# Check if we have a mallinfo2 libc call
239#
240AC_DEFUN([AC_HAVE_MALLINFO2],
241 [ AC_MSG_CHECKING([for mallinfo2 ])
1a35c8df
DW
242 AC_COMPILE_IFELSE(
243 [ AC_LANG_PROGRAM([[
c74f0468 244#include <malloc.h>
1a35c8df
DW
245 ]], [[
246struct mallinfo2 test;
c74f0468 247
1a35c8df
DW
248test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
249test = mallinfo2();
250 ]])
c74f0468
DW
251 ], have_mallinfo2=yes
252 AC_MSG_RESULT(yes),
253 AC_MSG_RESULT(no))
254 AC_SUBST(have_mallinfo2)
255 ])
256
b364a9c0
DW
257#
258# Check if we have a openat call
259#
260AC_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#
274AC_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 ])
03c0cd8f
DW
284
285#
286# Check if we have the SG_IO ioctl
287#
288AC_DEFUN([AC_HAVE_SG_IO],
289 [ AC_MSG_CHECKING([for struct sg_io_hdr ])
69d66277
DC
290 AC_COMPILE_IFELSE(
291 [ AC_LANG_PROGRAM([[
292#include <scsi/sg.h>
d6642ab8 293#include <sys/ioctl.h>
69d66277
DC
294 ]], [[
295struct sg_io_hdr hdr;
296ioctl(0, SG_IO, &hdr);
297 ]])
03c0cd8f
DW
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#
307AC_DEFUN([AC_HAVE_HDIO_GETGEO],
308 [ AC_MSG_CHECKING([for struct hd_geometry ])
69d66277
DC
309 AC_COMPILE_IFELSE(
310 [ AC_LANG_PROGRAM([[
d6642ab8
AS
311#include <linux/hdreg.h>
312#include <sys/ioctl.h>
69d66277
DC
313 ]], [[
314struct hd_geometry hdr;
315ioctl(0, HDIO_GETGEO, &hdr);
316 ]])
03c0cd8f
DW
317 ], have_hdio_getgeo=yes
318 AC_MSG_RESULT(yes),
319 AC_MSG_RESULT(no))
320 AC_SUBST(have_hdio_getgeo)
321 ])
1b0adc71 322
e61f1552
DW
323AC_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 ])