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"
284 if test -e "../zlib/contrib/vstudio/vc14/x86/ZlibStatReleaseWithoutAsm/zlibstat.lib"; then
285 echo "Building with zlib support"
286 output_sym "CONFIG_ZLIB"
287 echo "LIBS=../zlib/contrib/vstudio/vc14/x86/ZlibStatReleaseWithoutAsm/zlibstat.lib" >> $config_host_mak
290 CC="x86_64-w64-mingw32-gcc"
291 if test -e "../zlib/contrib/vstudio/vc14/x64/ZlibStatReleaseWithoutAsm/zlibstat.lib"; then
292 echo "Building with zlib support"
293 output_sym "CONFIG_ZLIB"
294 echo "LIBS=../zlib/contrib/vstudio/vc14/x64/ZlibStatReleaseWithoutAsm/zlibstat.lib" >> $config_host_mak
298 output_sym "CONFIG_LITTLE_ENDIAN"
299 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
300 output_sym "CONFIG_32BIT"
302 output_sym "CONFIG_64BIT_LLP64"
304 output_sym "CONFIG_FADVISE"
305 output_sym "CONFIG_SOCKLEN_T"
306 output_sym "CONFIG_FADVISE"
307 output_sym "CONFIG_SFAA"
308 output_sym "CONFIG_RUSAGE_THREAD"
309 output_sym "CONFIG_WINDOWSAIO"
310 output_sym "CONFIG_FDATASYNC"
311 output_sym "CONFIG_CLOCK_MONOTONIC"
312 output_sym "CONFIG_GETTIMEOFDAY"
313 output_sym "CONFIG_CLOCK_GETTIME"
314 output_sym "CONFIG_SCHED_IDLE"
315 output_sym "CONFIG_TCP_NODELAY"
316 output_sym "CONFIG_TLS_THREAD"
317 output_sym "CONFIG_IPV6"
318 echo "CC=$CC" >> $config_host_mak
319 echo "BUILD_CFLAGS=$CFLAGS -I../zlib -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
325 if test ! -z "$cpu" ; then
326 # command line argument
328 elif check_define __i386__ ; then
330 elif check_define __x86_64__ ; then
332 elif check_define __sparc__ ; then
333 if check_define __arch64__ ; then
338 elif check_define _ARCH_PPC ; then
339 if check_define _ARCH_PPC64 ; then
344 elif check_define __mips__ ; then
346 elif check_define __ia64__ ; then
348 elif check_define __s390__ ; then
349 if check_define __s390x__ ; then
354 elif check_define __arm__ ; then
356 elif check_define __aarch64__ ; then
358 elif check_define __hppa__ ; then
364 # Normalise host CPU name and set ARCH.
366 ia64|ppc|ppc64|s390|s390x|sparc64)
369 i386|i486|i586|i686|i86pc|BePC)
381 hppa|parisc|parisc64)
395 if test -z "$CC" ; then
396 if test "$targetos" = "FreeBSD"; then
405 cc="${CC-${cross_prefix}gcc}"
407 ##########################################
408 # check cross compile
417 if compile_prog "" "" "cross"; then
418 $TMPE 2>/dev/null || cross_compile="yes"
420 fatal "compile test failed"
423 ##########################################
426 if test "$cross_compile" = "no" ; then
428 #include <inttypes.h>
431 volatile uint32_t i=0x01234567;
432 return (*((uint8_t*)(&i))) == 0x67;
435 if compile_prog "" "" "endian"; then
436 $TMPE && bigendian="yes"
439 # If we're cross compiling, try our best to work it out and rely on the
440 # run-time check to fail if we get it wrong.
445 #if __BYTE_ORDER != __BIG_ENDIAN
446 # error "Unknown endianness"
450 compile_prog "" "" "endian" && bigendian="yes"
451 check_define "__ARMEB__" && bigendian="yes"
452 check_define "__MIPSEB__" && bigendian="yes"
456 echo "Operating system $targetos"
458 echo "Big endian $bigendian"
460 echo "Cross compile $cross_compile"
463 ##########################################
464 # See if we need to build a static build
465 if test "$build_static" = "yes" ; then
466 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
467 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
471 echo "Static build $build_static"
473 ##########################################
478 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
481 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
485 if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
487 elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
490 fatal "Unknown wordsize"
492 echo "Wordsize $wordsize"
494 ##########################################
502 if (inflateInit(&stream) != Z_OK)
507 if compile_prog "" "-lz" "zlib" ; then
513 ##########################################
516 if test "$esx" != "yes" ; then
526 if compile_prog "" "-laio" "libaio" ; then
530 if test "$libaio" = "yes" ; then
531 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
536 echo "Linux AIO support $libaio"
538 ##########################################
551 if compile_prog "" "" "posixaio" ; then
553 elif compile_prog "" "-lrt" "posixaio"; then
558 echo "POSIX AIO support $posix_aio"
559 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
561 ##########################################
562 # posix aio fsync probe
564 if test "$posix_aio" = "yes" ; then
571 return aio_fsync(O_SYNC, &cb);
575 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
579 echo "POSIX AIO fsync $posix_aio_fsync"
581 ##########################################
585 #include <sys/types.h>
586 #include <sys/asynch.h>
591 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
595 if compile_prog "" "-laio" "solarisaio" ; then
599 echo "Solaris AIO support $solaris_aio"
601 ##########################################
602 # __sync_fetch_and_add test
605 #include <inttypes.h>
606 static int sfaa(uint64_t *ptr)
608 return __sync_fetch_and_add(ptr, 0);
611 int main(int argc, char **argv)
618 if compile_prog "" "" "__sync_fetch_and_add()" ; then
621 echo "__sync_fetch_and_add $sfaa"
623 ##########################################
628 #include <infiniband/arch.h>
629 int main(int argc, char **argv)
631 struct ibv_pd *pd = ibv_alloc_pd(NULL);
635 if compile_prog "" "-libverbs" "libverbs" ; then
637 LIBS="-libverbs $LIBS"
639 echo "libverbs $libverbs"
641 ##########################################
646 #include <rdma/rdma_cma.h>
647 int main(int argc, char **argv)
649 rdma_destroy_qp(NULL);
653 if compile_prog "" "-lrdmacm" "rdma"; then
655 LIBS="-lrdmacm $LIBS"
657 echo "rdmacm $rdmacm"
659 ##########################################
660 # Linux fallocate probe
665 #include <linux/falloc.h>
666 int main(int argc, char **argv)
668 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
672 if compile_prog "" "" "linux_fallocate"; then
673 linux_fallocate="yes"
675 echo "Linux fallocate $linux_fallocate"
677 ##########################################
678 # POSIX fadvise probe
683 int main(int argc, char **argv)
685 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
689 if compile_prog "" "" "posix_fadvise"; then
692 echo "POSIX fadvise $posix_fadvise"
694 ##########################################
695 # POSIX fallocate probe
700 int main(int argc, char **argv)
702 int r = posix_fallocate(0, 0, 1024);
706 if compile_prog "" "" "posix_fallocate"; then
707 posix_fallocate="yes"
709 echo "POSIX fallocate $posix_fallocate"
711 ##########################################
712 # sched_set/getaffinity 2 or 3 argument test
713 linux_2arg_affinity="no"
714 linux_3arg_affinity="no"
717 int main(int argc, char **argv)
720 return sched_setaffinity(0, sizeof(mask), &mask);
723 if compile_prog "" "" "sched_setaffinity(,,)"; then
724 linux_3arg_affinity="yes"
728 int main(int argc, char **argv)
731 return sched_setaffinity(0, &mask);
734 if compile_prog "" "" "sched_setaffinity(,)"; then
735 linux_2arg_affinity="yes"
738 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
739 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
741 ##########################################
742 # clock_gettime probe
747 int main(int argc, char **argv)
749 return clock_gettime(0, NULL);
752 if compile_prog "" "" "clock_gettime"; then
754 elif compile_prog "" "-lrt" "clock_gettime"; then
758 echo "clock_gettime $clock_gettime"
760 ##########################################
761 # CLOCK_MONOTONIC probe
763 if test "$clock_gettime" = "yes" ; then
767 int main(int argc, char **argv)
769 return clock_gettime(CLOCK_MONOTONIC, NULL);
772 if compile_prog "" "$LIBS" "clock monotonic"; then
773 clock_monotonic="yes"
776 echo "CLOCK_MONOTONIC $clock_monotonic"
778 ##########################################
779 # CLOCK_MONOTONIC_RAW probe
780 clock_monotonic_raw="no"
781 if test "$clock_gettime" = "yes" ; then
785 int main(int argc, char **argv)
787 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
790 if compile_prog "" "$LIBS" "clock monotonic"; then
791 clock_monotonic_raw="yes"
794 echo "CLOCK_MONOTONIC_RAW $clock_monotonic_raw"
796 ##########################################
797 # CLOCK_MONOTONIC_PRECISE probe
798 clock_monotonic_precise="no"
799 if test "$clock_gettime" = "yes" ; then
803 int main(int argc, char **argv)
805 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
808 if compile_prog "" "$LIBS" "clock monotonic precise"; then
809 clock_monotonic_precise="yes"
812 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
814 ##########################################
821 int main(int argc, char **argv)
824 memset(&cid, 0, sizeof(cid));
825 return clock_gettime(cid, NULL);
828 if compile_prog "" "$LIBS" "clockid_t"; then
831 echo "clockid_t $clockid_t"
833 ##########################################
834 # gettimeofday() probe
837 #include <sys/time.h>
839 int main(int argc, char **argv)
842 return gettimeofday(&tv, NULL);
845 if compile_prog "" "" "gettimeofday"; then
848 echo "gettimeofday $gettimeofday"
850 ##########################################
856 int main(int argc, char **argv)
861 if compile_prog "" "" "fdatasync"; then
864 echo "fdatasync $fdatasync"
866 ##########################################
867 # sync_file_range() probe
873 #include <linux/fs.h>
874 int main(int argc, char **argv)
876 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
877 SYNC_FILE_RANGE_WAIT_AFTER;
878 return sync_file_range(0, 0, 0, flags);
881 if compile_prog "" "" "sync_file_range"; then
882 sync_file_range="yes"
884 echo "sync_file_range $sync_file_range"
886 ##########################################
887 # ext4 move extent probe
891 #include <sys/ioctl.h>
892 int main(int argc, char **argv)
894 struct move_extent me;
895 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
898 if compile_prog "" "" "ext4 move extent" ; then
900 elif test $targetos = "Linux" ; then
901 # On Linux, just default to it on and let it error at runtime if we really
902 # don't have it. None of my updated systems have it defined, but it does
903 # work. Takes a while to bubble back.
906 echo "EXT4 move extent $ext4_me"
908 ##########################################
914 int main(int argc, char **argv)
916 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
919 if compile_prog "" "" "linux splice"; then
922 echo "Linux splice(2) $linux_splice"
924 ##########################################
929 #include <guasi_syscalls.h>
930 int main(int argc, char **argv)
932 guasi_t ctx = guasi_create(0, 0, 0);
936 if compile_prog "" "" "guasi"; then
941 ##########################################
945 #include <nvm/nvm_primitives.h>
946 int main(int argc, char **argv)
948 nvm_version_t ver_info;
951 handle = nvm_get_handle(0, &ver_info);
952 return nvm_atomic_write(handle, 0, 0, 0);
955 if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
956 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
959 echo "Fusion-io atomic engine $fusion_aw"
961 ##########################################
966 int main(int argc, char **argv)
968 return numa_available();
971 if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
975 echo "libnuma $libnuma"
977 ##########################################
978 # libnuma 2.x version API
979 if test "$libnuma" = "yes" ; then
983 int main(int argc, char **argv)
985 struct bitmask *mask = numa_parse_nodestring(NULL);
986 return mask->size == 0;
989 if compile_prog "" "" "libnuma api"; then
992 echo "libnuma v2 $libnuma_v2"
995 ##########################################
1000 int main(int argc, char **argv)
1002 static char *string = "This is a string";
1003 strsep(&string, "needle");
1007 if compile_prog "" "" "strsep"; then
1010 echo "strsep $strsep"
1012 ##########################################
1013 # strcasestr() probe
1017 int main(int argc, char **argv)
1019 return strcasestr(argv[0], argv[1]) != NULL;
1022 if compile_prog "" "" "strcasestr"; then
1025 echo "strcasestr $strcasestr"
1027 ##########################################
1032 int main(int argc, char **argv)
1034 static char dst[64];
1035 static char *string = "This is a string";
1036 memset(dst, 0, sizeof(dst));
1037 strlcat(dst, string, sizeof(dst));
1041 if compile_prog "" "" "strlcat"; then
1044 echo "strlcat $strlcat"
1046 ##########################################
1047 # getopt_long_only() probe
1048 getopt_long_only="no"
1053 int main(int argc, char **argv)
1055 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1059 if compile_prog "" "" "getopt_long_only"; then
1060 getopt_long_only="yes"
1062 echo "getopt_long_only() $getopt_long_only"
1064 ##########################################
1068 #include <sys/socket.h>
1069 #include <arpa/inet.h>
1071 int main(int argc, char **argv)
1074 return inet_aton(NULL, &in);
1077 if compile_prog "" "" "inet_aton"; then
1080 echo "inet_aton $inet_aton"
1082 ##########################################
1086 #include <sys/socket.h>
1087 int main(int argc, char **argv)
1093 if compile_prog "" "" "socklen_t"; then
1096 echo "socklen_t $socklen_t"
1098 ##########################################
1099 # Whether or not __thread is supported for TLS
1103 static __thread int ret;
1104 int main(int argc, char **argv)
1109 if compile_prog "" "" "__thread"; then
1112 echo "__thread $tls_thread"
1114 ##########################################
1115 # Check if we have required gtk/glib support for gfio
1117 if test "$gfio_check" = "yes" ; then
1121 #include <gtk/gtk.h>
1124 gdk_threads_enter();
1125 gdk_threads_leave();
1127 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
1130 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1131 ORG_LDFLAGS=$LDFLAGS
1132 LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1133 if test "$?" != "0" ; then
1134 echo "configure: gtk and gthread not found"
1137 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1138 if test "$?" != "0" ; then
1139 echo "configure: gtk and gthread not found"
1142 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1144 if test "$r" != "0" ; then
1146 GFIO_LIBS="$LIBS $GTK_LIBS"
1147 CFLAGS="$CFLAGS $GTK_CFLAGS"
1149 echo "GTK found, but need version 2.18 or higher"
1153 echo "Please install gtk and gdk libraries"
1156 LDFLAGS=$ORG_LDFLAGS
1159 if test "$gfio_check" = "yes" ; then
1160 echo "gtk 2.18 or higher $gfio"
1163 # Check whether we have getrusage(RUSAGE_THREAD)
1166 #include <sys/time.h>
1167 #include <sys/resource.h>
1168 int main(int argc, char **argv)
1171 getrusage(RUSAGE_THREAD, &ru);
1175 if compile_prog "" "" "RUSAGE_THREAD"; then
1178 echo "RUSAGE_THREAD $rusage_thread"
1180 ##########################################
1181 # Check whether we have SCHED_IDLE
1185 int main(int argc, char **argv)
1187 struct sched_param p;
1188 return sched_setscheduler(0, SCHED_IDLE, &p);
1191 if compile_prog "" "" "SCHED_IDLE"; then
1194 echo "SCHED_IDLE $sched_idle"
1196 ##########################################
1197 # Check whether we have TCP_NODELAY
1201 #include <sys/types.h>
1202 #include <sys/socket.h>
1203 #include <netinet/tcp.h>
1204 int main(int argc, char **argv)
1206 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1209 if compile_prog "" "" "TCP_NODELAY"; then
1212 echo "TCP_NODELAY $tcp_nodelay"
1214 ##########################################
1215 # Check whether we have SO_SNDBUF
1219 #include <sys/types.h>
1220 #include <sys/socket.h>
1221 #include <netinet/tcp.h>
1222 int main(int argc, char **argv)
1224 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1225 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1228 if compile_prog "" "" "SO_SNDBUF"; then
1231 echo "Net engine window_size $window_size"
1233 ##########################################
1234 # Check whether we have TCP_MAXSEG
1238 #include <sys/types.h>
1239 #include <sys/socket.h>
1240 #include <netinet/tcp.h>
1241 #include <arpa/inet.h>
1242 #include <netinet/in.h>
1243 int main(int argc, char **argv)
1245 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1248 if compile_prog "" "" "TCP_MAXSEG"; then
1251 echo "TCP_MAXSEG $mss"
1253 ##########################################
1254 # Check whether we have RLIMIT_MEMLOCK
1257 #include <sys/time.h>
1258 #include <sys/resource.h>
1259 int main(int argc, char **argv)
1262 return getrlimit(RLIMIT_MEMLOCK, &rl);
1265 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1266 rlimit_memlock="yes"
1268 echo "RLIMIT_MEMLOCK $rlimit_memlock"
1270 ##########################################
1271 # Check whether we have pwritev/preadv
1275 #include <sys/uio.h>
1276 int main(int argc, char **argv)
1278 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1281 if compile_prog "" "" "pwritev"; then
1284 echo "pwritev/preadv $pwritev"
1286 ##########################################
1287 # Check whether we have pwritev2/preadv2
1291 #include <sys/uio.h>
1292 int main(int argc, char **argv)
1294 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1297 if compile_prog "" "" "pwritev2"; then
1300 echo "pwritev2/preadv2 $pwritev2"
1302 ##########################################
1303 # Check whether we have the required functions for ipv6
1306 #include <sys/types.h>
1307 #include <sys/socket.h>
1308 #include <netinet/in.h>
1311 int main(int argc, char **argv)
1313 struct addrinfo hints;
1314 struct in6_addr addr;
1317 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1319 printf("%s\n", gai_strerror(ret));
1324 if compile_prog "" "" "ipv6"; then
1327 echo "IPv6 helpers $ipv6"
1329 ##########################################
1333 #include <rbd/librbd.h>
1335 int main(int argc, char **argv)
1339 rados_ioctx_t io_ctx;
1340 const char pool[] = "rbd";
1342 int major, minor, extra;
1343 rbd_version(&major, &minor, &extra);
1345 rados_ioctx_create(cluster, pool, &io_ctx);
1349 if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
1350 LIBS="-lrbd -lrados $LIBS"
1353 echo "Rados Block Device engine $rbd"
1355 ##########################################
1356 # check for rbd_poll
1358 if test "$rbd" = "yes"; then
1360 #include <rbd/librbd.h>
1361 #include <sys/eventfd.h>
1363 int main(int argc, char **argv)
1366 rbd_completion_t comp;
1368 int fd = eventfd(0, EFD_NONBLOCK);
1369 rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1370 rbd_poll_io_events(image, comp, 1);
1375 if compile_prog "" "-lrbd -lrados" "rbd"; then
1378 echo "rbd_poll $rbd_poll"
1381 ##########################################
1382 # check for rbd_invaidate_cache()
1384 if test "$rbd" = "yes"; then
1386 #include <rbd/librbd.h>
1388 int main(int argc, char **argv)
1392 return rbd_invalidate_cache(image);
1395 if compile_prog "" "-lrbd -lrados" "rbd"; then
1398 echo "rbd_invalidate_cache $rbd_inval"
1401 ##########################################
1405 #include <rbd/librbd.h>
1406 #include <zipkin_c.h>
1408 int main(int argc, char **argv)
1411 struct blkin_trace_info t_info;
1412 blkin_init_trace_info(&t_info);
1413 rbd_completion_t completion;
1418 r = rbd_aio_write_traced(image, off, len, buf, completion, &t_info);
1422 if test "$disable_rbd" != "yes" && test "$disable_rbd_blkin" != "yes" \
1423 && compile_prog "" "-lrbd -lrados -lblkin" "rbd_blkin"; then
1424 LIBS="-lblkin $LIBS"
1427 echo "rbd blkin tracing $rbd_blkin"
1429 ##########################################
1430 # Check whether we have setvbuf
1434 int main(int argc, char **argv)
1438 setvbuf(f, buf, _IOFBF, sizeof(buf));
1442 if compile_prog "" "" "setvbuf"; then
1445 echo "setvbuf $setvbuf"
1450 #include <glusterfs/api/glfs.h>
1452 int main(int argc, char **argv)
1455 glfs_t *g = glfs_new("foo");
1460 if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1461 LIBS="-lgfapi -lglusterfs $LIBS"
1464 echo "Gluster API engine $gfapi"
1466 ##########################################
1467 # check for gfapi fadvise support
1468 if test "$gfapi" = "yes" ; then
1471 #include <glusterfs/api/glfs.h>
1473 int main(int argc, char **argv)
1476 int ret = glfs_fadvise(fd, 0, 0, 1);
1481 if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1484 echo "Gluster API use fadvise $gf_fadvise"
1487 ##########################################
1488 # check for gfapi trim support
1490 if test "$gfapi" = "yes" ; then
1492 #include <glusterfs/api/glfs.h>
1494 int main(int argc, char **argv)
1496 return glfs_discard_async(NULL, 0, 0);
1499 if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1502 echo "Gluster API trim support $gf_trim"
1505 ##########################################
1506 # Check if we support stckf on s390
1507 s390_z196_facilities="no"
1509 #define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1510 int main(int argc, char **argv)
1512 /* We want just 1 double word to be returned. */
1513 register unsigned long reg0 asm("0") = 0;
1514 unsigned long stfle_bits;
1515 asm volatile(".machine push" "\n\t"
1516 ".machine \"z9-109\"" "\n\t"
1519 : "=QS" (stfle_bits), "+d" (reg0)
1522 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1528 if compile_prog "" "" "s390_z196_facilities"; then
1530 if [[ $? -eq 0 ]]; then
1531 s390_z196_facilities="yes"
1534 echo "s390_z196_facilities $s390_z196_facilities"
1536 ##########################################
1537 # Check if we have required environment variables configured for libhdfs
1538 if test "$libhdfs" = "yes" ; then
1540 if test "$JAVA_HOME" = "" ; then
1541 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1544 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1545 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1548 if test "$FIO_LIBHDFS_LIB" = "" ; then
1549 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1552 if test "$hdfs_conf_error" = "1" ; then
1556 if test "$FIO_HDFS_CPU" = "x86_64" ; then
1557 FIO_HDFS_CPU="amd64"
1560 echo "HDFS engine $libhdfs"
1562 ##########################################
1563 # Check whether we have MTD
1567 #include <mtd/mtd-user.h>
1568 #include <sys/ioctl.h>
1569 int main(int argc, char **argv)
1571 struct mtd_write_req ops;
1572 struct mtd_info_user info;
1573 memset(&ops, 0, sizeof(ops));
1574 info.type = MTD_MLCNANDFLASH;
1575 return ioctl(0, MEMGETINFO, &info);
1578 if compile_prog "" "" "mtd"; then
1583 ##########################################
1584 # Check whether we have libpmem
1587 #include <libpmem.h>
1588 int main(int argc, char **argv)
1591 rc = pmem_is_pmem(0, 0);
1595 if compile_prog "" "-lpmem" "libpmem"; then
1599 echo "libpmem $libpmem"
1601 ##########################################
1602 # Check whether we have libpmemblk
1603 # libpmem is a prerequisite
1605 if test "$libpmem" = "yes"; then
1607 #include <libpmemblk.h>
1608 int main(int argc, char **argv)
1611 pbp = pmemblk_open("", 0);
1615 if compile_prog "" "-lpmemblk" "libpmemblk"; then
1617 LIBS="-lpmemblk $LIBS"
1620 echo "libpmemblk $libpmemblk"
1622 # Choose the ioengines
1623 if test "$libpmem" = "yes" && test "$disable_pmem" = "no"; then
1625 if test "$libpmemblk" = "yes"; then
1630 ##########################################
1631 # Report whether pmemblk engine is enabled
1632 echo "NVML pmemblk engine $pmemblk"
1634 ##########################################
1635 # Report whether dev-dax engine is enabled
1636 echo "NVML dev-dax engine $devdax"
1638 # Check if we have lex/yacc available
1643 if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
1644 if test "$targetos" != "SunOS" ; then
1645 LEX=$(which lex 2> /dev/null)
1646 if test -x "$LEX" ; then
1649 YACC=$(which bison 2> /dev/null)
1650 if test -x "$YACC" ; then
1654 YACC=$(which yacc 2> /dev/null)
1655 if test -x "$YACC" ; then
1659 if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1663 if test "$arith" = "yes" ; then
1665 extern int yywrap(void);
1667 int main(int argc, char **argv)
1673 if compile_prog "" "-ll" "lex"; then
1682 # Check if lex fails using -o
1683 if test "$arith" = "yes" ; then
1684 if test "$force_no_lex_o" = "yes" ; then
1687 $LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1688 if test "$?" = "0" ; then
1696 echo "lex/yacc for arithmetic $arith"
1698 ##########################################
1699 # Check whether we have setmntent/getmntent
1704 int main(int argc, char **argv)
1706 FILE *mtab = setmntent(NULL, "r");
1707 struct mntent *mnt = getmntent(mtab);
1712 if compile_prog "" "" "getmntent"; then
1715 echo "getmntent $getmntent"
1717 ##########################################
1718 # Check whether we have getmntinfo
1719 # These are originally added for BSDs, but may also work
1720 # on other operating systems with getmntinfo(3).
1722 # getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
1723 # Note that NetBSD needs -Werror to catch warning as error.
1727 #include <sys/param.h>
1728 #include <sys/mount.h>
1729 int main(int argc, char **argv)
1732 return getmntinfo(&st, MNT_NOWAIT);
1735 if compile_prog "-Werror" "" "getmntinfo"; then
1738 echo "getmntinfo $getmntinfo"
1740 # getmntinfo(3) for NetBSD.
1741 getmntinfo_statvfs="no"
1744 #include <sys/statvfs.h>
1745 int main(int argc, char **argv)
1748 return getmntinfo(&st, MNT_NOWAIT);
1751 # Skip the test if the one with statfs arg is detected.
1752 if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
1753 getmntinfo_statvfs="yes"
1754 echo "getmntinfo_statvfs $getmntinfo_statvfs"
1757 ##########################################
1758 # Check whether we have _Static_assert
1764 #ifdef __compiler_offsetof
1765 #define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
1767 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1770 #define container_of(ptr, type, member) ({ \
1771 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
1772 (type *)( (char *)__mptr - offsetof(type,member) );})
1778 int main(int argc, char **argv)
1780 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
1784 if compile_prog "" "" "static_assert"; then
1787 echo "Static Assert $static_assert"
1789 ##########################################
1790 # Check whether we have bool / stdbool.h
1793 #include <stdbool.h>
1794 int main(int argc, char **argv)
1797 return var != false;
1800 if compile_prog "" "" "bool"; then
1803 echo "bool $have_bool"
1805 ##########################################
1806 # check march=armv8-a+crc+crypto
1807 march_armv8_a_crc_crypto="no"
1808 if test "$cpu" = "arm64" ; then
1815 if compile_prog "-march=armv8-a+crc+crypto" "" ""; then
1816 march_armv8_a_crc_crypto="yes"
1817 CFLAGS="$CFLAGS -march=armv8-a+crc+crypto -DARCH_HAVE_CRC_CRYPTO"
1820 echo "march_armv8_a_crc_crypto $march_armv8_a_crc_crypto"
1823 #############################################################################
1825 if test "$wordsize" = "64" ; then
1826 output_sym "CONFIG_64BIT"
1827 elif test "$wordsize" = "32" ; then
1828 output_sym "CONFIG_32BIT"
1830 fatal "Unknown wordsize!"
1832 if test "$bigendian" = "yes" ; then
1833 output_sym "CONFIG_BIG_ENDIAN"
1835 output_sym "CONFIG_LITTLE_ENDIAN"
1837 if test "$zlib" = "yes" ; then
1838 output_sym "CONFIG_ZLIB"
1840 if test "$libaio" = "yes" ; then
1841 output_sym "CONFIG_LIBAIO"
1843 if test "$posix_aio" = "yes" ; then
1844 output_sym "CONFIG_POSIXAIO"
1846 if test "$posix_aio_fsync" = "yes" ; then
1847 output_sym "CONFIG_POSIXAIO_FSYNC"
1849 if test "$linux_fallocate" = "yes" ; then
1850 output_sym "CONFIG_LINUX_FALLOCATE"
1852 if test "$posix_fallocate" = "yes" ; then
1853 output_sym "CONFIG_POSIX_FALLOCATE"
1855 if test "$fdatasync" = "yes" ; then
1856 output_sym "CONFIG_FDATASYNC"
1858 if test "$sync_file_range" = "yes" ; then
1859 output_sym "CONFIG_SYNC_FILE_RANGE"
1861 if test "$sfaa" = "yes" ; then
1862 output_sym "CONFIG_SFAA"
1864 if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
1865 output_sym "CONFIG_RDMA"
1867 if test "$clock_gettime" = "yes" ; then
1868 output_sym "CONFIG_CLOCK_GETTIME"
1870 if test "$clock_monotonic" = "yes" ; then
1871 output_sym "CONFIG_CLOCK_MONOTONIC"
1873 if test "$clock_monotonic_raw" = "yes" ; then
1874 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
1876 if test "$clock_monotonic_precise" = "yes" ; then
1877 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
1879 if test "$clockid_t" = "yes"; then
1880 output_sym "CONFIG_CLOCKID_T"
1882 if test "$gettimeofday" = "yes" ; then
1883 output_sym "CONFIG_GETTIMEOFDAY"
1885 if test "$posix_fadvise" = "yes" ; then
1886 output_sym "CONFIG_POSIX_FADVISE"
1888 if test "$linux_3arg_affinity" = "yes" ; then
1889 output_sym "CONFIG_3ARG_AFFINITY"
1890 elif test "$linux_2arg_affinity" = "yes" ; then
1891 output_sym "CONFIG_2ARG_AFFINITY"
1893 if test "$strsep" = "yes" ; then
1894 output_sym "CONFIG_STRSEP"
1896 if test "$strcasestr" = "yes" ; then
1897 output_sym "CONFIG_STRCASESTR"
1899 if test "$strlcat" = "yes" ; then
1900 output_sym "CONFIG_STRLCAT"
1902 if test "$getopt_long_only" = "yes" ; then
1903 output_sym "CONFIG_GETOPT_LONG_ONLY"
1905 if test "$inet_aton" = "yes" ; then
1906 output_sym "CONFIG_INET_ATON"
1908 if test "$socklen_t" = "yes" ; then
1909 output_sym "CONFIG_SOCKLEN_T"
1911 if test "$ext4_me" = "yes" ; then
1912 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1914 if test "$linux_splice" = "yes" ; then
1915 output_sym "CONFIG_LINUX_SPLICE"
1917 if test "$guasi" = "yes" ; then
1918 output_sym "CONFIG_GUASI"
1920 if test "$fusion_aw" = "yes" ; then
1921 output_sym "CONFIG_FUSION_AW"
1923 if test "$libnuma_v2" = "yes" ; then
1924 output_sym "CONFIG_LIBNUMA"
1926 if test "$solaris_aio" = "yes" ; then
1927 output_sym "CONFIG_SOLARISAIO"
1929 if test "$tls_thread" = "yes" ; then
1930 output_sym "CONFIG_TLS_THREAD"
1932 if test "$rusage_thread" = "yes" ; then
1933 output_sym "CONFIG_RUSAGE_THREAD"
1935 if test "$gfio" = "yes" ; then
1936 echo "CONFIG_GFIO=y" >> $config_host_mak
1938 if test "$esx" = "yes" ; then
1939 output_sym "CONFIG_ESX"
1940 output_sym "CONFIG_NO_SHM"
1942 if test "$sched_idle" = "yes" ; then
1943 output_sym "CONFIG_SCHED_IDLE"
1945 if test "$tcp_nodelay" = "yes" ; then
1946 output_sym "CONFIG_TCP_NODELAY"
1948 if test "$window_size" = "yes" ; then
1949 output_sym "CONFIG_NET_WINDOWSIZE"
1951 if test "$mss" = "yes" ; then
1952 output_sym "CONFIG_NET_MSS"
1954 if test "$rlimit_memlock" = "yes" ; then
1955 output_sym "CONFIG_RLIMIT_MEMLOCK"
1957 if test "$pwritev" = "yes" ; then
1958 output_sym "CONFIG_PWRITEV"
1960 if test "$pwritev2" = "yes" ; then
1961 output_sym "CONFIG_PWRITEV2"
1963 if test "$ipv6" = "yes" ; then
1964 output_sym "CONFIG_IPV6"
1966 if test "$rbd" = "yes" ; then
1967 output_sym "CONFIG_RBD"
1969 if test "$rbd_poll" = "yes" ; then
1970 output_sym "CONFIG_RBD_POLL"
1972 if test "$rbd_inval" = "yes" ; then
1973 output_sym "CONFIG_RBD_INVAL"
1975 if test "$rbd_blkin" = "yes" ; then
1976 output_sym "CONFIG_RBD_BLKIN"
1978 if test "$setvbuf" = "yes" ; then
1979 output_sym "CONFIG_SETVBUF"
1981 if test "$s390_z196_facilities" = "yes" ; then
1982 output_sym "CONFIG_S390_Z196_FACILITIES"
1983 CFLAGS="$CFLAGS -march=z9-109"
1985 if test "$gfapi" = "yes" ; then
1986 output_sym "CONFIG_GFAPI"
1988 if test "$gf_fadvise" = "yes" ; then
1989 output_sym "CONFIG_GF_FADVISE"
1991 if test "$gf_trim" = "yes" ; then
1992 output_sym "CONFIG_GF_TRIM"
1994 if test "$libhdfs" = "yes" ; then
1995 output_sym "CONFIG_LIBHDFS"
1996 echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
1997 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
1998 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
1999 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
2001 if test "$mtd" = "yes" ; then
2002 output_sym "CONFIG_MTD"
2004 if test "$pmemblk" = "yes" ; then
2005 output_sym "CONFIG_PMEMBLK"
2007 if test "$devdax" = "yes" ; then
2008 output_sym "CONFIG_LINUX_DEVDAX"
2010 if test "$arith" = "yes" ; then
2011 output_sym "CONFIG_ARITHMETIC"
2012 if test "$yacc_is_bison" = "yes" ; then
2013 echo "YACC=$YACC -y" >> $config_host_mak
2015 echo "YACC=$YACC" >> $config_host_mak
2017 if test "$lex_use_o" = "yes" ; then
2018 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
2021 if test "$getmntent" = "yes" ; then
2022 output_sym "CONFIG_GETMNTENT"
2024 if test "$getmntinfo" = "yes" ; then
2025 output_sym "CONFIG_GETMNTINFO"
2027 if test "$getmntinfo_statvfs" = "yes" ; then
2028 output_sym "CONFIG_GETMNTINFO_STATVFS"
2030 if test "$static_assert" = "yes" ; then
2031 output_sym "CONFIG_STATIC_ASSERT"
2033 if test "$have_bool" = "yes" ; then
2034 output_sym "CONFIG_HAVE_BOOL"
2037 if test "$zlib" = "no" ; then
2038 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
2041 echo "LIBS+=$LIBS" >> $config_host_mak
2042 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
2043 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
2044 echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
2045 echo "CC=$cc" >> $config_host_mak
2046 echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
2047 echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
2049 if [ `dirname $0` != "." -a ! -e Makefile ]; then
2050 cat > Makefile <<EOF
2051 SRCDIR:=`dirname $0`
2052 include \$(SRCDIR)/Makefile