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-rbd-blkin) disable_rbd_blkin="yes"
171 --disable-gfapi) disable_gfapi="yes"
173 --enable-libhdfs) libhdfs="yes"
175 --enable-pmemblk) pmemblk="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"
189 echo "Bad option $opt"
195 if test "$show_help" = "yes" ; then
196 echo "--prefix= Use this directory as installation prefix"
197 echo "--cpu= Specify target CPU if auto-detect fails"
198 echo "--cc= Specify compiler to use"
199 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
200 echo "--build-32bit-win Enable 32-bit build on Windows"
201 echo "--build-static Build a static fio"
202 echo "--esx Configure build options for esx"
203 echo "--enable-gfio Enable building of gtk gfio"
204 echo "--disable-numa Disable libnuma even if found"
205 echo "--disable-gfapi Disable gfapi"
206 echo "--enable-libhdfs Enable hdfs support"
207 echo "--enable-pmemblk Enable NVML libpmemblk support"
208 echo "--disable-lex Disable use of lex/yacc for math"
209 echo "--enable-lex Enable use of lex/yacc for math"
210 echo "--disable-shm Disable SHM support"
211 echo "--disable-optimizations Don't enable compiler optimizations"
215 cross_prefix=${cross_prefix-${CROSS_COMPILE}}
216 cc="${CC-${cross_prefix}gcc}"
218 if check_define __ANDROID__ ; then
220 elif check_define __linux__ ; then
222 elif check_define __OpenBSD__ ; then
224 elif check_define __sun__ ; then
226 CFLAGS="$CFLAGS -D_REENTRANT"
227 elif check_define _WIN32 ; then
233 echo "# Automatically generated by configure - do not modify" > $config_host_mak
234 printf "# Configured with:" >> $config_host_mak
235 printf " '%s'" "$0" "$@" >> $config_host_mak
236 echo >> $config_host_mak
237 echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
239 if test "$no_shm" = "yes" ; then
240 output_sym "CONFIG_NO_SHM"
243 if test "$disable_opt" = "yes" ; then
244 output_sym "CONFIG_FIO_NO_OPT"
247 # Some host OSes need non-standard checks for which CPU to use.
248 # Note that these checks are broken for cross-compilation: if you're
249 # cross-compiling to one of these OSes then you'll need to specify
250 # the correct CPU with the --cpu option.
253 # Unless explicitly enabled, turn off lex.
254 if test -z "$disable_lex" ; then
261 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
262 # we can run 64-bit userspace code.
263 # If the user didn't specify a CPU explicitly and the kernel says this is
264 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
266 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
271 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
272 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
275 LIBS="-lnsl -lsocket"
278 echo "Forcing known good options on Windows"
279 if test -z "$CC" ; then
280 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
281 CC="i686-w64-mingw32-gcc"
283 CC="x86_64-w64-mingw32-gcc"
286 output_sym "CONFIG_LITTLE_ENDIAN"
287 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
288 output_sym "CONFIG_32BIT"
290 output_sym "CONFIG_64BIT_LLP64"
292 output_sym "CONFIG_FADVISE"
293 output_sym "CONFIG_SOCKLEN_T"
294 output_sym "CONFIG_FADVISE"
295 output_sym "CONFIG_SFAA"
296 output_sym "CONFIG_RUSAGE_THREAD"
297 output_sym "CONFIG_WINDOWSAIO"
298 output_sym "CONFIG_FDATASYNC"
299 output_sym "CONFIG_CLOCK_MONOTONIC"
300 output_sym "CONFIG_GETTIMEOFDAY"
301 output_sym "CONFIG_CLOCK_GETTIME"
302 output_sym "CONFIG_SCHED_IDLE"
303 output_sym "CONFIG_TCP_NODELAY"
304 output_sym "CONFIG_TLS_THREAD"
305 output_sym "CONFIG_IPV6"
306 echo "CC=$CC" >> $config_host_mak
307 echo "BUILD_CFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
312 if test ! -z "$cpu" ; then
313 # command line argument
315 elif check_define __i386__ ; then
317 elif check_define __x86_64__ ; then
319 elif check_define __sparc__ ; then
320 if check_define __arch64__ ; then
325 elif check_define _ARCH_PPC ; then
326 if check_define _ARCH_PPC64 ; then
331 elif check_define __mips__ ; then
333 elif check_define __ia64__ ; then
335 elif check_define __s390__ ; then
336 if check_define __s390x__ ; then
341 elif check_define __arm__ ; then
343 elif check_define __hppa__ ; then
349 # Normalise host CPU name and set ARCH.
351 ia64|ppc|ppc64|s390|s390x|sparc64)
354 i386|i486|i586|i686|i86pc|BePC)
363 hppa|parisc|parisc64)
377 if test -z "$CC" ; then
378 if test "$targetos" = "FreeBSD"; then
387 cc="${CC-${cross_prefix}gcc}"
389 ##########################################
390 # check cross compile
399 if compile_prog "" "" "cross"; then
400 $TMPE 2>/dev/null || cross_compile="yes"
402 fatal "compile test failed"
405 ##########################################
408 if test "$cross_compile" = "no" ; then
410 #include <inttypes.h>
413 volatile uint32_t i=0x01234567;
414 return (*((uint8_t*)(&i))) == 0x67;
417 if compile_prog "" "" "endian"; then
418 $TMPE && bigendian="yes"
421 # If we're cross compiling, try our best to work it out and rely on the
422 # run-time check to fail if we get it wrong.
427 #if __BYTE_ORDER != __BIG_ENDIAN
428 # error "Unknown endianness"
432 compile_prog "" "" "endian" && bigendian="yes"
433 check_define "__ARMEB__" && bigendian="yes"
434 check_define "__MIPSEB__" && bigendian="yes"
438 echo "Operating system $targetos"
440 echo "Big endian $bigendian"
442 echo "Cross compile $cross_compile"
445 ##########################################
446 # See if we need to build a static build
447 if test "$build_static" = "yes" ; then
448 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
449 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
453 echo "Static build $build_static"
455 ##########################################
460 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
463 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
467 if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
469 elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
472 fatal "Unknown wordsize"
474 echo "Wordsize $wordsize"
476 ##########################################
484 if (inflateInit(&stream) != Z_OK)
489 if compile_prog "" "-lz" "zlib" ; then
495 ##########################################
498 if test "$esx" != "yes" ; then
508 if compile_prog "" "-laio" "libaio" ; then
512 if test "$libaio" = "yes" ; then
513 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
518 echo "Linux AIO support $libaio"
520 ##########################################
533 if compile_prog "" "" "posixaio" ; then
535 elif compile_prog "" "-lrt" "posixaio"; then
540 echo "POSIX AIO support $posix_aio"
541 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
543 ##########################################
544 # posix aio fsync probe
546 if test "$posix_aio" = "yes" ; then
553 return aio_fsync(O_SYNC, &cb);
557 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
561 echo "POSIX AIO fsync $posix_aio_fsync"
563 ##########################################
567 #include <sys/types.h>
568 #include <sys/asynch.h>
573 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
577 if compile_prog "" "-laio" "solarisaio" ; then
581 echo "Solaris AIO support $solaris_aio"
583 ##########################################
584 # __sync_fetch_and_add test
587 #include <inttypes.h>
588 static int sfaa(uint64_t *ptr)
590 return __sync_fetch_and_add(ptr, 0);
593 int main(int argc, char **argv)
600 if compile_prog "" "" "__sync_fetch_and_add()" ; then
603 echo "__sync_fetch_and_add $sfaa"
605 ##########################################
610 #include <infiniband/arch.h>
611 int main(int argc, char **argv)
613 struct ibv_pd *pd = ibv_alloc_pd(NULL);
617 if compile_prog "" "-libverbs" "libverbs" ; then
619 LIBS="-libverbs $LIBS"
621 echo "libverbs $libverbs"
623 ##########################################
628 #include <rdma/rdma_cma.h>
629 int main(int argc, char **argv)
631 rdma_destroy_qp(NULL);
635 if compile_prog "" "-lrdmacm" "rdma"; then
637 LIBS="-lrdmacm $LIBS"
639 echo "rdmacm $rdmacm"
641 ##########################################
642 # Linux fallocate probe
647 #include <linux/falloc.h>
648 int main(int argc, char **argv)
650 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
654 if compile_prog "" "" "linux_fallocate"; then
655 linux_fallocate="yes"
657 echo "Linux fallocate $linux_fallocate"
659 ##########################################
660 # POSIX fadvise probe
665 int main(int argc, char **argv)
667 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
671 if compile_prog "" "" "posix_fadvise"; then
674 echo "POSIX fadvise $posix_fadvise"
676 ##########################################
677 # POSIX fallocate probe
682 int main(int argc, char **argv)
684 int r = posix_fallocate(0, 0, 1024);
688 if compile_prog "" "" "posix_fallocate"; then
689 posix_fallocate="yes"
691 echo "POSIX fallocate $posix_fallocate"
693 ##########################################
694 # sched_set/getaffinity 2 or 3 argument test
695 linux_2arg_affinity="no"
696 linux_3arg_affinity="no"
699 int main(int argc, char **argv)
702 return sched_setaffinity(0, sizeof(mask), &mask);
705 if compile_prog "" "" "sched_setaffinity(,,)"; then
706 linux_3arg_affinity="yes"
710 int main(int argc, char **argv)
713 return sched_setaffinity(0, &mask);
716 if compile_prog "" "" "sched_setaffinity(,)"; then
717 linux_2arg_affinity="yes"
720 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
721 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
723 ##########################################
724 # clock_gettime probe
729 int main(int argc, char **argv)
731 return clock_gettime(0, NULL);
734 if compile_prog "" "" "clock_gettime"; then
736 elif compile_prog "" "-lrt" "clock_gettime"; then
740 echo "clock_gettime $clock_gettime"
742 ##########################################
743 # CLOCK_MONOTONIC probe
745 if test "$clock_gettime" = "yes" ; then
749 int main(int argc, char **argv)
751 return clock_gettime(CLOCK_MONOTONIC, NULL);
754 if compile_prog "" "$LIBS" "clock monotonic"; then
755 clock_monotonic="yes"
758 echo "CLOCK_MONOTONIC $clock_monotonic"
760 ##########################################
761 # CLOCK_MONOTONIC_RAW probe
762 clock_monotonic_raw="no"
763 if test "$clock_gettime" = "yes" ; then
767 int main(int argc, char **argv)
769 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
772 if compile_prog "" "$LIBS" "clock monotonic"; then
773 clock_monotonic_raw="yes"
776 echo "CLOCK_MONOTONIC_RAW $clock_monotonic_raw"
778 ##########################################
779 # CLOCK_MONOTONIC_PRECISE probe
780 clock_monotonic_precise="no"
781 if test "$clock_gettime" = "yes" ; then
785 int main(int argc, char **argv)
787 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
790 if compile_prog "" "$LIBS" "clock monotonic precise"; then
791 clock_monotonic_precise="yes"
794 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
796 ##########################################
797 # gettimeofday() probe
800 #include <sys/time.h>
802 int main(int argc, char **argv)
805 return gettimeofday(&tv, NULL);
808 if compile_prog "" "" "gettimeofday"; then
811 echo "gettimeofday $gettimeofday"
813 ##########################################
819 int main(int argc, char **argv)
824 if compile_prog "" "" "fdatasync"; then
827 echo "fdatasync $fdatasync"
829 ##########################################
830 # sync_file_range() probe
836 #include <linux/fs.h>
837 int main(int argc, char **argv)
839 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
840 SYNC_FILE_RANGE_WAIT_AFTER;
841 return sync_file_range(0, 0, 0, flags);
844 if compile_prog "" "" "sync_file_range"; then
845 sync_file_range="yes"
847 echo "sync_file_range $sync_file_range"
849 ##########################################
850 # ext4 move extent probe
854 #include <sys/ioctl.h>
855 int main(int argc, char **argv)
857 struct move_extent me;
858 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
861 if compile_prog "" "" "ext4 move extent" ; then
863 elif test $targetos = "Linux" ; then
864 # On Linux, just default to it on and let it error at runtime if we really
865 # don't have it. None of my updated systems have it defined, but it does
866 # work. Takes a while to bubble back.
869 echo "EXT4 move extent $ext4_me"
871 ##########################################
877 int main(int argc, char **argv)
879 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
882 if compile_prog "" "" "linux splice"; then
885 echo "Linux splice(2) $linux_splice"
887 ##########################################
892 #include <guasi_syscalls.h>
893 int main(int argc, char **argv)
895 guasi_t ctx = guasi_create(0, 0, 0);
899 if compile_prog "" "" "guasi"; then
904 ##########################################
908 #include <nvm/nvm_primitives.h>
909 int main(int argc, char **argv)
911 nvm_version_t ver_info;
914 handle = nvm_get_handle(0, &ver_info);
915 return nvm_atomic_write(handle, 0, 0, 0);
918 if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
919 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
922 echo "Fusion-io atomic engine $fusion_aw"
924 ##########################################
929 int main(int argc, char **argv)
931 return numa_available();
934 if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
938 echo "libnuma $libnuma"
940 ##########################################
941 # libnuma 2.x version API
942 if test "$libnuma" = "yes" ; then
946 int main(int argc, char **argv)
948 struct bitmask *mask = numa_parse_nodestring(NULL);
949 return mask->size == 0;
952 if compile_prog "" "" "libnuma api"; then
955 echo "libnuma v2 $libnuma_v2"
958 ##########################################
963 int main(int argc, char **argv)
965 static char *string = "This is a string";
966 strsep(&string, "needle");
970 if compile_prog "" "" "strsep"; then
973 echo "strsep $strsep"
975 ##########################################
980 int main(int argc, char **argv)
982 return strcasestr(argv[0], argv[1]) != NULL;
985 if compile_prog "" "" "strcasestr"; then
988 echo "strcasestr $strcasestr"
990 ##########################################
995 int main(int argc, char **argv)
998 static char *string = "This is a string";
999 memset(dst, 0, sizeof(dst));
1000 strlcat(dst, string, sizeof(dst));
1004 if compile_prog "" "" "strlcat"; then
1007 echo "strlcat $strlcat"
1009 ##########################################
1010 # getopt_long_only() probe
1011 getopt_long_only="no"
1016 int main(int argc, char **argv)
1018 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1022 if compile_prog "" "" "getopt_long_only"; then
1023 getopt_long_only="yes"
1025 echo "getopt_long_only() $getopt_long_only"
1027 ##########################################
1031 #include <sys/socket.h>
1032 #include <arpa/inet.h>
1034 int main(int argc, char **argv)
1037 return inet_aton(NULL, &in);
1040 if compile_prog "" "" "inet_aton"; then
1043 echo "inet_aton $inet_aton"
1045 ##########################################
1049 #include <sys/socket.h>
1050 int main(int argc, char **argv)
1056 if compile_prog "" "" "socklen_t"; then
1059 echo "socklen_t $socklen_t"
1061 ##########################################
1062 # Whether or not __thread is supported for TLS
1066 static __thread int ret;
1067 int main(int argc, char **argv)
1072 if compile_prog "" "" "__thread"; then
1075 echo "__thread $tls_thread"
1077 ##########################################
1078 # Check if we have required gtk/glib support for gfio
1080 if test "$gfio_check" = "yes" ; then
1084 #include <gtk/gtk.h>
1087 gdk_threads_enter();
1088 gdk_threads_leave();
1090 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
1093 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1094 ORG_LDFLAGS=$LDFLAGS
1095 LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1096 if test "$?" != "0" ; then
1097 echo "configure: gtk and gthread not found"
1100 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1101 if test "$?" != "0" ; then
1102 echo "configure: gtk and gthread not found"
1105 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1107 if test "$r" != "0" ; then
1109 GFIO_LIBS="$LIBS $GTK_LIBS"
1110 CFLAGS="$CFLAGS $GTK_CFLAGS"
1112 echo "GTK found, but need version 2.18 or higher"
1116 echo "Please install gtk and gdk libraries"
1119 LDFLAGS=$ORG_LDFLAGS
1122 if test "$gfio_check" = "yes" ; then
1123 echo "gtk 2.18 or higher $gfio"
1126 # Check whether we have getrusage(RUSAGE_THREAD)
1129 #include <sys/time.h>
1130 #include <sys/resource.h>
1131 int main(int argc, char **argv)
1134 getrusage(RUSAGE_THREAD, &ru);
1138 if compile_prog "" "" "RUSAGE_THREAD"; then
1141 echo "RUSAGE_THREAD $rusage_thread"
1143 ##########################################
1144 # Check whether we have SCHED_IDLE
1148 int main(int argc, char **argv)
1150 struct sched_param p;
1151 return sched_setscheduler(0, SCHED_IDLE, &p);
1154 if compile_prog "" "" "SCHED_IDLE"; then
1157 echo "SCHED_IDLE $sched_idle"
1159 ##########################################
1160 # Check whether we have TCP_NODELAY
1164 #include <sys/types.h>
1165 #include <sys/socket.h>
1166 #include <netinet/tcp.h>
1167 int main(int argc, char **argv)
1169 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1172 if compile_prog "" "" "TCP_NODELAY"; then
1175 echo "TCP_NODELAY $tcp_nodelay"
1177 ##########################################
1178 # Check whether we have SO_SNDBUF
1182 #include <sys/types.h>
1183 #include <sys/socket.h>
1184 #include <netinet/tcp.h>
1185 int main(int argc, char **argv)
1187 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1188 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1191 if compile_prog "" "" "SO_SNDBUF"; then
1194 echo "Net engine window_size $window_size"
1196 ##########################################
1197 # Check whether we have TCP_MAXSEG
1201 #include <sys/types.h>
1202 #include <sys/socket.h>
1203 #include <netinet/tcp.h>
1204 #include <arpa/inet.h>
1205 #include <netinet/in.h>
1206 int main(int argc, char **argv)
1208 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1211 if compile_prog "" "" "TCP_MAXSEG"; then
1214 echo "TCP_MAXSEG $mss"
1216 ##########################################
1217 # Check whether we have RLIMIT_MEMLOCK
1220 #include <sys/time.h>
1221 #include <sys/resource.h>
1222 int main(int argc, char **argv)
1225 return getrlimit(RLIMIT_MEMLOCK, &rl);
1228 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1229 rlimit_memlock="yes"
1231 echo "RLIMIT_MEMLOCK $rlimit_memlock"
1233 ##########################################
1234 # Check whether we have pwritev/preadv
1238 #include <sys/uio.h>
1239 int main(int argc, char **argv)
1241 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1244 if compile_prog "" "" "pwritev"; then
1247 echo "pwritev/preadv $pwritev"
1249 ##########################################
1250 # Check whether we have pwritev2/preadv2
1254 #include <sys/uio.h>
1255 int main(int argc, char **argv)
1257 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1260 if compile_prog "" "" "pwritev2"; then
1263 echo "pwritev2/preadv2 $pwritev2"
1265 ##########################################
1266 # Check whether we have the required functions for ipv6
1269 #include <sys/types.h>
1270 #include <sys/socket.h>
1271 #include <netinet/in.h>
1274 int main(int argc, char **argv)
1276 struct addrinfo hints;
1277 struct in6_addr addr;
1280 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1282 printf("%s\n", gai_strerror(ret));
1287 if compile_prog "" "" "ipv6"; then
1290 echo "IPv6 helpers $ipv6"
1292 ##########################################
1296 #include <rbd/librbd.h>
1298 int main(int argc, char **argv)
1302 rados_ioctx_t io_ctx;
1303 const char pool[] = "rbd";
1305 int major, minor, extra;
1306 rbd_version(&major, &minor, &extra);
1308 rados_ioctx_create(cluster, pool, &io_ctx);
1312 if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
1313 LIBS="-lrbd -lrados $LIBS"
1316 echo "Rados Block Device engine $rbd"
1318 ##########################################
1319 # check for rbd_invaidate_cache()
1321 if test "$rbd" = "yes"; then
1323 #include <rbd/librbd.h>
1325 int main(int argc, char **argv)
1329 return rbd_invalidate_cache(image);
1332 if compile_prog "" "-lrbd -lrados" "rbd"; then
1335 echo "rbd_invalidate_cache $rbd_inval"
1338 ##########################################
1342 #include <rbd/librbd.h>
1343 #include <zipkin_c.h>
1345 int main(int argc, char **argv)
1348 struct blkin_trace_info t_info;
1349 blkin_init_trace_info(&t_info);
1350 rbd_completion_t completion;
1355 r = rbd_aio_write_traced(image, off, len, buf, completion, &t_info);
1359 if test "$disable_rbd" != "yes" && test "$disable_rbd_blkin" != "yes" \
1360 && compile_prog "" "-lrbd -lrados -lblkin" "rbd_blkin"; then
1361 LIBS="-lblkin $LIBS"
1364 echo "rbd blkin tracing $rbd_blkin"
1366 ##########################################
1367 # Check whether we have setvbuf
1371 int main(int argc, char **argv)
1375 setvbuf(f, buf, _IOFBF, sizeof(buf));
1379 if compile_prog "" "" "setvbuf"; then
1382 echo "setvbuf $setvbuf"
1387 #include <glusterfs/api/glfs.h>
1389 int main(int argc, char **argv)
1392 glfs_t *g = glfs_new("foo");
1397 if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1398 LIBS="-lgfapi -lglusterfs $LIBS"
1401 echo "Gluster API engine $gfapi"
1403 ##########################################
1404 # check for gfapi fadvise support
1405 if test "$gfapi" = "yes" ; then
1408 #include <glusterfs/api/glfs.h>
1410 int main(int argc, char **argv)
1413 int ret = glfs_fadvise(fd, 0, 0, 1);
1418 if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1421 echo "Gluster API use fadvise $gf_fadvise"
1424 ##########################################
1425 # check for gfapi trim support
1427 if test "$gfapi" = "yes" ; then
1429 #include <glusterfs/api/glfs.h>
1431 int main(int argc, char **argv)
1433 return glfs_discard_async(NULL, 0, 0);
1436 if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1439 echo "Gluster API trim support $gf_trim"
1442 ##########################################
1443 # Check if we support stckf on s390
1444 s390_z196_facilities="no"
1446 #define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1447 int main(int argc, char **argv)
1449 /* We want just 1 double word to be returned. */
1450 register unsigned long reg0 asm("0") = 0;
1451 unsigned long stfle_bits;
1452 asm volatile(".machine push" "\n\t"
1453 ".machine \"z9-109\"" "\n\t"
1456 : "=QS" (stfle_bits), "+d" (reg0)
1459 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1465 if compile_prog "" "" "s390_z196_facilities"; then
1467 if [[ $? -eq 0 ]]; then
1468 s390_z196_facilities="yes"
1471 echo "s390_z196_facilities $s390_z196_facilities"
1473 ##########################################
1474 # Check if we have required environment variables configured for libhdfs
1475 if test "$libhdfs" = "yes" ; then
1477 if test "$JAVA_HOME" = "" ; then
1478 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1481 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1482 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1485 if test "$FIO_LIBHDFS_LIB" = "" ; then
1486 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1489 if test "$hdfs_conf_error" = "1" ; then
1493 echo "HDFS engine $libhdfs"
1495 ##########################################
1496 # Check whether we have MTD
1500 #include <mtd/mtd-user.h>
1501 #include <sys/ioctl.h>
1502 int main(int argc, char **argv)
1504 struct mtd_write_req ops;
1505 struct mtd_info_user info;
1506 memset(&ops, 0, sizeof(ops));
1507 info.type = MTD_MLCNANDFLASH;
1508 return ioctl(0, MEMGETINFO, &info);
1511 if compile_prog "" "" "mtd"; then
1516 ##########################################
1517 # Report whether pmemblk engine is enabled
1518 echo "NVML libpmemblk engine $pmemblk"
1520 # Check if we have lex/yacc available
1525 if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
1526 if test "$targetos" != "SunOS" ; then
1527 LEX=$(which lex 2> /dev/null)
1528 if test -x "$LEX" ; then
1531 YACC=$(which bison 2> /dev/null)
1532 if test -x "$YACC" ; then
1536 YACC=$(which yacc 2> /dev/null)
1537 if test -x "$YACC" ; then
1541 if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1545 if test "$arith" = "yes" ; then
1547 extern int yywrap(void);
1549 int main(int argc, char **argv)
1555 if compile_prog "" "-ll" "lex"; then
1564 # Check if lex fails using -o
1565 if test "$arith" = "yes" ; then
1566 if test "$force_no_lex_o" = "yes" ; then
1569 $LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1570 if test "$?" = "0" ; then
1578 echo "lex/yacc for arithmetic $arith"
1580 ##########################################
1581 # Check whether we have setmntent/getmntent
1586 int main(int argc, char **argv)
1588 FILE *mtab = setmntent(NULL, "r");
1589 struct mntent *mnt = getmntent(mtab);
1594 if compile_prog "" "" "getmntent"; then
1597 echo "getmntent $getmntent"
1599 ##########################################
1600 # Check whether we have getmntinfo
1604 #include <sys/param.h>
1605 #include <sys/mount.h>
1606 int main(int argc, char **argv)
1609 return getmntinfo(&st, MNT_NOWAIT);
1612 if compile_prog "" "" "getmntinfo"; then
1615 echo "getmntinfo $getmntinfo"
1617 ##########################################
1618 # Check whether we have _Static_assert
1624 #ifdef __compiler_offsetof
1625 #define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
1627 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1630 #define container_of(ptr, type, member) ({ \
1631 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
1632 (type *)( (char *)__mptr - offsetof(type,member) );})
1638 int main(int argc, char **argv)
1640 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
1644 if compile_prog "" "" "static_assert"; then
1647 echo "Static Assert $static_assert"
1649 ##########################################
1650 # Check whether we have bool / stdbool.h
1653 #include <stdbool.h>
1654 int main(int argc, char **argv)
1657 return var != false;
1660 if compile_prog "" "" "bool"; then
1663 echo "bool $have_bool"
1665 #############################################################################
1667 if test "$wordsize" = "64" ; then
1668 output_sym "CONFIG_64BIT"
1669 elif test "$wordsize" = "32" ; then
1670 output_sym "CONFIG_32BIT"
1672 fatal "Unknown wordsize!"
1674 if test "$bigendian" = "yes" ; then
1675 output_sym "CONFIG_BIG_ENDIAN"
1677 output_sym "CONFIG_LITTLE_ENDIAN"
1679 if test "$zlib" = "yes" ; then
1680 output_sym "CONFIG_ZLIB"
1682 if test "$libaio" = "yes" ; then
1683 output_sym "CONFIG_LIBAIO"
1685 if test "$posix_aio" = "yes" ; then
1686 output_sym "CONFIG_POSIXAIO"
1688 if test "$posix_aio_fsync" = "yes" ; then
1689 output_sym "CONFIG_POSIXAIO_FSYNC"
1691 if test "$linux_fallocate" = "yes" ; then
1692 output_sym "CONFIG_LINUX_FALLOCATE"
1694 if test "$posix_fallocate" = "yes" ; then
1695 output_sym "CONFIG_POSIX_FALLOCATE"
1697 if test "$fdatasync" = "yes" ; then
1698 output_sym "CONFIG_FDATASYNC"
1700 if test "$sync_file_range" = "yes" ; then
1701 output_sym "CONFIG_SYNC_FILE_RANGE"
1703 if test "$sfaa" = "yes" ; then
1704 output_sym "CONFIG_SFAA"
1706 if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
1707 output_sym "CONFIG_RDMA"
1709 if test "$clock_gettime" = "yes" ; then
1710 output_sym "CONFIG_CLOCK_GETTIME"
1712 if test "$clock_monotonic" = "yes" ; then
1713 output_sym "CONFIG_CLOCK_MONOTONIC"
1715 if test "$clock_monotonic_raw" = "yes" ; then
1716 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
1718 if test "$clock_monotonic_precise" = "yes" ; then
1719 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
1721 if test "$gettimeofday" = "yes" ; then
1722 output_sym "CONFIG_GETTIMEOFDAY"
1724 if test "$posix_fadvise" = "yes" ; then
1725 output_sym "CONFIG_POSIX_FADVISE"
1727 if test "$linux_3arg_affinity" = "yes" ; then
1728 output_sym "CONFIG_3ARG_AFFINITY"
1729 elif test "$linux_2arg_affinity" = "yes" ; then
1730 output_sym "CONFIG_2ARG_AFFINITY"
1732 if test "$strsep" = "yes" ; then
1733 output_sym "CONFIG_STRSEP"
1735 if test "$strcasestr" = "yes" ; then
1736 output_sym "CONFIG_STRCASESTR"
1738 if test "$strlcat" = "yes" ; then
1739 output_sym "CONFIG_STRLCAT"
1741 if test "$getopt_long_only" = "yes" ; then
1742 output_sym "CONFIG_GETOPT_LONG_ONLY"
1744 if test "$inet_aton" = "yes" ; then
1745 output_sym "CONFIG_INET_ATON"
1747 if test "$socklen_t" = "yes" ; then
1748 output_sym "CONFIG_SOCKLEN_T"
1750 if test "$ext4_me" = "yes" ; then
1751 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1753 if test "$linux_splice" = "yes" ; then
1754 output_sym "CONFIG_LINUX_SPLICE"
1756 if test "$guasi" = "yes" ; then
1757 output_sym "CONFIG_GUASI"
1759 if test "$fusion_aw" = "yes" ; then
1760 output_sym "CONFIG_FUSION_AW"
1762 if test "$libnuma_v2" = "yes" ; then
1763 output_sym "CONFIG_LIBNUMA"
1765 if test "$solaris_aio" = "yes" ; then
1766 output_sym "CONFIG_SOLARISAIO"
1768 if test "$tls_thread" = "yes" ; then
1769 output_sym "CONFIG_TLS_THREAD"
1771 if test "$rusage_thread" = "yes" ; then
1772 output_sym "CONFIG_RUSAGE_THREAD"
1774 if test "$gfio" = "yes" ; then
1775 echo "CONFIG_GFIO=y" >> $config_host_mak
1777 if test "$esx" = "yes" ; then
1778 output_sym "CONFIG_ESX"
1779 output_sym "CONFIG_NO_SHM"
1781 if test "$sched_idle" = "yes" ; then
1782 output_sym "CONFIG_SCHED_IDLE"
1784 if test "$tcp_nodelay" = "yes" ; then
1785 output_sym "CONFIG_TCP_NODELAY"
1787 if test "$window_size" = "yes" ; then
1788 output_sym "CONFIG_NET_WINDOWSIZE"
1790 if test "$mss" = "yes" ; then
1791 output_sym "CONFIG_NET_MSS"
1793 if test "$rlimit_memlock" = "yes" ; then
1794 output_sym "CONFIG_RLIMIT_MEMLOCK"
1796 if test "$pwritev" = "yes" ; then
1797 output_sym "CONFIG_PWRITEV"
1799 if test "$pwritev2" = "yes" ; then
1800 output_sym "CONFIG_PWRITEV2"
1802 if test "$ipv6" = "yes" ; then
1803 output_sym "CONFIG_IPV6"
1805 if test "$rbd" = "yes" ; then
1806 output_sym "CONFIG_RBD"
1808 if test "$rbd_inval" = "yes" ; then
1809 output_sym "CONFIG_RBD_INVAL"
1811 if test "$rbd_blkin" = "yes" ; then
1812 output_sym "CONFIG_RBD_BLKIN"
1814 if test "$setvbuf" = "yes" ; then
1815 output_sym "CONFIG_SETVBUF"
1817 if test "$s390_z196_facilities" = "yes" ; then
1818 output_sym "CONFIG_S390_Z196_FACILITIES"
1819 CFLAGS="$CFLAGS -march=z9-109"
1821 if test "$gfapi" = "yes" ; then
1822 output_sym "CONFIG_GFAPI"
1824 if test "$gf_fadvise" = "yes" ; then
1825 output_sym "CONFIG_GF_FADVISE"
1827 if test "$gf_trim" = "yes" ; then
1828 output_sym "CONFIG_GF_TRIM"
1830 if test "$libhdfs" = "yes" ; then
1831 output_sym "CONFIG_LIBHDFS"
1832 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
1833 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
1834 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
1836 if test "$mtd" = "yes" ; then
1837 output_sym "CONFIG_MTD"
1839 if test "$pmemblk" = "yes" ; then
1840 output_sym "CONFIG_PMEMBLK"
1842 if test "$arith" = "yes" ; then
1843 output_sym "CONFIG_ARITHMETIC"
1844 if test "$yacc_is_bison" = "yes" ; then
1845 echo "YACC=$YACC -y" >> $config_host_mak
1847 echo "YACC=$YACC" >> $config_host_mak
1849 if test "$lex_use_o" = "yes" ; then
1850 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
1853 if test "$getmntent" = "yes" ; then
1854 output_sym "CONFIG_GETMNTENT"
1856 if test "$getmntinfo" = "yes" ; then
1857 output_sym "CONFIG_GETMNTINFO"
1859 if test "$static_assert" = "yes" ; then
1860 output_sym "CONFIG_STATIC_ASSERT"
1862 if test "$have_bool" = "yes" ; then
1863 output_sym "CONFIG_HAVE_BOOL"
1866 if test "$zlib" = "no" ; then
1867 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
1870 echo "LIBS+=$LIBS" >> $config_host_mak
1871 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
1872 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
1873 echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
1874 echo "CC=$cc" >> $config_host_mak
1875 echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
1876 echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
1878 if [ `dirname $0` != "." -a ! -e Makefile ]; then
1879 cat > Makefile <<EOF
1880 SRCDIR:=`dirname $0`
1881 include \$(SRCDIR)/Makefile