3 # Fio configure script. Heavily influenced by the manual qemu configure
4 # script. Sad this this is easier than autoconf and enemies.
7 # set temporary file name
8 if test ! -z "$TMPDIR" ; then
10 elif test ! -z "$TEMPDIR" ; then
16 TMPC="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.c"
17 TMPO="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.o"
18 TMPE="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.exe"
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>
22 trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
26 config_host_mak="config-host.mak"
27 config_host_h="config-host.h"
29 rm -rf $config_host_mak
34 echo "Configure failed, check config.log and/or the above output"
35 rm -rf $config_host_mak
41 CFLAGS="-D_GNU_SOURCE -include config-host.h"
44 # Print a helpful header at the top of config.log
45 echo "# FIO configure log $(date)" >> config.log
46 printf "# Configured with:" >> config.log
47 printf " '%s'" "$0" "$@" >> config.log
49 echo "#" >> config.log
51 # Print configure header at the top of $config_host_h
52 echo "/*" > $config_host_h
53 echo " * Automatically generated by configure - do not modify" >> $config_host_h
54 printf " * Configured with:" >> $config_host_h
55 printf " * '%s'" "$0" "$@" >> $config_host_h
56 echo "" >> $config_host_h
57 echo " */" >> $config_host_h
60 # Run the compiler, capturing its output to the log.
61 echo $cc "$@" >> config.log
62 $cc "$@" >> config.log 2>&1 || return $?
63 # Test passed. If this is an --enable-werror build, rerun
64 # the test with -Werror and bail out if it fails. This
65 # makes warning-generating-errors in configure test code
66 # obvious to developers.
67 if test "$werror" != "yes"; then
70 # Don't bother rerunning the compile if we were already using -Werror
76 echo $cc -Werror "$@" >> config.log
77 $cc -Werror "$@" >> config.log 2>&1 && return $?
78 echo "ERROR: configure test passed without -Werror but failed with -Werror."
79 echo "This is probably a bug in the configure script. The failing command"
80 echo "will be at the bottom of config.log."
81 fatal "You can run configure with --disable-werror to bypass this check."
85 do_cc $CFLAGS -c -o $TMPO $TMPC
90 local_ldflags="$2 $LIBS"
91 echo "Compiling test case $3" >> config.log
92 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
100 echo "ERROR: User requested feature $feature"
101 if test ! -z "$packages" ; then
102 echo "ERROR: That feature needs $packages installed"
104 echo "ERROR: configure was not able to find it"
109 type "$1" >/dev/null 2>&1
115 #error $1 not defined
126 echo "$1=y" >> $config_host_mak
127 echo "#define $1" >> $config_host_h
146 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
148 --prefix=*) prefix="$optarg"
150 --cpu=*) cpu="$optarg"
152 # esx is cross compiled and cannot be detect through simple uname calls
158 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
160 --build-32bit-win) build_32bit_win="yes"
162 --build-static) build_static="yes"
167 --disable-numa) disable_numa="yes"
169 --disable-rbd) disable_rbd="yes"
171 --disable-rbd-blkin) disable_rbd_blkin="yes"
173 --disable-gfapi) disable_gfapi="yes"
175 --enable-libhdfs) libhdfs="yes"
177 --disable-lex) disable_lex="yes"
179 --enable-lex) disable_lex="no"
181 --disable-shm) no_shm="yes"
183 --disable-optimizations) disable_opt="yes"
185 --disable-pmem) disable_pmem="yes"
191 echo "Bad option $opt"
197 if test "$show_help" = "yes" ; then
198 echo "--prefix= Use this directory as installation prefix"
199 echo "--cpu= Specify target CPU if auto-detect fails"
200 echo "--cc= Specify compiler to use"
201 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
202 echo "--build-32bit-win Enable 32-bit build on Windows"
203 echo "--build-static Build a static fio"
204 echo "--esx Configure build options for esx"
205 echo "--enable-gfio Enable building of gtk gfio"
206 echo "--disable-numa Disable libnuma even if found"
207 echo "--disable-gfapi Disable gfapi"
208 echo "--enable-libhdfs Enable hdfs support"
209 echo "--disable-lex Disable use of lex/yacc for math"
210 echo "--disable-pmem Disable pmem based engines even if found"
211 echo "--enable-lex Enable use of lex/yacc for math"
212 echo "--disable-shm Disable SHM support"
213 echo "--disable-optimizations Don't enable compiler optimizations"
217 cross_prefix=${cross_prefix-${CROSS_COMPILE}}
218 cc="${CC-${cross_prefix}gcc}"
220 if check_define __ANDROID__ ; then
222 elif check_define __linux__ ; then
224 elif check_define __OpenBSD__ ; then
226 elif check_define __sun__ ; then
228 CFLAGS="$CFLAGS -D_REENTRANT"
229 elif check_define _WIN32 ; then
235 echo "# Automatically generated by configure - do not modify" > $config_host_mak
236 printf "# Configured with:" >> $config_host_mak
237 printf " '%s'" "$0" "$@" >> $config_host_mak
238 echo >> $config_host_mak
239 echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
241 if test "$no_shm" = "yes" ; then
242 output_sym "CONFIG_NO_SHM"
245 if test "$disable_opt" = "yes" ; then
246 output_sym "CONFIG_FIO_NO_OPT"
249 # Some host OSes need non-standard checks for which CPU to use.
250 # Note that these checks are broken for cross-compilation: if you're
251 # cross-compiling to one of these OSes then you'll need to specify
252 # the correct CPU with the --cpu option.
255 # Unless explicitly enabled, turn off lex.
256 if test -z "$disable_lex" ; then
263 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
264 # we can run 64-bit userspace code.
265 # If the user didn't specify a CPU explicitly and the kernel says this is
266 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
268 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
273 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
274 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
277 LIBS="-lnsl -lsocket"
280 echo "Forcing known good options on Windows"
281 if test -z "$CC" ; then
282 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
283 CC="i686-w64-mingw32-gcc"
285 CC="x86_64-w64-mingw32-gcc"
288 output_sym "CONFIG_LITTLE_ENDIAN"
289 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
290 output_sym "CONFIG_32BIT"
292 output_sym "CONFIG_64BIT_LLP64"
294 output_sym "CONFIG_FADVISE"
295 output_sym "CONFIG_SOCKLEN_T"
296 output_sym "CONFIG_FADVISE"
297 output_sym "CONFIG_SFAA"
298 output_sym "CONFIG_RUSAGE_THREAD"
299 output_sym "CONFIG_WINDOWSAIO"
300 output_sym "CONFIG_FDATASYNC"
301 output_sym "CONFIG_CLOCK_MONOTONIC"
302 output_sym "CONFIG_GETTIMEOFDAY"
303 output_sym "CONFIG_CLOCK_GETTIME"
304 output_sym "CONFIG_SCHED_IDLE"
305 output_sym "CONFIG_TCP_NODELAY"
306 output_sym "CONFIG_TLS_THREAD"
307 output_sym "CONFIG_IPV6"
308 echo "CC=$CC" >> $config_host_mak
309 echo "BUILD_CFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
314 if test ! -z "$cpu" ; then
315 # command line argument
317 elif check_define __i386__ ; then
319 elif check_define __x86_64__ ; then
321 elif check_define __sparc__ ; then
322 if check_define __arch64__ ; then
327 elif check_define _ARCH_PPC ; then
328 if check_define _ARCH_PPC64 ; then
333 elif check_define __mips__ ; then
335 elif check_define __ia64__ ; then
337 elif check_define __s390__ ; then
338 if check_define __s390x__ ; then
343 elif check_define __arm__ ; then
345 elif check_define __aarch64__ ; then
347 elif check_define __hppa__ ; then
353 # Normalise host CPU name and set ARCH.
355 ia64|ppc|ppc64|s390|s390x|sparc64)
358 i386|i486|i586|i686|i86pc|BePC)
370 hppa|parisc|parisc64)
384 if test -z "$CC" ; then
385 if test "$targetos" = "FreeBSD"; then
394 cc="${CC-${cross_prefix}gcc}"
396 ##########################################
397 # check cross compile
406 if compile_prog "" "" "cross"; then
407 $TMPE 2>/dev/null || cross_compile="yes"
409 fatal "compile test failed"
412 ##########################################
415 if test "$cross_compile" = "no" ; then
417 #include <inttypes.h>
420 volatile uint32_t i=0x01234567;
421 return (*((uint8_t*)(&i))) == 0x67;
424 if compile_prog "" "" "endian"; then
425 $TMPE && bigendian="yes"
428 # If we're cross compiling, try our best to work it out and rely on the
429 # run-time check to fail if we get it wrong.
434 #if __BYTE_ORDER != __BIG_ENDIAN
435 # error "Unknown endianness"
439 compile_prog "" "" "endian" && bigendian="yes"
440 check_define "__ARMEB__" && bigendian="yes"
441 check_define "__MIPSEB__" && bigendian="yes"
445 echo "Operating system $targetos"
447 echo "Big endian $bigendian"
449 echo "Cross compile $cross_compile"
452 ##########################################
453 # See if we need to build a static build
454 if test "$build_static" = "yes" ; then
455 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
456 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
460 echo "Static build $build_static"
462 ##########################################
467 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
470 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
474 if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
476 elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
479 fatal "Unknown wordsize"
481 echo "Wordsize $wordsize"
483 ##########################################
491 if (inflateInit(&stream) != Z_OK)
496 if compile_prog "" "-lz" "zlib" ; then
502 ##########################################
505 if test "$esx" != "yes" ; then
515 if compile_prog "" "-laio" "libaio" ; then
519 if test "$libaio" = "yes" ; then
520 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
525 echo "Linux AIO support $libaio"
527 ##########################################
540 if compile_prog "" "" "posixaio" ; then
542 elif compile_prog "" "-lrt" "posixaio"; then
547 echo "POSIX AIO support $posix_aio"
548 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
550 ##########################################
551 # posix aio fsync probe
553 if test "$posix_aio" = "yes" ; then
560 return aio_fsync(O_SYNC, &cb);
564 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
568 echo "POSIX AIO fsync $posix_aio_fsync"
570 ##########################################
574 #include <sys/types.h>
575 #include <sys/asynch.h>
580 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
584 if compile_prog "" "-laio" "solarisaio" ; then
588 echo "Solaris AIO support $solaris_aio"
590 ##########################################
591 # __sync_fetch_and_add test
594 #include <inttypes.h>
595 static int sfaa(uint64_t *ptr)
597 return __sync_fetch_and_add(ptr, 0);
600 int main(int argc, char **argv)
607 if compile_prog "" "" "__sync_fetch_and_add()" ; then
610 echo "__sync_fetch_and_add $sfaa"
612 ##########################################
617 #include <infiniband/arch.h>
618 int main(int argc, char **argv)
620 struct ibv_pd *pd = ibv_alloc_pd(NULL);
624 if compile_prog "" "-libverbs" "libverbs" ; then
626 LIBS="-libverbs $LIBS"
628 echo "libverbs $libverbs"
630 ##########################################
635 #include <rdma/rdma_cma.h>
636 int main(int argc, char **argv)
638 rdma_destroy_qp(NULL);
642 if compile_prog "" "-lrdmacm" "rdma"; then
644 LIBS="-lrdmacm $LIBS"
646 echo "rdmacm $rdmacm"
648 ##########################################
649 # Linux fallocate probe
654 #include <linux/falloc.h>
655 int main(int argc, char **argv)
657 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
661 if compile_prog "" "" "linux_fallocate"; then
662 linux_fallocate="yes"
664 echo "Linux fallocate $linux_fallocate"
666 ##########################################
667 # POSIX fadvise probe
672 int main(int argc, char **argv)
674 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
678 if compile_prog "" "" "posix_fadvise"; then
681 echo "POSIX fadvise $posix_fadvise"
683 ##########################################
684 # POSIX fallocate probe
689 int main(int argc, char **argv)
691 int r = posix_fallocate(0, 0, 1024);
695 if compile_prog "" "" "posix_fallocate"; then
696 posix_fallocate="yes"
698 echo "POSIX fallocate $posix_fallocate"
700 ##########################################
701 # sched_set/getaffinity 2 or 3 argument test
702 linux_2arg_affinity="no"
703 linux_3arg_affinity="no"
706 int main(int argc, char **argv)
709 return sched_setaffinity(0, sizeof(mask), &mask);
712 if compile_prog "" "" "sched_setaffinity(,,)"; then
713 linux_3arg_affinity="yes"
717 int main(int argc, char **argv)
720 return sched_setaffinity(0, &mask);
723 if compile_prog "" "" "sched_setaffinity(,)"; then
724 linux_2arg_affinity="yes"
727 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
728 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
730 ##########################################
731 # clock_gettime probe
736 int main(int argc, char **argv)
738 return clock_gettime(0, NULL);
741 if compile_prog "" "" "clock_gettime"; then
743 elif compile_prog "" "-lrt" "clock_gettime"; then
747 echo "clock_gettime $clock_gettime"
749 ##########################################
750 # CLOCK_MONOTONIC probe
752 if test "$clock_gettime" = "yes" ; then
756 int main(int argc, char **argv)
758 return clock_gettime(CLOCK_MONOTONIC, NULL);
761 if compile_prog "" "$LIBS" "clock monotonic"; then
762 clock_monotonic="yes"
765 echo "CLOCK_MONOTONIC $clock_monotonic"
767 ##########################################
768 # CLOCK_MONOTONIC_RAW probe
769 clock_monotonic_raw="no"
770 if test "$clock_gettime" = "yes" ; then
774 int main(int argc, char **argv)
776 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
779 if compile_prog "" "$LIBS" "clock monotonic"; then
780 clock_monotonic_raw="yes"
783 echo "CLOCK_MONOTONIC_RAW $clock_monotonic_raw"
785 ##########################################
786 # CLOCK_MONOTONIC_PRECISE probe
787 clock_monotonic_precise="no"
788 if test "$clock_gettime" = "yes" ; then
792 int main(int argc, char **argv)
794 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
797 if compile_prog "" "$LIBS" "clock monotonic precise"; then
798 clock_monotonic_precise="yes"
801 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
803 ##########################################
810 int main(int argc, char **argv)
813 memset(&cid, 0, sizeof(cid));
814 return clock_gettime(cid, NULL);
817 if compile_prog "" "$LIBS" "clockid_t"; then
820 echo "clockid_t $clockid_t"
822 ##########################################
823 # gettimeofday() probe
826 #include <sys/time.h>
828 int main(int argc, char **argv)
831 return gettimeofday(&tv, NULL);
834 if compile_prog "" "" "gettimeofday"; then
837 echo "gettimeofday $gettimeofday"
839 ##########################################
845 int main(int argc, char **argv)
850 if compile_prog "" "" "fdatasync"; then
853 echo "fdatasync $fdatasync"
855 ##########################################
856 # sync_file_range() probe
862 #include <linux/fs.h>
863 int main(int argc, char **argv)
865 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
866 SYNC_FILE_RANGE_WAIT_AFTER;
867 return sync_file_range(0, 0, 0, flags);
870 if compile_prog "" "" "sync_file_range"; then
871 sync_file_range="yes"
873 echo "sync_file_range $sync_file_range"
875 ##########################################
876 # ext4 move extent probe
880 #include <sys/ioctl.h>
881 int main(int argc, char **argv)
883 struct move_extent me;
884 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
887 if compile_prog "" "" "ext4 move extent" ; then
889 elif test $targetos = "Linux" ; then
890 # On Linux, just default to it on and let it error at runtime if we really
891 # don't have it. None of my updated systems have it defined, but it does
892 # work. Takes a while to bubble back.
895 echo "EXT4 move extent $ext4_me"
897 ##########################################
903 int main(int argc, char **argv)
905 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
908 if compile_prog "" "" "linux splice"; then
911 echo "Linux splice(2) $linux_splice"
913 ##########################################
918 #include <guasi_syscalls.h>
919 int main(int argc, char **argv)
921 guasi_t ctx = guasi_create(0, 0, 0);
925 if compile_prog "" "" "guasi"; then
930 ##########################################
934 #include <nvm/nvm_primitives.h>
935 int main(int argc, char **argv)
937 nvm_version_t ver_info;
940 handle = nvm_get_handle(0, &ver_info);
941 return nvm_atomic_write(handle, 0, 0, 0);
944 if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
945 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
948 echo "Fusion-io atomic engine $fusion_aw"
950 ##########################################
955 int main(int argc, char **argv)
957 return numa_available();
960 if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
964 echo "libnuma $libnuma"
966 ##########################################
967 # libnuma 2.x version API
968 if test "$libnuma" = "yes" ; then
972 int main(int argc, char **argv)
974 struct bitmask *mask = numa_parse_nodestring(NULL);
975 return mask->size == 0;
978 if compile_prog "" "" "libnuma api"; then
981 echo "libnuma v2 $libnuma_v2"
984 ##########################################
989 int main(int argc, char **argv)
991 static char *string = "This is a string";
992 strsep(&string, "needle");
996 if compile_prog "" "" "strsep"; then
999 echo "strsep $strsep"
1001 ##########################################
1002 # strcasestr() probe
1006 int main(int argc, char **argv)
1008 return strcasestr(argv[0], argv[1]) != NULL;
1011 if compile_prog "" "" "strcasestr"; then
1014 echo "strcasestr $strcasestr"
1016 ##########################################
1021 int main(int argc, char **argv)
1023 static char dst[64];
1024 static char *string = "This is a string";
1025 memset(dst, 0, sizeof(dst));
1026 strlcat(dst, string, sizeof(dst));
1030 if compile_prog "" "" "strlcat"; then
1033 echo "strlcat $strlcat"
1035 ##########################################
1036 # getopt_long_only() probe
1037 getopt_long_only="no"
1042 int main(int argc, char **argv)
1044 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1048 if compile_prog "" "" "getopt_long_only"; then
1049 getopt_long_only="yes"
1051 echo "getopt_long_only() $getopt_long_only"
1053 ##########################################
1057 #include <sys/socket.h>
1058 #include <arpa/inet.h>
1060 int main(int argc, char **argv)
1063 return inet_aton(NULL, &in);
1066 if compile_prog "" "" "inet_aton"; then
1069 echo "inet_aton $inet_aton"
1071 ##########################################
1075 #include <sys/socket.h>
1076 int main(int argc, char **argv)
1082 if compile_prog "" "" "socklen_t"; then
1085 echo "socklen_t $socklen_t"
1087 ##########################################
1088 # Whether or not __thread is supported for TLS
1092 static __thread int ret;
1093 int main(int argc, char **argv)
1098 if compile_prog "" "" "__thread"; then
1101 echo "__thread $tls_thread"
1103 ##########################################
1104 # Check if we have required gtk/glib support for gfio
1106 if test "$gfio_check" = "yes" ; then
1110 #include <gtk/gtk.h>
1113 gdk_threads_enter();
1114 gdk_threads_leave();
1116 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
1119 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1120 ORG_LDFLAGS=$LDFLAGS
1121 LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1122 if test "$?" != "0" ; then
1123 echo "configure: gtk and gthread not found"
1126 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1127 if test "$?" != "0" ; then
1128 echo "configure: gtk and gthread not found"
1131 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1133 if test "$r" != "0" ; then
1135 GFIO_LIBS="$LIBS $GTK_LIBS"
1136 CFLAGS="$CFLAGS $GTK_CFLAGS"
1138 echo "GTK found, but need version 2.18 or higher"
1142 echo "Please install gtk and gdk libraries"
1145 LDFLAGS=$ORG_LDFLAGS
1148 if test "$gfio_check" = "yes" ; then
1149 echo "gtk 2.18 or higher $gfio"
1152 # Check whether we have getrusage(RUSAGE_THREAD)
1155 #include <sys/time.h>
1156 #include <sys/resource.h>
1157 int main(int argc, char **argv)
1160 getrusage(RUSAGE_THREAD, &ru);
1164 if compile_prog "" "" "RUSAGE_THREAD"; then
1167 echo "RUSAGE_THREAD $rusage_thread"
1169 ##########################################
1170 # Check whether we have SCHED_IDLE
1174 int main(int argc, char **argv)
1176 struct sched_param p;
1177 return sched_setscheduler(0, SCHED_IDLE, &p);
1180 if compile_prog "" "" "SCHED_IDLE"; then
1183 echo "SCHED_IDLE $sched_idle"
1185 ##########################################
1186 # Check whether we have TCP_NODELAY
1190 #include <sys/types.h>
1191 #include <sys/socket.h>
1192 #include <netinet/tcp.h>
1193 int main(int argc, char **argv)
1195 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1198 if compile_prog "" "" "TCP_NODELAY"; then
1201 echo "TCP_NODELAY $tcp_nodelay"
1203 ##########################################
1204 # Check whether we have SO_SNDBUF
1208 #include <sys/types.h>
1209 #include <sys/socket.h>
1210 #include <netinet/tcp.h>
1211 int main(int argc, char **argv)
1213 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1214 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1217 if compile_prog "" "" "SO_SNDBUF"; then
1220 echo "Net engine window_size $window_size"
1222 ##########################################
1223 # Check whether we have TCP_MAXSEG
1227 #include <sys/types.h>
1228 #include <sys/socket.h>
1229 #include <netinet/tcp.h>
1230 #include <arpa/inet.h>
1231 #include <netinet/in.h>
1232 int main(int argc, char **argv)
1234 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1237 if compile_prog "" "" "TCP_MAXSEG"; then
1240 echo "TCP_MAXSEG $mss"
1242 ##########################################
1243 # Check whether we have RLIMIT_MEMLOCK
1246 #include <sys/time.h>
1247 #include <sys/resource.h>
1248 int main(int argc, char **argv)
1251 return getrlimit(RLIMIT_MEMLOCK, &rl);
1254 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1255 rlimit_memlock="yes"
1257 echo "RLIMIT_MEMLOCK $rlimit_memlock"
1259 ##########################################
1260 # Check whether we have pwritev/preadv
1264 #include <sys/uio.h>
1265 int main(int argc, char **argv)
1267 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1270 if compile_prog "" "" "pwritev"; then
1273 echo "pwritev/preadv $pwritev"
1275 ##########################################
1276 # Check whether we have pwritev2/preadv2
1280 #include <sys/uio.h>
1281 int main(int argc, char **argv)
1283 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1286 if compile_prog "" "" "pwritev2"; then
1289 echo "pwritev2/preadv2 $pwritev2"
1291 ##########################################
1292 # Check whether we have the required functions for ipv6
1295 #include <sys/types.h>
1296 #include <sys/socket.h>
1297 #include <netinet/in.h>
1300 int main(int argc, char **argv)
1302 struct addrinfo hints;
1303 struct in6_addr addr;
1306 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1308 printf("%s\n", gai_strerror(ret));
1313 if compile_prog "" "" "ipv6"; then
1316 echo "IPv6 helpers $ipv6"
1318 ##########################################
1322 #include <rbd/librbd.h>
1324 int main(int argc, char **argv)
1328 rados_ioctx_t io_ctx;
1329 const char pool[] = "rbd";
1331 int major, minor, extra;
1332 rbd_version(&major, &minor, &extra);
1334 rados_ioctx_create(cluster, pool, &io_ctx);
1338 if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
1339 LIBS="-lrbd -lrados $LIBS"
1342 echo "Rados Block Device engine $rbd"
1344 ##########################################
1345 # check for rbd_poll
1347 if test "$rbd" = "yes"; then
1349 #include <rbd/librbd.h>
1350 #include <sys/eventfd.h>
1352 int main(int argc, char **argv)
1355 rbd_completion_t comp;
1357 int fd = eventfd(0, EFD_NONBLOCK);
1358 rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1359 rbd_poll_io_events(image, comp, 1);
1364 if compile_prog "" "-lrbd -lrados" "rbd"; then
1367 echo "rbd_poll $rbd_poll"
1370 ##########################################
1371 # check for rbd_invaidate_cache()
1373 if test "$rbd" = "yes"; then
1375 #include <rbd/librbd.h>
1377 int main(int argc, char **argv)
1381 return rbd_invalidate_cache(image);
1384 if compile_prog "" "-lrbd -lrados" "rbd"; then
1387 echo "rbd_invalidate_cache $rbd_inval"
1390 ##########################################
1394 #include <rbd/librbd.h>
1395 #include <zipkin_c.h>
1397 int main(int argc, char **argv)
1400 struct blkin_trace_info t_info;
1401 blkin_init_trace_info(&t_info);
1402 rbd_completion_t completion;
1407 r = rbd_aio_write_traced(image, off, len, buf, completion, &t_info);
1411 if test "$disable_rbd" != "yes" && test "$disable_rbd_blkin" != "yes" \
1412 && compile_prog "" "-lrbd -lrados -lblkin" "rbd_blkin"; then
1413 LIBS="-lblkin $LIBS"
1416 echo "rbd blkin tracing $rbd_blkin"
1418 ##########################################
1419 # Check whether we have setvbuf
1423 int main(int argc, char **argv)
1427 setvbuf(f, buf, _IOFBF, sizeof(buf));
1431 if compile_prog "" "" "setvbuf"; then
1434 echo "setvbuf $setvbuf"
1439 #include <glusterfs/api/glfs.h>
1441 int main(int argc, char **argv)
1444 glfs_t *g = glfs_new("foo");
1449 if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1450 LIBS="-lgfapi -lglusterfs $LIBS"
1453 echo "Gluster API engine $gfapi"
1455 ##########################################
1456 # check for gfapi fadvise support
1457 if test "$gfapi" = "yes" ; then
1460 #include <glusterfs/api/glfs.h>
1462 int main(int argc, char **argv)
1465 int ret = glfs_fadvise(fd, 0, 0, 1);
1470 if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1473 echo "Gluster API use fadvise $gf_fadvise"
1476 ##########################################
1477 # check for gfapi trim support
1479 if test "$gfapi" = "yes" ; then
1481 #include <glusterfs/api/glfs.h>
1483 int main(int argc, char **argv)
1485 return glfs_discard_async(NULL, 0, 0);
1488 if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1491 echo "Gluster API trim support $gf_trim"
1494 ##########################################
1495 # Check if we support stckf on s390
1496 s390_z196_facilities="no"
1498 #define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1499 int main(int argc, char **argv)
1501 /* We want just 1 double word to be returned. */
1502 register unsigned long reg0 asm("0") = 0;
1503 unsigned long stfle_bits;
1504 asm volatile(".machine push" "\n\t"
1505 ".machine \"z9-109\"" "\n\t"
1508 : "=QS" (stfle_bits), "+d" (reg0)
1511 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1517 if compile_prog "" "" "s390_z196_facilities"; then
1519 if [[ $? -eq 0 ]]; then
1520 s390_z196_facilities="yes"
1523 echo "s390_z196_facilities $s390_z196_facilities"
1525 ##########################################
1526 # Check if we have required environment variables configured for libhdfs
1527 if test "$libhdfs" = "yes" ; then
1529 if test "$JAVA_HOME" = "" ; then
1530 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1533 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1534 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1537 if test "$FIO_LIBHDFS_LIB" = "" ; then
1538 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1541 if test "$hdfs_conf_error" = "1" ; then
1545 if test "$FIO_HDFS_CPU" = "x86_64" ; then
1546 FIO_HDFS_CPU="amd64"
1549 echo "HDFS engine $libhdfs"
1551 ##########################################
1552 # Check whether we have MTD
1556 #include <mtd/mtd-user.h>
1557 #include <sys/ioctl.h>
1558 int main(int argc, char **argv)
1560 struct mtd_write_req ops;
1561 struct mtd_info_user info;
1562 memset(&ops, 0, sizeof(ops));
1563 info.type = MTD_MLCNANDFLASH;
1564 return ioctl(0, MEMGETINFO, &info);
1567 if compile_prog "" "" "mtd"; then
1572 ##########################################
1573 # Check whether we have libpmem
1576 #include <libpmem.h>
1577 int main(int argc, char **argv)
1580 rc = pmem_is_pmem(0, 0);
1584 if compile_prog "" "-lpmem" "libpmem"; then
1587 echo "libpmem $libpmem"
1589 ##########################################
1590 # Check whether we have libpmemblk
1593 #include <libpmemblk.h>
1594 int main(int argc, char **argv)
1597 rc = pmemblk_open("", 0);
1601 if compile_prog "" "-lpmemblk -lpmem" "libpmemblk"; then
1604 echo "libpmemblk $libpmemblk"
1606 if test "$libpmem" = "yes" && test "$disable_pmem" = "no"; then
1608 if test "$libpmemblk" = "yes"; then
1613 ##########################################
1614 # Report whether pmemblk engine is enabled
1615 echo "NVML libpmemblk engine $pmemblk"
1617 ##########################################
1618 # Report whether dev-dax engine is enabled
1619 echo "NVML Device Dax engine $devdax"
1621 # Check if we have lex/yacc available
1626 if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
1627 if test "$targetos" != "SunOS" ; then
1628 LEX=$(which lex 2> /dev/null)
1629 if test -x "$LEX" ; then
1632 YACC=$(which bison 2> /dev/null)
1633 if test -x "$YACC" ; then
1637 YACC=$(which yacc 2> /dev/null)
1638 if test -x "$YACC" ; then
1642 if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1646 if test "$arith" = "yes" ; then
1648 extern int yywrap(void);
1650 int main(int argc, char **argv)
1656 if compile_prog "" "-ll" "lex"; then
1665 # Check if lex fails using -o
1666 if test "$arith" = "yes" ; then
1667 if test "$force_no_lex_o" = "yes" ; then
1670 $LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1671 if test "$?" = "0" ; then
1679 echo "lex/yacc for arithmetic $arith"
1681 ##########################################
1682 # Check whether we have setmntent/getmntent
1687 int main(int argc, char **argv)
1689 FILE *mtab = setmntent(NULL, "r");
1690 struct mntent *mnt = getmntent(mtab);
1695 if compile_prog "" "" "getmntent"; then
1698 echo "getmntent $getmntent"
1700 ##########################################
1701 # Check whether we have getmntinfo
1702 # These are originally added for BSDs, but may also work
1703 # on other operating systems with getmntinfo(3).
1705 # getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
1706 # Note that NetBSD needs -Werror to catch warning as error.
1710 #include <sys/param.h>
1711 #include <sys/mount.h>
1712 int main(int argc, char **argv)
1715 return getmntinfo(&st, MNT_NOWAIT);
1718 if compile_prog "-Werror" "" "getmntinfo"; then
1721 echo "getmntinfo $getmntinfo"
1723 # getmntinfo(3) for NetBSD.
1724 getmntinfo_statvfs="no"
1727 #include <sys/statvfs.h>
1728 int main(int argc, char **argv)
1731 return getmntinfo(&st, MNT_NOWAIT);
1734 # Skip the test if the one with statfs arg is detected.
1735 if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
1736 getmntinfo_statvfs="yes"
1737 echo "getmntinfo_statvfs $getmntinfo_statvfs"
1740 ##########################################
1741 # Check whether we have _Static_assert
1747 #ifdef __compiler_offsetof
1748 #define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
1750 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1753 #define container_of(ptr, type, member) ({ \
1754 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
1755 (type *)( (char *)__mptr - offsetof(type,member) );})
1761 int main(int argc, char **argv)
1763 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
1767 if compile_prog "" "" "static_assert"; then
1770 echo "Static Assert $static_assert"
1772 ##########################################
1773 # Check whether we have bool / stdbool.h
1776 #include <stdbool.h>
1777 int main(int argc, char **argv)
1780 return var != false;
1783 if compile_prog "" "" "bool"; then
1786 echo "bool $have_bool"
1788 ##########################################
1789 # check march=armv8-a+crc+crypto
1790 march_armv8_a_crc_crypto="no"
1791 if test "$cpu" = "arm64" ; then
1798 if compile_prog "-march=armv8-a+crc+crypto" "" ""; then
1799 march_armv8_a_crc_crypto="yes"
1800 CFLAGS="$CFLAGS -march=armv8-a+crc+crypto -DARCH_HAVE_CRC_CRYPTO"
1803 echo "march_armv8_a_crc_crypto $march_armv8_a_crc_crypto"
1806 #############################################################################
1808 if test "$wordsize" = "64" ; then
1809 output_sym "CONFIG_64BIT"
1810 elif test "$wordsize" = "32" ; then
1811 output_sym "CONFIG_32BIT"
1813 fatal "Unknown wordsize!"
1815 if test "$bigendian" = "yes" ; then
1816 output_sym "CONFIG_BIG_ENDIAN"
1818 output_sym "CONFIG_LITTLE_ENDIAN"
1820 if test "$zlib" = "yes" ; then
1821 output_sym "CONFIG_ZLIB"
1823 if test "$libaio" = "yes" ; then
1824 output_sym "CONFIG_LIBAIO"
1826 if test "$posix_aio" = "yes" ; then
1827 output_sym "CONFIG_POSIXAIO"
1829 if test "$posix_aio_fsync" = "yes" ; then
1830 output_sym "CONFIG_POSIXAIO_FSYNC"
1832 if test "$linux_fallocate" = "yes" ; then
1833 output_sym "CONFIG_LINUX_FALLOCATE"
1835 if test "$posix_fallocate" = "yes" ; then
1836 output_sym "CONFIG_POSIX_FALLOCATE"
1838 if test "$fdatasync" = "yes" ; then
1839 output_sym "CONFIG_FDATASYNC"
1841 if test "$sync_file_range" = "yes" ; then
1842 output_sym "CONFIG_SYNC_FILE_RANGE"
1844 if test "$sfaa" = "yes" ; then
1845 output_sym "CONFIG_SFAA"
1847 if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
1848 output_sym "CONFIG_RDMA"
1850 if test "$clock_gettime" = "yes" ; then
1851 output_sym "CONFIG_CLOCK_GETTIME"
1853 if test "$clock_monotonic" = "yes" ; then
1854 output_sym "CONFIG_CLOCK_MONOTONIC"
1856 if test "$clock_monotonic_raw" = "yes" ; then
1857 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
1859 if test "$clock_monotonic_precise" = "yes" ; then
1860 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
1862 if test "$clockid_t" = "yes"; then
1863 output_sym "CONFIG_CLOCKID_T"
1865 if test "$gettimeofday" = "yes" ; then
1866 output_sym "CONFIG_GETTIMEOFDAY"
1868 if test "$posix_fadvise" = "yes" ; then
1869 output_sym "CONFIG_POSIX_FADVISE"
1871 if test "$linux_3arg_affinity" = "yes" ; then
1872 output_sym "CONFIG_3ARG_AFFINITY"
1873 elif test "$linux_2arg_affinity" = "yes" ; then
1874 output_sym "CONFIG_2ARG_AFFINITY"
1876 if test "$strsep" = "yes" ; then
1877 output_sym "CONFIG_STRSEP"
1879 if test "$strcasestr" = "yes" ; then
1880 output_sym "CONFIG_STRCASESTR"
1882 if test "$strlcat" = "yes" ; then
1883 output_sym "CONFIG_STRLCAT"
1885 if test "$getopt_long_only" = "yes" ; then
1886 output_sym "CONFIG_GETOPT_LONG_ONLY"
1888 if test "$inet_aton" = "yes" ; then
1889 output_sym "CONFIG_INET_ATON"
1891 if test "$socklen_t" = "yes" ; then
1892 output_sym "CONFIG_SOCKLEN_T"
1894 if test "$ext4_me" = "yes" ; then
1895 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1897 if test "$linux_splice" = "yes" ; then
1898 output_sym "CONFIG_LINUX_SPLICE"
1900 if test "$guasi" = "yes" ; then
1901 output_sym "CONFIG_GUASI"
1903 if test "$fusion_aw" = "yes" ; then
1904 output_sym "CONFIG_FUSION_AW"
1906 if test "$libnuma_v2" = "yes" ; then
1907 output_sym "CONFIG_LIBNUMA"
1909 if test "$solaris_aio" = "yes" ; then
1910 output_sym "CONFIG_SOLARISAIO"
1912 if test "$tls_thread" = "yes" ; then
1913 output_sym "CONFIG_TLS_THREAD"
1915 if test "$rusage_thread" = "yes" ; then
1916 output_sym "CONFIG_RUSAGE_THREAD"
1918 if test "$gfio" = "yes" ; then
1919 echo "CONFIG_GFIO=y" >> $config_host_mak
1921 if test "$esx" = "yes" ; then
1922 output_sym "CONFIG_ESX"
1923 output_sym "CONFIG_NO_SHM"
1925 if test "$sched_idle" = "yes" ; then
1926 output_sym "CONFIG_SCHED_IDLE"
1928 if test "$tcp_nodelay" = "yes" ; then
1929 output_sym "CONFIG_TCP_NODELAY"
1931 if test "$window_size" = "yes" ; then
1932 output_sym "CONFIG_NET_WINDOWSIZE"
1934 if test "$mss" = "yes" ; then
1935 output_sym "CONFIG_NET_MSS"
1937 if test "$rlimit_memlock" = "yes" ; then
1938 output_sym "CONFIG_RLIMIT_MEMLOCK"
1940 if test "$pwritev" = "yes" ; then
1941 output_sym "CONFIG_PWRITEV"
1943 if test "$pwritev2" = "yes" ; then
1944 output_sym "CONFIG_PWRITEV2"
1946 if test "$ipv6" = "yes" ; then
1947 output_sym "CONFIG_IPV6"
1949 if test "$rbd" = "yes" ; then
1950 output_sym "CONFIG_RBD"
1952 if test "$rbd_poll" = "yes" ; then
1953 output_sym "CONFIG_RBD_POLL"
1955 if test "$rbd_inval" = "yes" ; then
1956 output_sym "CONFIG_RBD_INVAL"
1958 if test "$rbd_blkin" = "yes" ; then
1959 output_sym "CONFIG_RBD_BLKIN"
1961 if test "$setvbuf" = "yes" ; then
1962 output_sym "CONFIG_SETVBUF"
1964 if test "$s390_z196_facilities" = "yes" ; then
1965 output_sym "CONFIG_S390_Z196_FACILITIES"
1966 CFLAGS="$CFLAGS -march=z9-109"
1968 if test "$gfapi" = "yes" ; then
1969 output_sym "CONFIG_GFAPI"
1971 if test "$gf_fadvise" = "yes" ; then
1972 output_sym "CONFIG_GF_FADVISE"
1974 if test "$gf_trim" = "yes" ; then
1975 output_sym "CONFIG_GF_TRIM"
1977 if test "$libhdfs" = "yes" ; then
1978 output_sym "CONFIG_LIBHDFS"
1979 echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
1980 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
1981 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
1982 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
1984 if test "$mtd" = "yes" ; then
1985 output_sym "CONFIG_MTD"
1987 if test "$pmemblk" = "yes" ; then
1988 output_sym "CONFIG_PMEMBLK"
1990 if test "$devdax" = "yes" ; then
1991 output_sym "CONFIG_LINUX_DEVDAX"
1993 if test "$arith" = "yes" ; then
1994 output_sym "CONFIG_ARITHMETIC"
1995 if test "$yacc_is_bison" = "yes" ; then
1996 echo "YACC=$YACC -y" >> $config_host_mak
1998 echo "YACC=$YACC" >> $config_host_mak
2000 if test "$lex_use_o" = "yes" ; then
2001 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
2004 if test "$getmntent" = "yes" ; then
2005 output_sym "CONFIG_GETMNTENT"
2007 if test "$getmntinfo" = "yes" ; then
2008 output_sym "CONFIG_GETMNTINFO"
2010 if test "$getmntinfo_statvfs" = "yes" ; then
2011 output_sym "CONFIG_GETMNTINFO_STATVFS"
2013 if test "$static_assert" = "yes" ; then
2014 output_sym "CONFIG_STATIC_ASSERT"
2016 if test "$have_bool" = "yes" ; then
2017 output_sym "CONFIG_HAVE_BOOL"
2020 if test "$zlib" = "no" ; then
2021 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
2024 echo "LIBS+=$LIBS" >> $config_host_mak
2025 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
2026 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
2027 echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
2028 echo "CC=$cc" >> $config_host_mak
2029 echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
2030 echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
2032 if [ `dirname $0` != "." -a ! -e Makefile ]; then
2033 cat > Makefile <<EOF
2034 SRCDIR:=`dirname $0`
2035 include \$(SRCDIR)/Makefile