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