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
144 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
146 --prefix=*) prefix="$optarg"
148 --cpu=*) cpu="$optarg"
150 # esx is cross compiled and cannot be detect through simple uname calls
156 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
158 --build-32bit-win) build_32bit_win="yes"
160 --build-static) build_static="yes"
165 --disable-numa) disable_numa="yes"
167 --disable-rbd) disable_rbd="yes"
169 --disable-gfapi) disable_gfapi="yes"
171 --enable-libhdfs) libhdfs="yes"
173 --enable-pmemblk) pmemblk="yes"
175 --disable-lex) disable_lex="yes"
177 --enable-lex) disable_lex="no"
179 --disable-shm) no_shm="yes"
181 --disable-optimizations) disable_opt="yes"
187 echo "Bad option $opt"
193 if test "$show_help" = "yes" ; then
194 echo "--prefix= Use this directory as installation prefix"
195 echo "--cpu= Specify target CPU if auto-detect fails"
196 echo "--cc= Specify compiler to use"
197 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
198 echo "--build-32bit-win Enable 32-bit build on Windows"
199 echo "--build-static Build a static fio"
200 echo "--esx Configure build options for esx"
201 echo "--enable-gfio Enable building of gtk gfio"
202 echo "--disable-numa Disable libnuma even if found"
203 echo "--disable-gfapi Disable gfapi"
204 echo "--enable-libhdfs Enable hdfs support"
205 echo "--enable-pmemblk Enable NVML libpmemblk support"
206 echo "--disable-lex Disable use of lex/yacc for math"
207 echo "--enable-lex Enable use of lex/yacc for math"
208 echo "--disable-shm Disable SHM support"
209 echo "--disable-optimizations Don't enable compiler optimizations"
213 cross_prefix=${cross_prefix-${CROSS_COMPILE}}
214 cc="${CC-${cross_prefix}gcc}"
216 if check_define __ANDROID__ ; then
218 elif check_define __linux__ ; then
220 elif check_define __OpenBSD__ ; then
222 elif check_define __sun__ ; then
224 CFLAGS="$CFLAGS -D_REENTRANT"
225 elif check_define _WIN32 ; then
231 echo "# Automatically generated by configure - do not modify" > $config_host_mak
232 printf "# Configured with:" >> $config_host_mak
233 printf " '%s'" "$0" "$@" >> $config_host_mak
234 echo >> $config_host_mak
235 echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
237 if test "$no_shm" = "yes" ; then
238 output_sym "CONFIG_NO_SHM"
241 if test "$disable_opt" = "yes" ; then
242 output_sym "CONFIG_FIO_NO_OPT"
245 # Some host OSes need non-standard checks for which CPU to use.
246 # Note that these checks are broken for cross-compilation: if you're
247 # cross-compiling to one of these OSes then you'll need to specify
248 # the correct CPU with the --cpu option.
251 # Unless explicitly enabled, turn off lex.
252 if test -z "$disable_lex" ; then
259 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
260 # we can run 64-bit userspace code.
261 # If the user didn't specify a CPU explicitly and the kernel says this is
262 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
264 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
269 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
270 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
273 LIBS="-lnsl -lsocket"
276 echo "Forcing known good options on Windows"
277 if test -z "$CC" ; then
278 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
279 CC="i686-w64-mingw32-gcc"
281 CC="x86_64-w64-mingw32-gcc"
284 output_sym "CONFIG_LITTLE_ENDIAN"
285 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
286 output_sym "CONFIG_32BIT"
288 output_sym "CONFIG_64BIT_LLP64"
290 output_sym "CONFIG_FADVISE"
291 output_sym "CONFIG_SOCKLEN_T"
292 output_sym "CONFIG_FADVISE"
293 output_sym "CONFIG_SFAA"
294 output_sym "CONFIG_RUSAGE_THREAD"
295 output_sym "CONFIG_WINDOWSAIO"
296 output_sym "CONFIG_FDATASYNC"
297 output_sym "CONFIG_CLOCK_MONOTONIC"
298 output_sym "CONFIG_GETTIMEOFDAY"
299 output_sym "CONFIG_CLOCK_GETTIME"
300 output_sym "CONFIG_SCHED_IDLE"
301 output_sym "CONFIG_TCP_NODELAY"
302 output_sym "CONFIG_TLS_THREAD"
303 output_sym "CONFIG_IPV6"
304 echo "CC=$CC" >> $config_host_mak
305 echo "BUILD_CFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
310 if test ! -z "$cpu" ; then
311 # command line argument
313 elif check_define __i386__ ; then
315 elif check_define __x86_64__ ; then
317 elif check_define __sparc__ ; then
318 if check_define __arch64__ ; then
323 elif check_define _ARCH_PPC ; then
324 if check_define _ARCH_PPC64 ; then
329 elif check_define __mips__ ; then
331 elif check_define __ia64__ ; then
333 elif check_define __s390__ ; then
334 if check_define __s390x__ ; then
339 elif check_define __arm__ ; then
341 elif check_define __hppa__ ; then
347 # Normalise host CPU name and set ARCH.
349 ia64|ppc|ppc64|s390|s390x|sparc64)
352 i386|i486|i586|i686|i86pc|BePC)
361 hppa|parisc|parisc64)
375 if test -z "$CC" ; then
376 if test "$targetos" = "FreeBSD"; then
385 cc="${CC-${cross_prefix}gcc}"
387 ##########################################
388 # check cross compile
397 if compile_prog "" "" "cross"; then
398 $TMPE 2>/dev/null || cross_compile="yes"
400 fatal "compile test failed"
403 ##########################################
406 if test "$cross_compile" = "no" ; then
408 #include <inttypes.h>
411 volatile uint32_t i=0x01234567;
412 return (*((uint8_t*)(&i))) == 0x67;
415 if compile_prog "" "" "endian"; then
416 $TMPE && bigendian="yes"
419 # If we're cross compiling, try our best to work it out and rely on the
420 # run-time check to fail if we get it wrong.
425 #if __BYTE_ORDER != __BIG_ENDIAN
426 # error "Unknown endianness"
430 compile_prog "" "" "endian" && bigendian="yes"
431 check_define "__ARMEB__" && bigendian="yes"
432 check_define "__MIPSEB__" && bigendian="yes"
436 echo "Operating system $targetos"
438 echo "Big endian $bigendian"
440 echo "Cross compile $cross_compile"
443 ##########################################
444 # See if we need to build a static build
445 if test "$build_static" = "yes" ; then
446 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
447 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
451 echo "Static build $build_static"
453 ##########################################
458 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
461 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
465 if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
467 elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
470 fatal "Unknown wordsize"
472 echo "Wordsize $wordsize"
474 ##########################################
482 if (inflateInit(&stream) != Z_OK)
487 if compile_prog "" "-lz" "zlib" ; then
493 ##########################################
496 if test "$esx" != "yes" ; then
506 if compile_prog "" "-laio" "libaio" ; then
510 if test "$libaio" = "yes" ; then
511 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
516 echo "Linux AIO support $libaio"
518 ##########################################
531 if compile_prog "" "" "posixaio" ; then
533 elif compile_prog "" "-lrt" "posixaio"; then
538 echo "POSIX AIO support $posix_aio"
539 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
541 ##########################################
542 # posix aio fsync probe
544 if test "$posix_aio" = "yes" ; then
551 return aio_fsync(O_SYNC, &cb);
555 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
559 echo "POSIX AIO fsync $posix_aio_fsync"
561 ##########################################
565 #include <sys/types.h>
566 #include <sys/asynch.h>
571 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
575 if compile_prog "" "-laio" "solarisaio" ; then
579 echo "Solaris AIO support $solaris_aio"
581 ##########################################
582 # __sync_fetch_and_add test
585 #include <inttypes.h>
586 static int sfaa(uint64_t *ptr)
588 return __sync_fetch_and_add(ptr, 0);
591 int main(int argc, char **argv)
598 if compile_prog "" "" "__sync_fetch_and_add()" ; then
601 echo "__sync_fetch_and_add $sfaa"
603 ##########################################
608 #include <infiniband/arch.h>
609 int main(int argc, char **argv)
611 struct ibv_pd *pd = ibv_alloc_pd(NULL);
615 if compile_prog "" "-libverbs" "libverbs" ; then
617 LIBS="-libverbs $LIBS"
619 echo "libverbs $libverbs"
621 ##########################################
626 #include <rdma/rdma_cma.h>
627 int main(int argc, char **argv)
629 rdma_destroy_qp(NULL);
633 if compile_prog "" "-lrdmacm" "rdma"; then
635 LIBS="-lrdmacm $LIBS"
637 echo "rdmacm $rdmacm"
639 ##########################################
640 # Linux fallocate probe
645 #include <linux/falloc.h>
646 int main(int argc, char **argv)
648 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
652 if compile_prog "" "" "linux_fallocate"; then
653 linux_fallocate="yes"
655 echo "Linux fallocate $linux_fallocate"
657 ##########################################
658 # POSIX fadvise probe
663 int main(int argc, char **argv)
665 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
669 if compile_prog "" "" "posix_fadvise"; then
672 echo "POSIX fadvise $posix_fadvise"
674 ##########################################
675 # POSIX fallocate probe
680 int main(int argc, char **argv)
682 int r = posix_fallocate(0, 0, 1024);
686 if compile_prog "" "" "posix_fallocate"; then
687 posix_fallocate="yes"
689 echo "POSIX fallocate $posix_fallocate"
691 ##########################################
692 # sched_set/getaffinity 2 or 3 argument test
693 linux_2arg_affinity="no"
694 linux_3arg_affinity="no"
697 int main(int argc, char **argv)
700 return sched_setaffinity(0, sizeof(mask), &mask);
703 if compile_prog "" "" "sched_setaffinity(,,)"; then
704 linux_3arg_affinity="yes"
708 int main(int argc, char **argv)
711 return sched_setaffinity(0, &mask);
714 if compile_prog "" "" "sched_setaffinity(,)"; then
715 linux_2arg_affinity="yes"
718 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
719 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
721 ##########################################
722 # clock_gettime probe
727 int main(int argc, char **argv)
729 return clock_gettime(0, NULL);
732 if compile_prog "" "" "clock_gettime"; then
734 elif compile_prog "" "-lrt" "clock_gettime"; then
738 echo "clock_gettime $clock_gettime"
740 ##########################################
741 # CLOCK_MONOTONIC probe
743 if test "$clock_gettime" = "yes" ; then
747 int main(int argc, char **argv)
749 return clock_gettime(CLOCK_MONOTONIC, NULL);
752 if compile_prog "" "$LIBS" "clock monotonic"; then
753 clock_monotonic="yes"
756 echo "CLOCK_MONOTONIC $clock_monotonic"
758 ##########################################
759 # CLOCK_MONOTONIC_RAW probe
760 clock_monotonic_raw="no"
761 if test "$clock_gettime" = "yes" ; then
765 int main(int argc, char **argv)
767 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
770 if compile_prog "" "$LIBS" "clock monotonic"; then
771 clock_monotonic_raw="yes"
774 echo "CLOCK_MONOTONIC_RAW $clock_monotonic_raw"
776 ##########################################
777 # CLOCK_MONOTONIC_PRECISE probe
778 clock_monotonic_precise="no"
779 if test "$clock_gettime" = "yes" ; then
783 int main(int argc, char **argv)
785 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
788 if compile_prog "" "$LIBS" "clock monotonic precise"; then
789 clock_monotonic_precise="yes"
792 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
794 ##########################################
795 # gettimeofday() probe
798 #include <sys/time.h>
800 int main(int argc, char **argv)
803 return gettimeofday(&tv, NULL);
806 if compile_prog "" "" "gettimeofday"; then
809 echo "gettimeofday $gettimeofday"
811 ##########################################
817 int main(int argc, char **argv)
822 if compile_prog "" "" "fdatasync"; then
825 echo "fdatasync $fdatasync"
827 ##########################################
828 # sync_file_range() probe
834 #include <linux/fs.h>
835 int main(int argc, char **argv)
837 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
838 SYNC_FILE_RANGE_WAIT_AFTER;
839 return sync_file_range(0, 0, 0, flags);
842 if compile_prog "" "" "sync_file_range"; then
843 sync_file_range="yes"
845 echo "sync_file_range $sync_file_range"
847 ##########################################
848 # ext4 move extent probe
852 #include <sys/ioctl.h>
853 int main(int argc, char **argv)
855 struct move_extent me;
856 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
859 if compile_prog "" "" "ext4 move extent" ; then
861 elif test $targetos = "Linux" ; then
862 # On Linux, just default to it on and let it error at runtime if we really
863 # don't have it. None of my updated systems have it defined, but it does
864 # work. Takes a while to bubble back.
867 echo "EXT4 move extent $ext4_me"
869 ##########################################
875 int main(int argc, char **argv)
877 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
880 if compile_prog "" "" "linux splice"; then
883 echo "Linux splice(2) $linux_splice"
885 ##########################################
890 #include <guasi_syscalls.h>
891 int main(int argc, char **argv)
893 guasi_t ctx = guasi_create(0, 0, 0);
897 if compile_prog "" "" "guasi"; then
902 ##########################################
906 #include <nvm/nvm_primitives.h>
907 int main(int argc, char **argv)
909 nvm_version_t ver_info;
912 handle = nvm_get_handle(0, &ver_info);
913 return nvm_atomic_write(handle, 0, 0, 0);
916 if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
917 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
920 echo "Fusion-io atomic engine $fusion_aw"
922 ##########################################
927 int main(int argc, char **argv)
929 return numa_available();
932 if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
936 echo "libnuma $libnuma"
938 ##########################################
939 # libnuma 2.x version API
940 if test "$libnuma" = "yes" ; then
944 int main(int argc, char **argv)
946 struct bitmask *mask = numa_parse_nodestring(NULL);
947 return mask->size == 0;
950 if compile_prog "" "" "libnuma api"; then
953 echo "libnuma v2 $libnuma_v2"
956 ##########################################
961 int main(int argc, char **argv)
963 static char *string = "This is a string";
964 strsep(&string, "needle");
968 if compile_prog "" "" "strsep"; then
971 echo "strsep $strsep"
973 ##########################################
978 int main(int argc, char **argv)
980 return strcasestr(argv[0], argv[1]) != NULL;
983 if compile_prog "" "" "strcasestr"; then
986 echo "strcasestr $strcasestr"
988 ##########################################
993 int main(int argc, char **argv)
996 static char *string = "This is a string";
997 memset(dst, 0, sizeof(dst));
998 strlcat(dst, string, sizeof(dst));
1002 if compile_prog "" "" "strlcat"; then
1005 echo "strlcat $strlcat"
1007 ##########################################
1008 # getopt_long_only() probe
1009 getopt_long_only="no"
1014 int main(int argc, char **argv)
1016 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1020 if compile_prog "" "" "getopt_long_only"; then
1021 getopt_long_only="yes"
1023 echo "getopt_long_only() $getopt_long_only"
1025 ##########################################
1029 #include <sys/socket.h>
1030 #include <arpa/inet.h>
1032 int main(int argc, char **argv)
1035 return inet_aton(NULL, &in);
1038 if compile_prog "" "" "inet_aton"; then
1041 echo "inet_aton $inet_aton"
1043 ##########################################
1047 #include <sys/socket.h>
1048 int main(int argc, char **argv)
1054 if compile_prog "" "" "socklen_t"; then
1057 echo "socklen_t $socklen_t"
1059 ##########################################
1060 # Whether or not __thread is supported for TLS
1064 static __thread int ret;
1065 int main(int argc, char **argv)
1070 if compile_prog "" "" "__thread"; then
1073 echo "__thread $tls_thread"
1075 ##########################################
1076 # Check if we have required gtk/glib support for gfio
1078 if test "$gfio_check" = "yes" ; then
1082 #include <gtk/gtk.h>
1085 gdk_threads_enter();
1086 gdk_threads_leave();
1088 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
1091 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1092 ORG_LDFLAGS=$LDFLAGS
1093 LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1094 if test "$?" != "0" ; then
1095 echo "configure: gtk and gthread not found"
1098 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1099 if test "$?" != "0" ; then
1100 echo "configure: gtk and gthread not found"
1103 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1105 if test "$r" != "0" ; then
1107 GFIO_LIBS="$LIBS $GTK_LIBS"
1108 CFLAGS="$CFLAGS $GTK_CFLAGS"
1110 echo "GTK found, but need version 2.18 or higher"
1114 echo "Please install gtk and gdk libraries"
1117 LDFLAGS=$ORG_LDFLAGS
1120 if test "$gfio_check" = "yes" ; then
1121 echo "gtk 2.18 or higher $gfio"
1124 # Check whether we have getrusage(RUSAGE_THREAD)
1127 #include <sys/time.h>
1128 #include <sys/resource.h>
1129 int main(int argc, char **argv)
1132 getrusage(RUSAGE_THREAD, &ru);
1136 if compile_prog "" "" "RUSAGE_THREAD"; then
1139 echo "RUSAGE_THREAD $rusage_thread"
1141 ##########################################
1142 # Check whether we have SCHED_IDLE
1146 int main(int argc, char **argv)
1148 struct sched_param p;
1149 return sched_setscheduler(0, SCHED_IDLE, &p);
1152 if compile_prog "" "" "SCHED_IDLE"; then
1155 echo "SCHED_IDLE $sched_idle"
1157 ##########################################
1158 # Check whether we have TCP_NODELAY
1162 #include <sys/types.h>
1163 #include <sys/socket.h>
1164 #include <netinet/tcp.h>
1165 int main(int argc, char **argv)
1167 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1170 if compile_prog "" "" "TCP_NODELAY"; then
1173 echo "TCP_NODELAY $tcp_nodelay"
1175 ##########################################
1176 # Check whether we have SO_SNDBUF
1180 #include <sys/types.h>
1181 #include <sys/socket.h>
1182 #include <netinet/tcp.h>
1183 int main(int argc, char **argv)
1185 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1186 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1189 if compile_prog "" "" "SO_SNDBUF"; then
1192 echo "Net engine window_size $window_size"
1194 ##########################################
1195 # Check whether we have TCP_MAXSEG
1199 #include <sys/types.h>
1200 #include <sys/socket.h>
1201 #include <netinet/tcp.h>
1202 #include <arpa/inet.h>
1203 #include <netinet/in.h>
1204 int main(int argc, char **argv)
1206 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1209 if compile_prog "" "" "TCP_MAXSEG"; then
1212 echo "TCP_MAXSEG $mss"
1214 ##########################################
1215 # Check whether we have RLIMIT_MEMLOCK
1218 #include <sys/time.h>
1219 #include <sys/resource.h>
1220 int main(int argc, char **argv)
1223 return getrlimit(RLIMIT_MEMLOCK, &rl);
1226 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1227 rlimit_memlock="yes"
1229 echo "RLIMIT_MEMLOCK $rlimit_memlock"
1231 ##########################################
1232 # Check whether we have pwritev/preadv
1236 #include <sys/uio.h>
1237 int main(int argc, char **argv)
1239 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1242 if compile_prog "" "" "pwritev"; then
1245 echo "pwritev/preadv $pwritev"
1247 ##########################################
1248 # Check whether we have pwritev2/preadv2
1252 #include <sys/uio.h>
1253 int main(int argc, char **argv)
1255 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1258 if compile_prog "" "" "pwritev2"; then
1261 echo "pwritev2/preadv2 $pwritev2"
1263 ##########################################
1264 # Check whether we have the required functions for ipv6
1267 #include <sys/types.h>
1268 #include <sys/socket.h>
1269 #include <netinet/in.h>
1272 int main(int argc, char **argv)
1274 struct addrinfo hints;
1275 struct in6_addr addr;
1278 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1280 printf("%s\n", gai_strerror(ret));
1285 if compile_prog "" "" "ipv6"; then
1288 echo "IPv6 helpers $ipv6"
1290 ##########################################
1294 #include <rbd/librbd.h>
1296 int main(int argc, char **argv)
1300 rados_ioctx_t io_ctx;
1301 const char pool[] = "rbd";
1303 int major, minor, extra;
1304 rbd_version(&major, &minor, &extra);
1306 rados_ioctx_create(cluster, pool, &io_ctx);
1310 if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
1311 LIBS="-lrbd -lrados $LIBS"
1314 echo "Rados Block Device engine $rbd"
1316 ##########################################
1317 # check for rbd_invaidate_cache()
1319 if test "$rbd" = "yes"; then
1321 #include <rbd/librbd.h>
1323 int main(int argc, char **argv)
1327 return rbd_invalidate_cache(image);
1330 if compile_prog "" "-lrbd -lrados" "rbd"; then
1333 echo "rbd_invalidate_cache $rbd_inval"
1336 ##########################################
1337 # Check whether we have setvbuf
1341 int main(int argc, char **argv)
1345 setvbuf(f, buf, _IOFBF, sizeof(buf));
1349 if compile_prog "" "" "setvbuf"; then
1352 echo "setvbuf $setvbuf"
1357 #include <glusterfs/api/glfs.h>
1359 int main(int argc, char **argv)
1362 glfs_t *g = glfs_new("foo");
1367 if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1368 LIBS="-lgfapi -lglusterfs $LIBS"
1371 echo "Gluster API engine $gfapi"
1373 ##########################################
1374 # check for gfapi fadvise support
1375 if test "$gfapi" = "yes" ; then
1378 #include <glusterfs/api/glfs.h>
1380 int main(int argc, char **argv)
1383 int ret = glfs_fadvise(fd, 0, 0, 1);
1388 if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1391 echo "Gluster API use fadvise $gf_fadvise"
1394 ##########################################
1395 # check for gfapi trim support
1397 if test "$gfapi" = "yes" ; then
1399 #include <glusterfs/api/glfs.h>
1401 int main(int argc, char **argv)
1403 return glfs_discard_async(NULL, 0, 0);
1406 if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1409 echo "Gluster API trim support $gf_trim"
1412 ##########################################
1413 # Check if we support stckf on s390
1414 s390_z196_facilities="no"
1416 #define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1417 int main(int argc, char **argv)
1419 /* We want just 1 double word to be returned. */
1420 register unsigned long reg0 asm("0") = 0;
1421 unsigned long stfle_bits;
1422 asm volatile(".machine push" "\n\t"
1423 ".machine \"z9-109\"" "\n\t"
1426 : "=QS" (stfle_bits), "+d" (reg0)
1429 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1435 if compile_prog "" "" "s390_z196_facilities"; then
1437 if [[ $? -eq 0 ]]; then
1438 s390_z196_facilities="yes"
1441 echo "s390_z196_facilities $s390_z196_facilities"
1443 ##########################################
1444 # Check if we have required environment variables configured for libhdfs
1445 if test "$libhdfs" = "yes" ; then
1447 if test "$JAVA_HOME" = "" ; then
1448 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1451 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1452 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1455 if test "$FIO_LIBHDFS_LIB" = "" ; then
1456 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1459 if test "$hdfs_conf_error" = "1" ; then
1463 echo "HDFS engine $libhdfs"
1465 ##########################################
1466 # Check whether we have MTD
1470 #include <mtd/mtd-user.h>
1471 #include <sys/ioctl.h>
1472 int main(int argc, char **argv)
1474 struct mtd_write_req ops;
1475 struct mtd_info_user info;
1476 memset(&ops, 0, sizeof(ops));
1477 info.type = MTD_MLCNANDFLASH;
1478 return ioctl(0, MEMGETINFO, &info);
1481 if compile_prog "" "" "mtd"; then
1486 ##########################################
1487 # Report whether pmemblk engine is enabled
1488 echo "NVML libpmemblk engine $pmemblk"
1490 # Check if we have lex/yacc available
1495 if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
1496 if test "$targetos" != "SunOS" ; then
1497 LEX=$(which lex 2> /dev/null)
1498 if test -x "$LEX" ; then
1501 YACC=$(which bison 2> /dev/null)
1502 if test -x "$YACC" ; then
1506 YACC=$(which yacc 2> /dev/null)
1507 if test -x "$YACC" ; then
1511 if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1515 if test "$arith" = "yes" ; then
1517 extern int yywrap(void);
1519 int main(int argc, char **argv)
1525 if compile_prog "" "-ll" "lex"; then
1534 # Check if lex fails using -o
1535 if test "$arith" = "yes" ; then
1536 if test "$force_no_lex_o" = "yes" ; then
1539 $LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1540 if test "$?" = "0" ; then
1548 echo "lex/yacc for arithmetic $arith"
1550 ##########################################
1551 # Check whether we have setmntent/getmntent
1556 int main(int argc, char **argv)
1558 FILE *mtab = setmntent(NULL, "r");
1559 struct mntent *mnt = getmntent(mtab);
1564 if compile_prog "" "" "getmntent"; then
1567 echo "getmntent $getmntent"
1569 ##########################################
1570 # Check whether we have getmntinfo
1574 #include <sys/param.h>
1575 #include <sys/mount.h>
1576 int main(int argc, char **argv)
1579 return getmntinfo(&st, MNT_NOWAIT);
1582 if compile_prog "" "" "getmntinfo"; then
1585 echo "getmntinfo $getmntinfo"
1587 ##########################################
1588 # Check whether we have _Static_assert
1594 #ifdef __compiler_offsetof
1595 #define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
1597 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1600 #define container_of(ptr, type, member) ({ \
1601 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
1602 (type *)( (char *)__mptr - offsetof(type,member) );})
1608 int main(int argc, char **argv)
1610 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
1614 if compile_prog "" "" "static_assert"; then
1617 echo "Static Assert $static_assert"
1619 ##########################################
1620 # Check whether we have bool / stdbool.h
1623 #include <stdbool.h>
1624 int main(int argc, char **argv)
1627 return var != false;
1630 if compile_prog "" "" "bool"; then
1633 echo "bool $have_bool"
1635 #############################################################################
1637 if test "$wordsize" = "64" ; then
1638 output_sym "CONFIG_64BIT"
1639 elif test "$wordsize" = "32" ; then
1640 output_sym "CONFIG_32BIT"
1642 fatal "Unknown wordsize!"
1644 if test "$bigendian" = "yes" ; then
1645 output_sym "CONFIG_BIG_ENDIAN"
1647 output_sym "CONFIG_LITTLE_ENDIAN"
1649 if test "$zlib" = "yes" ; then
1650 output_sym "CONFIG_ZLIB"
1652 if test "$libaio" = "yes" ; then
1653 output_sym "CONFIG_LIBAIO"
1655 if test "$posix_aio" = "yes" ; then
1656 output_sym "CONFIG_POSIXAIO"
1658 if test "$posix_aio_fsync" = "yes" ; then
1659 output_sym "CONFIG_POSIXAIO_FSYNC"
1661 if test "$linux_fallocate" = "yes" ; then
1662 output_sym "CONFIG_LINUX_FALLOCATE"
1664 if test "$posix_fallocate" = "yes" ; then
1665 output_sym "CONFIG_POSIX_FALLOCATE"
1667 if test "$fdatasync" = "yes" ; then
1668 output_sym "CONFIG_FDATASYNC"
1670 if test "$sync_file_range" = "yes" ; then
1671 output_sym "CONFIG_SYNC_FILE_RANGE"
1673 if test "$sfaa" = "yes" ; then
1674 output_sym "CONFIG_SFAA"
1676 if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
1677 output_sym "CONFIG_RDMA"
1679 if test "$clock_gettime" = "yes" ; then
1680 output_sym "CONFIG_CLOCK_GETTIME"
1682 if test "$clock_monotonic" = "yes" ; then
1683 output_sym "CONFIG_CLOCK_MONOTONIC"
1685 if test "$clock_monotonic_raw" = "yes" ; then
1686 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
1688 if test "$clock_monotonic_precise" = "yes" ; then
1689 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
1691 if test "$gettimeofday" = "yes" ; then
1692 output_sym "CONFIG_GETTIMEOFDAY"
1694 if test "$posix_fadvise" = "yes" ; then
1695 output_sym "CONFIG_POSIX_FADVISE"
1697 if test "$linux_3arg_affinity" = "yes" ; then
1698 output_sym "CONFIG_3ARG_AFFINITY"
1699 elif test "$linux_2arg_affinity" = "yes" ; then
1700 output_sym "CONFIG_2ARG_AFFINITY"
1702 if test "$strsep" = "yes" ; then
1703 output_sym "CONFIG_STRSEP"
1705 if test "$strcasestr" = "yes" ; then
1706 output_sym "CONFIG_STRCASESTR"
1708 if test "$strlcat" = "yes" ; then
1709 output_sym "CONFIG_STRLCAT"
1711 if test "$getopt_long_only" = "yes" ; then
1712 output_sym "CONFIG_GETOPT_LONG_ONLY"
1714 if test "$inet_aton" = "yes" ; then
1715 output_sym "CONFIG_INET_ATON"
1717 if test "$socklen_t" = "yes" ; then
1718 output_sym "CONFIG_SOCKLEN_T"
1720 if test "$ext4_me" = "yes" ; then
1721 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1723 if test "$linux_splice" = "yes" ; then
1724 output_sym "CONFIG_LINUX_SPLICE"
1726 if test "$guasi" = "yes" ; then
1727 output_sym "CONFIG_GUASI"
1729 if test "$fusion_aw" = "yes" ; then
1730 output_sym "CONFIG_FUSION_AW"
1732 if test "$libnuma_v2" = "yes" ; then
1733 output_sym "CONFIG_LIBNUMA"
1735 if test "$solaris_aio" = "yes" ; then
1736 output_sym "CONFIG_SOLARISAIO"
1738 if test "$tls_thread" = "yes" ; then
1739 output_sym "CONFIG_TLS_THREAD"
1741 if test "$rusage_thread" = "yes" ; then
1742 output_sym "CONFIG_RUSAGE_THREAD"
1744 if test "$gfio" = "yes" ; then
1745 echo "CONFIG_GFIO=y" >> $config_host_mak
1747 if test "$esx" = "yes" ; then
1748 output_sym "CONFIG_ESX"
1749 output_sym "CONFIG_NO_SHM"
1751 if test "$sched_idle" = "yes" ; then
1752 output_sym "CONFIG_SCHED_IDLE"
1754 if test "$tcp_nodelay" = "yes" ; then
1755 output_sym "CONFIG_TCP_NODELAY"
1757 if test "$window_size" = "yes" ; then
1758 output_sym "CONFIG_NET_WINDOWSIZE"
1760 if test "$mss" = "yes" ; then
1761 output_sym "CONFIG_NET_MSS"
1763 if test "$rlimit_memlock" = "yes" ; then
1764 output_sym "CONFIG_RLIMIT_MEMLOCK"
1766 if test "$pwritev" = "yes" ; then
1767 output_sym "CONFIG_PWRITEV"
1769 if test "$pwritev2" = "yes" ; then
1770 output_sym "CONFIG_PWRITEV2"
1772 if test "$ipv6" = "yes" ; then
1773 output_sym "CONFIG_IPV6"
1775 if test "$rbd" = "yes" ; then
1776 output_sym "CONFIG_RBD"
1778 if test "$rbd_inval" = "yes" ; then
1779 output_sym "CONFIG_RBD_INVAL"
1781 if test "$setvbuf" = "yes" ; then
1782 output_sym "CONFIG_SETVBUF"
1784 if test "$s390_z196_facilities" = "yes" ; then
1785 output_sym "CONFIG_S390_Z196_FACILITIES"
1786 CFLAGS="$CFLAGS -march=z9-109"
1788 if test "$gfapi" = "yes" ; then
1789 output_sym "CONFIG_GFAPI"
1791 if test "$gf_fadvise" = "yes" ; then
1792 output_sym "CONFIG_GF_FADVISE"
1794 if test "$gf_trim" = "yes" ; then
1795 output_sym "CONFIG_GF_TRIM"
1797 if test "$libhdfs" = "yes" ; then
1798 output_sym "CONFIG_LIBHDFS"
1799 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
1800 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
1801 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
1803 if test "$mtd" = "yes" ; then
1804 output_sym "CONFIG_MTD"
1806 if test "$pmemblk" = "yes" ; then
1807 output_sym "CONFIG_PMEMBLK"
1809 if test "$arith" = "yes" ; then
1810 output_sym "CONFIG_ARITHMETIC"
1811 if test "$yacc_is_bison" = "yes" ; then
1812 echo "YACC=$YACC -y" >> $config_host_mak
1814 echo "YACC=$YACC" >> $config_host_mak
1816 if test "$lex_use_o" = "yes" ; then
1817 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
1820 if test "$getmntent" = "yes" ; then
1821 output_sym "CONFIG_GETMNTENT"
1823 if test "$getmntinfo" = "yes" ; then
1824 output_sym "CONFIG_GETMNTINFO"
1826 if test "$static_assert" = "yes" ; then
1827 output_sym "CONFIG_STATIC_ASSERT"
1829 if test "$have_bool" = "yes" ; then
1830 output_sym "CONFIG_HAVE_BOOL"
1833 if test "$zlib" = "no" ; then
1834 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
1837 echo "LIBS+=$LIBS" >> $config_host_mak
1838 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
1839 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
1840 echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
1841 echo "CC=$cc" >> $config_host_mak
1842 echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
1843 echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
1845 if [ `dirname $0` != "." -a ! -e Makefile ]; then
1846 cat > Makefile <<EOF
1847 SRCDIR:=`dirname $0`
1848 include \$(SRCDIR)/Makefile