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