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