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