Improve Valgrind instrumentation of memory allocations
[fio.git] / configure
CommitLineData
67bf9823
JA
1#!/bin/sh
2#
3# Fio configure script. Heavily influenced by the manual qemu configure
c922e0b0 4# script. Sad this is easier than autoconf and enemies.
67bf9823
JA
5#
6
7# set temporary file name
8if test ! -z "$TMPDIR" ; then
9 TMPDIR1="${TMPDIR}"
10elif test ! -z "$TEMPDIR" ; then
11 TMPDIR1="${TEMPDIR}"
12else
13 TMPDIR1="/tmp"
14fi
15
16TMPC="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.c"
17TMPO="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.o"
18TMPE="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.exe"
19
20# NB: do not call "exit" in the trap handler; this is buggy with some shells;
21# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
22trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
23
24rm -rf config.log
25
26config_host_mak="config-host.mak"
4feafb1e
JA
27config_host_h="config-host.h"
28
29rm -rf $config_host_mak
30rm -rf $config_host_h
67bf9823 31
d7145a78
JA
32fatal() {
33 echo $@
34 echo "Configure failed, check config.log and/or the above output"
35 rm -rf $config_host_mak
36 rm -rf $config_host_h
37 exit 1
38}
39
484b0b65
TK
40# Print result for each configuration test
41print_config() {
42 printf "%-30s%s\n" "$1" "$2"
43}
44
44404c5a 45# Default CFLAGS
af4862b3
JA
46CFLAGS="-D_GNU_SOURCE -include config-host.h"
47BUILD_CFLAGS=""
67bf9823
JA
48
49# Print a helpful header at the top of config.log
50echo "# FIO configure log $(date)" >> config.log
51printf "# Configured with:" >> config.log
52printf " '%s'" "$0" "$@" >> config.log
53echo >> config.log
54echo "#" >> config.log
55
7560fe7c
JA
56# Print configure header at the top of $config_host_h
57echo "/*" > $config_host_h
58echo " * Automatically generated by configure - do not modify" >> $config_host_h
59printf " * Configured with:" >> $config_host_h
60printf " * '%s'" "$0" "$@" >> $config_host_h
61echo "" >> $config_host_h
62echo " */" >> $config_host_h
63
67bf9823
JA
64do_cc() {
65 # Run the compiler, capturing its output to the log.
66 echo $cc "$@" >> config.log
67 $cc "$@" >> config.log 2>&1 || return $?
68 # Test passed. If this is an --enable-werror build, rerun
69 # the test with -Werror and bail out if it fails. This
70 # makes warning-generating-errors in configure test code
71 # obvious to developers.
72 if test "$werror" != "yes"; then
73 return 0
74 fi
75 # Don't bother rerunning the compile if we were already using -Werror
76 case "$*" in
77 *-Werror*)
78 return 0
79 ;;
80 esac
81 echo $cc -Werror "$@" >> config.log
82 $cc -Werror "$@" >> config.log 2>&1 && return $?
83 echo "ERROR: configure test passed without -Werror but failed with -Werror."
84 echo "This is probably a bug in the configure script. The failing command"
85 echo "will be at the bottom of config.log."
d7145a78 86 fatal "You can run configure with --disable-werror to bypass this check."
67bf9823
JA
87}
88
89compile_object() {
90 do_cc $CFLAGS -c -o $TMPO $TMPC
91}
92
93compile_prog() {
94 local_cflags="$1"
adaa46d8 95 local_ldflags="$2 $LIBS"
67bf9823
JA
96 echo "Compiling test case $3" >> config.log
97 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
98}
99
100feature_not_found() {
101 feature=$1
c55d728b 102 packages=$2
67bf9823
JA
103
104 echo "ERROR"
105 echo "ERROR: User requested feature $feature"
c55d728b
JA
106 if test ! -z "$packages" ; then
107 echo "ERROR: That feature needs $packages installed"
108 fi
67bf9823 109 echo "ERROR: configure was not able to find it"
d7145a78 110 fatal "ERROR"
67bf9823
JA
111}
112
113has() {
114 type "$1" >/dev/null 2>&1
115}
116
117check_define() {
118 cat > $TMPC <<EOF
119#if !defined($1)
120#error $1 not defined
121#endif
122int main(void)
123{
124 return 0;
125}
126EOF
127 compile_object
128}
129
4feafb1e
JA
130output_sym() {
131 echo "$1=y" >> $config_host_mak
132 echo "#define $1" >> $config_host_h
133}
134
67bf9823
JA
135targetos=""
136cpu=""
137
91f94d5b 138# default options
47f44635
JA
139show_help="no"
140exit_val=0
ebec2094 141gfio_check="no"
1b10477b 142libhdfs="no"
43f3cec2 143pmemblk="no"
cbb15e42 144devdax="no"
ae0db592 145pmem="no"
de26b824 146disable_lex=""
3ee2a3c1 147disable_pmem="no"
a817dc3b 148disable_native="no"
9f75af77 149march_set="no"
020d54bd 150prefix=/usr/local
91f94d5b 151
cb1125b0
JA
152# parse options
153for opt do
154 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
155 case "$opt" in
020d54bd
JA
156 --prefix=*) prefix="$optarg"
157 ;;
8b156d8e
JA
158 --cpu=*) cpu="$optarg"
159 ;;
c8931876
JA
160 # esx is cross compiled and cannot be detect through simple uname calls
161 --esx)
162 esx="yes"
163 ;;
cb1125b0
JA
164 --cc=*) CC="$optarg"
165 ;;
208e4c8b
JA
166 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
167 ;;
b7c12794 168 --build-32bit-win) build_32bit_win="yes"
7409711b 169 ;;
d2aeedb9
JA
170 --build-static) build_static="yes"
171 ;;
bad7e42c 172 --enable-gfio) gfio_check="yes"
899fab33 173 ;;
44462517
CF
174 --disable-numa) disable_numa="yes"
175 ;;
f678f8d2
MF
176 --disable-rdma) disable_rdma="yes"
177 ;;
d5f9b0ea
IF
178 --disable-rados) disable_rados="yes"
179 ;;
ce18290e
TM
180 --disable-rbd) disable_rbd="yes"
181 ;;
182 --disable-gfapi) disable_gfapi="yes"
183 ;;
1b10477b
MM
184 --enable-libhdfs) libhdfs="yes"
185 ;;
a655bbc4
JA
186 --disable-lex) disable_lex="yes"
187 ;;
de26b824
JA
188 --enable-lex) disable_lex="no"
189 ;;
61054f0d
JA
190 --disable-shm) no_shm="yes"
191 ;;
192 --disable-optimizations) disable_opt="yes"
ba40757e 193 ;;
3ee2a3c1
DJ
194 --disable-pmem) disable_pmem="yes"
195 ;;
03553853
YR
196 --enable-cuda) enable_cuda="yes"
197 ;;
a817dc3b
JA
198 --disable-native) disable_native="yes"
199 ;;
827da4f5 200 --help)
47f44635 201 show_help="yes"
827da4f5 202 ;;
cb1125b0
JA
203 *)
204 echo "Bad option $opt"
47f44635
JA
205 show_help="yes"
206 exit_val=1
cb1125b0
JA
207 esac
208done
209
47f44635 210if test "$show_help" = "yes" ; then
05cef7a0
TK
211 echo "--prefix= Use this directory as installation prefix"
212 echo "--cpu= Specify target CPU if auto-detect fails"
213 echo "--cc= Specify compiler to use"
214 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
215 echo "--build-32bit-win Enable 32-bit build on Windows"
216 echo "--build-static Build a static fio"
217 echo "--esx Configure build options for esx"
218 echo "--enable-gfio Enable building of gtk gfio"
219 echo "--disable-numa Disable libnuma even if found"
03553853 220 echo "--disable-rdma Disable RDMA support even if found"
05cef7a0
TK
221 echo "--disable-gfapi Disable gfapi"
222 echo "--enable-libhdfs Enable hdfs support"
223 echo "--disable-lex Disable use of lex/yacc for math"
224 echo "--disable-pmem Disable pmem based engines even if found"
225 echo "--enable-lex Enable use of lex/yacc for math"
226 echo "--disable-shm Disable SHM support"
61054f0d 227 echo "--disable-optimizations Don't enable compiler optimizations"
03553853 228 echo "--enable-cuda Enable GPUDirect RDMA support"
a817dc3b 229 echo "--disable-native Don't build for native host"
b7a99316 230 exit $exit_val
47f44635
JA
231fi
232
47986339 233cross_prefix=${cross_prefix-${CROSS_COMPILE}}
b73af738
SW
234# Preferred compiler (can be overriden later after we know the platform):
235# ${CC} (if set)
236# ${cross_prefix}gcc (if cross-prefix specified)
237# gcc if available
238# clang if available
239if test -z "${CC}${cross_prefix}"; then
240 if has gcc; then
241 cc=gcc
242 elif has clang; then
243 cc=clang
244 fi
245else
246 cc="${CC-${cross_prefix}gcc}"
247fi
47986339 248
6d0e9f83
AC
249if check_define __ANDROID__ ; then
250 targetos="Android"
251elif check_define __linux__ ; then
67bf9823 252 targetos="Linux"
67bf9823
JA
253elif check_define __OpenBSD__ ; then
254 targetos='OpenBSD'
89556808
BVA
255elif check_define __NetBSD__ ; then
256 targetos='NetBSD'
67bf9823
JA
257elif check_define __sun__ ; then
258 targetos='SunOS'
7cb024f8 259 CFLAGS="$CFLAGS -D_REENTRANT"
b24f59ab
SH
260elif check_define _WIN32 ; then
261 targetos='CYGWIN'
67bf9823
JA
262else
263 targetos=`uname -s`
264fi
265
53cd4eee
AC
266echo "# Automatically generated by configure - do not modify" > $config_host_mak
267printf "# Configured with:" >> $config_host_mak
268printf " '%s'" "$0" "$@" >> $config_host_mak
269echo >> $config_host_mak
270echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
271
61054f0d
JA
272if test "$no_shm" = "yes" ; then
273 output_sym "CONFIG_NO_SHM"
274fi
275
276if test "$disable_opt" = "yes" ; then
277 output_sym "CONFIG_FIO_NO_OPT"
278fi
279
67bf9823
JA
280# Some host OSes need non-standard checks for which CPU to use.
281# Note that these checks are broken for cross-compilation: if you're
282# cross-compiling to one of these OSes then you'll need to specify
283# the correct CPU with the --cpu option.
284case $targetos in
26532556 285AIX|OpenBSD|NetBSD)
de26b824 286 # Unless explicitly enabled, turn off lex.
baa78fdc 287 # OpenBSD will hit syntax error when enabled.
de26b824
JA
288 if test -z "$disable_lex" ; then
289 disable_lex="yes"
daf705b5
JA
290 else
291 force_no_lex_o="yes"
de26b824
JA
292 fi
293 ;;
67bf9823
JA
294Darwin)
295 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
296 # we can run 64-bit userspace code.
297 # If the user didn't specify a CPU explicitly and the kernel says this is
298 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
299 # detection code.
300 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
301 cpu="x86_64"
302 fi
ccf2d89d
SW
303 # Error at compile time linking of weak/partial symbols if possible...
304cat > $TMPC <<EOF
305int main(void)
306{
307 return 0;
308}
309EOF
310 if compile_prog "" "-Wl,-no_weak_imports" "disable weak symbols"; then
311 echo "Disabling weak symbols"
312 LDFLAGS="$LDFLAGS -Wl,-no_weak_imports"
313 fi
67bf9823
JA
314 ;;
315SunOS)
316 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
317 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
318 cpu="x86_64"
319 fi
adaa46d8 320 LIBS="-lnsl -lsocket"
cfd94f79
JA
321 ;;
322CYGWIN*)
ca205a75
TK
323 # We still force some options, so keep this message here.
324 echo "Forcing some known good options on Windows"
b73af738 325 if test -z "${CC}${cross_prefix}"; then
7409711b 326 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
b73af738 327 cc="i686-w64-mingw32-gcc"
7409711b 328 else
b73af738 329 cc="x86_64-w64-mingw32-gcc"
7409711b 330 fi
4578d01f 331 fi
7409711b
HL
332 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
333 output_sym "CONFIG_32BIT"
334 else
335 output_sym "CONFIG_64BIT_LLP64"
336 fi
ca205a75
TK
337 # We need this to be output_sym'd here because this is Windows specific.
338 # The regular configure path never sets this config.
4feafb1e 339 output_sym "CONFIG_WINDOWSAIO"
ca205a75
TK
340 # We now take the regular configuration path without having exit 0 here.
341 # Flags below are still necessary mostly for MinGW.
342 socklen_t="yes"
343 sfaa="yes"
a250edd0
JA
344 sync_sync="yes"
345 cmp_swap="yes"
ca205a75
TK
346 rusage_thread="yes"
347 fdatasync="yes"
348 clock_gettime="yes" # clock_monotonic probe has dependency on this
349 clock_monotonic="yes"
350 gettimeofday="yes"
351 sched_idle="yes"
352 tcp_nodelay="yes"
353 tls_thread="yes"
354 static_assert="yes"
355 ipv6="yes"
4252396e 356 mkdir_two="no"
b86770c6 357 echo "BUILD_CFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
6d0e9f83 358 ;;
67bf9823
JA
359esac
360
b73af738
SW
361# Now we know the target platform we can have another guess at the preferred
362# compiler when it wasn't explictly set
363if test -z "${CC}${cross_prefix}"; then
364 if test "$targetos" = "FreeBSD" || test "$targetos" = "Darwin"; then
365 if has clang; then
366 cc=clang
367 fi
368 fi
369fi
370if test -z "$cc"; then
371 echo "configure: failed to find compiler"
372 exit 1
373fi
374
67bf9823
JA
375if test ! -z "$cpu" ; then
376 # command line argument
377 :
378elif check_define __i386__ ; then
379 cpu="i386"
380elif check_define __x86_64__ ; then
381 cpu="x86_64"
382elif check_define __sparc__ ; then
383 if check_define __arch64__ ; then
384 cpu="sparc64"
385 else
386 cpu="sparc"
387 fi
388elif check_define _ARCH_PPC ; then
389 if check_define _ARCH_PPC64 ; then
390 cpu="ppc64"
391 else
392 cpu="ppc"
393 fi
394elif check_define __mips__ ; then
395 cpu="mips"
396elif check_define __ia64__ ; then
397 cpu="ia64"
398elif check_define __s390__ ; then
399 if check_define __s390x__ ; then
400 cpu="s390x"
401 else
402 cpu="s390"
403 fi
404elif check_define __arm__ ; then
405 cpu="arm"
214e2d56 406elif check_define __aarch64__ ; then
407 cpu="aarch64"
67bf9823
JA
408elif check_define __hppa__ ; then
409 cpu="hppa"
410else
411 cpu=`uname -m`
412fi
413
414# Normalise host CPU name and set ARCH.
415case "$cpu" in
416 ia64|ppc|ppc64|s390|s390x|sparc64)
417 cpu="$cpu"
418 ;;
419 i386|i486|i586|i686|i86pc|BePC)
95ef38ab 420 cpu="x86"
67bf9823
JA
421 ;;
422 x86_64|amd64)
423 cpu="x86_64"
424 ;;
425 armv*b|armv*l|arm)
426 cpu="arm"
427 ;;
214e2d56 428 aarch64)
429 cpu="arm64"
430 ;;
67bf9823
JA
431 hppa|parisc|parisc64)
432 cpu="hppa"
433 ;;
434 mips*)
435 cpu="mips"
436 ;;
437 sparc|sun4[cdmuv])
438 cpu="sparc"
439 ;;
440 *)
8b156d8e 441 echo "Unknown CPU"
67bf9823
JA
442 ;;
443esac
444
1a17cfdb
AC
445##########################################
446# check cross compile
447
ca205a75
TK
448if test "$cross_compile" != "yes" ; then
449 cross_compile="no"
450fi
1a17cfdb
AC
451cat > $TMPC <<EOF
452int main(void)
453{
454 return 0;
455}
456EOF
457if compile_prog "" "" "cross"; then
458 $TMPE 2>/dev/null || cross_compile="yes"
459else
460 fatal "compile test failed"
461fi
462
0dcebdf4
JA
463##########################################
464# check endianness
ca205a75
TK
465if test "$bigendian" != "yes" ; then
466 bigendian="no"
467fi
1a17cfdb
AC
468if test "$cross_compile" = "no" ; then
469 cat > $TMPC <<EOF
0dcebdf4
JA
470#include <inttypes.h>
471int main(void)
472{
473 volatile uint32_t i=0x01234567;
474 return (*((uint8_t*)(&i))) == 0x67;
475}
476EOF
1a17cfdb
AC
477 if compile_prog "" "" "endian"; then
478 $TMPE && bigendian="yes"
479 fi
480else
481 # If we're cross compiling, try our best to work it out and rely on the
482 # run-time check to fail if we get it wrong.
483 cat > $TMPC <<EOF
484#include <endian.h>
485int main(void)
486{
487#if __BYTE_ORDER != __BIG_ENDIAN
488# error "Unknown endianness"
489#endif
490}
491EOF
492 compile_prog "" "" "endian" && bigendian="yes"
493 check_define "__ARMEB__" && bigendian="yes"
494 check_define "__MIPSEB__" && bigendian="yes"
0dcebdf4
JA
495fi
496
497
484b0b65
TK
498print_config "Operating system" "$targetos"
499print_config "CPU" "$cpu"
500print_config "Big endian" "$bigendian"
501print_config "Compiler" "$cc"
502print_config "Cross compile" "$cross_compile"
67bf9823
JA
503echo
504
d2aeedb9
JA
505##########################################
506# See if we need to build a static build
507if test "$build_static" = "yes" ; then
508 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
509 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
510else
511 build_static="no"
512fi
484b0b65 513print_config "Static build" "$build_static"
d2aeedb9 514
67bf9823
JA
515##########################################
516# check for wordsize
517wordsize="0"
518cat > $TMPC <<EOF
142429e5
AC
519#include <limits.h>
520#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
67bf9823
JA
521int main(void)
522{
142429e5 523 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
67bf9823
JA
524 return 0;
525}
526EOF
142429e5
AC
527if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
528 wordsize="32"
529elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
530 wordsize="64"
531else
532 fatal "Unknown wordsize"
67bf9823 533fi
484b0b65 534print_config "Wordsize" "$wordsize"
67bf9823 535
a9bca4aa
JA
536##########################################
537# zlib probe
ca205a75
TK
538if test "$zlib" != "yes" ; then
539 zlib="no"
540fi
a9bca4aa 541cat > $TMPC <<EOF
804a1e05 542#include <zlib.h>
a9bca4aa
JA
543int main(void)
544{
545 z_stream stream;
546 if (inflateInit(&stream) != Z_OK)
547 return 1;
548 return 0;
549}
550EOF
551if compile_prog "" "-lz" "zlib" ; then
552 zlib=yes
553 LIBS="-lz $LIBS"
a9bca4aa 554fi
484b0b65 555print_config "zlib" "$zlib"
a9bca4aa 556
67bf9823
JA
557##########################################
558# linux-aio probe
ca205a75
TK
559if test "$libaio" != "yes" ; then
560 libaio="no"
561fi
7c77ebef 562if test "$esx" != "yes" ; then
563 cat > $TMPC <<EOF
67bf9823
JA
564#include <libaio.h>
565#include <stddef.h>
566int main(void)
567{
568 io_setup(0, NULL);
569 return 0;
570}
571EOF
7c77ebef 572 if compile_prog "" "-laio" "libaio" ; then
573 libaio=yes
574 LIBS="-laio $LIBS"
575 else
576 if test "$libaio" = "yes" ; then
577 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
578 fi
579 libaio=no
67bf9823 580 fi
67bf9823 581fi
484b0b65 582print_config "Linux AIO support" "$libaio"
67bf9823
JA
583
584##########################################
585# posix aio probe
ca205a75
TK
586if test "$posix_aio" != "yes" ; then
587 posix_aio="no"
588fi
589if test "$posix_aio_lrt" != "yes" ; then
590 posix_aio_lrt="no"
591fi
67bf9823
JA
592cat > $TMPC <<EOF
593#include <aio.h>
594int main(void)
595{
596 struct aiocb cb;
597 aio_read(&cb);
598 return 0;
599}
600EOF
601if compile_prog "" "" "posixaio" ; then
602 posix_aio="yes"
603elif compile_prog "" "-lrt" "posixaio"; then
604 posix_aio="yes"
605 posix_aio_lrt="yes"
606 LIBS="-lrt $LIBS"
607fi
484b0b65
TK
608print_config "POSIX AIO support" "$posix_aio"
609print_config "POSIX AIO support needs -lrt" "$posix_aio_lrt"
67bf9823
JA
610
611##########################################
612# posix aio fsync probe
ca205a75
TK
613if test "$posix_aio_fsync" != "yes" ; then
614 posix_aio_fsync="no"
615fi
67bf9823
JA
616if test "$posix_aio" = "yes" ; then
617 cat > $TMPC <<EOF
618#include <fcntl.h>
619#include <aio.h>
620int main(void)
621{
622 struct aiocb cb;
623 return aio_fsync(O_SYNC, &cb);
624 return 0;
625}
626EOF
627 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
628 posix_aio_fsync=yes
629 fi
630fi
484b0b65 631print_config "POSIX AIO fsync" "$posix_aio_fsync"
67bf9823 632
06eac6b2
SW
633##########################################
634# POSIX pshared attribute probe
d418fa90
TK
635if test "$posix_pshared" != "yes" ; then
636 posix_pshared="no"
637fi
06eac6b2
SW
638cat > $TMPC <<EOF
639#include <unistd.h>
640int main(void)
641{
642#if defined(_POSIX_THREAD_PROCESS_SHARED) && ((_POSIX_THREAD_PROCESS_SHARED + 0) > 0)
643# if defined(__CYGWIN__)
644# error "_POSIX_THREAD_PROCESS_SHARED is buggy on Cygwin"
645# elif defined(__APPLE__)
646# include <AvailabilityMacros.h>
647# include <TargetConditionals.h>
648# if TARGET_OS_MAC && MAC_OS_X_VERSION_MIN_REQUIRED < 1070
649# error "_POSIX_THREAD_PROCESS_SHARED is buggy/unsupported prior to OSX 10.7"
650# endif
651# endif
652#else
653# error "_POSIX_THREAD_PROCESS_SHARED is unsupported"
654#endif
655 return 0;
656}
657EOF
658if compile_prog "" "$LIBS" "posix_pshared" ; then
659 posix_pshared=yes
660fi
484b0b65 661print_config "POSIX pshared support" "$posix_pshared"
06eac6b2 662
67bf9823
JA
663##########################################
664# solaris aio probe
ca205a75
TK
665if test "$solaris_aio" != "yes" ; then
666 solaris_aio="no"
667fi
67bf9823
JA
668cat > $TMPC <<EOF
669#include <sys/types.h>
670#include <sys/asynch.h>
671#include <unistd.h>
672int main(void)
673{
674 aio_result_t res;
675 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
676 return 0;
677}
678EOF
679if compile_prog "" "-laio" "solarisaio" ; then
680 solaris_aio=yes
681 LIBS="-laio $LIBS"
682fi
484b0b65 683print_config "Solaris AIO support" "$solaris_aio"
67bf9823
JA
684
685##########################################
f5cd2907 686# __sync_fetch_and_add test
ca205a75
TK
687if test "$sfaa" != "yes" ; then
688 sfaa="no"
689fi
67bf9823 690cat > $TMPC << EOF
958886d8
JA
691#include <inttypes.h>
692static int sfaa(uint64_t *ptr)
67bf9823 693{
9c639a76 694 return __sync_fetch_and_add(ptr, 0);
67bf9823
JA
695}
696
697int main(int argc, char **argv)
698{
958886d8 699 uint64_t val = 42;
67bf9823
JA
700 sfaa(&val);
701 return val;
702}
703EOF
704if compile_prog "" "" "__sync_fetch_and_add()" ; then
705 sfaa="yes"
706fi
484b0b65 707print_config "__sync_fetch_and_add" "$sfaa"
67bf9823 708
a250edd0
JA
709##########################################
710# __sync_synchronize() test
711if test "$sync_sync" != "yes" ; then
712 sync_sync="no"
713fi
714cat > $TMPC << EOF
715#include <inttypes.h>
716
717int main(int argc, char **argv)
718{
719 __sync_synchronize();
720 return 0;
721}
722EOF
723if compile_prog "" "" "__sync_synchronize()" ; then
724 sync_sync="yes"
725fi
726print_config "__sync_synchronize" "$sync_sync"
727
728##########################################
729# __sync_val_compare_and_swap() test
730if test "$cmp_swap" != "yes" ; then
731 cmp_swap="no"
732fi
733cat > $TMPC << EOF
734#include <inttypes.h>
735
736int main(int argc, char **argv)
737{
738 int x = 0;
739 return __sync_val_compare_and_swap(&x, 1, 2);
740}
741EOF
742if compile_prog "" "" "__sync_val_compare_and_swap()" ; then
743 cmp_swap="yes"
744fi
745print_config "__sync_val_compare_and_swap" "$cmp_swap"
746
67bf9823
JA
747##########################################
748# libverbs probe
ca205a75
TK
749if test "$libverbs" != "yes" ; then
750 libverbs="no"
751fi
67bf9823 752cat > $TMPC << EOF
eb3bfdd8 753#include <infiniband/verbs.h>
67bf9823
JA
754int main(int argc, char **argv)
755{
756 struct ibv_pd *pd = ibv_alloc_pd(NULL);
757 return 0;
758}
759EOF
f678f8d2 760if test "$disable_rdma" != "yes" && compile_prog "" "-libverbs" "libverbs" ; then
67bf9823
JA
761 libverbs="yes"
762 LIBS="-libverbs $LIBS"
763fi
484b0b65 764print_config "libverbs" "$libverbs"
67bf9823
JA
765
766##########################################
767# rdmacm probe
ca205a75
TK
768if test "$rdmacm" != "yes" ; then
769 rdmacm="no"
770fi
67bf9823
JA
771cat > $TMPC << EOF
772#include <stdio.h>
773#include <rdma/rdma_cma.h>
774int main(int argc, char **argv)
775{
776 rdma_destroy_qp(NULL);
777 return 0;
778}
779EOF
f678f8d2 780if test "$disable_rdma" != "yes" && compile_prog "" "-lrdmacm" "rdma"; then
67bf9823
JA
781 rdmacm="yes"
782 LIBS="-lrdmacm $LIBS"
783fi
484b0b65 784print_config "rdmacm" "$rdmacm"
67bf9823
JA
785
786##########################################
787# Linux fallocate probe
ca205a75
TK
788if test "$linux_fallocate" != "yes" ; then
789 linux_fallocate="no"
790fi
67bf9823
JA
791cat > $TMPC << EOF
792#include <stdio.h>
aa6738a5 793#include <fcntl.h>
67bf9823
JA
794#include <linux/falloc.h>
795int main(int argc, char **argv)
796{
797 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
798 return r;
799}
800EOF
801if compile_prog "" "" "linux_fallocate"; then
802 linux_fallocate="yes"
803fi
484b0b65 804print_config "Linux fallocate" "$linux_fallocate"
67bf9823
JA
805
806##########################################
807# POSIX fadvise probe
ca205a75
TK
808if test "$posix_fadvise" != "yes" ; then
809 posix_fadvise="no"
810fi
67bf9823
JA
811cat > $TMPC << EOF
812#include <stdio.h>
813#include <fcntl.h>
814int main(int argc, char **argv)
815{
816 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
817 return r;
818}
819EOF
820if compile_prog "" "" "posix_fadvise"; then
821 posix_fadvise="yes"
822fi
484b0b65 823print_config "POSIX fadvise" "$posix_fadvise"
67bf9823
JA
824
825##########################################
826# POSIX fallocate probe
ca205a75
TK
827if test "$posix_fallocate" != "yes" ; then
828 posix_fallocate="no"
829fi
67bf9823
JA
830cat > $TMPC << EOF
831#include <stdio.h>
832#include <fcntl.h>
833int main(int argc, char **argv)
834{
835 int r = posix_fallocate(0, 0, 1024);
836 return r;
837}
838EOF
839if compile_prog "" "" "posix_fallocate"; then
840 posix_fallocate="yes"
841fi
484b0b65 842print_config "POSIX fallocate" "$posix_fallocate"
67bf9823
JA
843
844##########################################
845# sched_set/getaffinity 2 or 3 argument test
ca205a75
TK
846if test "$linux_2arg_affinity" != "yes" ; then
847 linux_2arg_affinity="no"
848fi
849if test "$linux_3arg_affinity" != "yes" ; then
850 linux_3arg_affinity="no"
851fi
67bf9823 852cat > $TMPC << EOF
67bf9823
JA
853#include <sched.h>
854int main(int argc, char **argv)
855{
856 cpu_set_t mask;
857 return sched_setaffinity(0, sizeof(mask), &mask);
858}
859EOF
860if compile_prog "" "" "sched_setaffinity(,,)"; then
861 linux_3arg_affinity="yes"
862else
863 cat > $TMPC << EOF
67bf9823
JA
864#include <sched.h>
865int main(int argc, char **argv)
866{
867 cpu_set_t mask;
868 return sched_setaffinity(0, &mask);
869}
870EOF
871 if compile_prog "" "" "sched_setaffinity(,)"; then
872 linux_2arg_affinity="yes"
873 fi
874fi
484b0b65
TK
875print_config "sched_setaffinity(3 arg)" "$linux_3arg_affinity"
876print_config "sched_setaffinity(2 arg)" "$linux_2arg_affinity"
67bf9823
JA
877
878##########################################
879# clock_gettime probe
ca205a75
TK
880if test "$clock_gettime" != "yes" ; then
881 clock_gettime="no"
882fi
67bf9823
JA
883cat > $TMPC << EOF
884#include <stdio.h>
885#include <time.h>
886int main(int argc, char **argv)
887{
888 return clock_gettime(0, NULL);
889}
890EOF
891if compile_prog "" "" "clock_gettime"; then
892 clock_gettime="yes"
893elif compile_prog "" "-lrt" "clock_gettime"; then
894 clock_gettime="yes"
895 LIBS="-lrt $LIBS"
896fi
484b0b65 897print_config "clock_gettime" "$clock_gettime"
67bf9823
JA
898
899##########################################
900# CLOCK_MONOTONIC probe
ca205a75
TK
901if test "$clock_monotonic" != "yes" ; then
902 clock_monotonic="no"
903fi
67bf9823
JA
904if test "$clock_gettime" = "yes" ; then
905 cat > $TMPC << EOF
906#include <stdio.h>
907#include <time.h>
908int main(int argc, char **argv)
909{
910 return clock_gettime(CLOCK_MONOTONIC, NULL);
911}
912EOF
913 if compile_prog "" "$LIBS" "clock monotonic"; then
914 clock_monotonic="yes"
915 fi
916fi
484b0b65 917print_config "CLOCK_MONOTONIC" "$clock_monotonic"
67bf9823 918
c544f604
SN
919##########################################
920# CLOCK_MONOTONIC_RAW probe
ca205a75
TK
921if test "$clock_monotonic_raw" != "yes" ; then
922 clock_monotonic_raw="no"
923fi
c544f604
SN
924if test "$clock_gettime" = "yes" ; then
925 cat > $TMPC << EOF
926#include <stdio.h>
927#include <time.h>
928int main(int argc, char **argv)
929{
930 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
931}
932EOF
933 if compile_prog "" "$LIBS" "clock monotonic"; then
934 clock_monotonic_raw="yes"
935 fi
936fi
484b0b65 937print_config "CLOCK_MONOTONIC_RAW" "$clock_monotonic_raw"
c544f604 938
67bf9823
JA
939##########################################
940# CLOCK_MONOTONIC_PRECISE probe
ca205a75
TK
941if test "$clock_monotonic_precise" != "yes" ; then
942 clock_monotonic_precise="no"
943fi
67bf9823
JA
944if test "$clock_gettime" = "yes" ; then
945 cat > $TMPC << EOF
946#include <stdio.h>
947#include <time.h>
948int main(int argc, char **argv)
949{
950 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
951}
952EOF
953 if compile_prog "" "$LIBS" "clock monotonic precise"; then
954 clock_monotonic_precise="yes"
955 fi
956fi
484b0b65 957print_config "CLOCK_MONOTONIC_PRECISE" "$clock_monotonic_precise"
67bf9823 958
25f8227d
JA
959##########################################
960# clockid_t probe
ca205a75
TK
961if test "$clockid_t" != "yes" ; then
962 clockid_t="no"
963fi
25f8227d 964cat > $TMPC << EOF
25f8227d 965#include <time.h>
209c37b4 966#include <string.h>
25f8227d
JA
967int main(int argc, char **argv)
968{
ccf2d89d 969 volatile clockid_t cid;
7fcad9e1 970 memset((void*)&cid, 0, sizeof(cid));
ccf2d89d 971 return 0;
25f8227d
JA
972}
973EOF
974if compile_prog "" "$LIBS" "clockid_t"; then
975 clockid_t="yes"
976fi
484b0b65 977print_config "clockid_t" "$clockid_t"
25f8227d 978
67bf9823
JA
979##########################################
980# gettimeofday() probe
ca205a75
TK
981if test "$gettimeofday" != "yes" ; then
982 gettimeofday="no"
983fi
67bf9823
JA
984cat > $TMPC << EOF
985#include <sys/time.h>
986#include <stdio.h>
987int main(int argc, char **argv)
988{
989 struct timeval tv;
990 return gettimeofday(&tv, NULL);
991}
992EOF
993if compile_prog "" "" "gettimeofday"; then
994 gettimeofday="yes"
995fi
484b0b65 996print_config "gettimeofday" "$gettimeofday"
67bf9823
JA
997
998##########################################
999# fdatasync() probe
ca205a75
TK
1000if test "$fdatasync" != "yes" ; then
1001 fdatasync="no"
1002fi
67bf9823
JA
1003cat > $TMPC << EOF
1004#include <stdio.h>
1005#include <unistd.h>
1006int main(int argc, char **argv)
1007{
1008 return fdatasync(0);
1009}
1010EOF
1011if compile_prog "" "" "fdatasync"; then
1012 fdatasync="yes"
1013fi
484b0b65 1014print_config "fdatasync" "$fdatasync"
67bf9823
JA
1015
1016##########################################
1017# sync_file_range() probe
ca205a75
TK
1018if test "$sync_file_range" != "yes" ; then
1019 sync_file_range="no"
1020fi
67bf9823
JA
1021cat > $TMPC << EOF
1022#include <stdio.h>
1023#include <unistd.h>
67bf9823
JA
1024#include <fcntl.h>
1025#include <linux/fs.h>
1026int main(int argc, char **argv)
1027{
1028 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
1029 SYNC_FILE_RANGE_WAIT_AFTER;
1030 return sync_file_range(0, 0, 0, flags);
1031}
1032EOF
1033if compile_prog "" "" "sync_file_range"; then
1034 sync_file_range="yes"
1035fi
484b0b65 1036print_config "sync_file_range" "$sync_file_range"
67bf9823
JA
1037
1038##########################################
1039# ext4 move extent probe
ca205a75
TK
1040if test "$ext4_me" != "yes" ; then
1041 ext4_me="no"
1042fi
67bf9823
JA
1043cat > $TMPC << EOF
1044#include <fcntl.h>
1045#include <sys/ioctl.h>
1046int main(int argc, char **argv)
1047{
1048 struct move_extent me;
1049 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
1050}
1051EOF
c7165b8d
JA
1052if compile_prog "" "" "ext4 move extent" ; then
1053 ext4_me="yes"
1054elif test $targetos = "Linux" ; then
1055 # On Linux, just default to it on and let it error at runtime if we really
1056 # don't have it. None of my updated systems have it defined, but it does
1057 # work. Takes a while to bubble back.
67bf9823
JA
1058 ext4_me="yes"
1059fi
484b0b65 1060print_config "EXT4 move extent" "$ext4_me"
67bf9823
JA
1061
1062##########################################
1063# splice probe
ca205a75
TK
1064if test "$linux_splice" != "yes" ; then
1065 linux_splice="no"
1066fi
67bf9823 1067cat > $TMPC << EOF
67bf9823
JA
1068#include <stdio.h>
1069#include <fcntl.h>
1070int main(int argc, char **argv)
1071{
1072 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
1073}
1074EOF
1075if compile_prog "" "" "linux splice"; then
1076 linux_splice="yes"
1077fi
484b0b65 1078print_config "Linux splice(2)" "$linux_splice"
67bf9823
JA
1079
1080##########################################
1081# GUASI probe
ca205a75
TK
1082if test "$guasi" != "yes" ; then
1083 guasi="no"
1084fi
67bf9823
JA
1085cat > $TMPC << EOF
1086#include <guasi.h>
1087#include <guasi_syscalls.h>
1088int main(int argc, char **argv)
1089{
1090 guasi_t ctx = guasi_create(0, 0, 0);
1091 return 0;
1092}
1093EOF
1094if compile_prog "" "" "guasi"; then
1095 guasi="yes"
1096fi
484b0b65 1097print_config "GUASI" "$guasi"
67bf9823
JA
1098
1099##########################################
1100# fusion-aw probe
ca205a75
TK
1101if test "$fusion_aw" != "yes" ; then
1102 fusion_aw="no"
1103fi
67bf9823 1104cat > $TMPC << EOF
b2c77c25 1105#include <nvm/nvm_primitives.h>
67bf9823
JA
1106int main(int argc, char **argv)
1107{
b2c77c25
SK
1108 nvm_version_t ver_info;
1109 nvm_handle_t handle;
1110
1111 handle = nvm_get_handle(0, &ver_info);
1112 return nvm_atomic_write(handle, 0, 0, 0);
67bf9823
JA
1113}
1114EOF
92aef550
ARJ
1115if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
1116 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
67bf9823
JA
1117 fusion_aw="yes"
1118fi
484b0b65 1119print_config "Fusion-io atomic engine" "$fusion_aw"
67bf9823
JA
1120
1121##########################################
1122# libnuma probe
ca205a75
TK
1123if test "$libnuma" != "yes" ; then
1124 libnuma="no"
1125fi
67bf9823
JA
1126cat > $TMPC << EOF
1127#include <numa.h>
1128int main(int argc, char **argv)
1129{
1130 return numa_available();
1131}
1132EOF
44462517 1133if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
67bf9823
JA
1134 libnuma="yes"
1135 LIBS="-lnuma $LIBS"
1136fi
484b0b65 1137print_config "libnuma" "$libnuma"
67bf9823 1138
50206d9b 1139##########################################
ca205a75 1140# libnuma 2.x version API, initialize with "no" only if $libnuma is set to "yes"
50206d9b
JA
1141if test "$libnuma" = "yes" ; then
1142libnuma_v2="no"
1143cat > $TMPC << EOF
1144#include <numa.h>
1145int main(int argc, char **argv)
1146{
1147 struct bitmask *mask = numa_parse_nodestring(NULL);
61bde962 1148 return mask->size == 0;
50206d9b
JA
1149}
1150EOF
1151if compile_prog "" "" "libnuma api"; then
1152 libnuma_v2="yes"
1153fi
484b0b65 1154print_config "libnuma v2" "$libnuma_v2"
50206d9b
JA
1155fi
1156
67bf9823
JA
1157##########################################
1158# strsep() probe
ca205a75
TK
1159if test "$strsep" != "yes" ; then
1160 strsep="no"
1161fi
67bf9823
JA
1162cat > $TMPC << EOF
1163#include <string.h>
1164int main(int argc, char **argv)
1165{
ae156be6
JA
1166 static char *string = "This is a string";
1167 strsep(&string, "needle");
67bf9823
JA
1168 return 0;
1169}
1170EOF
1171if compile_prog "" "" "strsep"; then
1172 strsep="yes"
1173fi
484b0b65 1174print_config "strsep" "$strsep"
67bf9823 1175
9ad8da82
JA
1176##########################################
1177# strcasestr() probe
ca205a75
TK
1178if test "$strcasestr" != "yes" ; then
1179 strcasestr="no"
1180fi
9ad8da82
JA
1181cat > $TMPC << EOF
1182#include <string.h>
1183int main(int argc, char **argv)
1184{
aa6738a5 1185 return strcasestr(argv[0], argv[1]) != NULL;
9ad8da82
JA
1186}
1187EOF
1188if compile_prog "" "" "strcasestr"; then
1189 strcasestr="yes"
1190fi
484b0b65 1191print_config "strcasestr" "$strcasestr"
9ad8da82 1192
5ad7be56
KD
1193##########################################
1194# strlcat() probe
ca205a75
TK
1195if test "$strlcat" != "yes" ; then
1196 strlcat="no"
1197fi
5ad7be56
KD
1198cat > $TMPC << EOF
1199#include <string.h>
1200int main(int argc, char **argv)
1201{
1202 static char dst[64];
1203 static char *string = "This is a string";
1204 memset(dst, 0, sizeof(dst));
1205 strlcat(dst, string, sizeof(dst));
1206 return 0;
1207}
1208EOF
1209if compile_prog "" "" "strlcat"; then
1210 strlcat="yes"
1211fi
484b0b65 1212print_config "strlcat" "$strlcat"
5ad7be56 1213
67bf9823
JA
1214##########################################
1215# getopt_long_only() probe
ca205a75
TK
1216if test "$getopt_long_only" != "yes" ; then
1217 getopt_long_only="no"
1218fi
67bf9823
JA
1219cat > $TMPC << EOF
1220#include <unistd.h>
1221#include <stdio.h>
aa6738a5 1222#include <getopt.h>
67bf9823
JA
1223int main(int argc, char **argv)
1224{
1225 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1226 return c;
1227}
1228EOF
1229if compile_prog "" "" "getopt_long_only"; then
1230 getopt_long_only="yes"
1231fi
484b0b65 1232print_config "getopt_long_only()" "$getopt_long_only"
67bf9823
JA
1233
1234##########################################
1235# inet_aton() probe
ca205a75
TK
1236if test "$inet_aton" != "yes" ; then
1237 inet_aton="no"
1238fi
67bf9823
JA
1239cat > $TMPC << EOF
1240#include <sys/socket.h>
1241#include <arpa/inet.h>
1242#include <stdio.h>
1243int main(int argc, char **argv)
1244{
1245 struct in_addr in;
1246 return inet_aton(NULL, &in);
1247}
1248EOF
1249if compile_prog "" "" "inet_aton"; then
1250 inet_aton="yes"
1251fi
484b0b65 1252print_config "inet_aton" "$inet_aton"
67bf9823
JA
1253
1254##########################################
1255# socklen_t probe
ca205a75
TK
1256if test "$socklen_t" != "yes" ; then
1257 socklen_t="no"
1258fi
67bf9823 1259cat > $TMPC << EOF
f6482613 1260#include <sys/socket.h>
67bf9823
JA
1261int main(int argc, char **argv)
1262{
1263 socklen_t len = 0;
1264 return len;
1265}
1266EOF
1267if compile_prog "" "" "socklen_t"; then
1268 socklen_t="yes"
1269fi
484b0b65 1270print_config "socklen_t" "$socklen_t"
67bf9823
JA
1271
1272##########################################
1273# Whether or not __thread is supported for TLS
ca205a75
TK
1274if test "$tls_thread" != "yes" ; then
1275 tls_thread="no"
1276fi
67bf9823
JA
1277cat > $TMPC << EOF
1278#include <stdio.h>
aa6738a5 1279static __thread int ret;
67bf9823
JA
1280int main(int argc, char **argv)
1281{
1282 return ret;
1283}
1284EOF
1285if compile_prog "" "" "__thread"; then
1286 tls_thread="yes"
1287fi
484b0b65 1288print_config "__thread" "$tls_thread"
67bf9823 1289
91f94d5b 1290##########################################
2639f056 1291# Check if we have required gtk/glib support for gfio
ca205a75
TK
1292if test "$gfio" != "yes" ; then
1293 gfio="no"
1294fi
ebec2094 1295if test "$gfio_check" = "yes" ; then
91f94d5b
JA
1296 cat > $TMPC << EOF
1297#include <glib.h>
1298#include <cairo.h>
1299#include <gtk/gtk.h>
1300int main(void)
1301{
1302 gdk_threads_enter();
91f94d5b 1303 gdk_threads_leave();
b7a99316 1304
ef2b61aa 1305 return GTK_CHECK_VERSION(2, 18, 0) ? 0 : 1; /* 0 on success */
91f94d5b
JA
1306}
1307EOF
1308GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
86719845
JA
1309ORG_LDFLAGS=$LDFLAGS
1310LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
91f94d5b
JA
1311if test "$?" != "0" ; then
1312 echo "configure: gtk and gthread not found"
1313 exit 1
1314fi
1315GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1316if test "$?" != "0" ; then
1317 echo "configure: gtk and gthread not found"
1318 exit 1
1319fi
b7a99316 1320if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
ef2b61aa
TK
1321 $TMPE
1322 if test "$?" = "0" ; then
b7a99316 1323 gfio="yes"
86719845 1324 GFIO_LIBS="$LIBS $GTK_LIBS"
b7a99316
JA
1325 CFLAGS="$CFLAGS $GTK_CFLAGS"
1326 else
1327 echo "GTK found, but need version 2.18 or higher"
1328 gfio="no"
1329 fi
91f94d5b
JA
1330else
1331 echo "Please install gtk and gdk libraries"
1332 gfio="no"
1333fi
86719845 1334LDFLAGS=$ORG_LDFLAGS
91f94d5b
JA
1335fi
1336
ebec2094 1337if test "$gfio_check" = "yes" ; then
484b0b65 1338 print_config "gtk 2.18 or higher" "$gfio"
ebec2094 1339fi
91f94d5b 1340
bda92394 1341##########################################
44404c5a 1342# Check whether we have getrusage(RUSAGE_THREAD)
ca205a75
TK
1343if test "$rusage_thread" != "yes" ; then
1344 rusage_thread="no"
1345fi
44404c5a
JA
1346cat > $TMPC << EOF
1347#include <sys/time.h>
1348#include <sys/resource.h>
1349int main(int argc, char **argv)
1350{
1351 struct rusage ru;
1352 getrusage(RUSAGE_THREAD, &ru);
1353 return 0;
1354}
1355EOF
1356if compile_prog "" "" "RUSAGE_THREAD"; then
1357 rusage_thread="yes"
1358fi
484b0b65 1359print_config "RUSAGE_THREAD" "$rusage_thread"
44404c5a 1360
7e09a9f1
JA
1361##########################################
1362# Check whether we have SCHED_IDLE
ca205a75
TK
1363if test "$sched_idle" != "yes" ; then
1364 sched_idle="no"
1365fi
7e09a9f1
JA
1366cat > $TMPC << EOF
1367#include <sched.h>
1368int main(int argc, char **argv)
1369{
1370 struct sched_param p;
1371 return sched_setscheduler(0, SCHED_IDLE, &p);
1372}
1373EOF
1374if compile_prog "" "" "SCHED_IDLE"; then
1375 sched_idle="yes"
1376fi
484b0b65 1377print_config "SCHED_IDLE" "$sched_idle"
7e09a9f1 1378
1eafa37a
JA
1379##########################################
1380# Check whether we have TCP_NODELAY
ca205a75
TK
1381if test "$tcp_nodelay" != "yes" ; then
1382 tcp_nodelay="no"
1383fi
1eafa37a
JA
1384cat > $TMPC << EOF
1385#include <stdio.h>
1386#include <sys/types.h>
1387#include <sys/socket.h>
1388#include <netinet/tcp.h>
1389int main(int argc, char **argv)
1390{
1391 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1392}
1393EOF
1394if compile_prog "" "" "TCP_NODELAY"; then
1395 tcp_nodelay="yes"
1396fi
484b0b65 1397print_config "TCP_NODELAY" "$tcp_nodelay"
1eafa37a 1398
1008602c
JA
1399##########################################
1400# Check whether we have SO_SNDBUF
ca205a75
TK
1401if test "$window_size" != "yes" ; then
1402 window_size="no"
1403fi
1008602c
JA
1404cat > $TMPC << EOF
1405#include <stdio.h>
1406#include <sys/types.h>
1407#include <sys/socket.h>
1408#include <netinet/tcp.h>
1409int main(int argc, char **argv)
1410{
1411 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1412 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1413}
1414EOF
1415if compile_prog "" "" "SO_SNDBUF"; then
1416 window_size="yes"
1417fi
484b0b65 1418print_config "Net engine window_size" "$window_size"
1008602c 1419
e5f34d95
JA
1420##########################################
1421# Check whether we have TCP_MAXSEG
ca205a75
TK
1422if test "$mss" != "yes" ; then
1423 mss="no"
1424fi
e5f34d95
JA
1425cat > $TMPC << EOF
1426#include <stdio.h>
1427#include <sys/types.h>
1428#include <sys/socket.h>
1429#include <netinet/tcp.h>
1430#include <arpa/inet.h>
1431#include <netinet/in.h>
1432int main(int argc, char **argv)
1433{
1434 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1435}
1436EOF
1437if compile_prog "" "" "TCP_MAXSEG"; then
1438 mss="yes"
1439fi
484b0b65 1440print_config "TCP_MAXSEG" "$mss"
e5f34d95 1441
38b9354a
JA
1442##########################################
1443# Check whether we have RLIMIT_MEMLOCK
ca205a75
TK
1444if test "$rlimit_memlock" != "yes" ; then
1445 rlimit_memlock="no"
1446fi
38b9354a
JA
1447cat > $TMPC << EOF
1448#include <sys/time.h>
1449#include <sys/resource.h>
1450int main(int argc, char **argv)
1451{
1452 struct rlimit rl;
1453 return getrlimit(RLIMIT_MEMLOCK, &rl);
1454}
1455EOF
1456if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1457 rlimit_memlock="yes"
1458fi
484b0b65 1459print_config "RLIMIT_MEMLOCK" "$rlimit_memlock"
38b9354a 1460
07fc0acd
JA
1461##########################################
1462# Check whether we have pwritev/preadv
ca205a75
TK
1463if test "$pwritev" != "yes" ; then
1464 pwritev="no"
1465fi
07fc0acd
JA
1466cat > $TMPC << EOF
1467#include <stdio.h>
1468#include <sys/uio.h>
1469int main(int argc, char **argv)
1470{
1471 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1472}
1473EOF
1474if compile_prog "" "" "pwritev"; then
1475 pwritev="yes"
1476fi
484b0b65 1477print_config "pwritev/preadv" "$pwritev"
07fc0acd 1478
2cafffbe
JA
1479##########################################
1480# Check whether we have pwritev2/preadv2
ca205a75
TK
1481if test "$pwritev2" != "yes" ; then
1482 pwritev2="no"
1483fi
2cafffbe
JA
1484cat > $TMPC << EOF
1485#include <stdio.h>
1486#include <sys/uio.h>
1487int main(int argc, char **argv)
1488{
1489 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1490}
1491EOF
1492if compile_prog "" "" "pwritev2"; then
1493 pwritev2="yes"
1494fi
484b0b65 1495print_config "pwritev2/preadv2" "$pwritev2"
2cafffbe 1496
ecad55e9
JA
1497##########################################
1498# Check whether we have the required functions for ipv6
ca205a75
TK
1499if test "$ipv6" != "yes" ; then
1500 ipv6="no"
1501fi
ecad55e9
JA
1502cat > $TMPC << EOF
1503#include <sys/types.h>
1504#include <sys/socket.h>
d219028d 1505#include <netinet/in.h>
ecad55e9
JA
1506#include <netdb.h>
1507#include <stdio.h>
1508int main(int argc, char **argv)
1509{
1510 struct addrinfo hints;
1511 struct in6_addr addr;
1512 int ret;
1513
1514 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1515 freeaddrinfo(NULL);
1516 printf("%s\n", gai_strerror(ret));
1517 addr = in6addr_any;
1518 return 0;
1519}
1520EOF
1521if compile_prog "" "" "ipv6"; then
1522 ipv6="yes"
1523fi
484b0b65 1524print_config "IPv6 helpers" "$ipv6"
07fc0acd 1525
d5f9b0ea
IF
1526##########################################
1527# check for rados
1528if test "$rados" != "yes" ; then
1529 rados="no"
1530fi
1531cat > $TMPC << EOF
1532#include <rados/librados.h>
1533
1534int main(int argc, char **argv)
1535{
1536 rados_t cluster;
1537 rados_ioctx_t io_ctx;
1538 const char cluster_name[] = "ceph";
1539 const char user_name[] = "client.admin";
1540 const char pool[] = "rados";
1541
1542 /* The rados_create2 signature required was only introduced in ceph 0.65 */
1543 rados_create2(&cluster, cluster_name, user_name, 0);
1544 rados_ioctx_create(cluster, pool, &io_ctx);
1545
1546 return 0;
1547}
1548EOF
1549if test "$disable_rados" != "yes" && compile_prog "" "-lrados" "rados"; then
1550 LIBS="-lrados $LIBS"
1551 rados="yes"
1552fi
1553print_config "Rados engine" "$rados"
1554
fc5c0345
DG
1555##########################################
1556# check for rbd
ca205a75
TK
1557if test "$rbd" != "yes" ; then
1558 rbd="no"
1559fi
fc5c0345
DG
1560cat > $TMPC << EOF
1561#include <rbd/librbd.h>
1562
1563int main(int argc, char **argv)
1564{
fc5c0345
DG
1565 rados_t cluster;
1566 rados_ioctx_t io_ctx;
fb9bc6e3
SW
1567 const char cluster_name[] = "ceph";
1568 const char user_name[] = "client.admin";
fc5c0345 1569 const char pool[] = "rbd";
fc5c0345 1570 int major, minor, extra;
fc5c0345 1571
fb9bc6e3
SW
1572 rbd_version(&major, &minor, &extra);
1573 /* The rados_create2 signature required was only introduced in ceph 0.65 */
1574 rados_create2(&cluster, cluster_name, user_name, 0);
fc5c0345 1575 rados_ioctx_create(cluster, pool, &io_ctx);
fb9bc6e3 1576
fc5c0345
DG
1577 return 0;
1578}
1579EOF
ce18290e 1580if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
fc5c0345
DG
1581 LIBS="-lrbd -lrados $LIBS"
1582 rbd="yes"
1583fi
484b0b65 1584print_config "Rados Block Device engine" "$rbd"
fc5c0345 1585
53b6c979
PL
1586##########################################
1587# check for rbd_poll
ca205a75
TK
1588if test "$rbd_poll" != "yes" ; then
1589 rbd_poll="no"
1590fi
53b6c979
PL
1591if test "$rbd" = "yes"; then
1592cat > $TMPC << EOF
1593#include <rbd/librbd.h>
1594#include <sys/eventfd.h>
1595
1596int main(int argc, char **argv)
1597{
1598 rbd_image_t image;
1599 rbd_completion_t comp;
1600
1601 int fd = eventfd(0, EFD_NONBLOCK);
1602 rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1603 rbd_poll_io_events(image, comp, 1);
1604
1605 return 0;
1606}
1607EOF
1608if compile_prog "" "-lrbd -lrados" "rbd"; then
1609 rbd_poll="yes"
1610fi
484b0b65 1611print_config "rbd_poll" "$rbd_poll"
53b6c979
PL
1612fi
1613
903b2812 1614##########################################
6266dd72 1615# check for rbd_invalidate_cache()
ca205a75
TK
1616if test "$rbd_inval" != "yes" ; then
1617 rbd_inval="no"
1618fi
903b2812
JA
1619if test "$rbd" = "yes"; then
1620cat > $TMPC << EOF
1621#include <rbd/librbd.h>
1622
1623int main(int argc, char **argv)
1624{
1625 rbd_image_t image;
1626
1627 return rbd_invalidate_cache(image);
1628}
1629EOF
1630if compile_prog "" "-lrbd -lrados" "rbd"; then
1631 rbd_inval="yes"
1632fi
484b0b65 1633print_config "rbd_invalidate_cache" "$rbd_inval"
903b2812
JA
1634fi
1635
2e802282
JA
1636##########################################
1637# Check whether we have setvbuf
ca205a75
TK
1638if test "$setvbuf" != "yes" ; then
1639 setvbuf="no"
1640fi
2e802282
JA
1641cat > $TMPC << EOF
1642#include <stdio.h>
1643int main(int argc, char **argv)
1644{
1645 FILE *f = NULL;
1646 char buf[80];
1647 setvbuf(f, buf, _IOFBF, sizeof(buf));
1648 return 0;
1649}
1650EOF
1651if compile_prog "" "" "setvbuf"; then
1652 setvbuf="yes"
1653fi
484b0b65 1654print_config "setvbuf" "$setvbuf"
fc5c0345 1655
bda92394 1656##########################################
6e7d7dfb 1657# check for gfapi
ca205a75
TK
1658if test "$gfapi" != "yes" ; then
1659 gfapi="no"
1660fi
6e7d7dfb 1661cat > $TMPC << EOF
1662#include <glusterfs/api/glfs.h>
1663
1664int main(int argc, char **argv)
1665{
6e7d7dfb 1666 glfs_t *g = glfs_new("foo");
1667
1668 return 0;
1669}
1670EOF
ce18290e 1671if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
6e7d7dfb 1672 LIBS="-lgfapi -lglusterfs $LIBS"
1673 gfapi="yes"
1674fi
484b0b65 1675print_config "Gluster API engine" "$gfapi"
6e7d7dfb 1676
6fa14b99 1677##########################################
ca205a75 1678# check for gfapi fadvise support, initialize with "no" only if $gfapi is set to "yes"
6876c98c 1679if test "$gfapi" = "yes" ; then
6fa14b99 1680gf_fadvise="no"
1681cat > $TMPC << EOF
1682#include <glusterfs/api/glfs.h>
1683
1684int main(int argc, char **argv)
1685{
1686 struct glfs_fd *fd;
1687 int ret = glfs_fadvise(fd, 0, 0, 1);
1688
1689 return 0;
1690}
1691EOF
6fa14b99 1692if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1693 gf_fadvise="yes"
1694fi
484b0b65 1695print_config "Gluster API use fadvise" "$gf_fadvise"
6876c98c
JA
1696fi
1697
1698##########################################
1699# check for gfapi trim support
ca205a75
TK
1700if test "$gf_trim" != "yes" ; then
1701 gf_trim="no"
1702fi
6876c98c
JA
1703if test "$gfapi" = "yes" ; then
1704cat > $TMPC << EOF
1705#include <glusterfs/api/glfs.h>
1706
1707int main(int argc, char **argv)
1708{
1709 return glfs_discard_async(NULL, 0, 0);
1710}
1711EOF
1712if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1713 gf_trim="yes"
1714fi
484b0b65 1715print_config "Gluster API trim support" "$gf_trim"
6876c98c 1716fi
fc5c0345 1717
81795ce3
CE
1718##########################################
1719# Check if we support stckf on s390
ca205a75
TK
1720if test "$s390_z196_facilities" != "yes" ; then
1721 s390_z196_facilities="no"
1722fi
81795ce3
CE
1723cat > $TMPC << EOF
1724#define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1725int main(int argc, char **argv)
1726{
1727 /* We want just 1 double word to be returned. */
1728 register unsigned long reg0 asm("0") = 0;
1729 unsigned long stfle_bits;
1730 asm volatile(".machine push" "\n\t"
1731 ".machine \"z9-109\"" "\n\t"
1732 "stfle %0" "\n\t"
1733 ".machine pop" "\n"
1734 : "=QS" (stfle_bits), "+d" (reg0)
1735 : : "cc");
1736
1737 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1738 return 0;
1739 else
1740 return -1;
1741}
1742EOF
1743if compile_prog "" "" "s390_z196_facilities"; then
1744 $TMPE
6a2c9363 1745 if [ $? -eq 0 ]; then
81795ce3
CE
1746 s390_z196_facilities="yes"
1747 fi
1748fi
484b0b65 1749print_config "s390_z196_facilities" "$s390_z196_facilities"
1b10477b
MM
1750
1751##########################################
1752# Check if we have required environment variables configured for libhdfs
1753if test "$libhdfs" = "yes" ; then
1754 hdfs_conf_error=0
1755 if test "$JAVA_HOME" = "" ; then
1756 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1757 hdfs_conf_error=1
1758 fi
1759 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1760 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1761 hdfs_conf_error=1
1762 fi
1763 if test "$FIO_LIBHDFS_LIB" = "" ; then
1764 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1765 hdfs_conf_error=1
1766 fi
1767 if test "$hdfs_conf_error" = "1" ; then
1768 exit 1
1769 fi
247e5436
JA
1770 FIO_HDFS_CPU=$cpu
1771 if test "$FIO_HDFS_CPU" = "x86_64" ; then
1772 FIO_HDFS_CPU="amd64"
1773 fi
1b10477b 1774fi
484b0b65 1775print_config "HDFS engine" "$libhdfs"
1b10477b 1776
b8116a87
DE
1777##########################################
1778# Check whether we have MTD
ca205a75
TK
1779if test "$mtd" != "yes" ; then
1780 mtd="no"
1781fi
b8116a87 1782cat > $TMPC << EOF
0e1c454a 1783#include <string.h>
b8116a87
DE
1784#include <mtd/mtd-user.h>
1785#include <sys/ioctl.h>
1786int main(int argc, char **argv)
1787{
0e1c454a 1788 struct mtd_write_req ops;
b8116a87 1789 struct mtd_info_user info;
0e1c454a 1790 memset(&ops, 0, sizeof(ops));
400cd0ff 1791 info.type = MTD_MLCNANDFLASH;
b8116a87
DE
1792 return ioctl(0, MEMGETINFO, &info);
1793}
1794EOF
1795if compile_prog "" "" "mtd"; then
1796 mtd="yes"
1797fi
484b0b65 1798print_config "MTD" "$mtd"
b8116a87 1799
3ee2a3c1
DJ
1800##########################################
1801# Check whether we have libpmem
ca205a75
TK
1802if test "$libpmem" != "yes" ; then
1803 libpmem="no"
1804fi
3ee2a3c1
DJ
1805cat > $TMPC << EOF
1806#include <libpmem.h>
1807int main(int argc, char **argv)
1808{
1809 int rc;
1810 rc = pmem_is_pmem(0, 0);
1811 return 0;
1812}
1813EOF
1814if compile_prog "" "-lpmem" "libpmem"; then
1815 libpmem="yes"
cf8775b8 1816 LIBS="-lpmem $LIBS"
3ee2a3c1 1817fi
484b0b65 1818print_config "libpmem" "$libpmem"
3ee2a3c1
DJ
1819
1820##########################################
1821# Check whether we have libpmemblk
cf8775b8 1822# libpmem is a prerequisite
ca205a75
TK
1823if test "$libpmemblk" != "yes" ; then
1824 libpmemblk="no"
1825fi
cf8775b8
RE
1826if test "$libpmem" = "yes"; then
1827 cat > $TMPC << EOF
3ee2a3c1
DJ
1828#include <libpmemblk.h>
1829int main(int argc, char **argv)
1830{
cf8775b8
RE
1831 PMEMblkpool *pbp;
1832 pbp = pmemblk_open("", 0);
3ee2a3c1
DJ
1833 return 0;
1834}
1835EOF
cf8775b8
RE
1836 if compile_prog "" "-lpmemblk" "libpmemblk"; then
1837 libpmemblk="yes"
1838 LIBS="-lpmemblk $LIBS"
1839 fi
3ee2a3c1 1840fi
484b0b65 1841print_config "libpmemblk" "$libpmemblk"
3ee2a3c1 1842
cf8775b8 1843# Choose the ioengines
3ee2a3c1 1844if test "$libpmem" = "yes" && test "$disable_pmem" = "no"; then
ae0db592 1845 pmem="yes"
3ee2a3c1
DJ
1846 devdax="yes"
1847 if test "$libpmemblk" = "yes"; then
1848 pmemblk="yes"
1849 fi
1850fi
1851
43f3cec2
BB
1852##########################################
1853# Report whether pmemblk engine is enabled
484b0b65 1854print_config "NVML pmemblk engine" "$pmemblk"
43f3cec2 1855
cbb15e42
DJ
1856##########################################
1857# Report whether dev-dax engine is enabled
484b0b65 1858print_config "NVML dev-dax engine" "$devdax"
cbb15e42 1859
ae0db592
TI
1860##########################################
1861# Report whether libpmem engine is enabled
1862print_config "NVML libpmem engine" "$pmem"
1863
bda92394 1864##########################################
b470a02c
SC
1865# Check if we have lex/yacc available
1866yacc="no"
e7b2c7a3 1867yacc_is_bison="no"
b470a02c
SC
1868lex="no"
1869arith="no"
de26b824 1870if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
cf6dd80e 1871if test "$targetos" != "SunOS" ; then
e7b2c7a3 1872LEX=$(which lex 2> /dev/null)
b470a02c
SC
1873if test -x "$LEX" ; then
1874 lex="yes"
1875fi
7e0049e9 1876YACC=$(which bison 2> /dev/null)
b470a02c
SC
1877if test -x "$YACC" ; then
1878 yacc="yes"
7e0049e9 1879 yacc_is_bison="yes"
e7b2c7a3 1880else
7e0049e9 1881 YACC=$(which yacc 2> /dev/null)
e7b2c7a3
JA
1882 if test -x "$YACC" ; then
1883 yacc="yes"
e7b2c7a3 1884 fi
b470a02c
SC
1885fi
1886if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1887 arith="yes"
1888fi
1889
1890if test "$arith" = "yes" ; then
1891cat > $TMPC << EOF
1892extern int yywrap(void);
1893
1894int main(int argc, char **argv)
1895{
1896 yywrap();
1897 return 0;
1898}
1899EOF
719cda03
JA
1900if compile_prog "" "-ll" "lex"; then
1901 LIBS="-ll $LIBS"
b470a02c
SC
1902else
1903 arith="no"
1904fi
1905fi
cf6dd80e 1906fi
a655bbc4 1907fi
b470a02c 1908
63bda378
JA
1909# Check if lex fails using -o
1910if test "$arith" = "yes" ; then
daf705b5
JA
1911if test "$force_no_lex_o" = "yes" ; then
1912 lex_use_o="no"
1913else
63bda378
JA
1914$LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1915if test "$?" = "0" ; then
1916 lex_use_o="yes"
1917else
1918 lex_use_o="no"
1919fi
1920fi
daf705b5 1921fi
63bda378 1922
484b0b65 1923print_config "lex/yacc for arithmetic" "$arith"
b470a02c 1924
aae599ba
JA
1925##########################################
1926# Check whether we have setmntent/getmntent
ca205a75
TK
1927if test "$getmntent" != "yes" ; then
1928 getmntent="no"
1929fi
aae599ba
JA
1930cat > $TMPC << EOF
1931#include <stdio.h>
1932#include <mntent.h>
1933int main(int argc, char **argv)
1934{
1935 FILE *mtab = setmntent(NULL, "r");
1936 struct mntent *mnt = getmntent(mtab);
1581b82a 1937 endmntent(mtab);
aae599ba
JA
1938 return 0;
1939}
1940EOF
1941if compile_prog "" "" "getmntent"; then
1942 getmntent="yes"
1943fi
484b0b65 1944print_config "getmntent" "$getmntent"
aae599ba 1945
e7e136da
TK
1946##########################################
1947# Check whether we have getmntinfo
b765bec0
TK
1948# These are originally added for BSDs, but may also work
1949# on other operating systems with getmntinfo(3).
1950
1951# getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
1952# Note that NetBSD needs -Werror to catch warning as error.
ca205a75
TK
1953if test "$getmntinfo" != "yes" ; then
1954 getmntinfo="no"
1955fi
e7e136da
TK
1956cat > $TMPC << EOF
1957#include <stdio.h>
1958#include <sys/param.h>
1959#include <sys/mount.h>
1960int main(int argc, char **argv)
1961{
9ada751d 1962 struct statfs *st;
e7e136da
TK
1963 return getmntinfo(&st, MNT_NOWAIT);
1964}
1965EOF
b765bec0 1966if compile_prog "-Werror" "" "getmntinfo"; then
e7e136da
TK
1967 getmntinfo="yes"
1968fi
484b0b65 1969print_config "getmntinfo" "$getmntinfo"
e7e136da 1970
b765bec0 1971# getmntinfo(3) for NetBSD.
ca205a75
TK
1972if test "$getmntinfo_statvfs" != "yes" ; then
1973 getmntinfo_statvfs="no"
1974fi
b765bec0
TK
1975cat > $TMPC << EOF
1976#include <stdio.h>
1977#include <sys/statvfs.h>
1978int main(int argc, char **argv)
1979{
1980 struct statvfs *st;
1981 return getmntinfo(&st, MNT_NOWAIT);
1982}
1983EOF
1984# Skip the test if the one with statfs arg is detected.
1985if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
1986 getmntinfo_statvfs="yes"
484b0b65 1987 print_config "getmntinfo_statvfs" "$getmntinfo_statvfs"
b765bec0
TK
1988fi
1989
5018f79f
AH
1990##########################################
1991# Check whether we have _Static_assert
ca205a75
TK
1992if test "$static_assert" != "yes" ; then
1993 static_assert="no"
1994fi
5018f79f
AH
1995cat > $TMPC << EOF
1996#include <assert.h>
94815a5c 1997#include <stdlib.h>
51b4c81e 1998#include <stddef.h>
94815a5c
JA
1999
2000struct foo {
2001 int a, b;
2002};
2003
5018f79f
AH
2004int main(int argc, char **argv)
2005{
94815a5c 2006 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
5018f79f
AH
2007 return 0 ;
2008}
2009EOF
2010if compile_prog "" "" "static_assert"; then
2011 static_assert="yes"
2012fi
484b0b65 2013print_config "Static Assert" "$static_assert"
e39c0676
JA
2014
2015##########################################
2016# Check whether we have bool / stdbool.h
ca205a75
TK
2017if test "$have_bool" != "yes" ; then
2018 have_bool="no"
2019fi
e39c0676
JA
2020cat > $TMPC << EOF
2021#include <stdbool.h>
2022int main(int argc, char **argv)
2023{
2024 bool var = true;
2025 return var != false;
2026}
2027EOF
2028if compile_prog "" "" "bool"; then
2029 have_bool="yes"
2030fi
484b0b65 2031print_config "bool" "$have_bool"
e39c0676 2032
b29c71c4
JA
2033##########################################
2034# Check whether we have strndup()
107ad008 2035strndup="no"
b29c71c4
JA
2036cat > $TMPC << EOF
2037#include <string.h>
2038#include <stdlib.h>
2039int main(int argc, char **argv)
2040{
2041 char *res = strndup("test string", 8);
2042
2043 free(res);
2044 return 0;
2045}
2046EOF
2047if compile_prog "" "" "strndup"; then
2048 strndup="yes"
2049fi
2050print_config "strndup" "$strndup"
2051
214e2d56 2052##########################################
0ffccc21
BVA
2053# <valgrind/drd.h> probe
2054# Note: presence of <valgrind/drd.h> implies that <valgrind/valgrind.h> is
2055# also available but not the other way around.
2056if test "$valgrind_dev" != "yes" ; then
2057 valgrind_dev="no"
2058fi
2059cat > $TMPC << EOF
2060#include <valgrind/drd.h>
2061int main(int argc, char **argv)
2062{
2063 return 0;
2064}
2065EOF
2066if compile_prog "" "" "valgrind_dev"; then
2067 valgrind_dev="yes"
2068fi
2069print_config "Valgrind headers" "$valgrind_dev"
2070
214e2d56 2071# check march=armv8-a+crc+crypto
ca205a75
TK
2072if test "$march_armv8_a_crc_crypto" != "yes" ; then
2073 march_armv8_a_crc_crypto="no"
2074fi
214e2d56 2075if test "$cpu" = "arm64" ; then
2076 cat > $TMPC <<EOF
9b153dc2
TT
2077#include <sys/auxv.h>
2078#include <arm_acle.h>
2079#include <arm_neon.h>
2080
214e2d56 2081int main(void)
2082{
2083 return 0;
2084}
2085EOF
2086 if compile_prog "-march=armv8-a+crc+crypto" "" ""; then
2087 march_armv8_a_crc_crypto="yes"
2088 CFLAGS="$CFLAGS -march=armv8-a+crc+crypto -DARCH_HAVE_CRC_CRYPTO"
9f75af77 2089 march_set="yes"
214e2d56 2090 fi
2091fi
484b0b65 2092print_config "march_armv8_a_crc_crypto" "$march_armv8_a_crc_crypto"
214e2d56 2093
03553853
YR
2094##########################################
2095# cuda probe
d418fa90
TK
2096if test "$cuda" != "yes" ; then
2097 cuda="no"
2098fi
03553853
YR
2099cat > $TMPC << EOF
2100#include <cuda.h>
2101int main(int argc, char **argv)
2102{
2103 return cuInit(0);
2104}
2105EOF
4bd2c8b9 2106if test "$enable_cuda" = "yes" && compile_prog "" "-lcuda" "cuda"; then
03553853
YR
2107 cuda="yes"
2108 LIBS="-lcuda $LIBS"
2109fi
484b0b65 2110print_config "cuda" "$cuda"
214e2d56 2111
4252396e
JA
2112##########################################
2113# mkdir() probe. mingw apparently has a one-argument mkdir :/
2114mkdir_two="no"
2115cat > $TMPC << EOF
2116#include <sys/stat.h>
2117#include <sys/types.h>
2118int main(int argc, char **argv)
2119{
2120 return mkdir("/tmp/bla", 0600);
2121}
2122EOF
2123if compile_prog "" "" "mkdir(a, b)"; then
2124 mkdir_two="yes"
2125fi
2126print_config "mkdir(a, b)" "$mkdir_two"
2127
a817dc3b
JA
2128##########################################
2129# check for cc -march=native
2130build_native="no"
2131cat > $TMPC << EOF
2132int main(int argc, char **argv)
2133{
2134 return 0;
2135}
2136EOF
c922e0b0
SW
2137if test "$disable_native" = "no" && test "$disable_opt" != "yes" && \
2138 compile_prog "-march=native" "" "march=native"; then
a817dc3b
JA
2139 build_native="yes"
2140fi
2141print_config "Build march=native" "$build_native"
2142
67bf9823
JA
2143#############################################################################
2144
67bf9823 2145if test "$wordsize" = "64" ; then
4feafb1e 2146 output_sym "CONFIG_64BIT"
67bf9823 2147elif test "$wordsize" = "32" ; then
4feafb1e 2148 output_sym "CONFIG_32BIT"
67bf9823 2149else
d7145a78 2150 fatal "Unknown wordsize!"
67bf9823 2151fi
0dcebdf4 2152if test "$bigendian" = "yes" ; then
4feafb1e 2153 output_sym "CONFIG_BIG_ENDIAN"
0dcebdf4 2154else
4feafb1e 2155 output_sym "CONFIG_LITTLE_ENDIAN"
0dcebdf4 2156fi
3989b143
JA
2157if test "$zlib" = "yes" ; then
2158 output_sym "CONFIG_ZLIB"
2159fi
67bf9823 2160if test "$libaio" = "yes" ; then
4feafb1e 2161 output_sym "CONFIG_LIBAIO"
67bf9823
JA
2162fi
2163if test "$posix_aio" = "yes" ; then
4feafb1e 2164 output_sym "CONFIG_POSIXAIO"
67bf9823
JA
2165fi
2166if test "$posix_aio_fsync" = "yes" ; then
4feafb1e 2167 output_sym "CONFIG_POSIXAIO_FSYNC"
67bf9823 2168fi
06eac6b2
SW
2169if test "$posix_pshared" = "yes" ; then
2170 output_sym "CONFIG_PSHARED"
2171fi
67bf9823 2172if test "$linux_fallocate" = "yes" ; then
4feafb1e 2173 output_sym "CONFIG_LINUX_FALLOCATE"
67bf9823
JA
2174fi
2175if test "$posix_fallocate" = "yes" ; then
4feafb1e 2176 output_sym "CONFIG_POSIX_FALLOCATE"
67bf9823
JA
2177fi
2178if test "$fdatasync" = "yes" ; then
4feafb1e 2179 output_sym "CONFIG_FDATASYNC"
67bf9823
JA
2180fi
2181if test "$sync_file_range" = "yes" ; then
4feafb1e 2182 output_sym "CONFIG_SYNC_FILE_RANGE"
67bf9823
JA
2183fi
2184if test "$sfaa" = "yes" ; then
4feafb1e 2185 output_sym "CONFIG_SFAA"
67bf9823 2186fi
a250edd0
JA
2187if test "$sync_sync" = "yes" ; then
2188 output_sym "CONFIG_SYNC_SYNC"
2189fi
2190if test "$cmp_swap" = "yes" ; then
2191 output_sym "CONFIG_CMP_SWAP"
2192fi
954cd73a 2193if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
4feafb1e 2194 output_sym "CONFIG_RDMA"
67bf9823
JA
2195fi
2196if test "$clock_gettime" = "yes" ; then
4feafb1e 2197 output_sym "CONFIG_CLOCK_GETTIME"
67bf9823
JA
2198fi
2199if test "$clock_monotonic" = "yes" ; then
4feafb1e 2200 output_sym "CONFIG_CLOCK_MONOTONIC"
67bf9823 2201fi
c544f604
SN
2202if test "$clock_monotonic_raw" = "yes" ; then
2203 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
2204fi
67bf9823 2205if test "$clock_monotonic_precise" = "yes" ; then
4feafb1e 2206 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
67bf9823 2207fi
25f8227d
JA
2208if test "$clockid_t" = "yes"; then
2209 output_sym "CONFIG_CLOCKID_T"
2210fi
67bf9823 2211if test "$gettimeofday" = "yes" ; then
4feafb1e 2212 output_sym "CONFIG_GETTIMEOFDAY"
67bf9823
JA
2213fi
2214if test "$posix_fadvise" = "yes" ; then
4feafb1e 2215 output_sym "CONFIG_POSIX_FADVISE"
67bf9823
JA
2216fi
2217if test "$linux_3arg_affinity" = "yes" ; then
4feafb1e 2218 output_sym "CONFIG_3ARG_AFFINITY"
67bf9823 2219elif test "$linux_2arg_affinity" = "yes" ; then
4feafb1e 2220 output_sym "CONFIG_2ARG_AFFINITY"
67bf9823
JA
2221fi
2222if test "$strsep" = "yes" ; then
4feafb1e 2223 output_sym "CONFIG_STRSEP"
67bf9823 2224fi
9ad8da82
JA
2225if test "$strcasestr" = "yes" ; then
2226 output_sym "CONFIG_STRCASESTR"
2227fi
5ad7be56
KD
2228if test "$strlcat" = "yes" ; then
2229 output_sym "CONFIG_STRLCAT"
2230fi
67bf9823 2231if test "$getopt_long_only" = "yes" ; then
4feafb1e 2232 output_sym "CONFIG_GETOPT_LONG_ONLY"
67bf9823
JA
2233fi
2234if test "$inet_aton" = "yes" ; then
4feafb1e 2235 output_sym "CONFIG_INET_ATON"
67bf9823
JA
2236fi
2237if test "$socklen_t" = "yes" ; then
4feafb1e 2238 output_sym "CONFIG_SOCKLEN_T"
67bf9823
JA
2239fi
2240if test "$ext4_me" = "yes" ; then
4feafb1e 2241 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
67bf9823
JA
2242fi
2243if test "$linux_splice" = "yes" ; then
4feafb1e 2244 output_sym "CONFIG_LINUX_SPLICE"
67bf9823
JA
2245fi
2246if test "$guasi" = "yes" ; then
4feafb1e 2247 output_sym "CONFIG_GUASI"
67bf9823
JA
2248fi
2249if test "$fusion_aw" = "yes" ; then
4feafb1e 2250 output_sym "CONFIG_FUSION_AW"
67bf9823 2251fi
50206d9b 2252if test "$libnuma_v2" = "yes" ; then
4feafb1e 2253 output_sym "CONFIG_LIBNUMA"
67bf9823
JA
2254fi
2255if test "$solaris_aio" = "yes" ; then
4feafb1e 2256 output_sym "CONFIG_SOLARISAIO"
67bf9823
JA
2257fi
2258if test "$tls_thread" = "yes" ; then
4feafb1e 2259 output_sym "CONFIG_TLS_THREAD"
67bf9823 2260fi
44404c5a 2261if test "$rusage_thread" = "yes" ; then
4feafb1e 2262 output_sym "CONFIG_RUSAGE_THREAD"
67bf9823 2263fi
91f94d5b 2264if test "$gfio" = "yes" ; then
bad7e42c 2265 output_sym "CONFIG_GFIO"
91f94d5b 2266fi
c8931876
JA
2267if test "$esx" = "yes" ; then
2268 output_sym "CONFIG_ESX"
2269 output_sym "CONFIG_NO_SHM"
2270fi
7e09a9f1
JA
2271if test "$sched_idle" = "yes" ; then
2272 output_sym "CONFIG_SCHED_IDLE"
2273fi
1eafa37a
JA
2274if test "$tcp_nodelay" = "yes" ; then
2275 output_sym "CONFIG_TCP_NODELAY"
2276fi
1008602c
JA
2277if test "$window_size" = "yes" ; then
2278 output_sym "CONFIG_NET_WINDOWSIZE"
2279fi
e5f34d95
JA
2280if test "$mss" = "yes" ; then
2281 output_sym "CONFIG_NET_MSS"
2282fi
38b9354a
JA
2283if test "$rlimit_memlock" = "yes" ; then
2284 output_sym "CONFIG_RLIMIT_MEMLOCK"
2285fi
07fc0acd
JA
2286if test "$pwritev" = "yes" ; then
2287 output_sym "CONFIG_PWRITEV"
2288fi
2cafffbe
JA
2289if test "$pwritev2" = "yes" ; then
2290 output_sym "CONFIG_PWRITEV2"
2291fi
ecad55e9
JA
2292if test "$ipv6" = "yes" ; then
2293 output_sym "CONFIG_IPV6"
2294fi
d5f9b0ea
IF
2295if test "$rados" = "yes" ; then
2296 output_sym "CONFIG_RADOS"
2297fi
fc5c0345
DG
2298if test "$rbd" = "yes" ; then
2299 output_sym "CONFIG_RBD"
2300fi
53b6c979
PL
2301if test "$rbd_poll" = "yes" ; then
2302 output_sym "CONFIG_RBD_POLL"
2303fi
903b2812
JA
2304if test "$rbd_inval" = "yes" ; then
2305 output_sym "CONFIG_RBD_INVAL"
2306fi
2e802282
JA
2307if test "$setvbuf" = "yes" ; then
2308 output_sym "CONFIG_SETVBUF"
2309fi
81795ce3
CE
2310if test "$s390_z196_facilities" = "yes" ; then
2311 output_sym "CONFIG_S390_Z196_FACILITIES"
2312 CFLAGS="$CFLAGS -march=z9-109"
9f75af77 2313 march_set="yes"
81795ce3 2314fi
6e7d7dfb 2315if test "$gfapi" = "yes" ; then
2316 output_sym "CONFIG_GFAPI"
2317fi
6fa14b99 2318if test "$gf_fadvise" = "yes" ; then
2319 output_sym "CONFIG_GF_FADVISE"
2320fi
6876c98c
JA
2321if test "$gf_trim" = "yes" ; then
2322 output_sym "CONFIG_GF_TRIM"
2323fi
1b10477b
MM
2324if test "$libhdfs" = "yes" ; then
2325 output_sym "CONFIG_LIBHDFS"
247e5436 2326 echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
1527dc50
FB
2327 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
2328 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
2329 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
2330 fi
b8116a87
DE
2331if test "$mtd" = "yes" ; then
2332 output_sym "CONFIG_MTD"
2333fi
43f3cec2
BB
2334if test "$pmemblk" = "yes" ; then
2335 output_sym "CONFIG_PMEMBLK"
2336fi
cbb15e42
DJ
2337if test "$devdax" = "yes" ; then
2338 output_sym "CONFIG_LINUX_DEVDAX"
2339fi
ae0db592
TI
2340if test "$pmem" = "yes" ; then
2341 output_sym "CONFIG_LIBPMEM"
2342fi
b470a02c
SC
2343if test "$arith" = "yes" ; then
2344 output_sym "CONFIG_ARITHMETIC"
e7b2c7a3
JA
2345 if test "$yacc_is_bison" = "yes" ; then
2346 echo "YACC=$YACC -y" >> $config_host_mak
2347 else
2348 echo "YACC=$YACC" >> $config_host_mak
2349 fi
63bda378
JA
2350 if test "$lex_use_o" = "yes" ; then
2351 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
2352 fi
b470a02c 2353fi
aae599ba
JA
2354if test "$getmntent" = "yes" ; then
2355 output_sym "CONFIG_GETMNTENT"
2356fi
e7e136da
TK
2357if test "$getmntinfo" = "yes" ; then
2358 output_sym "CONFIG_GETMNTINFO"
2359fi
b765bec0
TK
2360if test "$getmntinfo_statvfs" = "yes" ; then
2361 output_sym "CONFIG_GETMNTINFO_STATVFS"
2362fi
5018f79f
AH
2363if test "$static_assert" = "yes" ; then
2364 output_sym "CONFIG_STATIC_ASSERT"
2365fi
e39c0676
JA
2366if test "$have_bool" = "yes" ; then
2367 output_sym "CONFIG_HAVE_BOOL"
2368fi
b29c71c4
JA
2369if test "$strndup" = "yes" ; then
2370 output_sym "CONFIG_HAVE_STRNDUP"
2371fi
484817a9
JA
2372if test "$disable_opt" = "yes" ; then
2373 output_sym "CONFIG_DISABLE_OPTIMIZATIONS"
2374fi
0ffccc21
BVA
2375if test "$valgrind_dev" = "yes"; then
2376 output_sym "CONFIG_VALGRIND_DEV"
2377fi
605cf82e 2378if test "$zlib" = "no" ; then
8f909424
JA
2379 echo "Consider installing zlib-dev (zlib-devel, some fio features depend on it."
2380 if test "$build_static" = "yes"; then
2381 echo "Note that some distros have separate packages for static libraries."
2382 fi
605cf82e 2383fi
03553853
YR
2384if test "$cuda" = "yes" ; then
2385 output_sym "CONFIG_CUDA"
2386fi
4252396e
JA
2387if test "$mkdir_two" = "yes" ; then
2388 output_sym "CONFIG_HAVE_MKDIR_TWO"
2389fi
9f75af77 2390if test "$march_set" = "no" && test "$build_native" = "yes" ; then
a817dc3b
JA
2391 output_sym "CONFIG_BUILD_NATIVE"
2392fi
605cf82e 2393
67bf9823 2394echo "LIBS+=$LIBS" >> $config_host_mak
86719845 2395echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
91f94d5b 2396echo "CFLAGS+=$CFLAGS" >> $config_host_mak
d2aeedb9 2397echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
67bf9823 2398echo "CC=$cc" >> $config_host_mak
af4862b3 2399echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
020d54bd 2400echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
c61a3a44 2401
59d8f412 2402if [ `dirname $0` != "." -a ! -e Makefile ]; then
c61a3a44
JF
2403 cat > Makefile <<EOF
2404SRCDIR:=`dirname $0`
2405include \$(SRCDIR)/Makefile
2406EOF
2407fi