fio: add additional support for dev-dax ioengine
[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
44404c5a 40# Default CFLAGS
af4862b3
JA
41CFLAGS="-D_GNU_SOURCE -include config-host.h"
42BUILD_CFLAGS=""
67bf9823
JA
43
44# Print a helpful header at the top of config.log
45echo "# FIO configure log $(date)" >> config.log
46printf "# Configured with:" >> config.log
47printf " '%s'" "$0" "$@" >> config.log
48echo >> config.log
49echo "#" >> config.log
50
7560fe7c
JA
51# Print configure header at the top of $config_host_h
52echo "/*" > $config_host_h
53echo " * Automatically generated by configure - do not modify" >> $config_host_h
54printf " * Configured with:" >> $config_host_h
55printf " * '%s'" "$0" "$@" >> $config_host_h
56echo "" >> $config_host_h
57echo " */" >> $config_host_h
58
67bf9823
JA
59do_cc() {
60 # Run the compiler, capturing its output to the log.
61 echo $cc "$@" >> config.log
62 $cc "$@" >> config.log 2>&1 || return $?
63 # Test passed. If this is an --enable-werror build, rerun
64 # the test with -Werror and bail out if it fails. This
65 # makes warning-generating-errors in configure test code
66 # obvious to developers.
67 if test "$werror" != "yes"; then
68 return 0
69 fi
70 # Don't bother rerunning the compile if we were already using -Werror
71 case "$*" in
72 *-Werror*)
73 return 0
74 ;;
75 esac
76 echo $cc -Werror "$@" >> config.log
77 $cc -Werror "$@" >> config.log 2>&1 && return $?
78 echo "ERROR: configure test passed without -Werror but failed with -Werror."
79 echo "This is probably a bug in the configure script. The failing command"
80 echo "will be at the bottom of config.log."
d7145a78 81 fatal "You can run configure with --disable-werror to bypass this check."
67bf9823
JA
82}
83
84compile_object() {
85 do_cc $CFLAGS -c -o $TMPO $TMPC
86}
87
88compile_prog() {
89 local_cflags="$1"
adaa46d8 90 local_ldflags="$2 $LIBS"
67bf9823
JA
91 echo "Compiling test case $3" >> config.log
92 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
93}
94
95feature_not_found() {
96 feature=$1
c55d728b 97 packages=$2
67bf9823
JA
98
99 echo "ERROR"
100 echo "ERROR: User requested feature $feature"
c55d728b
JA
101 if test ! -z "$packages" ; then
102 echo "ERROR: That feature needs $packages installed"
103 fi
67bf9823 104 echo "ERROR: configure was not able to find it"
d7145a78 105 fatal "ERROR"
67bf9823
JA
106}
107
108has() {
109 type "$1" >/dev/null 2>&1
110}
111
112check_define() {
113 cat > $TMPC <<EOF
114#if !defined($1)
115#error $1 not defined
116#endif
117int main(void)
118{
119 return 0;
120}
121EOF
122 compile_object
123}
124
4feafb1e
JA
125output_sym() {
126 echo "$1=y" >> $config_host_mak
127 echo "#define $1" >> $config_host_h
128}
129
67bf9823
JA
130targetos=""
131cpu=""
132
91f94d5b 133# default options
47f44635
JA
134show_help="no"
135exit_val=0
ebec2094 136gfio_check="no"
1b10477b 137libhdfs="no"
43f3cec2 138pmemblk="no"
cbb15e42 139devdax="no"
de26b824 140disable_lex=""
020d54bd 141prefix=/usr/local
91f94d5b 142
cb1125b0
JA
143# parse options
144for opt do
145 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
146 case "$opt" in
020d54bd
JA
147 --prefix=*) prefix="$optarg"
148 ;;
8b156d8e
JA
149 --cpu=*) cpu="$optarg"
150 ;;
c8931876
JA
151 # esx is cross compiled and cannot be detect through simple uname calls
152 --esx)
153 esx="yes"
154 ;;
cb1125b0
JA
155 --cc=*) CC="$optarg"
156 ;;
208e4c8b
JA
157 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
158 ;;
b7c12794 159 --build-32bit-win) build_32bit_win="yes"
7409711b 160 ;;
d2aeedb9
JA
161 --build-static) build_static="yes"
162 ;;
91f94d5b 163 --enable-gfio)
ebec2094 164 gfio_check="yes"
899fab33 165 ;;
44462517
CF
166 --disable-numa) disable_numa="yes"
167 ;;
ce18290e
TM
168 --disable-rbd) disable_rbd="yes"
169 ;;
a4c4c346 170 --disable-rbd-blkin) disable_rbd_blkin="yes"
171 ;;
ce18290e
TM
172 --disable-gfapi) disable_gfapi="yes"
173 ;;
1b10477b
MM
174 --enable-libhdfs) libhdfs="yes"
175 ;;
43f3cec2
BB
176 --enable-pmemblk) pmemblk="yes"
177 ;;
cbb15e42
DJ
178 --enable-devdax) devdax="yes"
179 ;;
a655bbc4
JA
180 --disable-lex) disable_lex="yes"
181 ;;
de26b824
JA
182 --enable-lex) disable_lex="no"
183 ;;
61054f0d
JA
184 --disable-shm) no_shm="yes"
185 ;;
186 --disable-optimizations) disable_opt="yes"
ba40757e 187 ;;
827da4f5 188 --help)
47f44635 189 show_help="yes"
827da4f5 190 ;;
cb1125b0
JA
191 *)
192 echo "Bad option $opt"
47f44635
JA
193 show_help="yes"
194 exit_val=1
cb1125b0
JA
195 esac
196done
197
47f44635 198if test "$show_help" = "yes" ; then
020d54bd 199 echo "--prefix= Use this directory as installation prefix"
8b156d8e 200 echo "--cpu= Specify target CPU if auto-detect fails"
b7a99316 201 echo "--cc= Specify compiler to use"
899fab33 202 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
b7c12794 203 echo "--build-32bit-win Enable 32-bit build on Windows"
d2aeedb9 204 echo "--build-static Build a static fio"
c8931876 205 echo "--esx Configure build options for esx"
b7a99316 206 echo "--enable-gfio Enable building of gtk gfio"
44462517 207 echo "--disable-numa Disable libnuma even if found"
c44ff511 208 echo "--disable-gfapi Disable gfapi"
1b10477b 209 echo "--enable-libhdfs Enable hdfs support"
43f3cec2 210 echo "--enable-pmemblk Enable NVML libpmemblk support"
cbb15e42 211 echo "--enable-devdax Enable NVM Device Dax support"
a655bbc4 212 echo "--disable-lex Disable use of lex/yacc for math"
de26b824 213 echo "--enable-lex Enable use of lex/yacc for math"
c44ff511 214 echo "--disable-shm Disable SHM support"
61054f0d 215 echo "--disable-optimizations Don't enable compiler optimizations"
b7a99316 216 exit $exit_val
47f44635
JA
217fi
218
47986339
SH
219cross_prefix=${cross_prefix-${CROSS_COMPILE}}
220cc="${CC-${cross_prefix}gcc}"
221
6d0e9f83
AC
222if check_define __ANDROID__ ; then
223 targetos="Android"
224elif check_define __linux__ ; then
67bf9823 225 targetos="Linux"
67bf9823
JA
226elif check_define __OpenBSD__ ; then
227 targetos='OpenBSD'
228elif check_define __sun__ ; then
229 targetos='SunOS'
7cb024f8 230 CFLAGS="$CFLAGS -D_REENTRANT"
b24f59ab
SH
231elif check_define _WIN32 ; then
232 targetos='CYGWIN'
67bf9823
JA
233else
234 targetos=`uname -s`
235fi
236
53cd4eee
AC
237echo "# Automatically generated by configure - do not modify" > $config_host_mak
238printf "# Configured with:" >> $config_host_mak
239printf " '%s'" "$0" "$@" >> $config_host_mak
240echo >> $config_host_mak
241echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
242
61054f0d
JA
243if test "$no_shm" = "yes" ; then
244 output_sym "CONFIG_NO_SHM"
245fi
246
247if test "$disable_opt" = "yes" ; then
248 output_sym "CONFIG_FIO_NO_OPT"
249fi
250
67bf9823
JA
251# Some host OSes need non-standard checks for which CPU to use.
252# Note that these checks are broken for cross-compilation: if you're
253# cross-compiling to one of these OSes then you'll need to specify
254# the correct CPU with the --cpu option.
255case $targetos in
de26b824
JA
256AIX)
257 # Unless explicitly enabled, turn off lex.
258 if test -z "$disable_lex" ; then
259 disable_lex="yes"
daf705b5
JA
260 else
261 force_no_lex_o="yes"
de26b824
JA
262 fi
263 ;;
67bf9823
JA
264Darwin)
265 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
266 # we can run 64-bit userspace code.
267 # If the user didn't specify a CPU explicitly and the kernel says this is
268 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
269 # detection code.
270 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
271 cpu="x86_64"
272 fi
273 ;;
274SunOS)
275 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
276 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
277 cpu="x86_64"
278 fi
adaa46d8 279 LIBS="-lnsl -lsocket"
cfd94f79
JA
280 ;;
281CYGWIN*)
282 echo "Forcing known good options on Windows"
4578d01f 283 if test -z "$CC" ; then
7409711b
HL
284 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
285 CC="i686-w64-mingw32-gcc"
286 else
287 CC="x86_64-w64-mingw32-gcc"
288 fi
4578d01f 289 fi
4feafb1e 290 output_sym "CONFIG_LITTLE_ENDIAN"
7409711b
HL
291 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
292 output_sym "CONFIG_32BIT"
293 else
294 output_sym "CONFIG_64BIT_LLP64"
295 fi
4feafb1e
JA
296 output_sym "CONFIG_FADVISE"
297 output_sym "CONFIG_SOCKLEN_T"
4feafb1e
JA
298 output_sym "CONFIG_FADVISE"
299 output_sym "CONFIG_SFAA"
300 output_sym "CONFIG_RUSAGE_THREAD"
301 output_sym "CONFIG_WINDOWSAIO"
302 output_sym "CONFIG_FDATASYNC"
59308a64 303 output_sym "CONFIG_CLOCK_MONOTONIC"
dc0518ca
BC
304 output_sym "CONFIG_GETTIMEOFDAY"
305 output_sym "CONFIG_CLOCK_GETTIME"
7e09a9f1 306 output_sym "CONFIG_SCHED_IDLE"
1eafa37a 307 output_sym "CONFIG_TCP_NODELAY"
7d6be13a 308 output_sym "CONFIG_TLS_THREAD"
ef07baa1 309 output_sym "CONFIG_IPV6"
4feafb1e 310 echo "CC=$CC" >> $config_host_mak
af4862b3 311 echo "BUILD_CFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
cfd94f79 312 exit 0
6d0e9f83 313 ;;
67bf9823
JA
314esac
315
316if test ! -z "$cpu" ; then
317 # command line argument
318 :
319elif check_define __i386__ ; then
320 cpu="i386"
321elif check_define __x86_64__ ; then
322 cpu="x86_64"
323elif check_define __sparc__ ; then
324 if check_define __arch64__ ; then
325 cpu="sparc64"
326 else
327 cpu="sparc"
328 fi
329elif check_define _ARCH_PPC ; then
330 if check_define _ARCH_PPC64 ; then
331 cpu="ppc64"
332 else
333 cpu="ppc"
334 fi
335elif check_define __mips__ ; then
336 cpu="mips"
337elif check_define __ia64__ ; then
338 cpu="ia64"
339elif check_define __s390__ ; then
340 if check_define __s390x__ ; then
341 cpu="s390x"
342 else
343 cpu="s390"
344 fi
345elif check_define __arm__ ; then
346 cpu="arm"
347elif check_define __hppa__ ; then
348 cpu="hppa"
349else
350 cpu=`uname -m`
351fi
352
353# Normalise host CPU name and set ARCH.
354case "$cpu" in
355 ia64|ppc|ppc64|s390|s390x|sparc64)
356 cpu="$cpu"
357 ;;
358 i386|i486|i586|i686|i86pc|BePC)
359 cpu="i386"
360 ;;
361 x86_64|amd64)
362 cpu="x86_64"
363 ;;
364 armv*b|armv*l|arm)
365 cpu="arm"
366 ;;
367 hppa|parisc|parisc64)
368 cpu="hppa"
369 ;;
370 mips*)
371 cpu="mips"
372 ;;
373 sparc|sun4[cdmuv])
374 cpu="sparc"
375 ;;
376 *)
8b156d8e 377 echo "Unknown CPU"
67bf9823
JA
378 ;;
379esac
380
dcbbf5b0 381if test -z "$CC" ; then
67bf9823
JA
382 if test "$targetos" = "FreeBSD"; then
383 if has clang; then
384 CC=clang
385 else
386 CC=gcc
387 fi
67bf9823
JA
388 fi
389fi
390
391cc="${CC-${cross_prefix}gcc}"
392
1a17cfdb
AC
393##########################################
394# check cross compile
395
396cross_compile="no"
397cat > $TMPC <<EOF
398int main(void)
399{
400 return 0;
401}
402EOF
403if compile_prog "" "" "cross"; then
404 $TMPE 2>/dev/null || cross_compile="yes"
405else
406 fatal "compile test failed"
407fi
408
0dcebdf4
JA
409##########################################
410# check endianness
411bigendian="no"
1a17cfdb
AC
412if test "$cross_compile" = "no" ; then
413 cat > $TMPC <<EOF
0dcebdf4
JA
414#include <inttypes.h>
415int main(void)
416{
417 volatile uint32_t i=0x01234567;
418 return (*((uint8_t*)(&i))) == 0x67;
419}
420EOF
1a17cfdb
AC
421 if compile_prog "" "" "endian"; then
422 $TMPE && bigendian="yes"
423 fi
424else
425 # If we're cross compiling, try our best to work it out and rely on the
426 # run-time check to fail if we get it wrong.
427 cat > $TMPC <<EOF
428#include <endian.h>
429int main(void)
430{
431#if __BYTE_ORDER != __BIG_ENDIAN
432# error "Unknown endianness"
433#endif
434}
435EOF
436 compile_prog "" "" "endian" && bigendian="yes"
437 check_define "__ARMEB__" && bigendian="yes"
438 check_define "__MIPSEB__" && bigendian="yes"
0dcebdf4
JA
439fi
440
441
67bf9823
JA
442echo "Operating system $targetos"
443echo "CPU $cpu"
0dcebdf4 444echo "Big endian $bigendian"
67bf9823 445echo "Compiler $cc"
1a17cfdb 446echo "Cross compile $cross_compile"
67bf9823
JA
447echo
448
d2aeedb9
JA
449##########################################
450# See if we need to build a static build
451if test "$build_static" = "yes" ; then
452 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
453 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
454else
455 build_static="no"
456fi
457echo "Static build $build_static"
458
67bf9823
JA
459##########################################
460# check for wordsize
461wordsize="0"
462cat > $TMPC <<EOF
142429e5
AC
463#include <limits.h>
464#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
67bf9823
JA
465int main(void)
466{
142429e5 467 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
67bf9823
JA
468 return 0;
469}
470EOF
142429e5
AC
471if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
472 wordsize="32"
473elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
474 wordsize="64"
475else
476 fatal "Unknown wordsize"
67bf9823
JA
477fi
478echo "Wordsize $wordsize"
479
a9bca4aa
JA
480##########################################
481# zlib probe
482zlib="no"
483cat > $TMPC <<EOF
804a1e05 484#include <zlib.h>
a9bca4aa
JA
485int main(void)
486{
487 z_stream stream;
488 if (inflateInit(&stream) != Z_OK)
489 return 1;
490 return 0;
491}
492EOF
493if compile_prog "" "-lz" "zlib" ; then
494 zlib=yes
495 LIBS="-lz $LIBS"
a9bca4aa
JA
496fi
497echo "zlib $zlib"
498
67bf9823
JA
499##########################################
500# linux-aio probe
501libaio="no"
7c77ebef 502if test "$esx" != "yes" ; then
503 cat > $TMPC <<EOF
67bf9823
JA
504#include <libaio.h>
505#include <stddef.h>
506int main(void)
507{
508 io_setup(0, NULL);
509 return 0;
510}
511EOF
7c77ebef 512 if compile_prog "" "-laio" "libaio" ; then
513 libaio=yes
514 LIBS="-laio $LIBS"
515 else
516 if test "$libaio" = "yes" ; then
517 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
518 fi
519 libaio=no
67bf9823 520 fi
67bf9823
JA
521fi
522echo "Linux AIO support $libaio"
523
524##########################################
525# posix aio probe
526posix_aio="no"
527posix_aio_lrt="no"
528cat > $TMPC <<EOF
529#include <aio.h>
530int main(void)
531{
532 struct aiocb cb;
533 aio_read(&cb);
534 return 0;
535}
536EOF
537if compile_prog "" "" "posixaio" ; then
538 posix_aio="yes"
539elif compile_prog "" "-lrt" "posixaio"; then
540 posix_aio="yes"
541 posix_aio_lrt="yes"
542 LIBS="-lrt $LIBS"
543fi
544echo "POSIX AIO support $posix_aio"
545echo "POSIX AIO support needs -lrt $posix_aio_lrt"
546
547##########################################
548# posix aio fsync probe
549posix_aio_fsync="no"
550if test "$posix_aio" = "yes" ; then
551 cat > $TMPC <<EOF
552#include <fcntl.h>
553#include <aio.h>
554int main(void)
555{
556 struct aiocb cb;
557 return aio_fsync(O_SYNC, &cb);
558 return 0;
559}
560EOF
561 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
562 posix_aio_fsync=yes
563 fi
564fi
565echo "POSIX AIO fsync $posix_aio_fsync"
566
567##########################################
568# solaris aio probe
569solaris_aio="no"
570cat > $TMPC <<EOF
571#include <sys/types.h>
572#include <sys/asynch.h>
573#include <unistd.h>
574int main(void)
575{
576 aio_result_t res;
577 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
578 return 0;
579}
580EOF
581if compile_prog "" "-laio" "solarisaio" ; then
582 solaris_aio=yes
583 LIBS="-laio $LIBS"
584fi
585echo "Solaris AIO support $solaris_aio"
586
587##########################################
f5cd2907 588# __sync_fetch_and_add test
67bf9823
JA
589sfaa="no"
590cat > $TMPC << EOF
958886d8
JA
591#include <inttypes.h>
592static int sfaa(uint64_t *ptr)
67bf9823 593{
9c639a76 594 return __sync_fetch_and_add(ptr, 0);
67bf9823
JA
595}
596
597int main(int argc, char **argv)
598{
958886d8 599 uint64_t val = 42;
67bf9823
JA
600 sfaa(&val);
601 return val;
602}
603EOF
604if compile_prog "" "" "__sync_fetch_and_add()" ; then
605 sfaa="yes"
606fi
9c639a76 607echo "__sync_fetch_and_add $sfaa"
67bf9823
JA
608
609##########################################
610# libverbs probe
611libverbs="no"
612cat > $TMPC << EOF
613#include <stdio.h>
614#include <infiniband/arch.h>
615int main(int argc, char **argv)
616{
617 struct ibv_pd *pd = ibv_alloc_pd(NULL);
618 return 0;
619}
620EOF
621if compile_prog "" "-libverbs" "libverbs" ; then
622 libverbs="yes"
623 LIBS="-libverbs $LIBS"
624fi
625echo "libverbs $libverbs"
626
627##########################################
628# rdmacm probe
629rdmacm="no"
630cat > $TMPC << EOF
631#include <stdio.h>
632#include <rdma/rdma_cma.h>
633int main(int argc, char **argv)
634{
635 rdma_destroy_qp(NULL);
636 return 0;
637}
638EOF
639if compile_prog "" "-lrdmacm" "rdma"; then
640 rdmacm="yes"
641 LIBS="-lrdmacm $LIBS"
642fi
643echo "rdmacm $rdmacm"
644
645##########################################
646# Linux fallocate probe
647linux_fallocate="no"
648cat > $TMPC << EOF
649#include <stdio.h>
aa6738a5 650#include <fcntl.h>
67bf9823
JA
651#include <linux/falloc.h>
652int main(int argc, char **argv)
653{
654 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
655 return r;
656}
657EOF
658if compile_prog "" "" "linux_fallocate"; then
659 linux_fallocate="yes"
660fi
661echo "Linux fallocate $linux_fallocate"
662
663##########################################
664# POSIX fadvise probe
665posix_fadvise="no"
666cat > $TMPC << EOF
667#include <stdio.h>
668#include <fcntl.h>
669int main(int argc, char **argv)
670{
671 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
672 return r;
673}
674EOF
675if compile_prog "" "" "posix_fadvise"; then
676 posix_fadvise="yes"
677fi
678echo "POSIX fadvise $posix_fadvise"
679
680##########################################
681# POSIX fallocate probe
682posix_fallocate="no"
683cat > $TMPC << EOF
684#include <stdio.h>
685#include <fcntl.h>
686int main(int argc, char **argv)
687{
688 int r = posix_fallocate(0, 0, 1024);
689 return r;
690}
691EOF
692if compile_prog "" "" "posix_fallocate"; then
693 posix_fallocate="yes"
694fi
695echo "POSIX fallocate $posix_fallocate"
696
697##########################################
698# sched_set/getaffinity 2 or 3 argument test
699linux_2arg_affinity="no"
700linux_3arg_affinity="no"
701cat > $TMPC << EOF
67bf9823
JA
702#include <sched.h>
703int main(int argc, char **argv)
704{
705 cpu_set_t mask;
706 return sched_setaffinity(0, sizeof(mask), &mask);
707}
708EOF
709if compile_prog "" "" "sched_setaffinity(,,)"; then
710 linux_3arg_affinity="yes"
711else
712 cat > $TMPC << EOF
67bf9823
JA
713#include <sched.h>
714int main(int argc, char **argv)
715{
716 cpu_set_t mask;
717 return sched_setaffinity(0, &mask);
718}
719EOF
720 if compile_prog "" "" "sched_setaffinity(,)"; then
721 linux_2arg_affinity="yes"
722 fi
723fi
724echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
725echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
726
727##########################################
728# clock_gettime probe
729clock_gettime="no"
730cat > $TMPC << EOF
731#include <stdio.h>
732#include <time.h>
733int main(int argc, char **argv)
734{
735 return clock_gettime(0, NULL);
736}
737EOF
738if compile_prog "" "" "clock_gettime"; then
739 clock_gettime="yes"
740elif compile_prog "" "-lrt" "clock_gettime"; then
741 clock_gettime="yes"
742 LIBS="-lrt $LIBS"
743fi
744echo "clock_gettime $clock_gettime"
745
746##########################################
747# CLOCK_MONOTONIC probe
748clock_monotonic="no"
749if test "$clock_gettime" = "yes" ; then
750 cat > $TMPC << EOF
751#include <stdio.h>
752#include <time.h>
753int main(int argc, char **argv)
754{
755 return clock_gettime(CLOCK_MONOTONIC, NULL);
756}
757EOF
758 if compile_prog "" "$LIBS" "clock monotonic"; then
759 clock_monotonic="yes"
760 fi
761fi
762echo "CLOCK_MONOTONIC $clock_monotonic"
763
c544f604
SN
764##########################################
765# CLOCK_MONOTONIC_RAW probe
766clock_monotonic_raw="no"
767if test "$clock_gettime" = "yes" ; then
768 cat > $TMPC << EOF
769#include <stdio.h>
770#include <time.h>
771int main(int argc, char **argv)
772{
773 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
774}
775EOF
776 if compile_prog "" "$LIBS" "clock monotonic"; then
777 clock_monotonic_raw="yes"
778 fi
779fi
780echo "CLOCK_MONOTONIC_RAW $clock_monotonic_raw"
781
67bf9823
JA
782##########################################
783# CLOCK_MONOTONIC_PRECISE probe
784clock_monotonic_precise="no"
785if test "$clock_gettime" = "yes" ; then
786 cat > $TMPC << EOF
787#include <stdio.h>
788#include <time.h>
789int main(int argc, char **argv)
790{
791 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
792}
793EOF
794 if compile_prog "" "$LIBS" "clock monotonic precise"; then
795 clock_monotonic_precise="yes"
796 fi
797fi
798echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
799
25f8227d
JA
800##########################################
801# clockid_t probe
802clockid_t="no"
803cat > $TMPC << EOF
804#include <stdio.h>
a214d131 805#include <string.h>
25f8227d
JA
806#include <time.h>
807int main(int argc, char **argv)
808{
a214d131
JA
809 clockid_t cid;
810 memset(&cid, 0, sizeof(cid));
25f8227d
JA
811 return clock_gettime(cid, NULL);
812}
813EOF
814if compile_prog "" "$LIBS" "clockid_t"; then
815 clockid_t="yes"
816fi
817echo "clockid_t $clockid_t"
818
67bf9823
JA
819##########################################
820# gettimeofday() probe
821gettimeofday="no"
822cat > $TMPC << EOF
823#include <sys/time.h>
824#include <stdio.h>
825int main(int argc, char **argv)
826{
827 struct timeval tv;
828 return gettimeofday(&tv, NULL);
829}
830EOF
831if compile_prog "" "" "gettimeofday"; then
832 gettimeofday="yes"
833fi
834echo "gettimeofday $gettimeofday"
835
836##########################################
837# fdatasync() probe
838fdatasync="no"
839cat > $TMPC << EOF
840#include <stdio.h>
841#include <unistd.h>
842int main(int argc, char **argv)
843{
844 return fdatasync(0);
845}
846EOF
847if compile_prog "" "" "fdatasync"; then
848 fdatasync="yes"
849fi
850echo "fdatasync $fdatasync"
851
852##########################################
853# sync_file_range() probe
854sync_file_range="no"
855cat > $TMPC << EOF
856#include <stdio.h>
857#include <unistd.h>
67bf9823
JA
858#include <fcntl.h>
859#include <linux/fs.h>
860int main(int argc, char **argv)
861{
862 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
863 SYNC_FILE_RANGE_WAIT_AFTER;
864 return sync_file_range(0, 0, 0, flags);
865}
866EOF
867if compile_prog "" "" "sync_file_range"; then
868 sync_file_range="yes"
869fi
870echo "sync_file_range $sync_file_range"
871
872##########################################
873# ext4 move extent probe
874ext4_me="no"
875cat > $TMPC << EOF
876#include <fcntl.h>
877#include <sys/ioctl.h>
878int main(int argc, char **argv)
879{
880 struct move_extent me;
881 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
882}
883EOF
c7165b8d
JA
884if compile_prog "" "" "ext4 move extent" ; then
885 ext4_me="yes"
886elif test $targetos = "Linux" ; then
887 # On Linux, just default to it on and let it error at runtime if we really
888 # don't have it. None of my updated systems have it defined, but it does
889 # work. Takes a while to bubble back.
67bf9823
JA
890 ext4_me="yes"
891fi
892echo "EXT4 move extent $ext4_me"
893
894##########################################
895# splice probe
896linux_splice="no"
897cat > $TMPC << EOF
67bf9823
JA
898#include <stdio.h>
899#include <fcntl.h>
900int main(int argc, char **argv)
901{
902 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
903}
904EOF
905if compile_prog "" "" "linux splice"; then
906 linux_splice="yes"
907fi
908echo "Linux splice(2) $linux_splice"
909
910##########################################
911# GUASI probe
912guasi="no"
913cat > $TMPC << EOF
914#include <guasi.h>
915#include <guasi_syscalls.h>
916int main(int argc, char **argv)
917{
918 guasi_t ctx = guasi_create(0, 0, 0);
919 return 0;
920}
921EOF
922if compile_prog "" "" "guasi"; then
923 guasi="yes"
924fi
925echo "GUASI $guasi"
926
927##########################################
928# fusion-aw probe
929fusion_aw="no"
930cat > $TMPC << EOF
b2c77c25 931#include <nvm/nvm_primitives.h>
67bf9823
JA
932int main(int argc, char **argv)
933{
b2c77c25
SK
934 nvm_version_t ver_info;
935 nvm_handle_t handle;
936
937 handle = nvm_get_handle(0, &ver_info);
938 return nvm_atomic_write(handle, 0, 0, 0);
67bf9823
JA
939}
940EOF
92aef550
ARJ
941if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
942 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
67bf9823
JA
943 fusion_aw="yes"
944fi
945echo "Fusion-io atomic engine $fusion_aw"
946
947##########################################
948# libnuma probe
949libnuma="no"
950cat > $TMPC << EOF
951#include <numa.h>
952int main(int argc, char **argv)
953{
954 return numa_available();
955}
956EOF
44462517 957if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
67bf9823
JA
958 libnuma="yes"
959 LIBS="-lnuma $LIBS"
960fi
961echo "libnuma $libnuma"
962
50206d9b
JA
963##########################################
964# libnuma 2.x version API
965if test "$libnuma" = "yes" ; then
966libnuma_v2="no"
967cat > $TMPC << EOF
968#include <numa.h>
969int main(int argc, char **argv)
970{
971 struct bitmask *mask = numa_parse_nodestring(NULL);
61bde962 972 return mask->size == 0;
50206d9b
JA
973}
974EOF
975if compile_prog "" "" "libnuma api"; then
976 libnuma_v2="yes"
977fi
978echo "libnuma v2 $libnuma_v2"
979fi
980
67bf9823
JA
981##########################################
982# strsep() probe
983strsep="no"
984cat > $TMPC << EOF
985#include <string.h>
986int main(int argc, char **argv)
987{
ae156be6
JA
988 static char *string = "This is a string";
989 strsep(&string, "needle");
67bf9823
JA
990 return 0;
991}
992EOF
993if compile_prog "" "" "strsep"; then
994 strsep="yes"
995fi
996echo "strsep $strsep"
997
9ad8da82
JA
998##########################################
999# strcasestr() probe
1000strcasestr="no"
1001cat > $TMPC << EOF
1002#include <string.h>
1003int main(int argc, char **argv)
1004{
aa6738a5 1005 return strcasestr(argv[0], argv[1]) != NULL;
9ad8da82
JA
1006}
1007EOF
1008if compile_prog "" "" "strcasestr"; then
1009 strcasestr="yes"
1010fi
1011echo "strcasestr $strcasestr"
1012
5ad7be56
KD
1013##########################################
1014# strlcat() probe
1015strlcat="no"
1016cat > $TMPC << EOF
1017#include <string.h>
1018int main(int argc, char **argv)
1019{
1020 static char dst[64];
1021 static char *string = "This is a string";
1022 memset(dst, 0, sizeof(dst));
1023 strlcat(dst, string, sizeof(dst));
1024 return 0;
1025}
1026EOF
1027if compile_prog "" "" "strlcat"; then
1028 strlcat="yes"
1029fi
1030echo "strlcat $strlcat"
1031
67bf9823
JA
1032##########################################
1033# getopt_long_only() probe
1034getopt_long_only="no"
1035cat > $TMPC << EOF
1036#include <unistd.h>
1037#include <stdio.h>
aa6738a5 1038#include <getopt.h>
67bf9823
JA
1039int main(int argc, char **argv)
1040{
1041 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1042 return c;
1043}
1044EOF
1045if compile_prog "" "" "getopt_long_only"; then
1046 getopt_long_only="yes"
1047fi
1048echo "getopt_long_only() $getopt_long_only"
1049
1050##########################################
1051# inet_aton() probe
1052inet_aton="no"
1053cat > $TMPC << EOF
1054#include <sys/socket.h>
1055#include <arpa/inet.h>
1056#include <stdio.h>
1057int main(int argc, char **argv)
1058{
1059 struct in_addr in;
1060 return inet_aton(NULL, &in);
1061}
1062EOF
1063if compile_prog "" "" "inet_aton"; then
1064 inet_aton="yes"
1065fi
1066echo "inet_aton $inet_aton"
1067
1068##########################################
1069# socklen_t probe
1070socklen_t="no"
1071cat > $TMPC << EOF
f6482613 1072#include <sys/socket.h>
67bf9823
JA
1073int main(int argc, char **argv)
1074{
1075 socklen_t len = 0;
1076 return len;
1077}
1078EOF
1079if compile_prog "" "" "socklen_t"; then
1080 socklen_t="yes"
1081fi
1082echo "socklen_t $socklen_t"
1083
1084##########################################
1085# Whether or not __thread is supported for TLS
1086tls_thread="no"
1087cat > $TMPC << EOF
1088#include <stdio.h>
aa6738a5 1089static __thread int ret;
67bf9823
JA
1090int main(int argc, char **argv)
1091{
1092 return ret;
1093}
1094EOF
1095if compile_prog "" "" "__thread"; then
1096 tls_thread="yes"
1097fi
1098echo "__thread $tls_thread"
1099
91f94d5b 1100##########################################
2639f056 1101# Check if we have required gtk/glib support for gfio
ebec2094
JA
1102gfio="no"
1103if test "$gfio_check" = "yes" ; then
91f94d5b
JA
1104 cat > $TMPC << EOF
1105#include <glib.h>
1106#include <cairo.h>
1107#include <gtk/gtk.h>
1108int main(void)
1109{
1110 gdk_threads_enter();
91f94d5b 1111 gdk_threads_leave();
b7a99316
JA
1112
1113 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
91f94d5b
JA
1114}
1115EOF
1116GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
86719845
JA
1117ORG_LDFLAGS=$LDFLAGS
1118LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
91f94d5b
JA
1119if test "$?" != "0" ; then
1120 echo "configure: gtk and gthread not found"
1121 exit 1
1122fi
1123GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1124if test "$?" != "0" ; then
1125 echo "configure: gtk and gthread not found"
1126 exit 1
1127fi
b7a99316
JA
1128if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1129 r=$($TMPE)
1130 if test "$r" != "0" ; then
1131 gfio="yes"
86719845 1132 GFIO_LIBS="$LIBS $GTK_LIBS"
b7a99316
JA
1133 CFLAGS="$CFLAGS $GTK_CFLAGS"
1134 else
1135 echo "GTK found, but need version 2.18 or higher"
1136 gfio="no"
1137 fi
91f94d5b
JA
1138else
1139 echo "Please install gtk and gdk libraries"
1140 gfio="no"
1141fi
86719845 1142LDFLAGS=$ORG_LDFLAGS
91f94d5b
JA
1143fi
1144
ebec2094
JA
1145if test "$gfio_check" = "yes" ; then
1146 echo "gtk 2.18 or higher $gfio"
1147fi
91f94d5b 1148
44404c5a
JA
1149# Check whether we have getrusage(RUSAGE_THREAD)
1150rusage_thread="no"
1151cat > $TMPC << EOF
1152#include <sys/time.h>
1153#include <sys/resource.h>
1154int main(int argc, char **argv)
1155{
1156 struct rusage ru;
1157 getrusage(RUSAGE_THREAD, &ru);
1158 return 0;
1159}
1160EOF
1161if compile_prog "" "" "RUSAGE_THREAD"; then
1162 rusage_thread="yes"
1163fi
1164echo "RUSAGE_THREAD $rusage_thread"
1165
7e09a9f1
JA
1166##########################################
1167# Check whether we have SCHED_IDLE
1168sched_idle="no"
1169cat > $TMPC << EOF
1170#include <sched.h>
1171int main(int argc, char **argv)
1172{
1173 struct sched_param p;
1174 return sched_setscheduler(0, SCHED_IDLE, &p);
1175}
1176EOF
1177if compile_prog "" "" "SCHED_IDLE"; then
1178 sched_idle="yes"
1179fi
1180echo "SCHED_IDLE $sched_idle"
1181
1eafa37a
JA
1182##########################################
1183# Check whether we have TCP_NODELAY
1184tcp_nodelay="no"
1185cat > $TMPC << EOF
1186#include <stdio.h>
1187#include <sys/types.h>
1188#include <sys/socket.h>
1189#include <netinet/tcp.h>
1190int main(int argc, char **argv)
1191{
1192 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1193}
1194EOF
1195if compile_prog "" "" "TCP_NODELAY"; then
1196 tcp_nodelay="yes"
1197fi
1198echo "TCP_NODELAY $tcp_nodelay"
1199
1008602c
JA
1200##########################################
1201# Check whether we have SO_SNDBUF
1202window_size="no"
1203cat > $TMPC << EOF
1204#include <stdio.h>
1205#include <sys/types.h>
1206#include <sys/socket.h>
1207#include <netinet/tcp.h>
1208int main(int argc, char **argv)
1209{
1210 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1211 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1212}
1213EOF
1214if compile_prog "" "" "SO_SNDBUF"; then
1215 window_size="yes"
1216fi
1217echo "Net engine window_size $window_size"
1218
e5f34d95
JA
1219##########################################
1220# Check whether we have TCP_MAXSEG
1221mss="no"
1222cat > $TMPC << EOF
1223#include <stdio.h>
1224#include <sys/types.h>
1225#include <sys/socket.h>
1226#include <netinet/tcp.h>
1227#include <arpa/inet.h>
1228#include <netinet/in.h>
1229int main(int argc, char **argv)
1230{
1231 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1232}
1233EOF
1234if compile_prog "" "" "TCP_MAXSEG"; then
1235 mss="yes"
1236fi
1237echo "TCP_MAXSEG $mss"
1238
38b9354a
JA
1239##########################################
1240# Check whether we have RLIMIT_MEMLOCK
1241rlimit_memlock="no"
1242cat > $TMPC << EOF
1243#include <sys/time.h>
1244#include <sys/resource.h>
1245int main(int argc, char **argv)
1246{
1247 struct rlimit rl;
1248 return getrlimit(RLIMIT_MEMLOCK, &rl);
1249}
1250EOF
1251if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1252 rlimit_memlock="yes"
1253fi
1254echo "RLIMIT_MEMLOCK $rlimit_memlock"
1255
07fc0acd
JA
1256##########################################
1257# Check whether we have pwritev/preadv
1258pwritev="no"
1259cat > $TMPC << EOF
1260#include <stdio.h>
1261#include <sys/uio.h>
1262int main(int argc, char **argv)
1263{
1264 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1265}
1266EOF
1267if compile_prog "" "" "pwritev"; then
1268 pwritev="yes"
1269fi
1270echo "pwritev/preadv $pwritev"
1271
2cafffbe
JA
1272##########################################
1273# Check whether we have pwritev2/preadv2
1274pwritev2="no"
1275cat > $TMPC << EOF
1276#include <stdio.h>
1277#include <sys/uio.h>
1278int main(int argc, char **argv)
1279{
1280 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1281}
1282EOF
1283if compile_prog "" "" "pwritev2"; then
1284 pwritev2="yes"
1285fi
1286echo "pwritev2/preadv2 $pwritev2"
1287
ecad55e9
JA
1288##########################################
1289# Check whether we have the required functions for ipv6
1290ipv6="no"
1291cat > $TMPC << EOF
1292#include <sys/types.h>
1293#include <sys/socket.h>
d219028d 1294#include <netinet/in.h>
ecad55e9
JA
1295#include <netdb.h>
1296#include <stdio.h>
1297int main(int argc, char **argv)
1298{
1299 struct addrinfo hints;
1300 struct in6_addr addr;
1301 int ret;
1302
1303 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1304 freeaddrinfo(NULL);
1305 printf("%s\n", gai_strerror(ret));
1306 addr = in6addr_any;
1307 return 0;
1308}
1309EOF
1310if compile_prog "" "" "ipv6"; then
1311 ipv6="yes"
1312fi
1313echo "IPv6 helpers $ipv6"
07fc0acd 1314
fc5c0345
DG
1315##########################################
1316# check for rbd
1317rbd="no"
1318cat > $TMPC << EOF
1319#include <rbd/librbd.h>
1320
1321int main(int argc, char **argv)
1322{
1323
1324 rados_t cluster;
1325 rados_ioctx_t io_ctx;
1326 const char pool[] = "rbd";
1327
1328 int major, minor, extra;
1329 rbd_version(&major, &minor, &extra);
1330
1331 rados_ioctx_create(cluster, pool, &io_ctx);
1332 return 0;
1333}
1334EOF
ce18290e 1335if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
fc5c0345
DG
1336 LIBS="-lrbd -lrados $LIBS"
1337 rbd="yes"
1338fi
1339echo "Rados Block Device engine $rbd"
1340
53b6c979
PL
1341##########################################
1342# check for rbd_poll
1343rbd_poll="no"
1344if test "$rbd" = "yes"; then
1345cat > $TMPC << EOF
1346#include <rbd/librbd.h>
1347#include <sys/eventfd.h>
1348
1349int main(int argc, char **argv)
1350{
1351 rbd_image_t image;
1352 rbd_completion_t comp;
1353
1354 int fd = eventfd(0, EFD_NONBLOCK);
1355 rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1356 rbd_poll_io_events(image, comp, 1);
1357
1358 return 0;
1359}
1360EOF
1361if compile_prog "" "-lrbd -lrados" "rbd"; then
1362 rbd_poll="yes"
1363fi
1364echo "rbd_poll $rbd_poll"
1365fi
1366
903b2812
JA
1367##########################################
1368# check for rbd_invaidate_cache()
1369rbd_inval="no"
1370if test "$rbd" = "yes"; then
1371cat > $TMPC << EOF
1372#include <rbd/librbd.h>
1373
1374int main(int argc, char **argv)
1375{
1376 rbd_image_t image;
1377
1378 return rbd_invalidate_cache(image);
1379}
1380EOF
1381if compile_prog "" "-lrbd -lrados" "rbd"; then
1382 rbd_inval="yes"
1383fi
1384echo "rbd_invalidate_cache $rbd_inval"
1385fi
1386
a4c4c346 1387##########################################
1388# check for blkin
1389rbd_blkin="no"
1390cat > $TMPC << EOF
1391#include <rbd/librbd.h>
1392#include <zipkin_c.h>
1393
1394int main(int argc, char **argv)
1395{
1396 int r;
1397 struct blkin_trace_info t_info;
1398 blkin_init_trace_info(&t_info);
1399 rbd_completion_t completion;
1400 rbd_image_t image;
1401 uint64_t off;
1402 size_t len;
1403 const char *buf;
1404 r = rbd_aio_write_traced(image, off, len, buf, completion, &t_info);
1405 return 0;
1406}
1407EOF
1408if test "$disable_rbd" != "yes" && test "$disable_rbd_blkin" != "yes" \
1409 && compile_prog "" "-lrbd -lrados -lblkin" "rbd_blkin"; then
1410 LIBS="-lblkin $LIBS"
1411 rbd_blkin="yes"
1412fi
1413echo "rbd blkin tracing $rbd_blkin"
1414
2e802282
JA
1415##########################################
1416# Check whether we have setvbuf
1417setvbuf="no"
1418cat > $TMPC << EOF
1419#include <stdio.h>
1420int main(int argc, char **argv)
1421{
1422 FILE *f = NULL;
1423 char buf[80];
1424 setvbuf(f, buf, _IOFBF, sizeof(buf));
1425 return 0;
1426}
1427EOF
1428if compile_prog "" "" "setvbuf"; then
1429 setvbuf="yes"
1430fi
1431echo "setvbuf $setvbuf"
fc5c0345 1432
6e7d7dfb 1433# check for gfapi
1434gfapi="no"
1435cat > $TMPC << EOF
1436#include <glusterfs/api/glfs.h>
1437
1438int main(int argc, char **argv)
1439{
1440
1441 glfs_t *g = glfs_new("foo");
1442
1443 return 0;
1444}
1445EOF
ce18290e 1446if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
6e7d7dfb 1447 LIBS="-lgfapi -lglusterfs $LIBS"
1448 gfapi="yes"
1449fi
6fa14b99 1450 echo "Gluster API engine $gfapi"
6e7d7dfb 1451
6fa14b99 1452##########################################
1453# check for gfapi fadvise support
6876c98c 1454if test "$gfapi" = "yes" ; then
6fa14b99 1455gf_fadvise="no"
1456cat > $TMPC << EOF
1457#include <glusterfs/api/glfs.h>
1458
1459int main(int argc, char **argv)
1460{
1461 struct glfs_fd *fd;
1462 int ret = glfs_fadvise(fd, 0, 0, 1);
1463
1464 return 0;
1465}
1466EOF
6fa14b99 1467if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1468 gf_fadvise="yes"
1469fi
1470echo "Gluster API use fadvise $gf_fadvise"
6876c98c
JA
1471fi
1472
1473##########################################
1474# check for gfapi trim support
1475gf_trim="no"
1476if test "$gfapi" = "yes" ; then
1477cat > $TMPC << EOF
1478#include <glusterfs/api/glfs.h>
1479
1480int main(int argc, char **argv)
1481{
1482 return glfs_discard_async(NULL, 0, 0);
1483}
1484EOF
1485if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1486 gf_trim="yes"
1487fi
1488echo "Gluster API trim support $gf_trim"
1489fi
fc5c0345 1490
81795ce3
CE
1491##########################################
1492# Check if we support stckf on s390
1493s390_z196_facilities="no"
1494cat > $TMPC << EOF
1495#define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1496int main(int argc, char **argv)
1497{
1498 /* We want just 1 double word to be returned. */
1499 register unsigned long reg0 asm("0") = 0;
1500 unsigned long stfle_bits;
1501 asm volatile(".machine push" "\n\t"
1502 ".machine \"z9-109\"" "\n\t"
1503 "stfle %0" "\n\t"
1504 ".machine pop" "\n"
1505 : "=QS" (stfle_bits), "+d" (reg0)
1506 : : "cc");
1507
1508 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1509 return 0;
1510 else
1511 return -1;
1512}
1513EOF
1514if compile_prog "" "" "s390_z196_facilities"; then
1515 $TMPE
1516 if [[ $? -eq 0 ]]; then
1517 s390_z196_facilities="yes"
1518 fi
1519fi
1520echo "s390_z196_facilities $s390_z196_facilities"
1b10477b
MM
1521
1522##########################################
1523# Check if we have required environment variables configured for libhdfs
1524if test "$libhdfs" = "yes" ; then
1525 hdfs_conf_error=0
1526 if test "$JAVA_HOME" = "" ; then
1527 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1528 hdfs_conf_error=1
1529 fi
1530 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1531 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1532 hdfs_conf_error=1
1533 fi
1534 if test "$FIO_LIBHDFS_LIB" = "" ; then
1535 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1536 hdfs_conf_error=1
1537 fi
1538 if test "$hdfs_conf_error" = "1" ; then
1539 exit 1
1540 fi
247e5436
JA
1541 FIO_HDFS_CPU=$cpu
1542 if test "$FIO_HDFS_CPU" = "x86_64" ; then
1543 FIO_HDFS_CPU="amd64"
1544 fi
1b10477b
MM
1545fi
1546echo "HDFS engine $libhdfs"
1547
b8116a87
DE
1548##########################################
1549# Check whether we have MTD
1550mtd="no"
1551cat > $TMPC << EOF
0e1c454a 1552#include <string.h>
b8116a87
DE
1553#include <mtd/mtd-user.h>
1554#include <sys/ioctl.h>
1555int main(int argc, char **argv)
1556{
0e1c454a 1557 struct mtd_write_req ops;
b8116a87 1558 struct mtd_info_user info;
0e1c454a 1559 memset(&ops, 0, sizeof(ops));
400cd0ff 1560 info.type = MTD_MLCNANDFLASH;
b8116a87
DE
1561 return ioctl(0, MEMGETINFO, &info);
1562}
1563EOF
1564if compile_prog "" "" "mtd"; then
1565 mtd="yes"
1566fi
1567echo "MTD $mtd"
1568
43f3cec2
BB
1569##########################################
1570# Report whether pmemblk engine is enabled
1571echo "NVML libpmemblk engine $pmemblk"
1572
cbb15e42
DJ
1573##########################################
1574# Report whether dev-dax engine is enabled
1575echo "NVM Device Dax engine $devdax"
1576
b470a02c
SC
1577# Check if we have lex/yacc available
1578yacc="no"
e7b2c7a3 1579yacc_is_bison="no"
b470a02c
SC
1580lex="no"
1581arith="no"
de26b824 1582if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
cf6dd80e 1583if test "$targetos" != "SunOS" ; then
e7b2c7a3 1584LEX=$(which lex 2> /dev/null)
b470a02c
SC
1585if test -x "$LEX" ; then
1586 lex="yes"
1587fi
7e0049e9 1588YACC=$(which bison 2> /dev/null)
b470a02c
SC
1589if test -x "$YACC" ; then
1590 yacc="yes"
7e0049e9 1591 yacc_is_bison="yes"
e7b2c7a3 1592else
7e0049e9 1593 YACC=$(which yacc 2> /dev/null)
e7b2c7a3
JA
1594 if test -x "$YACC" ; then
1595 yacc="yes"
e7b2c7a3 1596 fi
b470a02c
SC
1597fi
1598if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1599 arith="yes"
1600fi
1601
1602if test "$arith" = "yes" ; then
1603cat > $TMPC << EOF
1604extern int yywrap(void);
1605
1606int main(int argc, char **argv)
1607{
1608 yywrap();
1609 return 0;
1610}
1611EOF
719cda03
JA
1612if compile_prog "" "-ll" "lex"; then
1613 LIBS="-ll $LIBS"
b470a02c
SC
1614else
1615 arith="no"
1616fi
1617fi
cf6dd80e 1618fi
a655bbc4 1619fi
b470a02c 1620
63bda378
JA
1621# Check if lex fails using -o
1622if test "$arith" = "yes" ; then
daf705b5
JA
1623if test "$force_no_lex_o" = "yes" ; then
1624 lex_use_o="no"
1625else
63bda378
JA
1626$LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1627if test "$?" = "0" ; then
1628 lex_use_o="yes"
1629else
1630 lex_use_o="no"
1631fi
1632fi
daf705b5 1633fi
63bda378 1634
b470a02c
SC
1635echo "lex/yacc for arithmetic $arith"
1636
aae599ba
JA
1637##########################################
1638# Check whether we have setmntent/getmntent
1639getmntent="no"
1640cat > $TMPC << EOF
1641#include <stdio.h>
1642#include <mntent.h>
1643int main(int argc, char **argv)
1644{
1645 FILE *mtab = setmntent(NULL, "r");
1646 struct mntent *mnt = getmntent(mtab);
1581b82a 1647 endmntent(mtab);
aae599ba
JA
1648 return 0;
1649}
1650EOF
1651if compile_prog "" "" "getmntent"; then
1652 getmntent="yes"
1653fi
1654echo "getmntent $getmntent"
1655
e7e136da
TK
1656##########################################
1657# Check whether we have getmntinfo
b765bec0
TK
1658# These are originally added for BSDs, but may also work
1659# on other operating systems with getmntinfo(3).
1660
1661# getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
1662# Note that NetBSD needs -Werror to catch warning as error.
e7e136da
TK
1663getmntinfo="no"
1664cat > $TMPC << EOF
1665#include <stdio.h>
1666#include <sys/param.h>
1667#include <sys/mount.h>
1668int main(int argc, char **argv)
1669{
9ada751d 1670 struct statfs *st;
e7e136da
TK
1671 return getmntinfo(&st, MNT_NOWAIT);
1672}
1673EOF
b765bec0 1674if compile_prog "-Werror" "" "getmntinfo"; then
e7e136da
TK
1675 getmntinfo="yes"
1676fi
1677echo "getmntinfo $getmntinfo"
1678
b765bec0
TK
1679# getmntinfo(3) for NetBSD.
1680getmntinfo_statvfs="no"
1681cat > $TMPC << EOF
1682#include <stdio.h>
1683#include <sys/statvfs.h>
1684int main(int argc, char **argv)
1685{
1686 struct statvfs *st;
1687 return getmntinfo(&st, MNT_NOWAIT);
1688}
1689EOF
1690# Skip the test if the one with statfs arg is detected.
1691if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
1692 getmntinfo_statvfs="yes"
1693 echo "getmntinfo_statvfs $getmntinfo_statvfs"
1694fi
1695
5018f79f
AH
1696##########################################
1697# Check whether we have _Static_assert
1698static_assert="no"
1699cat > $TMPC << EOF
1700#include <assert.h>
94815a5c
JA
1701#include <stdlib.h>
1702#undef offsetof
1703#ifdef __compiler_offsetof
1704#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
1705#else
1706#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1707#endif
1708
1709#define container_of(ptr, type, member) ({ \
1710 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
1711 (type *)( (char *)__mptr - offsetof(type,member) );})
1712
1713struct foo {
1714 int a, b;
1715};
1716
5018f79f
AH
1717int main(int argc, char **argv)
1718{
94815a5c 1719 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
5018f79f
AH
1720 return 0 ;
1721}
1722EOF
1723if compile_prog "" "" "static_assert"; then
1724 static_assert="yes"
1725fi
1726echo "Static Assert $static_assert"
e39c0676
JA
1727
1728##########################################
1729# Check whether we have bool / stdbool.h
1730have_bool="no"
1731cat > $TMPC << EOF
1732#include <stdbool.h>
1733int main(int argc, char **argv)
1734{
1735 bool var = true;
1736 return var != false;
1737}
1738EOF
1739if compile_prog "" "" "bool"; then
1740 have_bool="yes"
1741fi
1742echo "bool $have_bool"
1743
67bf9823
JA
1744#############################################################################
1745
67bf9823 1746if test "$wordsize" = "64" ; then
4feafb1e 1747 output_sym "CONFIG_64BIT"
67bf9823 1748elif test "$wordsize" = "32" ; then
4feafb1e 1749 output_sym "CONFIG_32BIT"
67bf9823 1750else
d7145a78 1751 fatal "Unknown wordsize!"
67bf9823 1752fi
0dcebdf4 1753if test "$bigendian" = "yes" ; then
4feafb1e 1754 output_sym "CONFIG_BIG_ENDIAN"
0dcebdf4 1755else
4feafb1e 1756 output_sym "CONFIG_LITTLE_ENDIAN"
0dcebdf4 1757fi
3989b143
JA
1758if test "$zlib" = "yes" ; then
1759 output_sym "CONFIG_ZLIB"
1760fi
67bf9823 1761if test "$libaio" = "yes" ; then
4feafb1e 1762 output_sym "CONFIG_LIBAIO"
67bf9823
JA
1763fi
1764if test "$posix_aio" = "yes" ; then
4feafb1e 1765 output_sym "CONFIG_POSIXAIO"
67bf9823
JA
1766fi
1767if test "$posix_aio_fsync" = "yes" ; then
4feafb1e 1768 output_sym "CONFIG_POSIXAIO_FSYNC"
67bf9823
JA
1769fi
1770if test "$linux_fallocate" = "yes" ; then
4feafb1e 1771 output_sym "CONFIG_LINUX_FALLOCATE"
67bf9823
JA
1772fi
1773if test "$posix_fallocate" = "yes" ; then
4feafb1e 1774 output_sym "CONFIG_POSIX_FALLOCATE"
67bf9823
JA
1775fi
1776if test "$fdatasync" = "yes" ; then
4feafb1e 1777 output_sym "CONFIG_FDATASYNC"
67bf9823
JA
1778fi
1779if test "$sync_file_range" = "yes" ; then
4feafb1e 1780 output_sym "CONFIG_SYNC_FILE_RANGE"
67bf9823
JA
1781fi
1782if test "$sfaa" = "yes" ; then
4feafb1e 1783 output_sym "CONFIG_SFAA"
67bf9823 1784fi
954cd73a 1785if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
4feafb1e 1786 output_sym "CONFIG_RDMA"
67bf9823
JA
1787fi
1788if test "$clock_gettime" = "yes" ; then
4feafb1e 1789 output_sym "CONFIG_CLOCK_GETTIME"
67bf9823
JA
1790fi
1791if test "$clock_monotonic" = "yes" ; then
4feafb1e 1792 output_sym "CONFIG_CLOCK_MONOTONIC"
67bf9823 1793fi
c544f604
SN
1794if test "$clock_monotonic_raw" = "yes" ; then
1795 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
1796fi
67bf9823 1797if test "$clock_monotonic_precise" = "yes" ; then
4feafb1e 1798 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
67bf9823 1799fi
25f8227d
JA
1800if test "$clockid_t" = "yes"; then
1801 output_sym "CONFIG_CLOCKID_T"
1802fi
67bf9823 1803if test "$gettimeofday" = "yes" ; then
4feafb1e 1804 output_sym "CONFIG_GETTIMEOFDAY"
67bf9823
JA
1805fi
1806if test "$posix_fadvise" = "yes" ; then
4feafb1e 1807 output_sym "CONFIG_POSIX_FADVISE"
67bf9823
JA
1808fi
1809if test "$linux_3arg_affinity" = "yes" ; then
4feafb1e 1810 output_sym "CONFIG_3ARG_AFFINITY"
67bf9823 1811elif test "$linux_2arg_affinity" = "yes" ; then
4feafb1e 1812 output_sym "CONFIG_2ARG_AFFINITY"
67bf9823
JA
1813fi
1814if test "$strsep" = "yes" ; then
4feafb1e 1815 output_sym "CONFIG_STRSEP"
67bf9823 1816fi
9ad8da82
JA
1817if test "$strcasestr" = "yes" ; then
1818 output_sym "CONFIG_STRCASESTR"
1819fi
5ad7be56
KD
1820if test "$strlcat" = "yes" ; then
1821 output_sym "CONFIG_STRLCAT"
1822fi
67bf9823 1823if test "$getopt_long_only" = "yes" ; then
4feafb1e 1824 output_sym "CONFIG_GETOPT_LONG_ONLY"
67bf9823
JA
1825fi
1826if test "$inet_aton" = "yes" ; then
4feafb1e 1827 output_sym "CONFIG_INET_ATON"
67bf9823
JA
1828fi
1829if test "$socklen_t" = "yes" ; then
4feafb1e 1830 output_sym "CONFIG_SOCKLEN_T"
67bf9823
JA
1831fi
1832if test "$ext4_me" = "yes" ; then
4feafb1e 1833 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
67bf9823
JA
1834fi
1835if test "$linux_splice" = "yes" ; then
4feafb1e 1836 output_sym "CONFIG_LINUX_SPLICE"
67bf9823
JA
1837fi
1838if test "$guasi" = "yes" ; then
4feafb1e 1839 output_sym "CONFIG_GUASI"
67bf9823
JA
1840fi
1841if test "$fusion_aw" = "yes" ; then
4feafb1e 1842 output_sym "CONFIG_FUSION_AW"
67bf9823 1843fi
50206d9b 1844if test "$libnuma_v2" = "yes" ; then
4feafb1e 1845 output_sym "CONFIG_LIBNUMA"
67bf9823
JA
1846fi
1847if test "$solaris_aio" = "yes" ; then
4feafb1e 1848 output_sym "CONFIG_SOLARISAIO"
67bf9823
JA
1849fi
1850if test "$tls_thread" = "yes" ; then
4feafb1e 1851 output_sym "CONFIG_TLS_THREAD"
67bf9823 1852fi
44404c5a 1853if test "$rusage_thread" = "yes" ; then
4feafb1e 1854 output_sym "CONFIG_RUSAGE_THREAD"
67bf9823 1855fi
91f94d5b
JA
1856if test "$gfio" = "yes" ; then
1857 echo "CONFIG_GFIO=y" >> $config_host_mak
1858fi
c8931876
JA
1859if test "$esx" = "yes" ; then
1860 output_sym "CONFIG_ESX"
1861 output_sym "CONFIG_NO_SHM"
1862fi
7e09a9f1
JA
1863if test "$sched_idle" = "yes" ; then
1864 output_sym "CONFIG_SCHED_IDLE"
1865fi
1eafa37a
JA
1866if test "$tcp_nodelay" = "yes" ; then
1867 output_sym "CONFIG_TCP_NODELAY"
1868fi
1008602c
JA
1869if test "$window_size" = "yes" ; then
1870 output_sym "CONFIG_NET_WINDOWSIZE"
1871fi
e5f34d95
JA
1872if test "$mss" = "yes" ; then
1873 output_sym "CONFIG_NET_MSS"
1874fi
38b9354a
JA
1875if test "$rlimit_memlock" = "yes" ; then
1876 output_sym "CONFIG_RLIMIT_MEMLOCK"
1877fi
07fc0acd
JA
1878if test "$pwritev" = "yes" ; then
1879 output_sym "CONFIG_PWRITEV"
1880fi
2cafffbe
JA
1881if test "$pwritev2" = "yes" ; then
1882 output_sym "CONFIG_PWRITEV2"
1883fi
ecad55e9
JA
1884if test "$ipv6" = "yes" ; then
1885 output_sym "CONFIG_IPV6"
1886fi
fc5c0345
DG
1887if test "$rbd" = "yes" ; then
1888 output_sym "CONFIG_RBD"
1889fi
53b6c979
PL
1890if test "$rbd_poll" = "yes" ; then
1891 output_sym "CONFIG_RBD_POLL"
1892fi
903b2812
JA
1893if test "$rbd_inval" = "yes" ; then
1894 output_sym "CONFIG_RBD_INVAL"
1895fi
a4c4c346 1896if test "$rbd_blkin" = "yes" ; then
1897 output_sym "CONFIG_RBD_BLKIN"
1898fi
2e802282
JA
1899if test "$setvbuf" = "yes" ; then
1900 output_sym "CONFIG_SETVBUF"
1901fi
81795ce3
CE
1902if test "$s390_z196_facilities" = "yes" ; then
1903 output_sym "CONFIG_S390_Z196_FACILITIES"
1904 CFLAGS="$CFLAGS -march=z9-109"
1905fi
6e7d7dfb 1906if test "$gfapi" = "yes" ; then
1907 output_sym "CONFIG_GFAPI"
1908fi
6fa14b99 1909if test "$gf_fadvise" = "yes" ; then
1910 output_sym "CONFIG_GF_FADVISE"
1911fi
6876c98c
JA
1912if test "$gf_trim" = "yes" ; then
1913 output_sym "CONFIG_GF_TRIM"
1914fi
1b10477b
MM
1915if test "$libhdfs" = "yes" ; then
1916 output_sym "CONFIG_LIBHDFS"
247e5436 1917 echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
1527dc50
FB
1918 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
1919 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
1920 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
1921 fi
b8116a87
DE
1922if test "$mtd" = "yes" ; then
1923 output_sym "CONFIG_MTD"
1924fi
43f3cec2
BB
1925if test "$pmemblk" = "yes" ; then
1926 output_sym "CONFIG_PMEMBLK"
1927fi
cbb15e42
DJ
1928if test "$devdax" = "yes" ; then
1929 output_sym "CONFIG_LINUX_DEVDAX"
1930fi
b470a02c
SC
1931if test "$arith" = "yes" ; then
1932 output_sym "CONFIG_ARITHMETIC"
e7b2c7a3
JA
1933 if test "$yacc_is_bison" = "yes" ; then
1934 echo "YACC=$YACC -y" >> $config_host_mak
1935 else
1936 echo "YACC=$YACC" >> $config_host_mak
1937 fi
63bda378
JA
1938 if test "$lex_use_o" = "yes" ; then
1939 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
1940 fi
b470a02c 1941fi
aae599ba
JA
1942if test "$getmntent" = "yes" ; then
1943 output_sym "CONFIG_GETMNTENT"
1944fi
e7e136da
TK
1945if test "$getmntinfo" = "yes" ; then
1946 output_sym "CONFIG_GETMNTINFO"
1947fi
b765bec0
TK
1948if test "$getmntinfo_statvfs" = "yes" ; then
1949 output_sym "CONFIG_GETMNTINFO_STATVFS"
1950fi
5018f79f
AH
1951if test "$static_assert" = "yes" ; then
1952 output_sym "CONFIG_STATIC_ASSERT"
1953fi
e39c0676
JA
1954if test "$have_bool" = "yes" ; then
1955 output_sym "CONFIG_HAVE_BOOL"
1956fi
67bf9823 1957
605cf82e
JA
1958if test "$zlib" = "no" ; then
1959 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
1960fi
1961
67bf9823 1962echo "LIBS+=$LIBS" >> $config_host_mak
86719845 1963echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
91f94d5b 1964echo "CFLAGS+=$CFLAGS" >> $config_host_mak
d2aeedb9 1965echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
67bf9823 1966echo "CC=$cc" >> $config_host_mak
af4862b3 1967echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
020d54bd 1968echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
c61a3a44 1969
59d8f412 1970if [ `dirname $0` != "." -a ! -e Makefile ]; then
c61a3a44
JF
1971 cat > Makefile <<EOF
1972SRCDIR:=`dirname $0`
1973include \$(SRCDIR)/Makefile
1974EOF
1975fi