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