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