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