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