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