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