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_FADVISE"
315 output_sym "CONFIG_SOCKLEN_T"
316 output_sym "CONFIG_FADVISE"
317 output_sym "CONFIG_SFAA"
318 output_sym "CONFIG_RUSAGE_THREAD"
319 output_sym "CONFIG_WINDOWSAIO"
320 output_sym "CONFIG_FDATASYNC"
321 output_sym "CONFIG_CLOCK_MONOTONIC"
322 output_sym "CONFIG_GETTIMEOFDAY"
323 output_sym "CONFIG_CLOCK_GETTIME"
324 output_sym "CONFIG_SCHED_IDLE"
325 output_sym "CONFIG_TCP_NODELAY"
326 output_sym "CONFIG_TLS_THREAD"
327 output_sym "CONFIG_STATIC_ASSERT"
328 output_sym "CONFIG_IPV6"
329 echo "CC=$CC" >> $config_host_mak
330 echo "BUILD_CFLAGS=$CFLAGS -I../zlib -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
336 if test ! -z "$cpu" ; then
337 # command line argument
339 elif check_define __i386__ ; then
341 elif check_define __x86_64__ ; then
343 elif check_define __sparc__ ; then
344 if check_define __arch64__ ; then
349 elif check_define _ARCH_PPC ; then
350 if check_define _ARCH_PPC64 ; then
355 elif check_define __mips__ ; then
357 elif check_define __ia64__ ; then
359 elif check_define __s390__ ; then
360 if check_define __s390x__ ; then
365 elif check_define __arm__ ; then
367 elif check_define __aarch64__ ; then
369 elif check_define __hppa__ ; then
375 # Normalise host CPU name and set ARCH.
377 ia64|ppc|ppc64|s390|s390x|sparc64)
380 i386|i486|i586|i686|i86pc|BePC)
392 hppa|parisc|parisc64)
406 if test -z "$CC" ; then
407 if test "$targetos" = "FreeBSD"; then
416 cc="${CC-${cross_prefix}gcc}"
418 ##########################################
419 # check cross compile
428 if compile_prog "" "" "cross"; then
429 $TMPE 2>/dev/null || cross_compile="yes"
431 fatal "compile test failed"
434 ##########################################
437 if test "$cross_compile" = "no" ; then
439 #include <inttypes.h>
442 volatile uint32_t i=0x01234567;
443 return (*((uint8_t*)(&i))) == 0x67;
446 if compile_prog "" "" "endian"; then
447 $TMPE && bigendian="yes"
450 # If we're cross compiling, try our best to work it out and rely on the
451 # run-time check to fail if we get it wrong.
456 #if __BYTE_ORDER != __BIG_ENDIAN
457 # error "Unknown endianness"
461 compile_prog "" "" "endian" && bigendian="yes"
462 check_define "__ARMEB__" && bigendian="yes"
463 check_define "__MIPSEB__" && bigendian="yes"
467 echo "Operating system $targetos"
469 echo "Big endian $bigendian"
471 echo "Cross compile $cross_compile"
474 ##########################################
475 # See if we need to build a static build
476 if test "$build_static" = "yes" ; then
477 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
478 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
482 echo "Static build $build_static"
484 ##########################################
489 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
492 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
496 if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
498 elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
501 fatal "Unknown wordsize"
503 echo "Wordsize $wordsize"
505 ##########################################
513 if (inflateInit(&stream) != Z_OK)
518 if compile_prog "" "-lz" "zlib" ; then
524 ##########################################
527 if test "$esx" != "yes" ; then
537 if compile_prog "" "-laio" "libaio" ; then
541 if test "$libaio" = "yes" ; then
542 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
547 echo "Linux AIO support $libaio"
549 ##########################################
562 if compile_prog "" "" "posixaio" ; then
564 elif compile_prog "" "-lrt" "posixaio"; then
569 echo "POSIX AIO support $posix_aio"
570 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
572 ##########################################
573 # posix aio fsync probe
575 if test "$posix_aio" = "yes" ; then
582 return aio_fsync(O_SYNC, &cb);
586 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
590 echo "POSIX AIO fsync $posix_aio_fsync"
592 ##########################################
596 #include <sys/types.h>
597 #include <sys/asynch.h>
602 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
606 if compile_prog "" "-laio" "solarisaio" ; then
610 echo "Solaris AIO support $solaris_aio"
612 ##########################################
613 # __sync_fetch_and_add test
616 #include <inttypes.h>
617 static int sfaa(uint64_t *ptr)
619 return __sync_fetch_and_add(ptr, 0);
622 int main(int argc, char **argv)
629 if compile_prog "" "" "__sync_fetch_and_add()" ; then
632 echo "__sync_fetch_and_add $sfaa"
634 ##########################################
639 #include <infiniband/arch.h>
640 int main(int argc, char **argv)
642 struct ibv_pd *pd = ibv_alloc_pd(NULL);
646 if compile_prog "" "-libverbs" "libverbs" ; then
648 LIBS="-libverbs $LIBS"
650 echo "libverbs $libverbs"
652 ##########################################
657 #include <rdma/rdma_cma.h>
658 int main(int argc, char **argv)
660 rdma_destroy_qp(NULL);
664 if compile_prog "" "-lrdmacm" "rdma"; then
666 LIBS="-lrdmacm $LIBS"
668 echo "rdmacm $rdmacm"
670 ##########################################
671 # Linux fallocate probe
676 #include <linux/falloc.h>
677 int main(int argc, char **argv)
679 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
683 if compile_prog "" "" "linux_fallocate"; then
684 linux_fallocate="yes"
686 echo "Linux fallocate $linux_fallocate"
688 ##########################################
689 # POSIX fadvise probe
694 int main(int argc, char **argv)
696 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
700 if compile_prog "" "" "posix_fadvise"; then
703 echo "POSIX fadvise $posix_fadvise"
705 ##########################################
706 # POSIX fallocate probe
711 int main(int argc, char **argv)
713 int r = posix_fallocate(0, 0, 1024);
717 if compile_prog "" "" "posix_fallocate"; then
718 posix_fallocate="yes"
720 echo "POSIX fallocate $posix_fallocate"
722 ##########################################
723 # sched_set/getaffinity 2 or 3 argument test
724 linux_2arg_affinity="no"
725 linux_3arg_affinity="no"
728 int main(int argc, char **argv)
731 return sched_setaffinity(0, sizeof(mask), &mask);
734 if compile_prog "" "" "sched_setaffinity(,,)"; then
735 linux_3arg_affinity="yes"
739 int main(int argc, char **argv)
742 return sched_setaffinity(0, &mask);
745 if compile_prog "" "" "sched_setaffinity(,)"; then
746 linux_2arg_affinity="yes"
749 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
750 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
752 ##########################################
753 # clock_gettime probe
758 int main(int argc, char **argv)
760 return clock_gettime(0, NULL);
763 if compile_prog "" "" "clock_gettime"; then
765 elif compile_prog "" "-lrt" "clock_gettime"; then
769 echo "clock_gettime $clock_gettime"
771 ##########################################
772 # CLOCK_MONOTONIC probe
774 if test "$clock_gettime" = "yes" ; then
778 int main(int argc, char **argv)
780 return clock_gettime(CLOCK_MONOTONIC, NULL);
783 if compile_prog "" "$LIBS" "clock monotonic"; then
784 clock_monotonic="yes"
787 echo "CLOCK_MONOTONIC $clock_monotonic"
789 ##########################################
790 # CLOCK_MONOTONIC_RAW probe
791 clock_monotonic_raw="no"
792 if test "$clock_gettime" = "yes" ; then
796 int main(int argc, char **argv)
798 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
801 if compile_prog "" "$LIBS" "clock monotonic"; then
802 clock_monotonic_raw="yes"
805 echo "CLOCK_MONOTONIC_RAW $clock_monotonic_raw"
807 ##########################################
808 # CLOCK_MONOTONIC_PRECISE probe
809 clock_monotonic_precise="no"
810 if test "$clock_gettime" = "yes" ; then
814 int main(int argc, char **argv)
816 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
819 if compile_prog "" "$LIBS" "clock monotonic precise"; then
820 clock_monotonic_precise="yes"
823 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
825 ##########################################
830 int main(int argc, char **argv)
832 volatile clockid_t cid;
833 memset(&cid, 0, sizeof(cid));
837 if compile_prog "" "$LIBS" "clockid_t"; then
840 echo "clockid_t $clockid_t"
842 ##########################################
843 # gettimeofday() probe
846 #include <sys/time.h>
848 int main(int argc, char **argv)
851 return gettimeofday(&tv, NULL);
854 if compile_prog "" "" "gettimeofday"; then
857 echo "gettimeofday $gettimeofday"
859 ##########################################
865 int main(int argc, char **argv)
870 if compile_prog "" "" "fdatasync"; then
873 echo "fdatasync $fdatasync"
875 ##########################################
876 # sync_file_range() probe
882 #include <linux/fs.h>
883 int main(int argc, char **argv)
885 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
886 SYNC_FILE_RANGE_WAIT_AFTER;
887 return sync_file_range(0, 0, 0, flags);
890 if compile_prog "" "" "sync_file_range"; then
891 sync_file_range="yes"
893 echo "sync_file_range $sync_file_range"
895 ##########################################
896 # ext4 move extent probe
900 #include <sys/ioctl.h>
901 int main(int argc, char **argv)
903 struct move_extent me;
904 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
907 if compile_prog "" "" "ext4 move extent" ; then
909 elif test $targetos = "Linux" ; then
910 # On Linux, just default to it on and let it error at runtime if we really
911 # don't have it. None of my updated systems have it defined, but it does
912 # work. Takes a while to bubble back.
915 echo "EXT4 move extent $ext4_me"
917 ##########################################
923 int main(int argc, char **argv)
925 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
928 if compile_prog "" "" "linux splice"; then
931 echo "Linux splice(2) $linux_splice"
933 ##########################################
938 #include <guasi_syscalls.h>
939 int main(int argc, char **argv)
941 guasi_t ctx = guasi_create(0, 0, 0);
945 if compile_prog "" "" "guasi"; then
950 ##########################################
954 #include <nvm/nvm_primitives.h>
955 int main(int argc, char **argv)
957 nvm_version_t ver_info;
960 handle = nvm_get_handle(0, &ver_info);
961 return nvm_atomic_write(handle, 0, 0, 0);
964 if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
965 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
968 echo "Fusion-io atomic engine $fusion_aw"
970 ##########################################
975 int main(int argc, char **argv)
977 return numa_available();
980 if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
984 echo "libnuma $libnuma"
986 ##########################################
987 # libnuma 2.x version API
988 if test "$libnuma" = "yes" ; then
992 int main(int argc, char **argv)
994 struct bitmask *mask = numa_parse_nodestring(NULL);
995 return mask->size == 0;
998 if compile_prog "" "" "libnuma api"; then
1001 echo "libnuma v2 $libnuma_v2"
1004 ##########################################
1009 int main(int argc, char **argv)
1011 static char *string = "This is a string";
1012 strsep(&string, "needle");
1016 if compile_prog "" "" "strsep"; then
1019 echo "strsep $strsep"
1021 ##########################################
1022 # strcasestr() probe
1026 int main(int argc, char **argv)
1028 return strcasestr(argv[0], argv[1]) != NULL;
1031 if compile_prog "" "" "strcasestr"; then
1034 echo "strcasestr $strcasestr"
1036 ##########################################
1041 int main(int argc, char **argv)
1043 static char dst[64];
1044 static char *string = "This is a string";
1045 memset(dst, 0, sizeof(dst));
1046 strlcat(dst, string, sizeof(dst));
1050 if compile_prog "" "" "strlcat"; then
1053 echo "strlcat $strlcat"
1055 ##########################################
1056 # getopt_long_only() probe
1057 getopt_long_only="no"
1062 int main(int argc, char **argv)
1064 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1068 if compile_prog "" "" "getopt_long_only"; then
1069 getopt_long_only="yes"
1071 echo "getopt_long_only() $getopt_long_only"
1073 ##########################################
1077 #include <sys/socket.h>
1078 #include <arpa/inet.h>
1080 int main(int argc, char **argv)
1083 return inet_aton(NULL, &in);
1086 if compile_prog "" "" "inet_aton"; then
1089 echo "inet_aton $inet_aton"
1091 ##########################################
1095 #include <sys/socket.h>
1096 int main(int argc, char **argv)
1102 if compile_prog "" "" "socklen_t"; then
1105 echo "socklen_t $socklen_t"
1107 ##########################################
1108 # Whether or not __thread is supported for TLS
1112 static __thread int ret;
1113 int main(int argc, char **argv)
1118 if compile_prog "" "" "__thread"; then
1121 echo "__thread $tls_thread"
1123 ##########################################
1124 # Check if we have required gtk/glib support for gfio
1126 if test "$gfio_check" = "yes" ; then
1130 #include <gtk/gtk.h>
1133 gdk_threads_enter();
1134 gdk_threads_leave();
1136 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
1139 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1140 ORG_LDFLAGS=$LDFLAGS
1141 LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1142 if test "$?" != "0" ; then
1143 echo "configure: gtk and gthread not found"
1146 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1147 if test "$?" != "0" ; then
1148 echo "configure: gtk and gthread not found"
1151 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1153 if test "$r" != "0" ; then
1155 GFIO_LIBS="$LIBS $GTK_LIBS"
1156 CFLAGS="$CFLAGS $GTK_CFLAGS"
1158 echo "GTK found, but need version 2.18 or higher"
1162 echo "Please install gtk and gdk libraries"
1165 LDFLAGS=$ORG_LDFLAGS
1168 if test "$gfio_check" = "yes" ; then
1169 echo "gtk 2.18 or higher $gfio"
1172 # Check whether we have getrusage(RUSAGE_THREAD)
1175 #include <sys/time.h>
1176 #include <sys/resource.h>
1177 int main(int argc, char **argv)
1180 getrusage(RUSAGE_THREAD, &ru);
1184 if compile_prog "" "" "RUSAGE_THREAD"; then
1187 echo "RUSAGE_THREAD $rusage_thread"
1189 ##########################################
1190 # Check whether we have SCHED_IDLE
1194 int main(int argc, char **argv)
1196 struct sched_param p;
1197 return sched_setscheduler(0, SCHED_IDLE, &p);
1200 if compile_prog "" "" "SCHED_IDLE"; then
1203 echo "SCHED_IDLE $sched_idle"
1205 ##########################################
1206 # Check whether we have TCP_NODELAY
1210 #include <sys/types.h>
1211 #include <sys/socket.h>
1212 #include <netinet/tcp.h>
1213 int main(int argc, char **argv)
1215 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1218 if compile_prog "" "" "TCP_NODELAY"; then
1221 echo "TCP_NODELAY $tcp_nodelay"
1223 ##########################################
1224 # Check whether we have SO_SNDBUF
1228 #include <sys/types.h>
1229 #include <sys/socket.h>
1230 #include <netinet/tcp.h>
1231 int main(int argc, char **argv)
1233 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1234 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1237 if compile_prog "" "" "SO_SNDBUF"; then
1240 echo "Net engine window_size $window_size"
1242 ##########################################
1243 # Check whether we have TCP_MAXSEG
1247 #include <sys/types.h>
1248 #include <sys/socket.h>
1249 #include <netinet/tcp.h>
1250 #include <arpa/inet.h>
1251 #include <netinet/in.h>
1252 int main(int argc, char **argv)
1254 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1257 if compile_prog "" "" "TCP_MAXSEG"; then
1260 echo "TCP_MAXSEG $mss"
1262 ##########################################
1263 # Check whether we have RLIMIT_MEMLOCK
1266 #include <sys/time.h>
1267 #include <sys/resource.h>
1268 int main(int argc, char **argv)
1271 return getrlimit(RLIMIT_MEMLOCK, &rl);
1274 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1275 rlimit_memlock="yes"
1277 echo "RLIMIT_MEMLOCK $rlimit_memlock"
1279 ##########################################
1280 # Check whether we have pwritev/preadv
1284 #include <sys/uio.h>
1285 int main(int argc, char **argv)
1287 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1290 if compile_prog "" "" "pwritev"; then
1293 echo "pwritev/preadv $pwritev"
1295 ##########################################
1296 # Check whether we have pwritev2/preadv2
1300 #include <sys/uio.h>
1301 int main(int argc, char **argv)
1303 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1306 if compile_prog "" "" "pwritev2"; then
1309 echo "pwritev2/preadv2 $pwritev2"
1311 ##########################################
1312 # Check whether we have the required functions for ipv6
1315 #include <sys/types.h>
1316 #include <sys/socket.h>
1317 #include <netinet/in.h>
1320 int main(int argc, char **argv)
1322 struct addrinfo hints;
1323 struct in6_addr addr;
1326 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1328 printf("%s\n", gai_strerror(ret));
1333 if compile_prog "" "" "ipv6"; then
1336 echo "IPv6 helpers $ipv6"
1338 ##########################################
1342 #include <rbd/librbd.h>
1344 int main(int argc, char **argv)
1348 rados_ioctx_t io_ctx;
1349 const char pool[] = "rbd";
1351 int major, minor, extra;
1352 rbd_version(&major, &minor, &extra);
1354 rados_ioctx_create(cluster, pool, &io_ctx);
1358 if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
1359 LIBS="-lrbd -lrados $LIBS"
1362 echo "Rados Block Device engine $rbd"
1364 ##########################################
1365 # check for rbd_poll
1367 if test "$rbd" = "yes"; then
1369 #include <rbd/librbd.h>
1370 #include <sys/eventfd.h>
1372 int main(int argc, char **argv)
1375 rbd_completion_t comp;
1377 int fd = eventfd(0, EFD_NONBLOCK);
1378 rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1379 rbd_poll_io_events(image, comp, 1);
1384 if compile_prog "" "-lrbd -lrados" "rbd"; then
1387 echo "rbd_poll $rbd_poll"
1390 ##########################################
1391 # check for rbd_invaidate_cache()
1393 if test "$rbd" = "yes"; then
1395 #include <rbd/librbd.h>
1397 int main(int argc, char **argv)
1401 return rbd_invalidate_cache(image);
1404 if compile_prog "" "-lrbd -lrados" "rbd"; then
1407 echo "rbd_invalidate_cache $rbd_inval"
1410 ##########################################
1414 #include <rbd/librbd.h>
1415 #include <zipkin_c.h>
1417 int main(int argc, char **argv)
1420 struct blkin_trace_info t_info;
1421 blkin_init_trace_info(&t_info);
1422 rbd_completion_t completion;
1427 r = rbd_aio_write_traced(image, off, len, buf, completion, &t_info);
1431 if test "$disable_rbd" != "yes" && test "$disable_rbd_blkin" != "yes" \
1432 && compile_prog "" "-lrbd -lrados -lblkin" "rbd_blkin"; then
1433 LIBS="-lblkin $LIBS"
1436 echo "rbd blkin tracing $rbd_blkin"
1438 ##########################################
1439 # Check whether we have setvbuf
1443 int main(int argc, char **argv)
1447 setvbuf(f, buf, _IOFBF, sizeof(buf));
1451 if compile_prog "" "" "setvbuf"; then
1454 echo "setvbuf $setvbuf"
1459 #include <glusterfs/api/glfs.h>
1461 int main(int argc, char **argv)
1464 glfs_t *g = glfs_new("foo");
1469 if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1470 LIBS="-lgfapi -lglusterfs $LIBS"
1473 echo "Gluster API engine $gfapi"
1475 ##########################################
1476 # check for gfapi fadvise support
1477 if test "$gfapi" = "yes" ; then
1480 #include <glusterfs/api/glfs.h>
1482 int main(int argc, char **argv)
1485 int ret = glfs_fadvise(fd, 0, 0, 1);
1490 if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1493 echo "Gluster API use fadvise $gf_fadvise"
1496 ##########################################
1497 # check for gfapi trim support
1499 if test "$gfapi" = "yes" ; then
1501 #include <glusterfs/api/glfs.h>
1503 int main(int argc, char **argv)
1505 return glfs_discard_async(NULL, 0, 0);
1508 if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1511 echo "Gluster API trim support $gf_trim"
1514 ##########################################
1515 # Check if we support stckf on s390
1516 s390_z196_facilities="no"
1518 #define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1519 int main(int argc, char **argv)
1521 /* We want just 1 double word to be returned. */
1522 register unsigned long reg0 asm("0") = 0;
1523 unsigned long stfle_bits;
1524 asm volatile(".machine push" "\n\t"
1525 ".machine \"z9-109\"" "\n\t"
1528 : "=QS" (stfle_bits), "+d" (reg0)
1531 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1537 if compile_prog "" "" "s390_z196_facilities"; then
1539 if [[ $? -eq 0 ]]; then
1540 s390_z196_facilities="yes"
1543 echo "s390_z196_facilities $s390_z196_facilities"
1545 ##########################################
1546 # Check if we have required environment variables configured for libhdfs
1547 if test "$libhdfs" = "yes" ; then
1549 if test "$JAVA_HOME" = "" ; then
1550 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1553 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1554 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1557 if test "$FIO_LIBHDFS_LIB" = "" ; then
1558 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1561 if test "$hdfs_conf_error" = "1" ; then
1565 if test "$FIO_HDFS_CPU" = "x86_64" ; then
1566 FIO_HDFS_CPU="amd64"
1569 echo "HDFS engine $libhdfs"
1571 ##########################################
1572 # Check whether we have MTD
1576 #include <mtd/mtd-user.h>
1577 #include <sys/ioctl.h>
1578 int main(int argc, char **argv)
1580 struct mtd_write_req ops;
1581 struct mtd_info_user info;
1582 memset(&ops, 0, sizeof(ops));
1583 info.type = MTD_MLCNANDFLASH;
1584 return ioctl(0, MEMGETINFO, &info);
1587 if compile_prog "" "" "mtd"; then
1592 ##########################################
1593 # Check whether we have libpmem
1596 #include <libpmem.h>
1597 int main(int argc, char **argv)
1600 rc = pmem_is_pmem(0, 0);
1604 if compile_prog "" "-lpmem" "libpmem"; then
1608 echo "libpmem $libpmem"
1610 ##########################################
1611 # Check whether we have libpmemblk
1612 # libpmem is a prerequisite
1614 if test "$libpmem" = "yes"; then
1616 #include <libpmemblk.h>
1617 int main(int argc, char **argv)
1620 pbp = pmemblk_open("", 0);
1624 if compile_prog "" "-lpmemblk" "libpmemblk"; then
1626 LIBS="-lpmemblk $LIBS"
1629 echo "libpmemblk $libpmemblk"
1631 # Choose the ioengines
1632 if test "$libpmem" = "yes" && test "$disable_pmem" = "no"; then
1634 if test "$libpmemblk" = "yes"; then
1639 ##########################################
1640 # Report whether pmemblk engine is enabled
1641 echo "NVML pmemblk engine $pmemblk"
1643 ##########################################
1644 # Report whether dev-dax engine is enabled
1645 echo "NVML dev-dax engine $devdax"
1647 # Check if we have lex/yacc available
1652 if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
1653 if test "$targetos" != "SunOS" ; then
1654 LEX=$(which lex 2> /dev/null)
1655 if test -x "$LEX" ; then
1658 YACC=$(which bison 2> /dev/null)
1659 if test -x "$YACC" ; then
1663 YACC=$(which yacc 2> /dev/null)
1664 if test -x "$YACC" ; then
1668 if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1672 if test "$arith" = "yes" ; then
1674 extern int yywrap(void);
1676 int main(int argc, char **argv)
1682 if compile_prog "" "-ll" "lex"; then
1691 # Check if lex fails using -o
1692 if test "$arith" = "yes" ; then
1693 if test "$force_no_lex_o" = "yes" ; then
1696 $LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1697 if test "$?" = "0" ; then
1705 echo "lex/yacc for arithmetic $arith"
1707 ##########################################
1708 # Check whether we have setmntent/getmntent
1713 int main(int argc, char **argv)
1715 FILE *mtab = setmntent(NULL, "r");
1716 struct mntent *mnt = getmntent(mtab);
1721 if compile_prog "" "" "getmntent"; then
1724 echo "getmntent $getmntent"
1726 ##########################################
1727 # Check whether we have getmntinfo
1728 # These are originally added for BSDs, but may also work
1729 # on other operating systems with getmntinfo(3).
1731 # getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
1732 # Note that NetBSD needs -Werror to catch warning as error.
1736 #include <sys/param.h>
1737 #include <sys/mount.h>
1738 int main(int argc, char **argv)
1741 return getmntinfo(&st, MNT_NOWAIT);
1744 if compile_prog "-Werror" "" "getmntinfo"; then
1747 echo "getmntinfo $getmntinfo"
1749 # getmntinfo(3) for NetBSD.
1750 getmntinfo_statvfs="no"
1753 #include <sys/statvfs.h>
1754 int main(int argc, char **argv)
1757 return getmntinfo(&st, MNT_NOWAIT);
1760 # Skip the test if the one with statfs arg is detected.
1761 if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
1762 getmntinfo_statvfs="yes"
1763 echo "getmntinfo_statvfs $getmntinfo_statvfs"
1766 ##########################################
1767 # Check whether we have _Static_assert
1773 #ifdef __compiler_offsetof
1774 #define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
1776 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1779 #define container_of(ptr, type, member) ({ \
1780 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
1781 (type *)( (char *)__mptr - offsetof(type,member) );})
1787 int main(int argc, char **argv)
1789 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
1793 if compile_prog "" "" "static_assert"; then
1796 echo "Static Assert $static_assert"
1798 ##########################################
1799 # Check whether we have bool / stdbool.h
1802 #include <stdbool.h>
1803 int main(int argc, char **argv)
1806 return var != false;
1809 if compile_prog "" "" "bool"; then
1812 echo "bool $have_bool"
1814 ##########################################
1815 # check march=armv8-a+crc+crypto
1816 march_armv8_a_crc_crypto="no"
1817 if test "$cpu" = "arm64" ; then
1824 if compile_prog "-march=armv8-a+crc+crypto" "" ""; then
1825 march_armv8_a_crc_crypto="yes"
1826 CFLAGS="$CFLAGS -march=armv8-a+crc+crypto -DARCH_HAVE_CRC_CRYPTO"
1829 echo "march_armv8_a_crc_crypto $march_armv8_a_crc_crypto"
1832 #############################################################################
1834 if test "$wordsize" = "64" ; then
1835 output_sym "CONFIG_64BIT"
1836 elif test "$wordsize" = "32" ; then
1837 output_sym "CONFIG_32BIT"
1839 fatal "Unknown wordsize!"
1841 if test "$bigendian" = "yes" ; then
1842 output_sym "CONFIG_BIG_ENDIAN"
1844 output_sym "CONFIG_LITTLE_ENDIAN"
1846 if test "$zlib" = "yes" ; then
1847 output_sym "CONFIG_ZLIB"
1849 if test "$libaio" = "yes" ; then
1850 output_sym "CONFIG_LIBAIO"
1852 if test "$posix_aio" = "yes" ; then
1853 output_sym "CONFIG_POSIXAIO"
1855 if test "$posix_aio_fsync" = "yes" ; then
1856 output_sym "CONFIG_POSIXAIO_FSYNC"
1858 if test "$linux_fallocate" = "yes" ; then
1859 output_sym "CONFIG_LINUX_FALLOCATE"
1861 if test "$posix_fallocate" = "yes" ; then
1862 output_sym "CONFIG_POSIX_FALLOCATE"
1864 if test "$fdatasync" = "yes" ; then
1865 output_sym "CONFIG_FDATASYNC"
1867 if test "$sync_file_range" = "yes" ; then
1868 output_sym "CONFIG_SYNC_FILE_RANGE"
1870 if test "$sfaa" = "yes" ; then
1871 output_sym "CONFIG_SFAA"
1873 if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
1874 output_sym "CONFIG_RDMA"
1876 if test "$clock_gettime" = "yes" ; then
1877 output_sym "CONFIG_CLOCK_GETTIME"
1879 if test "$clock_monotonic" = "yes" ; then
1880 output_sym "CONFIG_CLOCK_MONOTONIC"
1882 if test "$clock_monotonic_raw" = "yes" ; then
1883 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
1885 if test "$clock_monotonic_precise" = "yes" ; then
1886 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
1888 if test "$clockid_t" = "yes"; then
1889 output_sym "CONFIG_CLOCKID_T"
1891 if test "$gettimeofday" = "yes" ; then
1892 output_sym "CONFIG_GETTIMEOFDAY"
1894 if test "$posix_fadvise" = "yes" ; then
1895 output_sym "CONFIG_POSIX_FADVISE"
1897 if test "$linux_3arg_affinity" = "yes" ; then
1898 output_sym "CONFIG_3ARG_AFFINITY"
1899 elif test "$linux_2arg_affinity" = "yes" ; then
1900 output_sym "CONFIG_2ARG_AFFINITY"
1902 if test "$strsep" = "yes" ; then
1903 output_sym "CONFIG_STRSEP"
1905 if test "$strcasestr" = "yes" ; then
1906 output_sym "CONFIG_STRCASESTR"
1908 if test "$strlcat" = "yes" ; then
1909 output_sym "CONFIG_STRLCAT"
1911 if test "$getopt_long_only" = "yes" ; then
1912 output_sym "CONFIG_GETOPT_LONG_ONLY"
1914 if test "$inet_aton" = "yes" ; then
1915 output_sym "CONFIG_INET_ATON"
1917 if test "$socklen_t" = "yes" ; then
1918 output_sym "CONFIG_SOCKLEN_T"
1920 if test "$ext4_me" = "yes" ; then
1921 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1923 if test "$linux_splice" = "yes" ; then
1924 output_sym "CONFIG_LINUX_SPLICE"
1926 if test "$guasi" = "yes" ; then
1927 output_sym "CONFIG_GUASI"
1929 if test "$fusion_aw" = "yes" ; then
1930 output_sym "CONFIG_FUSION_AW"
1932 if test "$libnuma_v2" = "yes" ; then
1933 output_sym "CONFIG_LIBNUMA"
1935 if test "$solaris_aio" = "yes" ; then
1936 output_sym "CONFIG_SOLARISAIO"
1938 if test "$tls_thread" = "yes" ; then
1939 output_sym "CONFIG_TLS_THREAD"
1941 if test "$rusage_thread" = "yes" ; then
1942 output_sym "CONFIG_RUSAGE_THREAD"
1944 if test "$gfio" = "yes" ; then
1945 echo "CONFIG_GFIO=y" >> $config_host_mak
1947 if test "$esx" = "yes" ; then
1948 output_sym "CONFIG_ESX"
1949 output_sym "CONFIG_NO_SHM"
1951 if test "$sched_idle" = "yes" ; then
1952 output_sym "CONFIG_SCHED_IDLE"
1954 if test "$tcp_nodelay" = "yes" ; then
1955 output_sym "CONFIG_TCP_NODELAY"
1957 if test "$window_size" = "yes" ; then
1958 output_sym "CONFIG_NET_WINDOWSIZE"
1960 if test "$mss" = "yes" ; then
1961 output_sym "CONFIG_NET_MSS"
1963 if test "$rlimit_memlock" = "yes" ; then
1964 output_sym "CONFIG_RLIMIT_MEMLOCK"
1966 if test "$pwritev" = "yes" ; then
1967 output_sym "CONFIG_PWRITEV"
1969 if test "$pwritev2" = "yes" ; then
1970 output_sym "CONFIG_PWRITEV2"
1972 if test "$ipv6" = "yes" ; then
1973 output_sym "CONFIG_IPV6"
1975 if test "$rbd" = "yes" ; then
1976 output_sym "CONFIG_RBD"
1978 if test "$rbd_poll" = "yes" ; then
1979 output_sym "CONFIG_RBD_POLL"
1981 if test "$rbd_inval" = "yes" ; then
1982 output_sym "CONFIG_RBD_INVAL"
1984 if test "$rbd_blkin" = "yes" ; then
1985 output_sym "CONFIG_RBD_BLKIN"
1987 if test "$setvbuf" = "yes" ; then
1988 output_sym "CONFIG_SETVBUF"
1990 if test "$s390_z196_facilities" = "yes" ; then
1991 output_sym "CONFIG_S390_Z196_FACILITIES"
1992 CFLAGS="$CFLAGS -march=z9-109"
1994 if test "$gfapi" = "yes" ; then
1995 output_sym "CONFIG_GFAPI"
1997 if test "$gf_fadvise" = "yes" ; then
1998 output_sym "CONFIG_GF_FADVISE"
2000 if test "$gf_trim" = "yes" ; then
2001 output_sym "CONFIG_GF_TRIM"
2003 if test "$libhdfs" = "yes" ; then
2004 output_sym "CONFIG_LIBHDFS"
2005 echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
2006 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
2007 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
2008 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
2010 if test "$mtd" = "yes" ; then
2011 output_sym "CONFIG_MTD"
2013 if test "$pmemblk" = "yes" ; then
2014 output_sym "CONFIG_PMEMBLK"
2016 if test "$devdax" = "yes" ; then
2017 output_sym "CONFIG_LINUX_DEVDAX"
2019 if test "$arith" = "yes" ; then
2020 output_sym "CONFIG_ARITHMETIC"
2021 if test "$yacc_is_bison" = "yes" ; then
2022 echo "YACC=$YACC -y" >> $config_host_mak
2024 echo "YACC=$YACC" >> $config_host_mak
2026 if test "$lex_use_o" = "yes" ; then
2027 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
2030 if test "$getmntent" = "yes" ; then
2031 output_sym "CONFIG_GETMNTENT"
2033 if test "$getmntinfo" = "yes" ; then
2034 output_sym "CONFIG_GETMNTINFO"
2036 if test "$getmntinfo_statvfs" = "yes" ; then
2037 output_sym "CONFIG_GETMNTINFO_STATVFS"
2039 if test "$static_assert" = "yes" ; then
2040 output_sym "CONFIG_STATIC_ASSERT"
2042 if test "$have_bool" = "yes" ; then
2043 output_sym "CONFIG_HAVE_BOOL"
2046 if test "$zlib" = "no" ; then
2047 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
2050 echo "LIBS+=$LIBS" >> $config_host_mak
2051 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
2052 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
2053 echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
2054 echo "CC=$cc" >> $config_host_mak
2055 echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
2056 echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
2058 if [ `dirname $0` != "." -a ! -e Makefile ]; then
2059 cat > Makefile <<EOF
2060 SRCDIR:=`dirname $0`
2061 include \$(SRCDIR)/Makefile