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