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 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
310 output_sym "CONFIG_32BIT"
312 output_sym "CONFIG_64BIT_LLP64"
314 output_sym "CONFIG_SOCKLEN_T"
315 output_sym "CONFIG_SFAA"
316 output_sym "CONFIG_RUSAGE_THREAD"
317 output_sym "CONFIG_WINDOWSAIO"
318 output_sym "CONFIG_FDATASYNC"
319 output_sym "CONFIG_CLOCK_MONOTONIC"
320 output_sym "CONFIG_GETTIMEOFDAY"
321 output_sym "CONFIG_CLOCK_GETTIME"
322 output_sym "CONFIG_SCHED_IDLE"
323 output_sym "CONFIG_TCP_NODELAY"
324 output_sym "CONFIG_TLS_THREAD"
325 output_sym "CONFIG_STATIC_ASSERT"
326 output_sym "CONFIG_IPV6"
327 echo "CC=$CC" >> $config_host_mak
328 echo "BUILD_CFLAGS=$CFLAGS -I../zlib -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
334 if test ! -z "$cpu" ; then
335 # command line argument
337 elif check_define __i386__ ; then
339 elif check_define __x86_64__ ; then
341 elif check_define __sparc__ ; then
342 if check_define __arch64__ ; then
347 elif check_define _ARCH_PPC ; then
348 if check_define _ARCH_PPC64 ; then
353 elif check_define __mips__ ; then
355 elif check_define __ia64__ ; then
357 elif check_define __s390__ ; then
358 if check_define __s390x__ ; then
363 elif check_define __arm__ ; then
365 elif check_define __aarch64__ ; then
367 elif check_define __hppa__ ; then
373 # Normalise host CPU name and set ARCH.
375 ia64|ppc|ppc64|s390|s390x|sparc64)
378 i386|i486|i586|i686|i86pc|BePC)
390 hppa|parisc|parisc64)
404 if test -z "$CC" ; then
405 if test "$targetos" = "FreeBSD"; then
414 cc="${CC-${cross_prefix}gcc}"
416 ##########################################
417 # check cross compile
426 if compile_prog "" "" "cross"; then
427 $TMPE 2>/dev/null || cross_compile="yes"
429 fatal "compile test failed"
432 ##########################################
435 if test "$cross_compile" = "no" ; then
437 #include <inttypes.h>
440 volatile uint32_t i=0x01234567;
441 return (*((uint8_t*)(&i))) == 0x67;
444 if compile_prog "" "" "endian"; then
445 $TMPE && bigendian="yes"
448 # If we're cross compiling, try our best to work it out and rely on the
449 # run-time check to fail if we get it wrong.
454 #if __BYTE_ORDER != __BIG_ENDIAN
455 # error "Unknown endianness"
459 compile_prog "" "" "endian" && bigendian="yes"
460 check_define "__ARMEB__" && bigendian="yes"
461 check_define "__MIPSEB__" && bigendian="yes"
465 echo "Operating system $targetos"
467 echo "Big endian $bigendian"
469 echo "Cross compile $cross_compile"
472 ##########################################
473 # See if we need to build a static build
474 if test "$build_static" = "yes" ; then
475 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
476 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
480 echo "Static build $build_static"
482 ##########################################
487 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
490 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
494 if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
496 elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
499 fatal "Unknown wordsize"
501 echo "Wordsize $wordsize"
503 ##########################################
511 if (inflateInit(&stream) != Z_OK)
516 if compile_prog "" "-lz" "zlib" ; then
522 ##########################################
525 if test "$esx" != "yes" ; then
535 if compile_prog "" "-laio" "libaio" ; then
539 if test "$libaio" = "yes" ; then
540 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
545 echo "Linux AIO support $libaio"
547 ##########################################
560 if compile_prog "" "" "posixaio" ; then
562 elif compile_prog "" "-lrt" "posixaio"; then
567 echo "POSIX AIO support $posix_aio"
568 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
570 ##########################################
571 # posix aio fsync probe
573 if test "$posix_aio" = "yes" ; then
580 return aio_fsync(O_SYNC, &cb);
584 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
588 echo "POSIX AIO fsync $posix_aio_fsync"
590 ##########################################
594 #include <sys/types.h>
595 #include <sys/asynch.h>
600 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
604 if compile_prog "" "-laio" "solarisaio" ; then
608 echo "Solaris AIO support $solaris_aio"
610 ##########################################
611 # __sync_fetch_and_add test
614 #include <inttypes.h>
615 static int sfaa(uint64_t *ptr)
617 return __sync_fetch_and_add(ptr, 0);
620 int main(int argc, char **argv)
627 if compile_prog "" "" "__sync_fetch_and_add()" ; then
630 echo "__sync_fetch_and_add $sfaa"
632 ##########################################
637 #include <infiniband/arch.h>
638 int main(int argc, char **argv)
640 struct ibv_pd *pd = ibv_alloc_pd(NULL);
644 if compile_prog "" "-libverbs" "libverbs" ; then
646 LIBS="-libverbs $LIBS"
648 echo "libverbs $libverbs"
650 ##########################################
655 #include <rdma/rdma_cma.h>
656 int main(int argc, char **argv)
658 rdma_destroy_qp(NULL);
662 if compile_prog "" "-lrdmacm" "rdma"; then
664 LIBS="-lrdmacm $LIBS"
666 echo "rdmacm $rdmacm"
668 ##########################################
669 # Linux fallocate probe
674 #include <linux/falloc.h>
675 int main(int argc, char **argv)
677 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
681 if compile_prog "" "" "linux_fallocate"; then
682 linux_fallocate="yes"
684 echo "Linux fallocate $linux_fallocate"
686 ##########################################
687 # POSIX fadvise probe
692 int main(int argc, char **argv)
694 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
698 if compile_prog "" "" "posix_fadvise"; then
701 echo "POSIX fadvise $posix_fadvise"
703 ##########################################
704 # POSIX fallocate probe
709 int main(int argc, char **argv)
711 int r = posix_fallocate(0, 0, 1024);
715 if compile_prog "" "" "posix_fallocate"; then
716 posix_fallocate="yes"
718 echo "POSIX fallocate $posix_fallocate"
720 ##########################################
721 # sched_set/getaffinity 2 or 3 argument test
722 linux_2arg_affinity="no"
723 linux_3arg_affinity="no"
726 int main(int argc, char **argv)
729 return sched_setaffinity(0, sizeof(mask), &mask);
732 if compile_prog "" "" "sched_setaffinity(,,)"; then
733 linux_3arg_affinity="yes"
737 int main(int argc, char **argv)
740 return sched_setaffinity(0, &mask);
743 if compile_prog "" "" "sched_setaffinity(,)"; then
744 linux_2arg_affinity="yes"
747 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
748 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
750 ##########################################
751 # clock_gettime probe
756 int main(int argc, char **argv)
758 return clock_gettime(0, NULL);
761 if compile_prog "" "" "clock_gettime"; then
763 elif compile_prog "" "-lrt" "clock_gettime"; then
767 echo "clock_gettime $clock_gettime"
769 ##########################################
770 # CLOCK_MONOTONIC probe
772 if test "$clock_gettime" = "yes" ; then
776 int main(int argc, char **argv)
778 return clock_gettime(CLOCK_MONOTONIC, NULL);
781 if compile_prog "" "$LIBS" "clock monotonic"; then
782 clock_monotonic="yes"
785 echo "CLOCK_MONOTONIC $clock_monotonic"
787 ##########################################
788 # CLOCK_MONOTONIC_RAW probe
789 clock_monotonic_raw="no"
790 if test "$clock_gettime" = "yes" ; then
794 int main(int argc, char **argv)
796 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
799 if compile_prog "" "$LIBS" "clock monotonic"; then
800 clock_monotonic_raw="yes"
803 echo "CLOCK_MONOTONIC_RAW $clock_monotonic_raw"
805 ##########################################
806 # CLOCK_MONOTONIC_PRECISE probe
807 clock_monotonic_precise="no"
808 if test "$clock_gettime" = "yes" ; then
812 int main(int argc, char **argv)
814 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
817 if compile_prog "" "$LIBS" "clock monotonic precise"; then
818 clock_monotonic_precise="yes"
821 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
823 ##########################################
828 int main(int argc, char **argv)
830 volatile clockid_t cid;
831 memset(&cid, 0, sizeof(cid));
835 if compile_prog "" "$LIBS" "clockid_t"; then
838 echo "clockid_t $clockid_t"
840 ##########################################
841 # gettimeofday() probe
844 #include <sys/time.h>
846 int main(int argc, char **argv)
849 return gettimeofday(&tv, NULL);
852 if compile_prog "" "" "gettimeofday"; then
855 echo "gettimeofday $gettimeofday"
857 ##########################################
863 int main(int argc, char **argv)
868 if compile_prog "" "" "fdatasync"; then
871 echo "fdatasync $fdatasync"
873 ##########################################
874 # sync_file_range() probe
880 #include <linux/fs.h>
881 int main(int argc, char **argv)
883 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
884 SYNC_FILE_RANGE_WAIT_AFTER;
885 return sync_file_range(0, 0, 0, flags);
888 if compile_prog "" "" "sync_file_range"; then
889 sync_file_range="yes"
891 echo "sync_file_range $sync_file_range"
893 ##########################################
894 # ext4 move extent probe
898 #include <sys/ioctl.h>
899 int main(int argc, char **argv)
901 struct move_extent me;
902 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
905 if compile_prog "" "" "ext4 move extent" ; then
907 elif test $targetos = "Linux" ; then
908 # On Linux, just default to it on and let it error at runtime if we really
909 # don't have it. None of my updated systems have it defined, but it does
910 # work. Takes a while to bubble back.
913 echo "EXT4 move extent $ext4_me"
915 ##########################################
921 int main(int argc, char **argv)
923 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
926 if compile_prog "" "" "linux splice"; then
929 echo "Linux splice(2) $linux_splice"
931 ##########################################
936 #include <guasi_syscalls.h>
937 int main(int argc, char **argv)
939 guasi_t ctx = guasi_create(0, 0, 0);
943 if compile_prog "" "" "guasi"; then
948 ##########################################
952 #include <nvm/nvm_primitives.h>
953 int main(int argc, char **argv)
955 nvm_version_t ver_info;
958 handle = nvm_get_handle(0, &ver_info);
959 return nvm_atomic_write(handle, 0, 0, 0);
962 if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
963 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
966 echo "Fusion-io atomic engine $fusion_aw"
968 ##########################################
973 int main(int argc, char **argv)
975 return numa_available();
978 if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
982 echo "libnuma $libnuma"
984 ##########################################
985 # libnuma 2.x version API
986 if test "$libnuma" = "yes" ; then
990 int main(int argc, char **argv)
992 struct bitmask *mask = numa_parse_nodestring(NULL);
993 return mask->size == 0;
996 if compile_prog "" "" "libnuma api"; then
999 echo "libnuma v2 $libnuma_v2"
1002 ##########################################
1007 int main(int argc, char **argv)
1009 static char *string = "This is a string";
1010 strsep(&string, "needle");
1014 if compile_prog "" "" "strsep"; then
1017 echo "strsep $strsep"
1019 ##########################################
1020 # strcasestr() probe
1024 int main(int argc, char **argv)
1026 return strcasestr(argv[0], argv[1]) != NULL;
1029 if compile_prog "" "" "strcasestr"; then
1032 echo "strcasestr $strcasestr"
1034 ##########################################
1039 int main(int argc, char **argv)
1041 static char dst[64];
1042 static char *string = "This is a string";
1043 memset(dst, 0, sizeof(dst));
1044 strlcat(dst, string, sizeof(dst));
1048 if compile_prog "" "" "strlcat"; then
1051 echo "strlcat $strlcat"
1053 ##########################################
1054 # getopt_long_only() probe
1055 getopt_long_only="no"
1060 int main(int argc, char **argv)
1062 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1066 if compile_prog "" "" "getopt_long_only"; then
1067 getopt_long_only="yes"
1069 echo "getopt_long_only() $getopt_long_only"
1071 ##########################################
1075 #include <sys/socket.h>
1076 #include <arpa/inet.h>
1078 int main(int argc, char **argv)
1081 return inet_aton(NULL, &in);
1084 if compile_prog "" "" "inet_aton"; then
1087 echo "inet_aton $inet_aton"
1089 ##########################################
1093 #include <sys/socket.h>
1094 int main(int argc, char **argv)
1100 if compile_prog "" "" "socklen_t"; then
1103 echo "socklen_t $socklen_t"
1105 ##########################################
1106 # Whether or not __thread is supported for TLS
1110 static __thread int ret;
1111 int main(int argc, char **argv)
1116 if compile_prog "" "" "__thread"; then
1119 echo "__thread $tls_thread"
1121 ##########################################
1122 # Check if we have required gtk/glib support for gfio
1124 if test "$gfio_check" = "yes" ; then
1128 #include <gtk/gtk.h>
1131 gdk_threads_enter();
1132 gdk_threads_leave();
1134 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
1137 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1138 ORG_LDFLAGS=$LDFLAGS
1139 LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1140 if test "$?" != "0" ; then
1141 echo "configure: gtk and gthread not found"
1144 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1145 if test "$?" != "0" ; then
1146 echo "configure: gtk and gthread not found"
1149 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1151 if test "$r" != "0" ; then
1153 GFIO_LIBS="$LIBS $GTK_LIBS"
1154 CFLAGS="$CFLAGS $GTK_CFLAGS"
1156 echo "GTK found, but need version 2.18 or higher"
1160 echo "Please install gtk and gdk libraries"
1163 LDFLAGS=$ORG_LDFLAGS
1166 if test "$gfio_check" = "yes" ; then
1167 echo "gtk 2.18 or higher $gfio"
1170 # Check whether we have getrusage(RUSAGE_THREAD)
1173 #include <sys/time.h>
1174 #include <sys/resource.h>
1175 int main(int argc, char **argv)
1178 getrusage(RUSAGE_THREAD, &ru);
1182 if compile_prog "" "" "RUSAGE_THREAD"; then
1185 echo "RUSAGE_THREAD $rusage_thread"
1187 ##########################################
1188 # Check whether we have SCHED_IDLE
1192 int main(int argc, char **argv)
1194 struct sched_param p;
1195 return sched_setscheduler(0, SCHED_IDLE, &p);
1198 if compile_prog "" "" "SCHED_IDLE"; then
1201 echo "SCHED_IDLE $sched_idle"
1203 ##########################################
1204 # Check whether we have TCP_NODELAY
1208 #include <sys/types.h>
1209 #include <sys/socket.h>
1210 #include <netinet/tcp.h>
1211 int main(int argc, char **argv)
1213 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1216 if compile_prog "" "" "TCP_NODELAY"; then
1219 echo "TCP_NODELAY $tcp_nodelay"
1221 ##########################################
1222 # Check whether we have SO_SNDBUF
1226 #include <sys/types.h>
1227 #include <sys/socket.h>
1228 #include <netinet/tcp.h>
1229 int main(int argc, char **argv)
1231 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1232 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1235 if compile_prog "" "" "SO_SNDBUF"; then
1238 echo "Net engine window_size $window_size"
1240 ##########################################
1241 # Check whether we have TCP_MAXSEG
1245 #include <sys/types.h>
1246 #include <sys/socket.h>
1247 #include <netinet/tcp.h>
1248 #include <arpa/inet.h>
1249 #include <netinet/in.h>
1250 int main(int argc, char **argv)
1252 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1255 if compile_prog "" "" "TCP_MAXSEG"; then
1258 echo "TCP_MAXSEG $mss"
1260 ##########################################
1261 # Check whether we have RLIMIT_MEMLOCK
1264 #include <sys/time.h>
1265 #include <sys/resource.h>
1266 int main(int argc, char **argv)
1269 return getrlimit(RLIMIT_MEMLOCK, &rl);
1272 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1273 rlimit_memlock="yes"
1275 echo "RLIMIT_MEMLOCK $rlimit_memlock"
1277 ##########################################
1278 # Check whether we have pwritev/preadv
1282 #include <sys/uio.h>
1283 int main(int argc, char **argv)
1285 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1288 if compile_prog "" "" "pwritev"; then
1291 echo "pwritev/preadv $pwritev"
1293 ##########################################
1294 # Check whether we have pwritev2/preadv2
1298 #include <sys/uio.h>
1299 int main(int argc, char **argv)
1301 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1304 if compile_prog "" "" "pwritev2"; then
1307 echo "pwritev2/preadv2 $pwritev2"
1309 ##########################################
1310 # Check whether we have the required functions for ipv6
1313 #include <sys/types.h>
1314 #include <sys/socket.h>
1315 #include <netinet/in.h>
1318 int main(int argc, char **argv)
1320 struct addrinfo hints;
1321 struct in6_addr addr;
1324 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1326 printf("%s\n", gai_strerror(ret));
1331 if compile_prog "" "" "ipv6"; then
1334 echo "IPv6 helpers $ipv6"
1336 ##########################################
1340 #include <rbd/librbd.h>
1342 int main(int argc, char **argv)
1346 rados_ioctx_t io_ctx;
1347 const char pool[] = "rbd";
1349 int major, minor, extra;
1350 rbd_version(&major, &minor, &extra);
1352 rados_ioctx_create(cluster, pool, &io_ctx);
1356 if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
1357 LIBS="-lrbd -lrados $LIBS"
1360 echo "Rados Block Device engine $rbd"
1362 ##########################################
1363 # check for rbd_poll
1365 if test "$rbd" = "yes"; then
1367 #include <rbd/librbd.h>
1368 #include <sys/eventfd.h>
1370 int main(int argc, char **argv)
1373 rbd_completion_t comp;
1375 int fd = eventfd(0, EFD_NONBLOCK);
1376 rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1377 rbd_poll_io_events(image, comp, 1);
1382 if compile_prog "" "-lrbd -lrados" "rbd"; then
1385 echo "rbd_poll $rbd_poll"
1388 ##########################################
1389 # check for rbd_invaidate_cache()
1391 if test "$rbd" = "yes"; then
1393 #include <rbd/librbd.h>
1395 int main(int argc, char **argv)
1399 return rbd_invalidate_cache(image);
1402 if compile_prog "" "-lrbd -lrados" "rbd"; then
1405 echo "rbd_invalidate_cache $rbd_inval"
1408 ##########################################
1412 #include <rbd/librbd.h>
1413 #include <zipkin_c.h>
1415 int main(int argc, char **argv)
1418 struct blkin_trace_info t_info;
1419 blkin_init_trace_info(&t_info);
1420 rbd_completion_t completion;
1425 r = rbd_aio_write_traced(image, off, len, buf, completion, &t_info);
1429 if test "$disable_rbd" != "yes" && test "$disable_rbd_blkin" != "yes" \
1430 && compile_prog "" "-lrbd -lrados -lblkin" "rbd_blkin"; then
1431 LIBS="-lblkin $LIBS"
1434 echo "rbd blkin tracing $rbd_blkin"
1436 ##########################################
1437 # Check whether we have setvbuf
1441 int main(int argc, char **argv)
1445 setvbuf(f, buf, _IOFBF, sizeof(buf));
1449 if compile_prog "" "" "setvbuf"; then
1452 echo "setvbuf $setvbuf"
1457 #include <glusterfs/api/glfs.h>
1459 int main(int argc, char **argv)
1462 glfs_t *g = glfs_new("foo");
1467 if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1468 LIBS="-lgfapi -lglusterfs $LIBS"
1471 echo "Gluster API engine $gfapi"
1473 ##########################################
1474 # check for gfapi fadvise support
1475 if test "$gfapi" = "yes" ; then
1478 #include <glusterfs/api/glfs.h>
1480 int main(int argc, char **argv)
1483 int ret = glfs_fadvise(fd, 0, 0, 1);
1488 if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1491 echo "Gluster API use fadvise $gf_fadvise"
1494 ##########################################
1495 # check for gfapi trim support
1497 if test "$gfapi" = "yes" ; then
1499 #include <glusterfs/api/glfs.h>
1501 int main(int argc, char **argv)
1503 return glfs_discard_async(NULL, 0, 0);
1506 if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1509 echo "Gluster API trim support $gf_trim"
1512 ##########################################
1513 # Check if we support stckf on s390
1514 s390_z196_facilities="no"
1516 #define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1517 int main(int argc, char **argv)
1519 /* We want just 1 double word to be returned. */
1520 register unsigned long reg0 asm("0") = 0;
1521 unsigned long stfle_bits;
1522 asm volatile(".machine push" "\n\t"
1523 ".machine \"z9-109\"" "\n\t"
1526 : "=QS" (stfle_bits), "+d" (reg0)
1529 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1535 if compile_prog "" "" "s390_z196_facilities"; then
1537 if [[ $? -eq 0 ]]; then
1538 s390_z196_facilities="yes"
1541 echo "s390_z196_facilities $s390_z196_facilities"
1543 ##########################################
1544 # Check if we have required environment variables configured for libhdfs
1545 if test "$libhdfs" = "yes" ; then
1547 if test "$JAVA_HOME" = "" ; then
1548 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1551 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1552 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1555 if test "$FIO_LIBHDFS_LIB" = "" ; then
1556 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1559 if test "$hdfs_conf_error" = "1" ; then
1563 if test "$FIO_HDFS_CPU" = "x86_64" ; then
1564 FIO_HDFS_CPU="amd64"
1567 echo "HDFS engine $libhdfs"
1569 ##########################################
1570 # Check whether we have MTD
1574 #include <mtd/mtd-user.h>
1575 #include <sys/ioctl.h>
1576 int main(int argc, char **argv)
1578 struct mtd_write_req ops;
1579 struct mtd_info_user info;
1580 memset(&ops, 0, sizeof(ops));
1581 info.type = MTD_MLCNANDFLASH;
1582 return ioctl(0, MEMGETINFO, &info);
1585 if compile_prog "" "" "mtd"; then
1590 ##########################################
1591 # Check whether we have libpmem
1594 #include <libpmem.h>
1595 int main(int argc, char **argv)
1598 rc = pmem_is_pmem(0, 0);
1602 if compile_prog "" "-lpmem" "libpmem"; then
1606 echo "libpmem $libpmem"
1608 ##########################################
1609 # Check whether we have libpmemblk
1610 # libpmem is a prerequisite
1612 if test "$libpmem" = "yes"; then
1614 #include <libpmemblk.h>
1615 int main(int argc, char **argv)
1618 pbp = pmemblk_open("", 0);
1622 if compile_prog "" "-lpmemblk" "libpmemblk"; then
1624 LIBS="-lpmemblk $LIBS"
1627 echo "libpmemblk $libpmemblk"
1629 # Choose the ioengines
1630 if test "$libpmem" = "yes" && test "$disable_pmem" = "no"; then
1632 if test "$libpmemblk" = "yes"; then
1637 ##########################################
1638 # Report whether pmemblk engine is enabled
1639 echo "NVML pmemblk engine $pmemblk"
1641 ##########################################
1642 # Report whether dev-dax engine is enabled
1643 echo "NVML dev-dax engine $devdax"
1645 # Check if we have lex/yacc available
1650 if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
1651 if test "$targetos" != "SunOS" ; then
1652 LEX=$(which lex 2> /dev/null)
1653 if test -x "$LEX" ; then
1656 YACC=$(which bison 2> /dev/null)
1657 if test -x "$YACC" ; then
1661 YACC=$(which yacc 2> /dev/null)
1662 if test -x "$YACC" ; then
1666 if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1670 if test "$arith" = "yes" ; then
1672 extern int yywrap(void);
1674 int main(int argc, char **argv)
1680 if compile_prog "" "-ll" "lex"; then
1689 # Check if lex fails using -o
1690 if test "$arith" = "yes" ; then
1691 if test "$force_no_lex_o" = "yes" ; then
1694 $LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1695 if test "$?" = "0" ; then
1703 echo "lex/yacc for arithmetic $arith"
1705 ##########################################
1706 # Check whether we have setmntent/getmntent
1711 int main(int argc, char **argv)
1713 FILE *mtab = setmntent(NULL, "r");
1714 struct mntent *mnt = getmntent(mtab);
1719 if compile_prog "" "" "getmntent"; then
1722 echo "getmntent $getmntent"
1724 ##########################################
1725 # Check whether we have getmntinfo
1726 # These are originally added for BSDs, but may also work
1727 # on other operating systems with getmntinfo(3).
1729 # getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
1730 # Note that NetBSD needs -Werror to catch warning as error.
1734 #include <sys/param.h>
1735 #include <sys/mount.h>
1736 int main(int argc, char **argv)
1739 return getmntinfo(&st, MNT_NOWAIT);
1742 if compile_prog "-Werror" "" "getmntinfo"; then
1745 echo "getmntinfo $getmntinfo"
1747 # getmntinfo(3) for NetBSD.
1748 getmntinfo_statvfs="no"
1751 #include <sys/statvfs.h>
1752 int main(int argc, char **argv)
1755 return getmntinfo(&st, MNT_NOWAIT);
1758 # Skip the test if the one with statfs arg is detected.
1759 if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
1760 getmntinfo_statvfs="yes"
1761 echo "getmntinfo_statvfs $getmntinfo_statvfs"
1764 ##########################################
1765 # Check whether we have _Static_assert
1771 #ifdef __compiler_offsetof
1772 #define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
1774 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1777 #define container_of(ptr, type, member) ({ \
1778 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
1779 (type *)( (char *)__mptr - offsetof(type,member) );})
1785 int main(int argc, char **argv)
1787 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
1791 if compile_prog "" "" "static_assert"; then
1794 echo "Static Assert $static_assert"
1796 ##########################################
1797 # Check whether we have bool / stdbool.h
1800 #include <stdbool.h>
1801 int main(int argc, char **argv)
1804 return var != false;
1807 if compile_prog "" "" "bool"; then
1810 echo "bool $have_bool"
1812 ##########################################
1813 # check march=armv8-a+crc+crypto
1814 march_armv8_a_crc_crypto="no"
1815 if test "$cpu" = "arm64" ; then
1822 if compile_prog "-march=armv8-a+crc+crypto" "" ""; then
1823 march_armv8_a_crc_crypto="yes"
1824 CFLAGS="$CFLAGS -march=armv8-a+crc+crypto -DARCH_HAVE_CRC_CRYPTO"
1827 echo "march_armv8_a_crc_crypto $march_armv8_a_crc_crypto"
1830 #############################################################################
1832 if test "$wordsize" = "64" ; then
1833 output_sym "CONFIG_64BIT"
1834 elif test "$wordsize" = "32" ; then
1835 output_sym "CONFIG_32BIT"
1837 fatal "Unknown wordsize!"
1839 if test "$bigendian" = "yes" ; then
1840 output_sym "CONFIG_BIG_ENDIAN"
1842 output_sym "CONFIG_LITTLE_ENDIAN"
1844 if test "$zlib" = "yes" ; then
1845 output_sym "CONFIG_ZLIB"
1847 if test "$libaio" = "yes" ; then
1848 output_sym "CONFIG_LIBAIO"
1850 if test "$posix_aio" = "yes" ; then
1851 output_sym "CONFIG_POSIXAIO"
1853 if test "$posix_aio_fsync" = "yes" ; then
1854 output_sym "CONFIG_POSIXAIO_FSYNC"
1856 if test "$linux_fallocate" = "yes" ; then
1857 output_sym "CONFIG_LINUX_FALLOCATE"
1859 if test "$posix_fallocate" = "yes" ; then
1860 output_sym "CONFIG_POSIX_FALLOCATE"
1862 if test "$fdatasync" = "yes" ; then
1863 output_sym "CONFIG_FDATASYNC"
1865 if test "$sync_file_range" = "yes" ; then
1866 output_sym "CONFIG_SYNC_FILE_RANGE"
1868 if test "$sfaa" = "yes" ; then
1869 output_sym "CONFIG_SFAA"
1871 if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
1872 output_sym "CONFIG_RDMA"
1874 if test "$clock_gettime" = "yes" ; then
1875 output_sym "CONFIG_CLOCK_GETTIME"
1877 if test "$clock_monotonic" = "yes" ; then
1878 output_sym "CONFIG_CLOCK_MONOTONIC"
1880 if test "$clock_monotonic_raw" = "yes" ; then
1881 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
1883 if test "$clock_monotonic_precise" = "yes" ; then
1884 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
1886 if test "$clockid_t" = "yes"; then
1887 output_sym "CONFIG_CLOCKID_T"
1889 if test "$gettimeofday" = "yes" ; then
1890 output_sym "CONFIG_GETTIMEOFDAY"
1892 if test "$posix_fadvise" = "yes" ; then
1893 output_sym "CONFIG_POSIX_FADVISE"
1895 if test "$linux_3arg_affinity" = "yes" ; then
1896 output_sym "CONFIG_3ARG_AFFINITY"
1897 elif test "$linux_2arg_affinity" = "yes" ; then
1898 output_sym "CONFIG_2ARG_AFFINITY"
1900 if test "$strsep" = "yes" ; then
1901 output_sym "CONFIG_STRSEP"
1903 if test "$strcasestr" = "yes" ; then
1904 output_sym "CONFIG_STRCASESTR"
1906 if test "$strlcat" = "yes" ; then
1907 output_sym "CONFIG_STRLCAT"
1909 if test "$getopt_long_only" = "yes" ; then
1910 output_sym "CONFIG_GETOPT_LONG_ONLY"
1912 if test "$inet_aton" = "yes" ; then
1913 output_sym "CONFIG_INET_ATON"
1915 if test "$socklen_t" = "yes" ; then
1916 output_sym "CONFIG_SOCKLEN_T"
1918 if test "$ext4_me" = "yes" ; then
1919 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1921 if test "$linux_splice" = "yes" ; then
1922 output_sym "CONFIG_LINUX_SPLICE"
1924 if test "$guasi" = "yes" ; then
1925 output_sym "CONFIG_GUASI"
1927 if test "$fusion_aw" = "yes" ; then
1928 output_sym "CONFIG_FUSION_AW"
1930 if test "$libnuma_v2" = "yes" ; then
1931 output_sym "CONFIG_LIBNUMA"
1933 if test "$solaris_aio" = "yes" ; then
1934 output_sym "CONFIG_SOLARISAIO"
1936 if test "$tls_thread" = "yes" ; then
1937 output_sym "CONFIG_TLS_THREAD"
1939 if test "$rusage_thread" = "yes" ; then
1940 output_sym "CONFIG_RUSAGE_THREAD"
1942 if test "$gfio" = "yes" ; then
1943 echo "CONFIG_GFIO=y" >> $config_host_mak
1945 if test "$esx" = "yes" ; then
1946 output_sym "CONFIG_ESX"
1947 output_sym "CONFIG_NO_SHM"
1949 if test "$sched_idle" = "yes" ; then
1950 output_sym "CONFIG_SCHED_IDLE"
1952 if test "$tcp_nodelay" = "yes" ; then
1953 output_sym "CONFIG_TCP_NODELAY"
1955 if test "$window_size" = "yes" ; then
1956 output_sym "CONFIG_NET_WINDOWSIZE"
1958 if test "$mss" = "yes" ; then
1959 output_sym "CONFIG_NET_MSS"
1961 if test "$rlimit_memlock" = "yes" ; then
1962 output_sym "CONFIG_RLIMIT_MEMLOCK"
1964 if test "$pwritev" = "yes" ; then
1965 output_sym "CONFIG_PWRITEV"
1967 if test "$pwritev2" = "yes" ; then
1968 output_sym "CONFIG_PWRITEV2"
1970 if test "$ipv6" = "yes" ; then
1971 output_sym "CONFIG_IPV6"
1973 if test "$rbd" = "yes" ; then
1974 output_sym "CONFIG_RBD"
1976 if test "$rbd_poll" = "yes" ; then
1977 output_sym "CONFIG_RBD_POLL"
1979 if test "$rbd_inval" = "yes" ; then
1980 output_sym "CONFIG_RBD_INVAL"
1982 if test "$rbd_blkin" = "yes" ; then
1983 output_sym "CONFIG_RBD_BLKIN"
1985 if test "$setvbuf" = "yes" ; then
1986 output_sym "CONFIG_SETVBUF"
1988 if test "$s390_z196_facilities" = "yes" ; then
1989 output_sym "CONFIG_S390_Z196_FACILITIES"
1990 CFLAGS="$CFLAGS -march=z9-109"
1992 if test "$gfapi" = "yes" ; then
1993 output_sym "CONFIG_GFAPI"
1995 if test "$gf_fadvise" = "yes" ; then
1996 output_sym "CONFIG_GF_FADVISE"
1998 if test "$gf_trim" = "yes" ; then
1999 output_sym "CONFIG_GF_TRIM"
2001 if test "$libhdfs" = "yes" ; then
2002 output_sym "CONFIG_LIBHDFS"
2003 echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
2004 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
2005 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
2006 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
2008 if test "$mtd" = "yes" ; then
2009 output_sym "CONFIG_MTD"
2011 if test "$pmemblk" = "yes" ; then
2012 output_sym "CONFIG_PMEMBLK"
2014 if test "$devdax" = "yes" ; then
2015 output_sym "CONFIG_LINUX_DEVDAX"
2017 if test "$arith" = "yes" ; then
2018 output_sym "CONFIG_ARITHMETIC"
2019 if test "$yacc_is_bison" = "yes" ; then
2020 echo "YACC=$YACC -y" >> $config_host_mak
2022 echo "YACC=$YACC" >> $config_host_mak
2024 if test "$lex_use_o" = "yes" ; then
2025 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
2028 if test "$getmntent" = "yes" ; then
2029 output_sym "CONFIG_GETMNTENT"
2031 if test "$getmntinfo" = "yes" ; then
2032 output_sym "CONFIG_GETMNTINFO"
2034 if test "$getmntinfo_statvfs" = "yes" ; then
2035 output_sym "CONFIG_GETMNTINFO_STATVFS"
2037 if test "$static_assert" = "yes" ; then
2038 output_sym "CONFIG_STATIC_ASSERT"
2040 if test "$have_bool" = "yes" ; then
2041 output_sym "CONFIG_HAVE_BOOL"
2044 if test "$zlib" = "no" ; then
2045 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
2048 echo "LIBS+=$LIBS" >> $config_host_mak
2049 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
2050 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
2051 echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
2052 echo "CC=$cc" >> $config_host_mak
2053 echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
2054 echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
2056 if [ `dirname $0` != "." -a ! -e Makefile ]; then
2057 cat > Makefile <<EOF
2058 SRCDIR:=`dirname $0`
2059 include \$(SRCDIR)/Makefile