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
271 # Error at compile time linking of weak/partial symbols if possible...
278 if compile_prog "" "-Wl,-no_weak_imports" "disable weak symbols"; then
279 echo "Disabling weak symbols"
280 LDFLAGS="$LDFLAGS -Wl,-no_weak_imports"
284 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
285 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
288 LIBS="-lnsl -lsocket"
291 echo "Forcing known good options on Windows"
292 if test -z "$CC" ; then
293 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
294 CC="i686-w64-mingw32-gcc"
295 if test -e "../zlib/contrib/vstudio/vc14/x86/ZlibStatReleaseWithoutAsm/zlibstat.lib"; then
296 echo "Building with zlib support"
297 output_sym "CONFIG_ZLIB"
298 echo "LIBS=../zlib/contrib/vstudio/vc14/x86/ZlibStatReleaseWithoutAsm/zlibstat.lib" >> $config_host_mak
301 CC="x86_64-w64-mingw32-gcc"
302 if test -e "../zlib/contrib/vstudio/vc14/x64/ZlibStatReleaseWithoutAsm/zlibstat.lib"; then
303 echo "Building with zlib support"
304 output_sym "CONFIG_ZLIB"
305 echo "LIBS=../zlib/contrib/vstudio/vc14/x64/ZlibStatReleaseWithoutAsm/zlibstat.lib" >> $config_host_mak
309 output_sym "CONFIG_LITTLE_ENDIAN"
310 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
311 output_sym "CONFIG_32BIT"
313 output_sym "CONFIG_64BIT_LLP64"
315 output_sym "CONFIG_SOCKLEN_T"
316 output_sym "CONFIG_SFAA"
317 output_sym "CONFIG_RUSAGE_THREAD"
318 output_sym "CONFIG_WINDOWSAIO"
319 output_sym "CONFIG_FDATASYNC"
320 output_sym "CONFIG_CLOCK_MONOTONIC"
321 output_sym "CONFIG_GETTIMEOFDAY"
322 output_sym "CONFIG_CLOCK_GETTIME"
323 output_sym "CONFIG_SCHED_IDLE"
324 output_sym "CONFIG_TCP_NODELAY"
325 output_sym "CONFIG_TLS_THREAD"
326 output_sym "CONFIG_STATIC_ASSERT"
327 output_sym "CONFIG_IPV6"
328 echo "CC=$CC" >> $config_host_mak
329 echo "BUILD_CFLAGS=$CFLAGS -I../zlib -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
335 if test ! -z "$cpu" ; then
336 # command line argument
338 elif check_define __i386__ ; then
340 elif check_define __x86_64__ ; then
342 elif check_define __sparc__ ; then
343 if check_define __arch64__ ; then
348 elif check_define _ARCH_PPC ; then
349 if check_define _ARCH_PPC64 ; then
354 elif check_define __mips__ ; then
356 elif check_define __ia64__ ; then
358 elif check_define __s390__ ; then
359 if check_define __s390x__ ; then
364 elif check_define __arm__ ; then
366 elif check_define __aarch64__ ; then
368 elif check_define __hppa__ ; then
374 # Normalise host CPU name and set ARCH.
376 ia64|ppc|ppc64|s390|s390x|sparc64)
379 i386|i486|i586|i686|i86pc|BePC)
391 hppa|parisc|parisc64)
405 if test -z "$CC" ; then
406 if test "$targetos" = "FreeBSD"; then
415 cc="${CC-${cross_prefix}gcc}"
417 ##########################################
418 # check cross compile
427 if compile_prog "" "" "cross"; then
428 $TMPE 2>/dev/null || cross_compile="yes"
430 fatal "compile test failed"
433 ##########################################
436 if test "$cross_compile" = "no" ; then
438 #include <inttypes.h>
441 volatile uint32_t i=0x01234567;
442 return (*((uint8_t*)(&i))) == 0x67;
445 if compile_prog "" "" "endian"; then
446 $TMPE && bigendian="yes"
449 # If we're cross compiling, try our best to work it out and rely on the
450 # run-time check to fail if we get it wrong.
455 #if __BYTE_ORDER != __BIG_ENDIAN
456 # error "Unknown endianness"
460 compile_prog "" "" "endian" && bigendian="yes"
461 check_define "__ARMEB__" && bigendian="yes"
462 check_define "__MIPSEB__" && bigendian="yes"
466 echo "Operating system $targetos"
468 echo "Big endian $bigendian"
470 echo "Cross compile $cross_compile"
473 ##########################################
474 # See if we need to build a static build
475 if test "$build_static" = "yes" ; then
476 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
477 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
481 echo "Static build $build_static"
483 ##########################################
488 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
491 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
495 if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
497 elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
500 fatal "Unknown wordsize"
502 echo "Wordsize $wordsize"
504 ##########################################
512 if (inflateInit(&stream) != Z_OK)
517 if compile_prog "" "-lz" "zlib" ; then
523 ##########################################
526 if test "$esx" != "yes" ; then
536 if compile_prog "" "-laio" "libaio" ; then
540 if test "$libaio" = "yes" ; then
541 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
546 echo "Linux AIO support $libaio"
548 ##########################################
561 if compile_prog "" "" "posixaio" ; then
563 elif compile_prog "" "-lrt" "posixaio"; then
568 echo "POSIX AIO support $posix_aio"
569 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
571 ##########################################
572 # posix aio fsync probe
574 if test "$posix_aio" = "yes" ; then
581 return aio_fsync(O_SYNC, &cb);
585 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
589 echo "POSIX AIO fsync $posix_aio_fsync"
591 ##########################################
595 #include <sys/types.h>
596 #include <sys/asynch.h>
601 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
605 if compile_prog "" "-laio" "solarisaio" ; then
609 echo "Solaris AIO support $solaris_aio"
611 ##########################################
612 # __sync_fetch_and_add test
615 #include <inttypes.h>
616 static int sfaa(uint64_t *ptr)
618 return __sync_fetch_and_add(ptr, 0);
621 int main(int argc, char **argv)
628 if compile_prog "" "" "__sync_fetch_and_add()" ; then
631 echo "__sync_fetch_and_add $sfaa"
633 ##########################################
638 #include <infiniband/arch.h>
639 int main(int argc, char **argv)
641 struct ibv_pd *pd = ibv_alloc_pd(NULL);
645 if compile_prog "" "-libverbs" "libverbs" ; then
647 LIBS="-libverbs $LIBS"
649 echo "libverbs $libverbs"
651 ##########################################
656 #include <rdma/rdma_cma.h>
657 int main(int argc, char **argv)
659 rdma_destroy_qp(NULL);
663 if compile_prog "" "-lrdmacm" "rdma"; then
665 LIBS="-lrdmacm $LIBS"
667 echo "rdmacm $rdmacm"
669 ##########################################
670 # Linux fallocate probe
675 #include <linux/falloc.h>
676 int main(int argc, char **argv)
678 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
682 if compile_prog "" "" "linux_fallocate"; then
683 linux_fallocate="yes"
685 echo "Linux fallocate $linux_fallocate"
687 ##########################################
688 # POSIX fadvise probe
693 int main(int argc, char **argv)
695 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
699 if compile_prog "" "" "posix_fadvise"; then
702 echo "POSIX fadvise $posix_fadvise"
704 ##########################################
705 # POSIX fallocate probe
710 int main(int argc, char **argv)
712 int r = posix_fallocate(0, 0, 1024);
716 if compile_prog "" "" "posix_fallocate"; then
717 posix_fallocate="yes"
719 echo "POSIX fallocate $posix_fallocate"
721 ##########################################
722 # sched_set/getaffinity 2 or 3 argument test
723 linux_2arg_affinity="no"
724 linux_3arg_affinity="no"
727 int main(int argc, char **argv)
730 return sched_setaffinity(0, sizeof(mask), &mask);
733 if compile_prog "" "" "sched_setaffinity(,,)"; then
734 linux_3arg_affinity="yes"
738 int main(int argc, char **argv)
741 return sched_setaffinity(0, &mask);
744 if compile_prog "" "" "sched_setaffinity(,)"; then
745 linux_2arg_affinity="yes"
748 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
749 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
751 ##########################################
752 # clock_gettime probe
757 int main(int argc, char **argv)
759 return clock_gettime(0, NULL);
762 if compile_prog "" "" "clock_gettime"; then
764 elif compile_prog "" "-lrt" "clock_gettime"; then
768 echo "clock_gettime $clock_gettime"
770 ##########################################
771 # CLOCK_MONOTONIC probe
773 if test "$clock_gettime" = "yes" ; then
777 int main(int argc, char **argv)
779 return clock_gettime(CLOCK_MONOTONIC, NULL);
782 if compile_prog "" "$LIBS" "clock monotonic"; then
783 clock_monotonic="yes"
786 echo "CLOCK_MONOTONIC $clock_monotonic"
788 ##########################################
789 # CLOCK_MONOTONIC_RAW probe
790 clock_monotonic_raw="no"
791 if test "$clock_gettime" = "yes" ; then
795 int main(int argc, char **argv)
797 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
800 if compile_prog "" "$LIBS" "clock monotonic"; then
801 clock_monotonic_raw="yes"
804 echo "CLOCK_MONOTONIC_RAW $clock_monotonic_raw"
806 ##########################################
807 # CLOCK_MONOTONIC_PRECISE probe
808 clock_monotonic_precise="no"
809 if test "$clock_gettime" = "yes" ; then
813 int main(int argc, char **argv)
815 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
818 if compile_prog "" "$LIBS" "clock monotonic precise"; then
819 clock_monotonic_precise="yes"
822 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
824 ##########################################
829 int main(int argc, char **argv)
831 volatile clockid_t cid;
832 memset(&cid, 0, sizeof(cid));
836 if compile_prog "" "$LIBS" "clockid_t"; then
839 echo "clockid_t $clockid_t"
841 ##########################################
842 # gettimeofday() probe
845 #include <sys/time.h>
847 int main(int argc, char **argv)
850 return gettimeofday(&tv, NULL);
853 if compile_prog "" "" "gettimeofday"; then
856 echo "gettimeofday $gettimeofday"
858 ##########################################
864 int main(int argc, char **argv)
869 if compile_prog "" "" "fdatasync"; then
872 echo "fdatasync $fdatasync"
874 ##########################################
875 # sync_file_range() probe
881 #include <linux/fs.h>
882 int main(int argc, char **argv)
884 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
885 SYNC_FILE_RANGE_WAIT_AFTER;
886 return sync_file_range(0, 0, 0, flags);
889 if compile_prog "" "" "sync_file_range"; then
890 sync_file_range="yes"
892 echo "sync_file_range $sync_file_range"
894 ##########################################
895 # ext4 move extent probe
899 #include <sys/ioctl.h>
900 int main(int argc, char **argv)
902 struct move_extent me;
903 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
906 if compile_prog "" "" "ext4 move extent" ; then
908 elif test $targetos = "Linux" ; then
909 # On Linux, just default to it on and let it error at runtime if we really
910 # don't have it. None of my updated systems have it defined, but it does
911 # work. Takes a while to bubble back.
914 echo "EXT4 move extent $ext4_me"
916 ##########################################
922 int main(int argc, char **argv)
924 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
927 if compile_prog "" "" "linux splice"; then
930 echo "Linux splice(2) $linux_splice"
932 ##########################################
937 #include <guasi_syscalls.h>
938 int main(int argc, char **argv)
940 guasi_t ctx = guasi_create(0, 0, 0);
944 if compile_prog "" "" "guasi"; then
949 ##########################################
953 #include <nvm/nvm_primitives.h>
954 int main(int argc, char **argv)
956 nvm_version_t ver_info;
959 handle = nvm_get_handle(0, &ver_info);
960 return nvm_atomic_write(handle, 0, 0, 0);
963 if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
964 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
967 echo "Fusion-io atomic engine $fusion_aw"
969 ##########################################
974 int main(int argc, char **argv)
976 return numa_available();
979 if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
983 echo "libnuma $libnuma"
985 ##########################################
986 # libnuma 2.x version API
987 if test "$libnuma" = "yes" ; then
991 int main(int argc, char **argv)
993 struct bitmask *mask = numa_parse_nodestring(NULL);
994 return mask->size == 0;
997 if compile_prog "" "" "libnuma api"; then
1000 echo "libnuma v2 $libnuma_v2"
1003 ##########################################
1008 int main(int argc, char **argv)
1010 static char *string = "This is a string";
1011 strsep(&string, "needle");
1015 if compile_prog "" "" "strsep"; then
1018 echo "strsep $strsep"
1020 ##########################################
1021 # strcasestr() probe
1025 int main(int argc, char **argv)
1027 return strcasestr(argv[0], argv[1]) != NULL;
1030 if compile_prog "" "" "strcasestr"; then
1033 echo "strcasestr $strcasestr"
1035 ##########################################
1040 int main(int argc, char **argv)
1042 static char dst[64];
1043 static char *string = "This is a string";
1044 memset(dst, 0, sizeof(dst));
1045 strlcat(dst, string, sizeof(dst));
1049 if compile_prog "" "" "strlcat"; then
1052 echo "strlcat $strlcat"
1054 ##########################################
1055 # getopt_long_only() probe
1056 getopt_long_only="no"
1061 int main(int argc, char **argv)
1063 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1067 if compile_prog "" "" "getopt_long_only"; then
1068 getopt_long_only="yes"
1070 echo "getopt_long_only() $getopt_long_only"
1072 ##########################################
1076 #include <sys/socket.h>
1077 #include <arpa/inet.h>
1079 int main(int argc, char **argv)
1082 return inet_aton(NULL, &in);
1085 if compile_prog "" "" "inet_aton"; then
1088 echo "inet_aton $inet_aton"
1090 ##########################################
1094 #include <sys/socket.h>
1095 int main(int argc, char **argv)
1101 if compile_prog "" "" "socklen_t"; then
1104 echo "socklen_t $socklen_t"
1106 ##########################################
1107 # Whether or not __thread is supported for TLS
1111 static __thread int ret;
1112 int main(int argc, char **argv)
1117 if compile_prog "" "" "__thread"; then
1120 echo "__thread $tls_thread"
1122 ##########################################
1123 # Check if we have required gtk/glib support for gfio
1125 if test "$gfio_check" = "yes" ; then
1129 #include <gtk/gtk.h>
1132 gdk_threads_enter();
1133 gdk_threads_leave();
1135 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
1138 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1139 ORG_LDFLAGS=$LDFLAGS
1140 LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1141 if test "$?" != "0" ; then
1142 echo "configure: gtk and gthread not found"
1145 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1146 if test "$?" != "0" ; then
1147 echo "configure: gtk and gthread not found"
1150 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1152 if test "$r" != "0" ; then
1154 GFIO_LIBS="$LIBS $GTK_LIBS"
1155 CFLAGS="$CFLAGS $GTK_CFLAGS"
1157 echo "GTK found, but need version 2.18 or higher"
1161 echo "Please install gtk and gdk libraries"
1164 LDFLAGS=$ORG_LDFLAGS
1167 if test "$gfio_check" = "yes" ; then
1168 echo "gtk 2.18 or higher $gfio"
1171 # Check whether we have getrusage(RUSAGE_THREAD)
1174 #include <sys/time.h>
1175 #include <sys/resource.h>
1176 int main(int argc, char **argv)
1179 getrusage(RUSAGE_THREAD, &ru);
1183 if compile_prog "" "" "RUSAGE_THREAD"; then
1186 echo "RUSAGE_THREAD $rusage_thread"
1188 ##########################################
1189 # Check whether we have SCHED_IDLE
1193 int main(int argc, char **argv)
1195 struct sched_param p;
1196 return sched_setscheduler(0, SCHED_IDLE, &p);
1199 if compile_prog "" "" "SCHED_IDLE"; then
1202 echo "SCHED_IDLE $sched_idle"
1204 ##########################################
1205 # Check whether we have TCP_NODELAY
1209 #include <sys/types.h>
1210 #include <sys/socket.h>
1211 #include <netinet/tcp.h>
1212 int main(int argc, char **argv)
1214 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1217 if compile_prog "" "" "TCP_NODELAY"; then
1220 echo "TCP_NODELAY $tcp_nodelay"
1222 ##########################################
1223 # Check whether we have SO_SNDBUF
1227 #include <sys/types.h>
1228 #include <sys/socket.h>
1229 #include <netinet/tcp.h>
1230 int main(int argc, char **argv)
1232 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1233 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1236 if compile_prog "" "" "SO_SNDBUF"; then
1239 echo "Net engine window_size $window_size"
1241 ##########################################
1242 # Check whether we have TCP_MAXSEG
1246 #include <sys/types.h>
1247 #include <sys/socket.h>
1248 #include <netinet/tcp.h>
1249 #include <arpa/inet.h>
1250 #include <netinet/in.h>
1251 int main(int argc, char **argv)
1253 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1256 if compile_prog "" "" "TCP_MAXSEG"; then
1259 echo "TCP_MAXSEG $mss"
1261 ##########################################
1262 # Check whether we have RLIMIT_MEMLOCK
1265 #include <sys/time.h>
1266 #include <sys/resource.h>
1267 int main(int argc, char **argv)
1270 return getrlimit(RLIMIT_MEMLOCK, &rl);
1273 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1274 rlimit_memlock="yes"
1276 echo "RLIMIT_MEMLOCK $rlimit_memlock"
1278 ##########################################
1279 # Check whether we have pwritev/preadv
1283 #include <sys/uio.h>
1284 int main(int argc, char **argv)
1286 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1289 if compile_prog "" "" "pwritev"; then
1292 echo "pwritev/preadv $pwritev"
1294 ##########################################
1295 # Check whether we have pwritev2/preadv2
1299 #include <sys/uio.h>
1300 int main(int argc, char **argv)
1302 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1305 if compile_prog "" "" "pwritev2"; then
1308 echo "pwritev2/preadv2 $pwritev2"
1310 ##########################################
1311 # Check whether we have the required functions for ipv6
1314 #include <sys/types.h>
1315 #include <sys/socket.h>
1316 #include <netinet/in.h>
1319 int main(int argc, char **argv)
1321 struct addrinfo hints;
1322 struct in6_addr addr;
1325 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1327 printf("%s\n", gai_strerror(ret));
1332 if compile_prog "" "" "ipv6"; then
1335 echo "IPv6 helpers $ipv6"
1337 ##########################################
1341 #include <rbd/librbd.h>
1343 int main(int argc, char **argv)
1347 rados_ioctx_t io_ctx;
1348 const char pool[] = "rbd";
1350 int major, minor, extra;
1351 rbd_version(&major, &minor, &extra);
1353 rados_ioctx_create(cluster, pool, &io_ctx);
1357 if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
1358 LIBS="-lrbd -lrados $LIBS"
1361 echo "Rados Block Device engine $rbd"
1363 ##########################################
1364 # check for rbd_poll
1366 if test "$rbd" = "yes"; then
1368 #include <rbd/librbd.h>
1369 #include <sys/eventfd.h>
1371 int main(int argc, char **argv)
1374 rbd_completion_t comp;
1376 int fd = eventfd(0, EFD_NONBLOCK);
1377 rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1378 rbd_poll_io_events(image, comp, 1);
1383 if compile_prog "" "-lrbd -lrados" "rbd"; then
1386 echo "rbd_poll $rbd_poll"
1389 ##########################################
1390 # check for rbd_invaidate_cache()
1392 if test "$rbd" = "yes"; then
1394 #include <rbd/librbd.h>
1396 int main(int argc, char **argv)
1400 return rbd_invalidate_cache(image);
1403 if compile_prog "" "-lrbd -lrados" "rbd"; then
1406 echo "rbd_invalidate_cache $rbd_inval"
1409 ##########################################
1413 #include <rbd/librbd.h>
1414 #include <zipkin_c.h>
1416 int main(int argc, char **argv)
1419 struct blkin_trace_info t_info;
1420 blkin_init_trace_info(&t_info);
1421 rbd_completion_t completion;
1426 r = rbd_aio_write_traced(image, off, len, buf, completion, &t_info);
1430 if test "$disable_rbd" != "yes" && test "$disable_rbd_blkin" != "yes" \
1431 && compile_prog "" "-lrbd -lrados -lblkin" "rbd_blkin"; then
1432 LIBS="-lblkin $LIBS"
1435 echo "rbd blkin tracing $rbd_blkin"
1437 ##########################################
1438 # Check whether we have setvbuf
1442 int main(int argc, char **argv)
1446 setvbuf(f, buf, _IOFBF, sizeof(buf));
1450 if compile_prog "" "" "setvbuf"; then
1453 echo "setvbuf $setvbuf"
1458 #include <glusterfs/api/glfs.h>
1460 int main(int argc, char **argv)
1463 glfs_t *g = glfs_new("foo");
1468 if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1469 LIBS="-lgfapi -lglusterfs $LIBS"
1472 echo "Gluster API engine $gfapi"
1474 ##########################################
1475 # check for gfapi fadvise support
1476 if test "$gfapi" = "yes" ; then
1479 #include <glusterfs/api/glfs.h>
1481 int main(int argc, char **argv)
1484 int ret = glfs_fadvise(fd, 0, 0, 1);
1489 if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1492 echo "Gluster API use fadvise $gf_fadvise"
1495 ##########################################
1496 # check for gfapi trim support
1498 if test "$gfapi" = "yes" ; then
1500 #include <glusterfs/api/glfs.h>
1502 int main(int argc, char **argv)
1504 return glfs_discard_async(NULL, 0, 0);
1507 if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1510 echo "Gluster API trim support $gf_trim"
1513 ##########################################
1514 # Check if we support stckf on s390
1515 s390_z196_facilities="no"
1517 #define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1518 int main(int argc, char **argv)
1520 /* We want just 1 double word to be returned. */
1521 register unsigned long reg0 asm("0") = 0;
1522 unsigned long stfle_bits;
1523 asm volatile(".machine push" "\n\t"
1524 ".machine \"z9-109\"" "\n\t"
1527 : "=QS" (stfle_bits), "+d" (reg0)
1530 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1536 if compile_prog "" "" "s390_z196_facilities"; then
1538 if [[ $? -eq 0 ]]; then
1539 s390_z196_facilities="yes"
1542 echo "s390_z196_facilities $s390_z196_facilities"
1544 ##########################################
1545 # Check if we have required environment variables configured for libhdfs
1546 if test "$libhdfs" = "yes" ; then
1548 if test "$JAVA_HOME" = "" ; then
1549 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1552 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1553 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1556 if test "$FIO_LIBHDFS_LIB" = "" ; then
1557 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1560 if test "$hdfs_conf_error" = "1" ; then
1564 if test "$FIO_HDFS_CPU" = "x86_64" ; then
1565 FIO_HDFS_CPU="amd64"
1568 echo "HDFS engine $libhdfs"
1570 ##########################################
1571 # Check whether we have MTD
1575 #include <mtd/mtd-user.h>
1576 #include <sys/ioctl.h>
1577 int main(int argc, char **argv)
1579 struct mtd_write_req ops;
1580 struct mtd_info_user info;
1581 memset(&ops, 0, sizeof(ops));
1582 info.type = MTD_MLCNANDFLASH;
1583 return ioctl(0, MEMGETINFO, &info);
1586 if compile_prog "" "" "mtd"; then
1591 ##########################################
1592 # Check whether we have libpmem
1595 #include <libpmem.h>
1596 int main(int argc, char **argv)
1599 rc = pmem_is_pmem(0, 0);
1603 if compile_prog "" "-lpmem" "libpmem"; then
1607 echo "libpmem $libpmem"
1609 ##########################################
1610 # Check whether we have libpmemblk
1611 # libpmem is a prerequisite
1613 if test "$libpmem" = "yes"; then
1615 #include <libpmemblk.h>
1616 int main(int argc, char **argv)
1619 pbp = pmemblk_open("", 0);
1623 if compile_prog "" "-lpmemblk" "libpmemblk"; then
1625 LIBS="-lpmemblk $LIBS"
1628 echo "libpmemblk $libpmemblk"
1630 # Choose the ioengines
1631 if test "$libpmem" = "yes" && test "$disable_pmem" = "no"; then
1633 if test "$libpmemblk" = "yes"; then
1638 ##########################################
1639 # Report whether pmemblk engine is enabled
1640 echo "NVML pmemblk engine $pmemblk"
1642 ##########################################
1643 # Report whether dev-dax engine is enabled
1644 echo "NVML dev-dax engine $devdax"
1646 # Check if we have lex/yacc available
1651 if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
1652 if test "$targetos" != "SunOS" ; then
1653 LEX=$(which lex 2> /dev/null)
1654 if test -x "$LEX" ; then
1657 YACC=$(which bison 2> /dev/null)
1658 if test -x "$YACC" ; then
1662 YACC=$(which yacc 2> /dev/null)
1663 if test -x "$YACC" ; then
1667 if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1671 if test "$arith" = "yes" ; then
1673 extern int yywrap(void);
1675 int main(int argc, char **argv)
1681 if compile_prog "" "-ll" "lex"; then
1690 # Check if lex fails using -o
1691 if test "$arith" = "yes" ; then
1692 if test "$force_no_lex_o" = "yes" ; then
1695 $LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1696 if test "$?" = "0" ; then
1704 echo "lex/yacc for arithmetic $arith"
1706 ##########################################
1707 # Check whether we have setmntent/getmntent
1712 int main(int argc, char **argv)
1714 FILE *mtab = setmntent(NULL, "r");
1715 struct mntent *mnt = getmntent(mtab);
1720 if compile_prog "" "" "getmntent"; then
1723 echo "getmntent $getmntent"
1725 ##########################################
1726 # Check whether we have getmntinfo
1727 # These are originally added for BSDs, but may also work
1728 # on other operating systems with getmntinfo(3).
1730 # getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
1731 # Note that NetBSD needs -Werror to catch warning as error.
1735 #include <sys/param.h>
1736 #include <sys/mount.h>
1737 int main(int argc, char **argv)
1740 return getmntinfo(&st, MNT_NOWAIT);
1743 if compile_prog "-Werror" "" "getmntinfo"; then
1746 echo "getmntinfo $getmntinfo"
1748 # getmntinfo(3) for NetBSD.
1749 getmntinfo_statvfs="no"
1752 #include <sys/statvfs.h>
1753 int main(int argc, char **argv)
1756 return getmntinfo(&st, MNT_NOWAIT);
1759 # Skip the test if the one with statfs arg is detected.
1760 if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
1761 getmntinfo_statvfs="yes"
1762 echo "getmntinfo_statvfs $getmntinfo_statvfs"
1765 ##########################################
1766 # Check whether we have _Static_assert
1772 #ifdef __compiler_offsetof
1773 #define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
1775 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1778 #define container_of(ptr, type, member) ({ \
1779 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
1780 (type *)( (char *)__mptr - offsetof(type,member) );})
1786 int main(int argc, char **argv)
1788 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
1792 if compile_prog "" "" "static_assert"; then
1795 echo "Static Assert $static_assert"
1797 ##########################################
1798 # Check whether we have bool / stdbool.h
1801 #include <stdbool.h>
1802 int main(int argc, char **argv)
1805 return var != false;
1808 if compile_prog "" "" "bool"; then
1811 echo "bool $have_bool"
1813 ##########################################
1814 # check march=armv8-a+crc+crypto
1815 march_armv8_a_crc_crypto="no"
1816 if test "$cpu" = "arm64" ; then
1823 if compile_prog "-march=armv8-a+crc+crypto" "" ""; then
1824 march_armv8_a_crc_crypto="yes"
1825 CFLAGS="$CFLAGS -march=armv8-a+crc+crypto -DARCH_HAVE_CRC_CRYPTO"
1828 echo "march_armv8_a_crc_crypto $march_armv8_a_crc_crypto"
1831 #############################################################################
1833 if test "$wordsize" = "64" ; then
1834 output_sym "CONFIG_64BIT"
1835 elif test "$wordsize" = "32" ; then
1836 output_sym "CONFIG_32BIT"
1838 fatal "Unknown wordsize!"
1840 if test "$bigendian" = "yes" ; then
1841 output_sym "CONFIG_BIG_ENDIAN"
1843 output_sym "CONFIG_LITTLE_ENDIAN"
1845 if test "$zlib" = "yes" ; then
1846 output_sym "CONFIG_ZLIB"
1848 if test "$libaio" = "yes" ; then
1849 output_sym "CONFIG_LIBAIO"
1851 if test "$posix_aio" = "yes" ; then
1852 output_sym "CONFIG_POSIXAIO"
1854 if test "$posix_aio_fsync" = "yes" ; then
1855 output_sym "CONFIG_POSIXAIO_FSYNC"
1857 if test "$linux_fallocate" = "yes" ; then
1858 output_sym "CONFIG_LINUX_FALLOCATE"
1860 if test "$posix_fallocate" = "yes" ; then
1861 output_sym "CONFIG_POSIX_FALLOCATE"
1863 if test "$fdatasync" = "yes" ; then
1864 output_sym "CONFIG_FDATASYNC"
1866 if test "$sync_file_range" = "yes" ; then
1867 output_sym "CONFIG_SYNC_FILE_RANGE"
1869 if test "$sfaa" = "yes" ; then
1870 output_sym "CONFIG_SFAA"
1872 if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
1873 output_sym "CONFIG_RDMA"
1875 if test "$clock_gettime" = "yes" ; then
1876 output_sym "CONFIG_CLOCK_GETTIME"
1878 if test "$clock_monotonic" = "yes" ; then
1879 output_sym "CONFIG_CLOCK_MONOTONIC"
1881 if test "$clock_monotonic_raw" = "yes" ; then
1882 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
1884 if test "$clock_monotonic_precise" = "yes" ; then
1885 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
1887 if test "$clockid_t" = "yes"; then
1888 output_sym "CONFIG_CLOCKID_T"
1890 if test "$gettimeofday" = "yes" ; then
1891 output_sym "CONFIG_GETTIMEOFDAY"
1893 if test "$posix_fadvise" = "yes" ; then
1894 output_sym "CONFIG_POSIX_FADVISE"
1896 if test "$linux_3arg_affinity" = "yes" ; then
1897 output_sym "CONFIG_3ARG_AFFINITY"
1898 elif test "$linux_2arg_affinity" = "yes" ; then
1899 output_sym "CONFIG_2ARG_AFFINITY"
1901 if test "$strsep" = "yes" ; then
1902 output_sym "CONFIG_STRSEP"
1904 if test "$strcasestr" = "yes" ; then
1905 output_sym "CONFIG_STRCASESTR"
1907 if test "$strlcat" = "yes" ; then
1908 output_sym "CONFIG_STRLCAT"
1910 if test "$getopt_long_only" = "yes" ; then
1911 output_sym "CONFIG_GETOPT_LONG_ONLY"
1913 if test "$inet_aton" = "yes" ; then
1914 output_sym "CONFIG_INET_ATON"
1916 if test "$socklen_t" = "yes" ; then
1917 output_sym "CONFIG_SOCKLEN_T"
1919 if test "$ext4_me" = "yes" ; then
1920 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1922 if test "$linux_splice" = "yes" ; then
1923 output_sym "CONFIG_LINUX_SPLICE"
1925 if test "$guasi" = "yes" ; then
1926 output_sym "CONFIG_GUASI"
1928 if test "$fusion_aw" = "yes" ; then
1929 output_sym "CONFIG_FUSION_AW"
1931 if test "$libnuma_v2" = "yes" ; then
1932 output_sym "CONFIG_LIBNUMA"
1934 if test "$solaris_aio" = "yes" ; then
1935 output_sym "CONFIG_SOLARISAIO"
1937 if test "$tls_thread" = "yes" ; then
1938 output_sym "CONFIG_TLS_THREAD"
1940 if test "$rusage_thread" = "yes" ; then
1941 output_sym "CONFIG_RUSAGE_THREAD"
1943 if test "$gfio" = "yes" ; then
1944 echo "CONFIG_GFIO=y" >> $config_host_mak
1946 if test "$esx" = "yes" ; then
1947 output_sym "CONFIG_ESX"
1948 output_sym "CONFIG_NO_SHM"
1950 if test "$sched_idle" = "yes" ; then
1951 output_sym "CONFIG_SCHED_IDLE"
1953 if test "$tcp_nodelay" = "yes" ; then
1954 output_sym "CONFIG_TCP_NODELAY"
1956 if test "$window_size" = "yes" ; then
1957 output_sym "CONFIG_NET_WINDOWSIZE"
1959 if test "$mss" = "yes" ; then
1960 output_sym "CONFIG_NET_MSS"
1962 if test "$rlimit_memlock" = "yes" ; then
1963 output_sym "CONFIG_RLIMIT_MEMLOCK"
1965 if test "$pwritev" = "yes" ; then
1966 output_sym "CONFIG_PWRITEV"
1968 if test "$pwritev2" = "yes" ; then
1969 output_sym "CONFIG_PWRITEV2"
1971 if test "$ipv6" = "yes" ; then
1972 output_sym "CONFIG_IPV6"
1974 if test "$rbd" = "yes" ; then
1975 output_sym "CONFIG_RBD"
1977 if test "$rbd_poll" = "yes" ; then
1978 output_sym "CONFIG_RBD_POLL"
1980 if test "$rbd_inval" = "yes" ; then
1981 output_sym "CONFIG_RBD_INVAL"
1983 if test "$rbd_blkin" = "yes" ; then
1984 output_sym "CONFIG_RBD_BLKIN"
1986 if test "$setvbuf" = "yes" ; then
1987 output_sym "CONFIG_SETVBUF"
1989 if test "$s390_z196_facilities" = "yes" ; then
1990 output_sym "CONFIG_S390_Z196_FACILITIES"
1991 CFLAGS="$CFLAGS -march=z9-109"
1993 if test "$gfapi" = "yes" ; then
1994 output_sym "CONFIG_GFAPI"
1996 if test "$gf_fadvise" = "yes" ; then
1997 output_sym "CONFIG_GF_FADVISE"
1999 if test "$gf_trim" = "yes" ; then
2000 output_sym "CONFIG_GF_TRIM"
2002 if test "$libhdfs" = "yes" ; then
2003 output_sym "CONFIG_LIBHDFS"
2004 echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
2005 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
2006 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
2007 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
2009 if test "$mtd" = "yes" ; then
2010 output_sym "CONFIG_MTD"
2012 if test "$pmemblk" = "yes" ; then
2013 output_sym "CONFIG_PMEMBLK"
2015 if test "$devdax" = "yes" ; then
2016 output_sym "CONFIG_LINUX_DEVDAX"
2018 if test "$arith" = "yes" ; then
2019 output_sym "CONFIG_ARITHMETIC"
2020 if test "$yacc_is_bison" = "yes" ; then
2021 echo "YACC=$YACC -y" >> $config_host_mak
2023 echo "YACC=$YACC" >> $config_host_mak
2025 if test "$lex_use_o" = "yes" ; then
2026 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
2029 if test "$getmntent" = "yes" ; then
2030 output_sym "CONFIG_GETMNTENT"
2032 if test "$getmntinfo" = "yes" ; then
2033 output_sym "CONFIG_GETMNTINFO"
2035 if test "$getmntinfo_statvfs" = "yes" ; then
2036 output_sym "CONFIG_GETMNTINFO_STATVFS"
2038 if test "$static_assert" = "yes" ; then
2039 output_sym "CONFIG_STATIC_ASSERT"
2041 if test "$have_bool" = "yes" ; then
2042 output_sym "CONFIG_HAVE_BOOL"
2044 if test "$disable_opt" = "yes" ; then
2045 output_sym "CONFIG_DISABLE_OPTIMIZATIONS"
2048 if test "$zlib" = "no" ; then
2049 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
2052 echo "LIBS+=$LIBS" >> $config_host_mak
2053 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
2054 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
2055 echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
2056 echo "CC=$cc" >> $config_host_mak
2057 echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
2058 echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
2060 if [ `dirname $0` != "." -a ! -e Makefile ]; then
2061 cat > Makefile <<EOF
2062 SRCDIR:=`dirname $0`
2063 include \$(SRCDIR)/Makefile