]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame_incremental - m4/package_libcdev.m4
configure: don't check for mincor
[thirdparty/xfsprogs-dev.git] / m4 / package_libcdev.m4
... / ...
CommitLineData
1#
2# Check if we have a fallocate libc call (Linux)
3#
4AC_DEFUN([AC_HAVE_FALLOCATE],
5 [ AC_MSG_CHECKING([for fallocate])
6 AC_LINK_IFELSE(
7 [ AC_LANG_PROGRAM([[
8#define _GNU_SOURCE
9#include <fcntl.h>
10#include <linux/falloc.h>
11 ]], [[
12fallocate(0, 0, 0, 0);
13 ]])
14 ], have_fallocate=yes
15 AC_MSG_RESULT(yes),
16 AC_MSG_RESULT(no))
17 AC_SUBST(have_fallocate)
18 ])
19
20#
21# Check if we have the fiemap ioctl (Linux)
22#
23AC_DEFUN([AC_HAVE_FIEMAP],
24 [ AC_MSG_CHECKING([for fiemap])
25 AC_LINK_IFELSE(
26 [ AC_LANG_PROGRAM([[
27#define _GNU_SOURCE
28#include <linux/fs.h>
29#include <linux/fiemap.h>
30#include <sys/ioctl.h>
31 ]], [[
32struct fiemap *fiemap;
33ioctl(0, FS_IOC_FIEMAP, (unsigned long)fiemap);
34 ]])
35 ], have_fiemap=yes
36 AC_MSG_RESULT(yes),
37 AC_MSG_RESULT(no))
38 AC_SUBST(have_fiemap)
39 ])
40
41#
42# Check if we have a preadv libc call (Linux)
43#
44AC_DEFUN([AC_HAVE_PREADV],
45 [ AC_MSG_CHECKING([for preadv])
46 AC_LINK_IFELSE(
47 [ AC_LANG_PROGRAM([[
48#define _BSD_SOURCE
49#define _DEFAULT_SOURCE
50#include <sys/uio.h>
51 ]], [[
52preadv(0, 0, 0, 0);
53 ]])
54 ], have_preadv=yes
55 AC_MSG_RESULT(yes),
56 AC_MSG_RESULT(no))
57 AC_SUBST(have_preadv)
58 ])
59
60#
61# Check if we have a pwritev2 libc call (Linux)
62#
63AC_DEFUN([AC_HAVE_PWRITEV2],
64 [ AC_MSG_CHECKING([for pwritev2])
65 AC_LINK_IFELSE(
66 [ AC_LANG_PROGRAM([[
67#define _GNU_SOURCE
68#include <sys/uio.h>
69 ]], [[
70pwritev2(0, 0, 0, 0, 0);
71 ]])
72 ], have_pwritev2=yes
73 AC_MSG_RESULT(yes),
74 AC_MSG_RESULT(no))
75 AC_SUBST(have_pwritev2)
76 ])
77
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])
83 AC_LINK_IFELSE(
84 [ AC_LANG_PROGRAM([[
85#define _GNU_SOURCE
86#include <sys/syscall.h>
87#include <unistd.h>
88 ]], [[
89syscall(__NR_copy_file_range, 0, 0, 0, 0, 0, 0);
90 ]])
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
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])
102 AC_LINK_IFELSE(
103 [ AC_LANG_PROGRAM([[
104#define _GNU_SOURCE
105#include <fcntl.h>
106 ]], [[
107sync_file_range(0, 0, 0, 0);
108 ]])
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
115#
116# Check if we have a syncfs libc call (Linux)
117#
118AC_DEFUN([AC_HAVE_SYNCFS],
119 [ AC_MSG_CHECKING([for syncfs])
120 AC_LINK_IFELSE(
121 [ AC_LANG_PROGRAM([[
122#define _GNU_SOURCE
123#include <unistd.h>
124 ]], [[
125syncfs(0);
126 ]])
127 ], have_syncfs=yes
128 AC_MSG_RESULT(yes),
129 AC_MSG_RESULT(no))
130 AC_SUBST(have_syncfs)
131 ])
132
133#
134# Check if we have a readdir libc call
135#
136AC_DEFUN([AC_HAVE_READDIR],
137 [ AC_MSG_CHECKING([for readdir])
138 AC_LINK_IFELSE(
139 [ AC_LANG_PROGRAM([[
140#include <dirent.h>
141 ]], [[
142readdir(0);
143 ]])
144 ], have_readdir=yes
145 AC_MSG_RESULT(yes),
146 AC_MSG_RESULT(no))
147 AC_SUBST(have_readdir)
148 ])
149
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
162#
163# Check if we have a fsetxattr call
164#
165AC_DEFUN([AC_HAVE_FSETXATTR],
166 [ AC_CHECK_DECL([fsetxattr],
167 have_fsetxattr=yes,
168 [],
169 [#include <sys/types.h>
170 #include <sys/xattr.h>]
171 )
172 AC_SUBST(have_fsetxattr)
173 ])
174
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 ])
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 [
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 )
206 AC_SUBST(need_internal_fsxattr)
207 ])
208
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
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
251#
252# Check if we have a FS_IOC_GETFSMAP ioctl (Linux)
253#
254AC_DEFUN([AC_HAVE_GETFSMAP],
255 [ AC_MSG_CHECKING([for GETFSMAP])
256 AC_LINK_IFELSE(
257 [ AC_LANG_PROGRAM([[
258#define _GNU_SOURCE
259#include <sys/syscall.h>
260#include <unistd.h>
261#include <linux/fs.h>
262#include <linux/fsmap.h>
263 ]], [[
264unsigned long x = FS_IOC_GETFSMAP;
265struct fsmap_head fh;
266 ]])
267 ], have_getfsmap=yes
268 AC_MSG_RESULT(yes),
269 AC_MSG_RESULT(no))
270 AC_SUBST(have_getfsmap)
271 ])
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 ])
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])
292 AC_COMPILE_IFELSE(
293 [ AC_LANG_PROGRAM([[
294#include <sys/mman.h>
295 ]], [[
296int flags = MAP_SYNC | MAP_SHARED_VALIDATE;
297 ]])
298 ], have_map_sync=yes
299 AC_MSG_RESULT(yes),
300 AC_MSG_RESULT(no))
301 AC_SUBST(have_map_sync)
302 ])
303
304#
305# Check if we have a mallinfo libc call
306#
307AC_DEFUN([AC_HAVE_MALLINFO],
308 [ AC_MSG_CHECKING([for mallinfo ])
309 AC_COMPILE_IFELSE(
310 [ AC_LANG_PROGRAM([[
311#include <malloc.h>
312 ]], [[
313struct mallinfo test;
314
315test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
316test = mallinfo();
317 ]])
318 ], have_mallinfo=yes
319 AC_MSG_RESULT(yes),
320 AC_MSG_RESULT(no))
321 AC_SUBST(have_mallinfo)
322 ])
323
324#
325# Check if we have a mallinfo2 libc call
326#
327AC_DEFUN([AC_HAVE_MALLINFO2],
328 [ AC_MSG_CHECKING([for mallinfo2 ])
329 AC_COMPILE_IFELSE(
330 [ AC_LANG_PROGRAM([[
331#include <malloc.h>
332 ]], [[
333struct mallinfo2 test;
334
335test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
336test = mallinfo2();
337 ]])
338 ], have_mallinfo2=yes
339 AC_MSG_RESULT(yes),
340 AC_MSG_RESULT(no))
341 AC_SUBST(have_mallinfo2)
342 ])
343
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 ])
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 ])
377 AC_COMPILE_IFELSE(
378 [ AC_LANG_PROGRAM([[
379#include <scsi/sg.h>
380#include <sys/ioctl.h>
381 ]], [[
382struct sg_io_hdr hdr;
383ioctl(0, SG_IO, &hdr);
384 ]])
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 ])
396 AC_COMPILE_IFELSE(
397 [ AC_LANG_PROGRAM([[
398#include <linux/hdreg.h>
399#include <sys/ioctl.h>
400 ]], [[
401struct hd_geometry hdr;
402ioctl(0, HDIO_GETGEO, &hdr);
403 ]])
404 ], have_hdio_getgeo=yes
405 AC_MSG_RESULT(yes),
406 AC_MSG_RESULT(no))
407 AC_SUBST(have_hdio_getgeo)
408 ])
409
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 ])