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