]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - m4/package_libcdev.m4
xfs_io/encrypt: support specifying crypto data unit size
[thirdparty/xfsprogs-dev.git] / m4 / package_libcdev.m4
CommitLineData
0bba1a49
NS
1#
2# Check if we have a working fadvise system call
f8149110 3#
0bba1a49
NS
4AC_DEFUN([AC_HAVE_FADVISE],
5 [ AC_MSG_CHECKING([for fadvise ])
69d66277
DC
6 AC_COMPILE_IFELSE(
7 [ AC_LANG_PROGRAM([[
0bba1a49 8#define _GNU_SOURCE
0bba1a49 9#include <fcntl.h>
69d66277
DC
10 ]], [[
11posix_fadvise(0, 1, 0, POSIX_FADV_NORMAL);
12 ]])
0bba1a49
NS
13 ], have_fadvise=yes
14 AC_MSG_RESULT(yes),
15 AC_MSG_RESULT(no))
16 AC_SUBST(have_fadvise)
17 ])
18
f8149110 19#
0bba1a49 20# Check if we have a working madvise system call
f8149110 21#
0bba1a49
NS
22AC_DEFUN([AC_HAVE_MADVISE],
23 [ AC_MSG_CHECKING([for madvise ])
69d66277
DC
24 AC_COMPILE_IFELSE(
25 [ AC_LANG_PROGRAM([[
0bba1a49 26#define _GNU_SOURCE
0bba1a49 27#include <sys/mman.h>
69d66277
DC
28 ]], [[
29posix_madvise(0, 0, MADV_NORMAL);
30 ]])
0bba1a49
NS
31 ], have_madvise=yes
32 AC_MSG_RESULT(yes),
33 AC_MSG_RESULT(no))
34 AC_SUBST(have_madvise)
35 ])
36
f8149110 37#
0bba1a49 38# Check if we have a working mincore system call
f8149110 39#
0bba1a49
NS
40AC_DEFUN([AC_HAVE_MINCORE],
41 [ AC_MSG_CHECKING([for mincore ])
69d66277
DC
42 AC_COMPILE_IFELSE(
43 [ AC_LANG_PROGRAM([[
0bba1a49 44#define _GNU_SOURCE
0bba1a49 45#include <sys/mman.h>
69d66277
DC
46 ]], [[
47mincore(0, 0, 0);
48 ]])
0bba1a49
NS
49 ], have_mincore=yes
50 AC_MSG_RESULT(yes),
51 AC_MSG_RESULT(no))
52 AC_SUBST(have_mincore)
53 ])
54
f8149110 55#
0bba1a49 56# Check if we have a working sendfile system call
f8149110 57#
0bba1a49
NS
58AC_DEFUN([AC_HAVE_SENDFILE],
59 [ AC_MSG_CHECKING([for sendfile ])
69d66277
DC
60 AC_COMPILE_IFELSE(
61 [ AC_LANG_PROGRAM([[
0bba1a49 62#define _GNU_SOURCE
0bba1a49 63#include <sys/sendfile.h>
69d66277
DC
64 ]], [[
65sendfile(0, 0, 0, 0);
66 ]])
0bba1a49
NS
67 ], have_sendfile=yes
68 AC_MSG_RESULT(yes),
69 AC_MSG_RESULT(no))
70 AC_SUBST(have_sendfile)
71 ])
cfe6e3f0
NS
72
73#
c4bd48ef 74# Check if we have a getmntent libc call (Linux)
cfe6e3f0
NS
75#
76AC_DEFUN([AC_HAVE_GETMNTENT],
77 [ AC_MSG_CHECKING([for getmntent ])
69d66277
DC
78 AC_COMPILE_IFELSE(
79 [ AC_LANG_PROGRAM([[
cfe6e3f0
NS
80#include <stdio.h>
81#include <mntent.h>
69d66277
DC
82 ]], [[
83getmntent(0);
84 ]])
cfe6e3f0
NS
85 ], have_getmntent=yes
86 AC_MSG_RESULT(yes),
87 AC_MSG_RESULT(no))
88 AC_SUBST(have_getmntent)
89 ])
90
c0b5232a
ES
91#
92# Check if we have a fallocate libc call (Linux)
93#
94AC_DEFUN([AC_HAVE_FALLOCATE],
95 [ AC_MSG_CHECKING([for fallocate])
69d66277
DC
96 AC_LINK_IFELSE(
97 [ AC_LANG_PROGRAM([[
c17c73e2 98#define _GNU_SOURCE
c17c73e2 99#include <fcntl.h>
c0b5232a 100#include <linux/falloc.h>
69d66277
DC
101 ]], [[
102fallocate(0, 0, 0, 0);
103 ]])
c0b5232a
ES
104 ], have_fallocate=yes
105 AC_MSG_RESULT(yes),
106 AC_MSG_RESULT(no))
107 AC_SUBST(have_fallocate)
108 ])
8f0e0912
CH
109
110#
111# Check if we have the fiemap ioctl (Linux)
112#
113AC_DEFUN([AC_HAVE_FIEMAP],
2912da5d 114 [ AC_MSG_CHECKING([for fiemap])
69d66277
DC
115 AC_LINK_IFELSE(
116 [ AC_LANG_PROGRAM([[
2912da5d 117#define _GNU_SOURCE
2912da5d
NS
118#include <linux/fs.h>
119#include <linux/fiemap.h>
d6642ab8 120#include <sys/ioctl.h>
69d66277
DC
121 ]], [[
122struct fiemap *fiemap;
123ioctl(0, FS_IOC_FIEMAP, (unsigned long)fiemap);
124 ]])
2912da5d
NS
125 ], have_fiemap=yes
126 AC_MSG_RESULT(yes),
127 AC_MSG_RESULT(no))
8f0e0912
CH
128 AC_SUBST(have_fiemap)
129 ])
197d5828
ES
130
131#
132# Check if we have a preadv libc call (Linux)
133#
134AC_DEFUN([AC_HAVE_PREADV],
135 [ AC_MSG_CHECKING([for preadv])
69d66277
DC
136 AC_LINK_IFELSE(
137 [ AC_LANG_PROGRAM([[
197d5828 138#define _BSD_SOURCE
c1436573 139#define _DEFAULT_SOURCE
197d5828 140#include <sys/uio.h>
69d66277
DC
141 ]], [[
142preadv(0, 0, 0, 0);
143 ]])
197d5828
ES
144 ], have_preadv=yes
145 AC_MSG_RESULT(yes),
146 AC_MSG_RESULT(no))
147 AC_SUBST(have_preadv)
148 ])
149
c5deeac9
GR
150#
151# Check if we have a pwritev2 libc call (Linux)
152#
153AC_DEFUN([AC_HAVE_PWRITEV2],
154 [ AC_MSG_CHECKING([for pwritev2])
69d66277
DC
155 AC_LINK_IFELSE(
156 [ AC_LANG_PROGRAM([[
d6642ab8 157#define _GNU_SOURCE
c5deeac9 158#include <sys/uio.h>
69d66277
DC
159 ]], [[
160pwritev2(0, 0, 0, 0, 0);
161 ]])
c5deeac9
GR
162 ], have_pwritev2=yes
163 AC_MSG_RESULT(yes),
164 AC_MSG_RESULT(no))
165 AC_SUBST(have_pwritev2)
166 ])
167
628e112a
AS
168#
169# Check if we have a copy_file_range system call (Linux)
170#
171AC_DEFUN([AC_HAVE_COPY_FILE_RANGE],
172 [ AC_MSG_CHECKING([for copy_file_range])
69d66277
DC
173 AC_LINK_IFELSE(
174 [ AC_LANG_PROGRAM([[
628e112a
AS
175#define _GNU_SOURCE
176#include <sys/syscall.h>
177#include <unistd.h>
69d66277
DC
178 ]], [[
179syscall(__NR_copy_file_range, 0, 0, 0, 0, 0, 0);
180 ]])
628e112a
AS
181 ], have_copy_file_range=yes
182 AC_MSG_RESULT(yes),
183 AC_MSG_RESULT(no))
184 AC_SUBST(have_copy_file_range)
185 ])
186
197d5828
ES
187#
188# Check if we have a sync_file_range libc call (Linux)
189#
190AC_DEFUN([AC_HAVE_SYNC_FILE_RANGE],
191 [ AC_MSG_CHECKING([for sync_file_range])
69d66277
DC
192 AC_LINK_IFELSE(
193 [ AC_LANG_PROGRAM([[
197d5828 194#define _GNU_SOURCE
197d5828 195#include <fcntl.h>
69d66277
DC
196 ]], [[
197sync_file_range(0, 0, 0, 0);
198 ]])
197d5828
ES
199 ], have_sync_file_range=yes
200 AC_MSG_RESULT(yes),
201 AC_MSG_RESULT(no))
202 AC_SUBST(have_sync_file_range)
203 ])
204
c7dd81c7
ES
205#
206# Check if we have a syncfs libc call (Linux)
207#
208AC_DEFUN([AC_HAVE_SYNCFS],
209 [ AC_MSG_CHECKING([for syncfs])
69d66277
DC
210 AC_LINK_IFELSE(
211 [ AC_LANG_PROGRAM([[
c7dd81c7 212#define _GNU_SOURCE
c7dd81c7 213#include <unistd.h>
69d66277
DC
214 ]], [[
215syncfs(0);
216 ]])
eb24bcff 217 ], have_syncfs=yes
c7dd81c7
ES
218 AC_MSG_RESULT(yes),
219 AC_MSG_RESULT(no))
220 AC_SUBST(have_syncfs)
221 ])
222
3bc05641
BF
223#
224# Check if we have a readdir libc call
225#
226AC_DEFUN([AC_HAVE_READDIR],
227 [ AC_MSG_CHECKING([for readdir])
69d66277
DC
228 AC_LINK_IFELSE(
229 [ AC_LANG_PROGRAM([[
3bc05641 230#include <dirent.h>
69d66277
DC
231 ]], [[
232readdir(0);
233 ]])
3bc05641
BF
234 ], have_readdir=yes
235 AC_MSG_RESULT(yes),
236 AC_MSG_RESULT(no))
237 AC_SUBST(have_readdir)
238 ])
239
5121281b
JT
240#
241# Check if we have a flc call (Mac OS X)
242#
243AC_DEFUN([AC_HAVE_FLS],
244 [ AC_CHECK_DECL([fls],
245 have_fls=yes,
246 [],
247 [#include <string.h>]
248 )
249 AC_SUBST(have_fls)
250 ])
251
c14c7b79 252#
f5629402 253# Check if we have a fsetxattr call
c14c7b79
JT
254#
255AC_DEFUN([AC_HAVE_FSETXATTR],
256 [ AC_CHECK_DECL([fsetxattr],
257 have_fsetxattr=yes,
258 [],
259 [#include <sys/types.h>
f5629402 260 #include <sys/xattr.h>]
c14c7b79
JT
261 )
262 AC_SUBST(have_fsetxattr)
263 ])
264
5ae294ea
JT
265#
266# Check if there is mntent.h
267#
268AC_DEFUN([AC_HAVE_MNTENT],
269 [ AC_CHECK_HEADERS(mntent.h,
270 have_mntent=yes)
271 AC_SUBST(have_mntent)
272 ])
a49984b3
JT
273
274#
275# Check if we have a mremap call (not on Mac OS X)
276#
277AC_DEFUN([AC_HAVE_MREMAP],
278 [ AC_CHECK_DECL([mremap],
279 have_mremap=yes,
280 [],
281 [#define _GNU_SOURCE
282 #include <sys/mman.h>]
283 )
284 AC_SUBST(have_mremap)
285 ])
6529e656
DW
286
287#
288# Check if we need to override the system struct fsxattr with
289# the internal definition. This /only/ happens if the system
290# actually defines struct fsxattr /and/ the system definition
291# is missing certain fields.
292#
293AC_DEFUN([AC_NEED_INTERNAL_FSXATTR],
294 [
1e51132f
DW
295 AC_CHECK_TYPE(struct fsxattr,
296 [
297 AC_CHECK_MEMBER(struct fsxattr.fsx_cowextsize,
298 ,
299 need_internal_fsxattr=yes,
300 [#include <linux/fs.h>]
301 )
302 ],,
303 [#include <linux/fs.h>]
304 )
6529e656
DW
305 AC_SUBST(need_internal_fsxattr)
306 ])
71956d72 307
dfe209d8
EB
308#
309# Check if we need to override the system struct fscrypt_add_key_arg
310# with the internal definition. This /only/ happens if the system
311# actually defines struct fscrypt_add_key_arg /and/ the system
312# definition is missing certain fields.
313#
314AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_ADD_KEY_ARG],
315 [
316 AC_CHECK_TYPE(struct fscrypt_add_key_arg,
317 [
318 AC_CHECK_MEMBER(struct fscrypt_add_key_arg.key_id,
319 ,
320 need_internal_fscrypt_add_key_arg=yes,
321 [#include <linux/fs.h>]
322 )
323 ],,
324 [#include <linux/fs.h>]
325 )
326 AC_SUBST(need_internal_fscrypt_add_key_arg)
327 ])
328
e97caf71
EB
329#
330# Check if we need to override the system struct fscrypt_policy_v2
331# with the internal definition. This /only/ happens if the system
332# actually defines struct fscrypt_policy_v2 /and/ the system
333# definition is missing certain fields.
334#
335AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_POLICY_V2],
336 [
337 AC_CHECK_TYPE(struct fscrypt_policy_v2,
338 [
339 AC_CHECK_MEMBER(struct fscrypt_policy_v2.log2_data_unit_size,
340 ,
341 need_internal_fscrypt_policy_v2=yes,
342 [#include <linux/fs.h>]
343 )
344 ],,
345 [#include <linux/fs.h>]
346 )
347 AC_SUBST(need_internal_fscrypt_policy_v2)
348 ])
349
71956d72
DW
350#
351# Check if we have a FS_IOC_GETFSMAP ioctl (Linux)
352#
353AC_DEFUN([AC_HAVE_GETFSMAP],
354 [ AC_MSG_CHECKING([for GETFSMAP])
69d66277
DC
355 AC_LINK_IFELSE(
356 [ AC_LANG_PROGRAM([[
71956d72
DW
357#define _GNU_SOURCE
358#include <sys/syscall.h>
359#include <unistd.h>
360#include <linux/fs.h>
361#include <linux/fsmap.h>
69d66277
DC
362 ]], [[
363unsigned long x = FS_IOC_GETFSMAP;
364struct fsmap_head fh;
365 ]])
71956d72
DW
366 ], have_getfsmap=yes
367 AC_MSG_RESULT(yes),
368 AC_MSG_RESULT(no))
369 AC_SUBST(have_getfsmap)
370 ])
ce9adab0
JM
371
372AC_DEFUN([AC_HAVE_STATFS_FLAGS],
373 [
374 AC_CHECK_TYPE(struct statfs,
375 [
376 AC_CHECK_MEMBER(struct statfs.f_flags,
377 have_statfs_flags=yes,,
378 [#include <sys/vfs.h>]
379 )
380 ],,
381 [#include <sys/vfs.h>]
382 )
383 AC_SUBST(have_statfs_flags)
384 ])
dad79683
RZ
385
386#
387# Check if we have MAP_SYNC defines (Linux)
388#
389AC_DEFUN([AC_HAVE_MAP_SYNC],
390 [ AC_MSG_CHECKING([for MAP_SYNC])
69d66277
DC
391 AC_COMPILE_IFELSE(
392 [ AC_LANG_PROGRAM([[
28965957 393#include <sys/mman.h>
69d66277
DC
394 ]], [[
395int flags = MAP_SYNC | MAP_SHARED_VALIDATE;
396 ]])
dad79683
RZ
397 ], have_map_sync=yes
398 AC_MSG_RESULT(yes),
399 AC_MSG_RESULT(no))
400 AC_SUBST(have_map_sync)
401 ])
173a0283
DW
402
403#
404# Check if we have a mallinfo libc call
405#
406AC_DEFUN([AC_HAVE_MALLINFO],
407 [ AC_MSG_CHECKING([for mallinfo ])
69d66277
DC
408 AC_COMPILE_IFELSE(
409 [ AC_LANG_PROGRAM([[
173a0283 410#include <malloc.h>
69d66277
DC
411 ]], [[
412struct mallinfo test;
173a0283 413
69d66277
DC
414test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
415test = mallinfo();
416 ]])
173a0283
DW
417 ], have_mallinfo=yes
418 AC_MSG_RESULT(yes),
419 AC_MSG_RESULT(no))
420 AC_SUBST(have_mallinfo)
421 ])
b364a9c0 422
c74f0468
DW
423#
424# Check if we have a mallinfo2 libc call
425#
426AC_DEFUN([AC_HAVE_MALLINFO2],
427 [ AC_MSG_CHECKING([for mallinfo2 ])
1a35c8df
DW
428 AC_COMPILE_IFELSE(
429 [ AC_LANG_PROGRAM([[
c74f0468 430#include <malloc.h>
1a35c8df
DW
431 ]], [[
432struct mallinfo2 test;
c74f0468 433
1a35c8df
DW
434test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
435test = mallinfo2();
436 ]])
c74f0468
DW
437 ], have_mallinfo2=yes
438 AC_MSG_RESULT(yes),
439 AC_MSG_RESULT(no))
440 AC_SUBST(have_mallinfo2)
441 ])
442
b364a9c0
DW
443#
444# Check if we have a openat call
445#
446AC_DEFUN([AC_HAVE_OPENAT],
447 [ AC_CHECK_DECL([openat],
448 have_openat=yes,
449 [],
450 [#include <sys/types.h>
451 #include <sys/stat.h>
452 #include <fcntl.h>]
453 )
454 AC_SUBST(have_openat)
455 ])
456
457#
458# Check if we have a fstatat call
459#
460AC_DEFUN([AC_HAVE_FSTATAT],
461 [ AC_CHECK_DECL([fstatat],
462 have_fstatat=yes,
463 [],
464 [#define _GNU_SOURCE
465 #include <sys/types.h>
466 #include <sys/stat.h>
467 #include <unistd.h>])
468 AC_SUBST(have_fstatat)
469 ])
03c0cd8f
DW
470
471#
472# Check if we have the SG_IO ioctl
473#
474AC_DEFUN([AC_HAVE_SG_IO],
475 [ AC_MSG_CHECKING([for struct sg_io_hdr ])
69d66277
DC
476 AC_COMPILE_IFELSE(
477 [ AC_LANG_PROGRAM([[
478#include <scsi/sg.h>
d6642ab8 479#include <sys/ioctl.h>
69d66277
DC
480 ]], [[
481struct sg_io_hdr hdr;
482ioctl(0, SG_IO, &hdr);
483 ]])
03c0cd8f
DW
484 ], have_sg_io=yes
485 AC_MSG_RESULT(yes),
486 AC_MSG_RESULT(no))
487 AC_SUBST(have_sg_io)
488 ])
489
490#
491# Check if we have the HDIO_GETGEO ioctl
492#
493AC_DEFUN([AC_HAVE_HDIO_GETGEO],
494 [ AC_MSG_CHECKING([for struct hd_geometry ])
69d66277
DC
495 AC_COMPILE_IFELSE(
496 [ AC_LANG_PROGRAM([[
d6642ab8
AS
497#include <linux/hdreg.h>
498#include <sys/ioctl.h>
69d66277
DC
499 ]], [[
500struct hd_geometry hdr;
501ioctl(0, HDIO_GETGEO, &hdr);
502 ]])
03c0cd8f
DW
503 ], have_hdio_getgeo=yes
504 AC_MSG_RESULT(yes),
505 AC_MSG_RESULT(no))
506 AC_SUBST(have_hdio_getgeo)
507 ])
1b0adc71 508
e61f1552
DW
509AC_DEFUN([AC_PACKAGE_CHECK_LTO],
510 [ AC_MSG_CHECKING([if C compiler supports LTO])
511 OLD_CFLAGS="$CFLAGS"
512 OLD_LDFLAGS="$LDFLAGS"
513 LTO_FLAGS="-flto -ffat-lto-objects"
514 CFLAGS="$CFLAGS $LTO_FLAGS"
515 LDFLAGS="$LDFLAGS $LTO_FLAGS"
516 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
517 [AC_MSG_RESULT([yes])]
518 [lto_cflags=$LTO_FLAGS]
519 [lto_ldflags=$LTO_FLAGS]
520 [AC_PATH_PROG(gcc_ar, gcc-ar,,)]
521 [AC_PATH_PROG(gcc_ranlib, gcc-ranlib,,)],
522 [AC_MSG_RESULT([no])])
523 if test -x "$gcc_ar" && test -x "$gcc_ranlib"; then
524 have_lto=yes
525 fi
526 CFLAGS="${OLD_CFLAGS}"
527 LDFLAGS="${OLD_LDFLAGS}"
528 AC_SUBST(gcc_ar)
529 AC_SUBST(gcc_ranlib)
530 AC_SUBST(have_lto)
531 AC_SUBST(lto_cflags)
532 AC_SUBST(lto_ldflags)
533 ])