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
145 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
147 --prefix=*) prefix="$optarg"
149 --cpu=*) cpu="$optarg"
151 # esx is cross compiled and cannot be detect through simple uname calls
157 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
159 --build-32bit-win) build_32bit_win="yes"
161 --build-static) build_static="yes"
166 --disable-numa) disable_numa="yes"
168 --disable-rbd) disable_rbd="yes"
170 --disable-rbd-blkin) disable_rbd_blkin="yes"
172 --disable-gfapi) disable_gfapi="yes"
174 --enable-libhdfs) libhdfs="yes"
176 --enable-pmemblk) pmemblk="yes"
178 --enable-devdax) devdax="yes"
180 --disable-lex) disable_lex="yes"
182 --enable-lex) disable_lex="no"
184 --disable-shm) no_shm="yes"
186 --disable-optimizations) disable_opt="yes"
192 echo "Bad option $opt"
198 if test "$show_help" = "yes" ; then
199 echo "--prefix= Use this directory as installation prefix"
200 echo "--cpu= Specify target CPU if auto-detect fails"
201 echo "--cc= Specify compiler to use"
202 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
203 echo "--build-32bit-win Enable 32-bit build on Windows"
204 echo "--build-static Build a static fio"
205 echo "--esx Configure build options for esx"
206 echo "--enable-gfio Enable building of gtk gfio"
207 echo "--disable-numa Disable libnuma even if found"
208 echo "--disable-gfapi Disable gfapi"
209 echo "--enable-libhdfs Enable hdfs support"
210 echo "--enable-pmemblk Enable NVML libpmemblk support"
211 echo "--enable-devdax Enable NVM Device Dax support"
212 echo "--disable-lex Disable use of lex/yacc for math"
213 echo "--enable-lex Enable use of lex/yacc for math"
214 echo "--disable-shm Disable SHM support"
215 echo "--disable-optimizations Don't enable compiler optimizations"
219 cross_prefix=${cross_prefix-${CROSS_COMPILE}}
220 cc="${CC-${cross_prefix}gcc}"
222 if check_define __ANDROID__ ; then
224 elif check_define __linux__ ; then
226 elif check_define __OpenBSD__ ; then
228 elif check_define __sun__ ; then
230 CFLAGS="$CFLAGS -D_REENTRANT"
231 elif check_define _WIN32 ; then
237 echo "# Automatically generated by configure - do not modify" > $config_host_mak
238 printf "# Configured with:" >> $config_host_mak
239 printf " '%s'" "$0" "$@" >> $config_host_mak
240 echo >> $config_host_mak
241 echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
243 if test "$no_shm" = "yes" ; then
244 output_sym "CONFIG_NO_SHM"
247 if test "$disable_opt" = "yes" ; then
248 output_sym "CONFIG_FIO_NO_OPT"
251 # Some host OSes need non-standard checks for which CPU to use.
252 # Note that these checks are broken for cross-compilation: if you're
253 # cross-compiling to one of these OSes then you'll need to specify
254 # the correct CPU with the --cpu option.
257 # Unless explicitly enabled, turn off lex.
258 if test -z "$disable_lex" ; then
265 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
266 # we can run 64-bit userspace code.
267 # If the user didn't specify a CPU explicitly and the kernel says this is
268 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
270 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
275 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
276 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
279 LIBS="-lnsl -lsocket"
282 echo "Forcing known good options on Windows"
283 if test -z "$CC" ; then
284 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
285 CC="i686-w64-mingw32-gcc"
287 CC="x86_64-w64-mingw32-gcc"
290 output_sym "CONFIG_LITTLE_ENDIAN"
291 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
292 output_sym "CONFIG_32BIT"
294 output_sym "CONFIG_64BIT_LLP64"
296 output_sym "CONFIG_FADVISE"
297 output_sym "CONFIG_SOCKLEN_T"
298 output_sym "CONFIG_FADVISE"
299 output_sym "CONFIG_SFAA"
300 output_sym "CONFIG_RUSAGE_THREAD"
301 output_sym "CONFIG_WINDOWSAIO"
302 output_sym "CONFIG_FDATASYNC"
303 output_sym "CONFIG_CLOCK_MONOTONIC"
304 output_sym "CONFIG_GETTIMEOFDAY"
305 output_sym "CONFIG_CLOCK_GETTIME"
306 output_sym "CONFIG_SCHED_IDLE"
307 output_sym "CONFIG_TCP_NODELAY"
308 output_sym "CONFIG_TLS_THREAD"
309 output_sym "CONFIG_IPV6"
310 echo "CC=$CC" >> $config_host_mak
311 echo "BUILD_CFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
316 if test ! -z "$cpu" ; then
317 # command line argument
319 elif check_define __i386__ ; then
321 elif check_define __x86_64__ ; then
323 elif check_define __sparc__ ; then
324 if check_define __arch64__ ; then
329 elif check_define _ARCH_PPC ; then
330 if check_define _ARCH_PPC64 ; then
335 elif check_define __mips__ ; then
337 elif check_define __ia64__ ; then
339 elif check_define __s390__ ; then
340 if check_define __s390x__ ; then
345 elif check_define __arm__ ; then
347 elif check_define __hppa__ ; then
353 # Normalise host CPU name and set ARCH.
355 ia64|ppc|ppc64|s390|s390x|sparc64)
358 i386|i486|i586|i686|i86pc|BePC)
367 hppa|parisc|parisc64)
381 if test -z "$CC" ; then
382 if test "$targetos" = "FreeBSD"; then
391 cc="${CC-${cross_prefix}gcc}"
393 ##########################################
394 # check cross compile
403 if compile_prog "" "" "cross"; then
404 $TMPE 2>/dev/null || cross_compile="yes"
406 fatal "compile test failed"
409 ##########################################
412 if test "$cross_compile" = "no" ; then
414 #include <inttypes.h>
417 volatile uint32_t i=0x01234567;
418 return (*((uint8_t*)(&i))) == 0x67;
421 if compile_prog "" "" "endian"; then
422 $TMPE && bigendian="yes"
425 # If we're cross compiling, try our best to work it out and rely on the
426 # run-time check to fail if we get it wrong.
431 #if __BYTE_ORDER != __BIG_ENDIAN
432 # error "Unknown endianness"
436 compile_prog "" "" "endian" && bigendian="yes"
437 check_define "__ARMEB__" && bigendian="yes"
438 check_define "__MIPSEB__" && bigendian="yes"
442 echo "Operating system $targetos"
444 echo "Big endian $bigendian"
446 echo "Cross compile $cross_compile"
449 ##########################################
450 # See if we need to build a static build
451 if test "$build_static" = "yes" ; then
452 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
453 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
457 echo "Static build $build_static"
459 ##########################################
464 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
467 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
471 if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
473 elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
476 fatal "Unknown wordsize"
478 echo "Wordsize $wordsize"
480 ##########################################
488 if (inflateInit(&stream) != Z_OK)
493 if compile_prog "" "-lz" "zlib" ; then
499 ##########################################
502 if test "$esx" != "yes" ; then
512 if compile_prog "" "-laio" "libaio" ; then
516 if test "$libaio" = "yes" ; then
517 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
522 echo "Linux AIO support $libaio"
524 ##########################################
537 if compile_prog "" "" "posixaio" ; then
539 elif compile_prog "" "-lrt" "posixaio"; then
544 echo "POSIX AIO support $posix_aio"
545 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
547 ##########################################
548 # posix aio fsync probe
550 if test "$posix_aio" = "yes" ; then
557 return aio_fsync(O_SYNC, &cb);
561 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
565 echo "POSIX AIO fsync $posix_aio_fsync"
567 ##########################################
571 #include <sys/types.h>
572 #include <sys/asynch.h>
577 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
581 if compile_prog "" "-laio" "solarisaio" ; then
585 echo "Solaris AIO support $solaris_aio"
587 ##########################################
588 # __sync_fetch_and_add test
591 #include <inttypes.h>
592 static int sfaa(uint64_t *ptr)
594 return __sync_fetch_and_add(ptr, 0);
597 int main(int argc, char **argv)
604 if compile_prog "" "" "__sync_fetch_and_add()" ; then
607 echo "__sync_fetch_and_add $sfaa"
609 ##########################################
614 #include <infiniband/arch.h>
615 int main(int argc, char **argv)
617 struct ibv_pd *pd = ibv_alloc_pd(NULL);
621 if compile_prog "" "-libverbs" "libverbs" ; then
623 LIBS="-libverbs $LIBS"
625 echo "libverbs $libverbs"
627 ##########################################
632 #include <rdma/rdma_cma.h>
633 int main(int argc, char **argv)
635 rdma_destroy_qp(NULL);
639 if compile_prog "" "-lrdmacm" "rdma"; then
641 LIBS="-lrdmacm $LIBS"
643 echo "rdmacm $rdmacm"
645 ##########################################
646 # Linux fallocate probe
651 #include <linux/falloc.h>
652 int main(int argc, char **argv)
654 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
658 if compile_prog "" "" "linux_fallocate"; then
659 linux_fallocate="yes"
661 echo "Linux fallocate $linux_fallocate"
663 ##########################################
664 # POSIX fadvise probe
669 int main(int argc, char **argv)
671 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
675 if compile_prog "" "" "posix_fadvise"; then
678 echo "POSIX fadvise $posix_fadvise"
680 ##########################################
681 # POSIX fallocate probe
686 int main(int argc, char **argv)
688 int r = posix_fallocate(0, 0, 1024);
692 if compile_prog "" "" "posix_fallocate"; then
693 posix_fallocate="yes"
695 echo "POSIX fallocate $posix_fallocate"
697 ##########################################
698 # sched_set/getaffinity 2 or 3 argument test
699 linux_2arg_affinity="no"
700 linux_3arg_affinity="no"
703 int main(int argc, char **argv)
706 return sched_setaffinity(0, sizeof(mask), &mask);
709 if compile_prog "" "" "sched_setaffinity(,,)"; then
710 linux_3arg_affinity="yes"
714 int main(int argc, char **argv)
717 return sched_setaffinity(0, &mask);
720 if compile_prog "" "" "sched_setaffinity(,)"; then
721 linux_2arg_affinity="yes"
724 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
725 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
727 ##########################################
728 # clock_gettime probe
733 int main(int argc, char **argv)
735 return clock_gettime(0, NULL);
738 if compile_prog "" "" "clock_gettime"; then
740 elif compile_prog "" "-lrt" "clock_gettime"; then
744 echo "clock_gettime $clock_gettime"
746 ##########################################
747 # CLOCK_MONOTONIC probe
749 if test "$clock_gettime" = "yes" ; then
753 int main(int argc, char **argv)
755 return clock_gettime(CLOCK_MONOTONIC, NULL);
758 if compile_prog "" "$LIBS" "clock monotonic"; then
759 clock_monotonic="yes"
762 echo "CLOCK_MONOTONIC $clock_monotonic"
764 ##########################################
765 # CLOCK_MONOTONIC_RAW probe
766 clock_monotonic_raw="no"
767 if test "$clock_gettime" = "yes" ; then
771 int main(int argc, char **argv)
773 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
776 if compile_prog "" "$LIBS" "clock monotonic"; then
777 clock_monotonic_raw="yes"
780 echo "CLOCK_MONOTONIC_RAW $clock_monotonic_raw"
782 ##########################################
783 # CLOCK_MONOTONIC_PRECISE probe
784 clock_monotonic_precise="no"
785 if test "$clock_gettime" = "yes" ; then
789 int main(int argc, char **argv)
791 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
794 if compile_prog "" "$LIBS" "clock monotonic precise"; then
795 clock_monotonic_precise="yes"
798 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
800 ##########################################
807 int main(int argc, char **argv)
810 memset(&cid, 0, sizeof(cid));
811 return clock_gettime(cid, NULL);
814 if compile_prog "" "$LIBS" "clockid_t"; then
817 echo "clockid_t $clockid_t"
819 ##########################################
820 # gettimeofday() probe
823 #include <sys/time.h>
825 int main(int argc, char **argv)
828 return gettimeofday(&tv, NULL);
831 if compile_prog "" "" "gettimeofday"; then
834 echo "gettimeofday $gettimeofday"
836 ##########################################
842 int main(int argc, char **argv)
847 if compile_prog "" "" "fdatasync"; then
850 echo "fdatasync $fdatasync"
852 ##########################################
853 # sync_file_range() probe
859 #include <linux/fs.h>
860 int main(int argc, char **argv)
862 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
863 SYNC_FILE_RANGE_WAIT_AFTER;
864 return sync_file_range(0, 0, 0, flags);
867 if compile_prog "" "" "sync_file_range"; then
868 sync_file_range="yes"
870 echo "sync_file_range $sync_file_range"
872 ##########################################
873 # ext4 move extent probe
877 #include <sys/ioctl.h>
878 int main(int argc, char **argv)
880 struct move_extent me;
881 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
884 if compile_prog "" "" "ext4 move extent" ; then
886 elif test $targetos = "Linux" ; then
887 # On Linux, just default to it on and let it error at runtime if we really
888 # don't have it. None of my updated systems have it defined, but it does
889 # work. Takes a while to bubble back.
892 echo "EXT4 move extent $ext4_me"
894 ##########################################
900 int main(int argc, char **argv)
902 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
905 if compile_prog "" "" "linux splice"; then
908 echo "Linux splice(2) $linux_splice"
910 ##########################################
915 #include <guasi_syscalls.h>
916 int main(int argc, char **argv)
918 guasi_t ctx = guasi_create(0, 0, 0);
922 if compile_prog "" "" "guasi"; then
927 ##########################################
931 #include <nvm/nvm_primitives.h>
932 int main(int argc, char **argv)
934 nvm_version_t ver_info;
937 handle = nvm_get_handle(0, &ver_info);
938 return nvm_atomic_write(handle, 0, 0, 0);
941 if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
942 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
945 echo "Fusion-io atomic engine $fusion_aw"
947 ##########################################
952 int main(int argc, char **argv)
954 return numa_available();
957 if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
961 echo "libnuma $libnuma"
963 ##########################################
964 # libnuma 2.x version API
965 if test "$libnuma" = "yes" ; then
969 int main(int argc, char **argv)
971 struct bitmask *mask = numa_parse_nodestring(NULL);
972 return mask->size == 0;
975 if compile_prog "" "" "libnuma api"; then
978 echo "libnuma v2 $libnuma_v2"
981 ##########################################
986 int main(int argc, char **argv)
988 static char *string = "This is a string";
989 strsep(&string, "needle");
993 if compile_prog "" "" "strsep"; then
996 echo "strsep $strsep"
998 ##########################################
1003 int main(int argc, char **argv)
1005 return strcasestr(argv[0], argv[1]) != NULL;
1008 if compile_prog "" "" "strcasestr"; then
1011 echo "strcasestr $strcasestr"
1013 ##########################################
1018 int main(int argc, char **argv)
1020 static char dst[64];
1021 static char *string = "This is a string";
1022 memset(dst, 0, sizeof(dst));
1023 strlcat(dst, string, sizeof(dst));
1027 if compile_prog "" "" "strlcat"; then
1030 echo "strlcat $strlcat"
1032 ##########################################
1033 # getopt_long_only() probe
1034 getopt_long_only="no"
1039 int main(int argc, char **argv)
1041 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1045 if compile_prog "" "" "getopt_long_only"; then
1046 getopt_long_only="yes"
1048 echo "getopt_long_only() $getopt_long_only"
1050 ##########################################
1054 #include <sys/socket.h>
1055 #include <arpa/inet.h>
1057 int main(int argc, char **argv)
1060 return inet_aton(NULL, &in);
1063 if compile_prog "" "" "inet_aton"; then
1066 echo "inet_aton $inet_aton"
1068 ##########################################
1072 #include <sys/socket.h>
1073 int main(int argc, char **argv)
1079 if compile_prog "" "" "socklen_t"; then
1082 echo "socklen_t $socklen_t"
1084 ##########################################
1085 # Whether or not __thread is supported for TLS
1089 static __thread int ret;
1090 int main(int argc, char **argv)
1095 if compile_prog "" "" "__thread"; then
1098 echo "__thread $tls_thread"
1100 ##########################################
1101 # Check if we have required gtk/glib support for gfio
1103 if test "$gfio_check" = "yes" ; then
1107 #include <gtk/gtk.h>
1110 gdk_threads_enter();
1111 gdk_threads_leave();
1113 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
1116 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1117 ORG_LDFLAGS=$LDFLAGS
1118 LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1119 if test "$?" != "0" ; then
1120 echo "configure: gtk and gthread not found"
1123 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1124 if test "$?" != "0" ; then
1125 echo "configure: gtk and gthread not found"
1128 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1130 if test "$r" != "0" ; then
1132 GFIO_LIBS="$LIBS $GTK_LIBS"
1133 CFLAGS="$CFLAGS $GTK_CFLAGS"
1135 echo "GTK found, but need version 2.18 or higher"
1139 echo "Please install gtk and gdk libraries"
1142 LDFLAGS=$ORG_LDFLAGS
1145 if test "$gfio_check" = "yes" ; then
1146 echo "gtk 2.18 or higher $gfio"
1149 # Check whether we have getrusage(RUSAGE_THREAD)
1152 #include <sys/time.h>
1153 #include <sys/resource.h>
1154 int main(int argc, char **argv)
1157 getrusage(RUSAGE_THREAD, &ru);
1161 if compile_prog "" "" "RUSAGE_THREAD"; then
1164 echo "RUSAGE_THREAD $rusage_thread"
1166 ##########################################
1167 # Check whether we have SCHED_IDLE
1171 int main(int argc, char **argv)
1173 struct sched_param p;
1174 return sched_setscheduler(0, SCHED_IDLE, &p);
1177 if compile_prog "" "" "SCHED_IDLE"; then
1180 echo "SCHED_IDLE $sched_idle"
1182 ##########################################
1183 # Check whether we have TCP_NODELAY
1187 #include <sys/types.h>
1188 #include <sys/socket.h>
1189 #include <netinet/tcp.h>
1190 int main(int argc, char **argv)
1192 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1195 if compile_prog "" "" "TCP_NODELAY"; then
1198 echo "TCP_NODELAY $tcp_nodelay"
1200 ##########################################
1201 # Check whether we have SO_SNDBUF
1205 #include <sys/types.h>
1206 #include <sys/socket.h>
1207 #include <netinet/tcp.h>
1208 int main(int argc, char **argv)
1210 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1211 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1214 if compile_prog "" "" "SO_SNDBUF"; then
1217 echo "Net engine window_size $window_size"
1219 ##########################################
1220 # Check whether we have TCP_MAXSEG
1224 #include <sys/types.h>
1225 #include <sys/socket.h>
1226 #include <netinet/tcp.h>
1227 #include <arpa/inet.h>
1228 #include <netinet/in.h>
1229 int main(int argc, char **argv)
1231 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1234 if compile_prog "" "" "TCP_MAXSEG"; then
1237 echo "TCP_MAXSEG $mss"
1239 ##########################################
1240 # Check whether we have RLIMIT_MEMLOCK
1243 #include <sys/time.h>
1244 #include <sys/resource.h>
1245 int main(int argc, char **argv)
1248 return getrlimit(RLIMIT_MEMLOCK, &rl);
1251 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1252 rlimit_memlock="yes"
1254 echo "RLIMIT_MEMLOCK $rlimit_memlock"
1256 ##########################################
1257 # Check whether we have pwritev/preadv
1261 #include <sys/uio.h>
1262 int main(int argc, char **argv)
1264 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1267 if compile_prog "" "" "pwritev"; then
1270 echo "pwritev/preadv $pwritev"
1272 ##########################################
1273 # Check whether we have pwritev2/preadv2
1277 #include <sys/uio.h>
1278 int main(int argc, char **argv)
1280 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1283 if compile_prog "" "" "pwritev2"; then
1286 echo "pwritev2/preadv2 $pwritev2"
1288 ##########################################
1289 # Check whether we have the required functions for ipv6
1292 #include <sys/types.h>
1293 #include <sys/socket.h>
1294 #include <netinet/in.h>
1297 int main(int argc, char **argv)
1299 struct addrinfo hints;
1300 struct in6_addr addr;
1303 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1305 printf("%s\n", gai_strerror(ret));
1310 if compile_prog "" "" "ipv6"; then
1313 echo "IPv6 helpers $ipv6"
1315 ##########################################
1319 #include <rbd/librbd.h>
1321 int main(int argc, char **argv)
1325 rados_ioctx_t io_ctx;
1326 const char pool[] = "rbd";
1328 int major, minor, extra;
1329 rbd_version(&major, &minor, &extra);
1331 rados_ioctx_create(cluster, pool, &io_ctx);
1335 if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
1336 LIBS="-lrbd -lrados $LIBS"
1339 echo "Rados Block Device engine $rbd"
1341 ##########################################
1342 # check for rbd_poll
1344 if test "$rbd" = "yes"; then
1346 #include <rbd/librbd.h>
1347 #include <sys/eventfd.h>
1349 int main(int argc, char **argv)
1352 rbd_completion_t comp;
1354 int fd = eventfd(0, EFD_NONBLOCK);
1355 rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1356 rbd_poll_io_events(image, comp, 1);
1361 if compile_prog "" "-lrbd -lrados" "rbd"; then
1364 echo "rbd_poll $rbd_poll"
1367 ##########################################
1368 # check for rbd_invaidate_cache()
1370 if test "$rbd" = "yes"; then
1372 #include <rbd/librbd.h>
1374 int main(int argc, char **argv)
1378 return rbd_invalidate_cache(image);
1381 if compile_prog "" "-lrbd -lrados" "rbd"; then
1384 echo "rbd_invalidate_cache $rbd_inval"
1387 ##########################################
1391 #include <rbd/librbd.h>
1392 #include <zipkin_c.h>
1394 int main(int argc, char **argv)
1397 struct blkin_trace_info t_info;
1398 blkin_init_trace_info(&t_info);
1399 rbd_completion_t completion;
1404 r = rbd_aio_write_traced(image, off, len, buf, completion, &t_info);
1408 if test "$disable_rbd" != "yes" && test "$disable_rbd_blkin" != "yes" \
1409 && compile_prog "" "-lrbd -lrados -lblkin" "rbd_blkin"; then
1410 LIBS="-lblkin $LIBS"
1413 echo "rbd blkin tracing $rbd_blkin"
1415 ##########################################
1416 # Check whether we have setvbuf
1420 int main(int argc, char **argv)
1424 setvbuf(f, buf, _IOFBF, sizeof(buf));
1428 if compile_prog "" "" "setvbuf"; then
1431 echo "setvbuf $setvbuf"
1436 #include <glusterfs/api/glfs.h>
1438 int main(int argc, char **argv)
1441 glfs_t *g = glfs_new("foo");
1446 if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1447 LIBS="-lgfapi -lglusterfs $LIBS"
1450 echo "Gluster API engine $gfapi"
1452 ##########################################
1453 # check for gfapi fadvise support
1454 if test "$gfapi" = "yes" ; then
1457 #include <glusterfs/api/glfs.h>
1459 int main(int argc, char **argv)
1462 int ret = glfs_fadvise(fd, 0, 0, 1);
1467 if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1470 echo "Gluster API use fadvise $gf_fadvise"
1473 ##########################################
1474 # check for gfapi trim support
1476 if test "$gfapi" = "yes" ; then
1478 #include <glusterfs/api/glfs.h>
1480 int main(int argc, char **argv)
1482 return glfs_discard_async(NULL, 0, 0);
1485 if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1488 echo "Gluster API trim support $gf_trim"
1491 ##########################################
1492 # Check if we support stckf on s390
1493 s390_z196_facilities="no"
1495 #define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1496 int main(int argc, char **argv)
1498 /* We want just 1 double word to be returned. */
1499 register unsigned long reg0 asm("0") = 0;
1500 unsigned long stfle_bits;
1501 asm volatile(".machine push" "\n\t"
1502 ".machine \"z9-109\"" "\n\t"
1505 : "=QS" (stfle_bits), "+d" (reg0)
1508 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1514 if compile_prog "" "" "s390_z196_facilities"; then
1516 if [[ $? -eq 0 ]]; then
1517 s390_z196_facilities="yes"
1520 echo "s390_z196_facilities $s390_z196_facilities"
1522 ##########################################
1523 # Check if we have required environment variables configured for libhdfs
1524 if test "$libhdfs" = "yes" ; then
1526 if test "$JAVA_HOME" = "" ; then
1527 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1530 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1531 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1534 if test "$FIO_LIBHDFS_LIB" = "" ; then
1535 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1538 if test "$hdfs_conf_error" = "1" ; then
1542 if test "$FIO_HDFS_CPU" = "x86_64" ; then
1543 FIO_HDFS_CPU="amd64"
1546 echo "HDFS engine $libhdfs"
1548 ##########################################
1549 # Check whether we have MTD
1553 #include <mtd/mtd-user.h>
1554 #include <sys/ioctl.h>
1555 int main(int argc, char **argv)
1557 struct mtd_write_req ops;
1558 struct mtd_info_user info;
1559 memset(&ops, 0, sizeof(ops));
1560 info.type = MTD_MLCNANDFLASH;
1561 return ioctl(0, MEMGETINFO, &info);
1564 if compile_prog "" "" "mtd"; then
1569 ##########################################
1570 # Report whether pmemblk engine is enabled
1571 echo "NVML libpmemblk engine $pmemblk"
1573 ##########################################
1574 # Report whether dev-dax engine is enabled
1575 echo "NVM Device Dax engine $devdax"
1577 # Check if we have lex/yacc available
1582 if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
1583 if test "$targetos" != "SunOS" ; then
1584 LEX=$(which lex 2> /dev/null)
1585 if test -x "$LEX" ; then
1588 YACC=$(which bison 2> /dev/null)
1589 if test -x "$YACC" ; then
1593 YACC=$(which yacc 2> /dev/null)
1594 if test -x "$YACC" ; then
1598 if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1602 if test "$arith" = "yes" ; then
1604 extern int yywrap(void);
1606 int main(int argc, char **argv)
1612 if compile_prog "" "-ll" "lex"; then
1621 # Check if lex fails using -o
1622 if test "$arith" = "yes" ; then
1623 if test "$force_no_lex_o" = "yes" ; then
1626 $LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1627 if test "$?" = "0" ; then
1635 echo "lex/yacc for arithmetic $arith"
1637 ##########################################
1638 # Check whether we have setmntent/getmntent
1643 int main(int argc, char **argv)
1645 FILE *mtab = setmntent(NULL, "r");
1646 struct mntent *mnt = getmntent(mtab);
1651 if compile_prog "" "" "getmntent"; then
1654 echo "getmntent $getmntent"
1656 ##########################################
1657 # Check whether we have getmntinfo
1658 # These are originally added for BSDs, but may also work
1659 # on other operating systems with getmntinfo(3).
1661 # getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
1662 # Note that NetBSD needs -Werror to catch warning as error.
1666 #include <sys/param.h>
1667 #include <sys/mount.h>
1668 int main(int argc, char **argv)
1671 return getmntinfo(&st, MNT_NOWAIT);
1674 if compile_prog "-Werror" "" "getmntinfo"; then
1677 echo "getmntinfo $getmntinfo"
1679 # getmntinfo(3) for NetBSD.
1680 getmntinfo_statvfs="no"
1683 #include <sys/statvfs.h>
1684 int main(int argc, char **argv)
1687 return getmntinfo(&st, MNT_NOWAIT);
1690 # Skip the test if the one with statfs arg is detected.
1691 if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
1692 getmntinfo_statvfs="yes"
1693 echo "getmntinfo_statvfs $getmntinfo_statvfs"
1696 ##########################################
1697 # Check whether we have _Static_assert
1703 #ifdef __compiler_offsetof
1704 #define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
1706 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1709 #define container_of(ptr, type, member) ({ \
1710 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
1711 (type *)( (char *)__mptr - offsetof(type,member) );})
1717 int main(int argc, char **argv)
1719 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
1723 if compile_prog "" "" "static_assert"; then
1726 echo "Static Assert $static_assert"
1728 ##########################################
1729 # Check whether we have bool / stdbool.h
1732 #include <stdbool.h>
1733 int main(int argc, char **argv)
1736 return var != false;
1739 if compile_prog "" "" "bool"; then
1742 echo "bool $have_bool"
1744 #############################################################################
1746 if test "$wordsize" = "64" ; then
1747 output_sym "CONFIG_64BIT"
1748 elif test "$wordsize" = "32" ; then
1749 output_sym "CONFIG_32BIT"
1751 fatal "Unknown wordsize!"
1753 if test "$bigendian" = "yes" ; then
1754 output_sym "CONFIG_BIG_ENDIAN"
1756 output_sym "CONFIG_LITTLE_ENDIAN"
1758 if test "$zlib" = "yes" ; then
1759 output_sym "CONFIG_ZLIB"
1761 if test "$libaio" = "yes" ; then
1762 output_sym "CONFIG_LIBAIO"
1764 if test "$posix_aio" = "yes" ; then
1765 output_sym "CONFIG_POSIXAIO"
1767 if test "$posix_aio_fsync" = "yes" ; then
1768 output_sym "CONFIG_POSIXAIO_FSYNC"
1770 if test "$linux_fallocate" = "yes" ; then
1771 output_sym "CONFIG_LINUX_FALLOCATE"
1773 if test "$posix_fallocate" = "yes" ; then
1774 output_sym "CONFIG_POSIX_FALLOCATE"
1776 if test "$fdatasync" = "yes" ; then
1777 output_sym "CONFIG_FDATASYNC"
1779 if test "$sync_file_range" = "yes" ; then
1780 output_sym "CONFIG_SYNC_FILE_RANGE"
1782 if test "$sfaa" = "yes" ; then
1783 output_sym "CONFIG_SFAA"
1785 if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
1786 output_sym "CONFIG_RDMA"
1788 if test "$clock_gettime" = "yes" ; then
1789 output_sym "CONFIG_CLOCK_GETTIME"
1791 if test "$clock_monotonic" = "yes" ; then
1792 output_sym "CONFIG_CLOCK_MONOTONIC"
1794 if test "$clock_monotonic_raw" = "yes" ; then
1795 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
1797 if test "$clock_monotonic_precise" = "yes" ; then
1798 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
1800 if test "$clockid_t" = "yes"; then
1801 output_sym "CONFIG_CLOCKID_T"
1803 if test "$gettimeofday" = "yes" ; then
1804 output_sym "CONFIG_GETTIMEOFDAY"
1806 if test "$posix_fadvise" = "yes" ; then
1807 output_sym "CONFIG_POSIX_FADVISE"
1809 if test "$linux_3arg_affinity" = "yes" ; then
1810 output_sym "CONFIG_3ARG_AFFINITY"
1811 elif test "$linux_2arg_affinity" = "yes" ; then
1812 output_sym "CONFIG_2ARG_AFFINITY"
1814 if test "$strsep" = "yes" ; then
1815 output_sym "CONFIG_STRSEP"
1817 if test "$strcasestr" = "yes" ; then
1818 output_sym "CONFIG_STRCASESTR"
1820 if test "$strlcat" = "yes" ; then
1821 output_sym "CONFIG_STRLCAT"
1823 if test "$getopt_long_only" = "yes" ; then
1824 output_sym "CONFIG_GETOPT_LONG_ONLY"
1826 if test "$inet_aton" = "yes" ; then
1827 output_sym "CONFIG_INET_ATON"
1829 if test "$socklen_t" = "yes" ; then
1830 output_sym "CONFIG_SOCKLEN_T"
1832 if test "$ext4_me" = "yes" ; then
1833 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1835 if test "$linux_splice" = "yes" ; then
1836 output_sym "CONFIG_LINUX_SPLICE"
1838 if test "$guasi" = "yes" ; then
1839 output_sym "CONFIG_GUASI"
1841 if test "$fusion_aw" = "yes" ; then
1842 output_sym "CONFIG_FUSION_AW"
1844 if test "$libnuma_v2" = "yes" ; then
1845 output_sym "CONFIG_LIBNUMA"
1847 if test "$solaris_aio" = "yes" ; then
1848 output_sym "CONFIG_SOLARISAIO"
1850 if test "$tls_thread" = "yes" ; then
1851 output_sym "CONFIG_TLS_THREAD"
1853 if test "$rusage_thread" = "yes" ; then
1854 output_sym "CONFIG_RUSAGE_THREAD"
1856 if test "$gfio" = "yes" ; then
1857 echo "CONFIG_GFIO=y" >> $config_host_mak
1859 if test "$esx" = "yes" ; then
1860 output_sym "CONFIG_ESX"
1861 output_sym "CONFIG_NO_SHM"
1863 if test "$sched_idle" = "yes" ; then
1864 output_sym "CONFIG_SCHED_IDLE"
1866 if test "$tcp_nodelay" = "yes" ; then
1867 output_sym "CONFIG_TCP_NODELAY"
1869 if test "$window_size" = "yes" ; then
1870 output_sym "CONFIG_NET_WINDOWSIZE"
1872 if test "$mss" = "yes" ; then
1873 output_sym "CONFIG_NET_MSS"
1875 if test "$rlimit_memlock" = "yes" ; then
1876 output_sym "CONFIG_RLIMIT_MEMLOCK"
1878 if test "$pwritev" = "yes" ; then
1879 output_sym "CONFIG_PWRITEV"
1881 if test "$pwritev2" = "yes" ; then
1882 output_sym "CONFIG_PWRITEV2"
1884 if test "$ipv6" = "yes" ; then
1885 output_sym "CONFIG_IPV6"
1887 if test "$rbd" = "yes" ; then
1888 output_sym "CONFIG_RBD"
1890 if test "$rbd_poll" = "yes" ; then
1891 output_sym "CONFIG_RBD_POLL"
1893 if test "$rbd_inval" = "yes" ; then
1894 output_sym "CONFIG_RBD_INVAL"
1896 if test "$rbd_blkin" = "yes" ; then
1897 output_sym "CONFIG_RBD_BLKIN"
1899 if test "$setvbuf" = "yes" ; then
1900 output_sym "CONFIG_SETVBUF"
1902 if test "$s390_z196_facilities" = "yes" ; then
1903 output_sym "CONFIG_S390_Z196_FACILITIES"
1904 CFLAGS="$CFLAGS -march=z9-109"
1906 if test "$gfapi" = "yes" ; then
1907 output_sym "CONFIG_GFAPI"
1909 if test "$gf_fadvise" = "yes" ; then
1910 output_sym "CONFIG_GF_FADVISE"
1912 if test "$gf_trim" = "yes" ; then
1913 output_sym "CONFIG_GF_TRIM"
1915 if test "$libhdfs" = "yes" ; then
1916 output_sym "CONFIG_LIBHDFS"
1917 echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
1918 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
1919 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
1920 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
1922 if test "$mtd" = "yes" ; then
1923 output_sym "CONFIG_MTD"
1925 if test "$pmemblk" = "yes" ; then
1926 output_sym "CONFIG_PMEMBLK"
1928 if test "$devdax" = "yes" ; then
1929 output_sym "CONFIG_LINUX_DEVDAX"
1931 if test "$arith" = "yes" ; then
1932 output_sym "CONFIG_ARITHMETIC"
1933 if test "$yacc_is_bison" = "yes" ; then
1934 echo "YACC=$YACC -y" >> $config_host_mak
1936 echo "YACC=$YACC" >> $config_host_mak
1938 if test "$lex_use_o" = "yes" ; then
1939 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
1942 if test "$getmntent" = "yes" ; then
1943 output_sym "CONFIG_GETMNTENT"
1945 if test "$getmntinfo" = "yes" ; then
1946 output_sym "CONFIG_GETMNTINFO"
1948 if test "$getmntinfo_statvfs" = "yes" ; then
1949 output_sym "CONFIG_GETMNTINFO_STATVFS"
1951 if test "$static_assert" = "yes" ; then
1952 output_sym "CONFIG_STATIC_ASSERT"
1954 if test "$have_bool" = "yes" ; then
1955 output_sym "CONFIG_HAVE_BOOL"
1958 if test "$zlib" = "no" ; then
1959 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
1962 echo "LIBS+=$LIBS" >> $config_host_mak
1963 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
1964 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
1965 echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
1966 echo "CC=$cc" >> $config_host_mak
1967 echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
1968 echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
1970 if [ `dirname $0` != "." -a ! -e Makefile ]; then
1971 cat > Makefile <<EOF
1972 SRCDIR:=`dirname $0`
1973 include \$(SRCDIR)/Makefile