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