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
143 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
145 --prefix=*) prefix="$optarg"
147 --cpu=*) cpu="$optarg"
149 # esx is cross compiled and cannot be detect through simple uname calls
155 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
157 --build-32bit-win) build_32bit_win="yes"
159 --build-static) build_static="yes"
164 --disable-numa) disable_numa="yes"
166 --disable-rbd) disable_rbd="yes"
168 --disable-gfapi) disable_gfapi="yes"
170 --enable-libhdfs) libhdfs="yes"
172 --disable-lex) disable_lex="yes"
174 --enable-lex) disable_lex="no"
176 --disable-shm) no_shm="yes"
178 --disable-optimizations) disable_opt="yes"
184 echo "Bad option $opt"
190 if test "$show_help" = "yes" ; then
191 echo "--prefix= Use this directory as installation prefix"
192 echo "--cpu= Specify target CPU if auto-detect fails"
193 echo "--cc= Specify compiler to use"
194 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
195 echo "--build-32bit-win Enable 32-bit build on Windows"
196 echo "--build-static Build a static fio"
197 echo "--esx Configure build options for esx"
198 echo "--enable-gfio Enable building of gtk gfio"
199 echo "--disable-numa Disable libnuma even if found"
200 echo "--disable-gfapi Disable gfapi"
201 echo "--enable-libhdfs Enable hdfs support"
202 echo "--disable-lex Disable use of lex/yacc for math"
203 echo "--enable-lex Enable use of lex/yacc for math"
204 echo "--disable-shm Disable SHM support"
205 echo "--disable-optimizations Don't enable compiler optimizations"
209 cross_prefix=${cross_prefix-${CROSS_COMPILE}}
210 cc="${CC-${cross_prefix}gcc}"
212 if check_define __ANDROID__ ; then
214 elif check_define __linux__ ; then
216 elif check_define __OpenBSD__ ; then
218 elif check_define __sun__ ; then
220 CFLAGS="$CFLAGS -D_REENTRANT"
221 elif check_define _WIN32 ; then
227 echo "# Automatically generated by configure - do not modify" > $config_host_mak
228 printf "# Configured with:" >> $config_host_mak
229 printf " '%s'" "$0" "$@" >> $config_host_mak
230 echo >> $config_host_mak
231 echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
233 if test "$no_shm" = "yes" ; then
234 output_sym "CONFIG_NO_SHM"
237 if test "$disable_opt" = "yes" ; then
238 output_sym "CONFIG_FIO_NO_OPT"
241 # Some host OSes need non-standard checks for which CPU to use.
242 # Note that these checks are broken for cross-compilation: if you're
243 # cross-compiling to one of these OSes then you'll need to specify
244 # the correct CPU with the --cpu option.
247 # Unless explicitly enabled, turn off lex.
248 if test -z "$disable_lex" ; then
255 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
256 # we can run 64-bit userspace code.
257 # If the user didn't specify a CPU explicitly and the kernel says this is
258 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
260 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
265 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
266 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
269 LIBS="-lnsl -lsocket"
272 echo "Forcing known good options on Windows"
273 if test -z "$CC" ; then
274 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
275 CC="i686-w64-mingw32-gcc"
277 CC="x86_64-w64-mingw32-gcc"
280 output_sym "CONFIG_LITTLE_ENDIAN"
281 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
282 output_sym "CONFIG_32BIT"
284 output_sym "CONFIG_64BIT_LLP64"
286 output_sym "CONFIG_FADVISE"
287 output_sym "CONFIG_SOCKLEN_T"
288 output_sym "CONFIG_FADVISE"
289 output_sym "CONFIG_SFAA"
290 output_sym "CONFIG_RUSAGE_THREAD"
291 output_sym "CONFIG_WINDOWSAIO"
292 output_sym "CONFIG_FDATASYNC"
293 output_sym "CONFIG_CLOCK_MONOTONIC"
294 output_sym "CONFIG_GETTIMEOFDAY"
295 output_sym "CONFIG_CLOCK_GETTIME"
296 output_sym "CONFIG_SCHED_IDLE"
297 output_sym "CONFIG_TCP_NODELAY"
298 output_sym "CONFIG_TLS_THREAD"
299 output_sym "CONFIG_IPV6"
300 echo "CC=$CC" >> $config_host_mak
301 echo "BUILD_CFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
306 if test ! -z "$cpu" ; then
307 # command line argument
309 elif check_define __i386__ ; then
311 elif check_define __x86_64__ ; then
313 elif check_define __sparc__ ; then
314 if check_define __arch64__ ; then
319 elif check_define _ARCH_PPC ; then
320 if check_define _ARCH_PPC64 ; then
325 elif check_define __mips__ ; then
327 elif check_define __ia64__ ; then
329 elif check_define __s390__ ; then
330 if check_define __s390x__ ; then
335 elif check_define __arm__ ; then
337 elif check_define __hppa__ ; then
343 # Normalise host CPU name and set ARCH.
345 ia64|ppc|ppc64|s390|s390x|sparc64)
348 i386|i486|i586|i686|i86pc|BePC)
357 hppa|parisc|parisc64)
371 if test -z "$CC" ; then
372 if test "$targetos" = "FreeBSD"; then
381 cc="${CC-${cross_prefix}gcc}"
383 ##########################################
384 # check cross compile
393 if compile_prog "" "" "cross"; then
394 $TMPE 2>/dev/null || cross_compile="yes"
396 fatal "compile test failed"
399 ##########################################
402 if test "$cross_compile" = "no" ; then
404 #include <inttypes.h>
407 volatile uint32_t i=0x01234567;
408 return (*((uint8_t*)(&i))) == 0x67;
411 if compile_prog "" "" "endian"; then
412 $TMPE && bigendian="yes"
415 # If we're cross compiling, try our best to work it out and rely on the
416 # run-time check to fail if we get it wrong.
421 #if __BYTE_ORDER != __BIG_ENDIAN
422 # error "Unknown endianness"
426 compile_prog "" "" "endian" && bigendian="yes"
427 check_define "__ARMEB__" && bigendian="yes"
428 check_define "__MIPSEB__" && bigendian="yes"
432 echo "Operating system $targetos"
434 echo "Big endian $bigendian"
436 echo "Cross compile $cross_compile"
439 ##########################################
440 # See if we need to build a static build
441 if test "$build_static" = "yes" ; then
442 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
443 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
447 echo "Static build $build_static"
449 ##########################################
454 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
457 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
461 if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
463 elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
466 fatal "Unknown wordsize"
468 echo "Wordsize $wordsize"
470 ##########################################
478 if (inflateInit(&stream) != Z_OK)
483 if compile_prog "" "-lz" "zlib" ; then
489 ##########################################
501 if compile_prog "" "-laio" "libaio" ; then
505 if test "$libaio" = "yes" ; then
506 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
510 echo "Linux AIO support $libaio"
512 ##########################################
525 if compile_prog "" "" "posixaio" ; then
527 elif compile_prog "" "-lrt" "posixaio"; then
532 echo "POSIX AIO support $posix_aio"
533 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
535 ##########################################
536 # posix aio fsync probe
538 if test "$posix_aio" = "yes" ; then
545 return aio_fsync(O_SYNC, &cb);
549 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
553 echo "POSIX AIO fsync $posix_aio_fsync"
555 ##########################################
559 #include <sys/types.h>
560 #include <sys/asynch.h>
565 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
569 if compile_prog "" "-laio" "solarisaio" ; then
573 echo "Solaris AIO support $solaris_aio"
575 ##########################################
576 # __sync_fetch_and_add test
579 #include <inttypes.h>
580 static int sfaa(uint64_t *ptr)
582 return __sync_fetch_and_add(ptr, 0);
585 int main(int argc, char **argv)
592 if compile_prog "" "" "__sync_fetch_and_add()" ; then
595 echo "__sync_fetch_and_add $sfaa"
597 ##########################################
602 #include <infiniband/arch.h>
603 int main(int argc, char **argv)
605 struct ibv_pd *pd = ibv_alloc_pd(NULL);
609 if compile_prog "" "-libverbs" "libverbs" ; then
611 LIBS="-libverbs $LIBS"
613 echo "libverbs $libverbs"
615 ##########################################
620 #include <rdma/rdma_cma.h>
621 int main(int argc, char **argv)
623 rdma_destroy_qp(NULL);
627 if compile_prog "" "-lrdmacm" "rdma"; then
629 LIBS="-lrdmacm $LIBS"
631 echo "rdmacm $rdmacm"
633 ##########################################
634 # Linux fallocate probe
639 #include <linux/falloc.h>
640 int main(int argc, char **argv)
642 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
646 if compile_prog "" "" "linux_fallocate"; then
647 linux_fallocate="yes"
649 echo "Linux fallocate $linux_fallocate"
651 ##########################################
652 # POSIX fadvise probe
657 int main(int argc, char **argv)
659 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
663 if compile_prog "" "" "posix_fadvise"; then
666 echo "POSIX fadvise $posix_fadvise"
668 ##########################################
669 # POSIX fallocate probe
674 int main(int argc, char **argv)
676 int r = posix_fallocate(0, 0, 1024);
680 if compile_prog "" "" "posix_fallocate"; then
681 posix_fallocate="yes"
683 echo "POSIX fallocate $posix_fallocate"
685 ##########################################
686 # sched_set/getaffinity 2 or 3 argument test
687 linux_2arg_affinity="no"
688 linux_3arg_affinity="no"
691 int main(int argc, char **argv)
694 return sched_setaffinity(0, sizeof(mask), &mask);
697 if compile_prog "" "" "sched_setaffinity(,,)"; then
698 linux_3arg_affinity="yes"
702 int main(int argc, char **argv)
705 return sched_setaffinity(0, &mask);
708 if compile_prog "" "" "sched_setaffinity(,)"; then
709 linux_2arg_affinity="yes"
712 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
713 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
715 ##########################################
716 # clock_gettime probe
721 int main(int argc, char **argv)
723 return clock_gettime(0, NULL);
726 if compile_prog "" "" "clock_gettime"; then
728 elif compile_prog "" "-lrt" "clock_gettime"; then
732 echo "clock_gettime $clock_gettime"
734 ##########################################
735 # CLOCK_MONOTONIC probe
737 if test "$clock_gettime" = "yes" ; then
741 int main(int argc, char **argv)
743 return clock_gettime(CLOCK_MONOTONIC, NULL);
746 if compile_prog "" "$LIBS" "clock monotonic"; then
747 clock_monotonic="yes"
750 echo "CLOCK_MONOTONIC $clock_monotonic"
752 ##########################################
753 # CLOCK_MONOTONIC_RAW probe
754 clock_monotonic_raw="no"
755 if test "$clock_gettime" = "yes" ; then
759 int main(int argc, char **argv)
761 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
764 if compile_prog "" "$LIBS" "clock monotonic"; then
765 clock_monotonic_raw="yes"
768 echo "CLOCK_MONOTONIC_RAW $clock_monotonic_raw"
770 ##########################################
771 # CLOCK_MONOTONIC_PRECISE probe
772 clock_monotonic_precise="no"
773 if test "$clock_gettime" = "yes" ; then
777 int main(int argc, char **argv)
779 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
782 if compile_prog "" "$LIBS" "clock monotonic precise"; then
783 clock_monotonic_precise="yes"
786 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
788 ##########################################
789 # gettimeofday() probe
792 #include <sys/time.h>
794 int main(int argc, char **argv)
797 return gettimeofday(&tv, NULL);
800 if compile_prog "" "" "gettimeofday"; then
803 echo "gettimeofday $gettimeofday"
805 ##########################################
811 int main(int argc, char **argv)
816 if compile_prog "" "" "fdatasync"; then
819 echo "fdatasync $fdatasync"
821 ##########################################
822 # sync_file_range() probe
828 #include <linux/fs.h>
829 int main(int argc, char **argv)
831 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
832 SYNC_FILE_RANGE_WAIT_AFTER;
833 return sync_file_range(0, 0, 0, flags);
836 if compile_prog "" "" "sync_file_range"; then
837 sync_file_range="yes"
839 echo "sync_file_range $sync_file_range"
841 ##########################################
842 # ext4 move extent probe
846 #include <sys/ioctl.h>
847 int main(int argc, char **argv)
849 struct move_extent me;
850 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
853 if compile_prog "" "" "ext4 move extent" ; then
855 elif test $targetos = "Linux" ; then
856 # On Linux, just default to it on and let it error at runtime if we really
857 # don't have it. None of my updated systems have it defined, but it does
858 # work. Takes a while to bubble back.
861 echo "EXT4 move extent $ext4_me"
863 ##########################################
869 int main(int argc, char **argv)
871 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
874 if compile_prog "" "" "linux splice"; then
877 echo "Linux splice(2) $linux_splice"
879 ##########################################
884 #include <guasi_syscalls.h>
885 int main(int argc, char **argv)
887 guasi_t ctx = guasi_create(0, 0, 0);
891 if compile_prog "" "" "guasi"; then
896 ##########################################
900 #include <nvm/nvm_primitives.h>
901 int main(int argc, char **argv)
903 nvm_version_t ver_info;
906 handle = nvm_get_handle(0, &ver_info);
907 return nvm_atomic_write(handle, 0, 0, 0);
910 if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
911 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
914 echo "Fusion-io atomic engine $fusion_aw"
916 ##########################################
921 int main(int argc, char **argv)
923 return numa_available();
926 if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
930 echo "libnuma $libnuma"
932 ##########################################
933 # libnuma 2.x version API
934 if test "$libnuma" = "yes" ; then
938 int main(int argc, char **argv)
940 struct bitmask *mask = numa_parse_nodestring(NULL);
941 return mask->size == 0;
944 if compile_prog "" "" "libnuma api"; then
947 echo "libnuma v2 $libnuma_v2"
950 ##########################################
955 int main(int argc, char **argv)
957 static char *string = "This is a string";
958 strsep(&string, "needle");
962 if compile_prog "" "" "strsep"; then
965 echo "strsep $strsep"
967 ##########################################
972 int main(int argc, char **argv)
974 return strcasestr(argv[0], argv[1]) != NULL;
977 if compile_prog "" "" "strcasestr"; then
980 echo "strcasestr $strcasestr"
982 ##########################################
987 int main(int argc, char **argv)
990 static char *string = "This is a string";
991 memset(dst, 0, sizeof(dst));
992 strlcat(dst, string, sizeof(dst));
996 if compile_prog "" "" "strlcat"; then
999 echo "strlcat $strlcat"
1001 ##########################################
1002 # getopt_long_only() probe
1003 getopt_long_only="no"
1008 int main(int argc, char **argv)
1010 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1014 if compile_prog "" "" "getopt_long_only"; then
1015 getopt_long_only="yes"
1017 echo "getopt_long_only() $getopt_long_only"
1019 ##########################################
1023 #include <sys/socket.h>
1024 #include <arpa/inet.h>
1026 int main(int argc, char **argv)
1029 return inet_aton(NULL, &in);
1032 if compile_prog "" "" "inet_aton"; then
1035 echo "inet_aton $inet_aton"
1037 ##########################################
1041 #include <sys/socket.h>
1042 int main(int argc, char **argv)
1048 if compile_prog "" "" "socklen_t"; then
1051 echo "socklen_t $socklen_t"
1053 ##########################################
1054 # Whether or not __thread is supported for TLS
1058 static __thread int ret;
1059 int main(int argc, char **argv)
1064 if compile_prog "" "" "__thread"; then
1067 echo "__thread $tls_thread"
1069 ##########################################
1070 # Check if we have required gtk/glib support for gfio
1072 if test "$gfio_check" = "yes" ; then
1076 #include <gtk/gtk.h>
1079 gdk_threads_enter();
1080 gdk_threads_leave();
1082 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
1085 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1086 ORG_LDFLAGS=$LDFLAGS
1087 LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1088 if test "$?" != "0" ; then
1089 echo "configure: gtk and gthread not found"
1092 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1093 if test "$?" != "0" ; then
1094 echo "configure: gtk and gthread not found"
1097 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1099 if test "$r" != "0" ; then
1101 GFIO_LIBS="$LIBS $GTK_LIBS"
1102 CFLAGS="$CFLAGS $GTK_CFLAGS"
1104 echo "GTK found, but need version 2.18 or higher"
1108 echo "Please install gtk and gdk libraries"
1111 LDFLAGS=$ORG_LDFLAGS
1114 if test "$gfio_check" = "yes" ; then
1115 echo "gtk 2.18 or higher $gfio"
1118 # Check whether we have getrusage(RUSAGE_THREAD)
1121 #include <sys/time.h>
1122 #include <sys/resource.h>
1123 int main(int argc, char **argv)
1126 getrusage(RUSAGE_THREAD, &ru);
1130 if compile_prog "" "" "RUSAGE_THREAD"; then
1133 echo "RUSAGE_THREAD $rusage_thread"
1135 ##########################################
1136 # Check whether we have SCHED_IDLE
1140 int main(int argc, char **argv)
1142 struct sched_param p;
1143 return sched_setscheduler(0, SCHED_IDLE, &p);
1146 if compile_prog "" "" "SCHED_IDLE"; then
1149 echo "SCHED_IDLE $sched_idle"
1151 ##########################################
1152 # Check whether we have TCP_NODELAY
1156 #include <sys/types.h>
1157 #include <sys/socket.h>
1158 #include <netinet/tcp.h>
1159 int main(int argc, char **argv)
1161 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1164 if compile_prog "" "" "TCP_NODELAY"; then
1167 echo "TCP_NODELAY $tcp_nodelay"
1169 ##########################################
1170 # Check whether we have SO_SNDBUF
1174 #include <sys/types.h>
1175 #include <sys/socket.h>
1176 #include <netinet/tcp.h>
1177 int main(int argc, char **argv)
1179 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1180 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1183 if compile_prog "" "" "SO_SNDBUF"; then
1186 echo "Net engine window_size $window_size"
1188 ##########################################
1189 # Check whether we have TCP_MAXSEG
1193 #include <sys/types.h>
1194 #include <sys/socket.h>
1195 #include <netinet/tcp.h>
1196 #include <arpa/inet.h>
1197 #include <netinet/in.h>
1198 int main(int argc, char **argv)
1200 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1203 if compile_prog "" "" "TCP_MAXSEG"; then
1206 echo "TCP_MAXSEG $mss"
1208 ##########################################
1209 # Check whether we have RLIMIT_MEMLOCK
1212 #include <sys/time.h>
1213 #include <sys/resource.h>
1214 int main(int argc, char **argv)
1217 return getrlimit(RLIMIT_MEMLOCK, &rl);
1220 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1221 rlimit_memlock="yes"
1223 echo "RLIMIT_MEMLOCK $rlimit_memlock"
1225 ##########################################
1226 # Check whether we have pwritev/preadv
1230 #include <sys/uio.h>
1231 int main(int argc, char **argv)
1233 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1236 if compile_prog "" "" "pwritev"; then
1239 echo "pwritev/preadv $pwritev"
1241 ##########################################
1242 # Check whether we have the required functions for ipv6
1245 #include <sys/types.h>
1246 #include <sys/socket.h>
1247 #include <netinet/in.h>
1250 int main(int argc, char **argv)
1252 struct addrinfo hints;
1253 struct in6_addr addr;
1256 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1258 printf("%s\n", gai_strerror(ret));
1263 if compile_prog "" "" "ipv6"; then
1266 echo "IPv6 helpers $ipv6"
1268 ##########################################
1272 #include <rbd/librbd.h>
1274 int main(int argc, char **argv)
1278 rados_ioctx_t io_ctx;
1279 const char pool[] = "rbd";
1281 int major, minor, extra;
1282 rbd_version(&major, &minor, &extra);
1284 rados_ioctx_create(cluster, pool, &io_ctx);
1288 if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
1289 LIBS="-lrbd -lrados $LIBS"
1292 echo "Rados Block Device engine $rbd"
1294 ##########################################
1295 # check for rbd_invaidate_cache()
1297 if test "$rbd" = "yes"; then
1299 #include <rbd/librbd.h>
1301 int main(int argc, char **argv)
1305 return rbd_invalidate_cache(image);
1308 if compile_prog "" "-lrbd -lrados" "rbd"; then
1311 echo "rbd_invalidate_cache $rbd_inval"
1314 ##########################################
1315 # Check whether we have setvbuf
1319 int main(int argc, char **argv)
1323 setvbuf(f, buf, _IOFBF, sizeof(buf));
1327 if compile_prog "" "" "setvbuf"; then
1330 echo "setvbuf $setvbuf"
1335 #include <glusterfs/api/glfs.h>
1337 int main(int argc, char **argv)
1340 glfs_t *g = glfs_new("foo");
1345 if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1346 LIBS="-lgfapi -lglusterfs $LIBS"
1349 echo "Gluster API engine $gfapi"
1351 ##########################################
1352 # check for gfapi fadvise support
1353 if test "$gfapi" = "yes" ; then
1356 #include <glusterfs/api/glfs.h>
1358 int main(int argc, char **argv)
1361 int ret = glfs_fadvise(fd, 0, 0, 1);
1366 if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1369 echo "Gluster API use fadvise $gf_fadvise"
1372 ##########################################
1373 # check for gfapi trim support
1375 if test "$gfapi" = "yes" ; then
1377 #include <glusterfs/api/glfs.h>
1379 int main(int argc, char **argv)
1381 return glfs_discard_async(NULL, 0, 0);
1384 if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1387 echo "Gluster API trim support $gf_trim"
1390 ##########################################
1391 # Check if we support stckf on s390
1392 s390_z196_facilities="no"
1394 #define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1395 int main(int argc, char **argv)
1397 /* We want just 1 double word to be returned. */
1398 register unsigned long reg0 asm("0") = 0;
1399 unsigned long stfle_bits;
1400 asm volatile(".machine push" "\n\t"
1401 ".machine \"z9-109\"" "\n\t"
1404 : "=QS" (stfle_bits), "+d" (reg0)
1407 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1413 if compile_prog "" "" "s390_z196_facilities"; then
1415 if [[ $? -eq 0 ]]; then
1416 s390_z196_facilities="yes"
1419 echo "s390_z196_facilities $s390_z196_facilities"
1421 ##########################################
1422 # Check if we have required environment variables configured for libhdfs
1423 if test "$libhdfs" = "yes" ; then
1425 if test "$JAVA_HOME" = "" ; then
1426 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1429 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1430 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1433 if test "$FIO_LIBHDFS_LIB" = "" ; then
1434 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1437 if test "$hdfs_conf_error" = "1" ; then
1441 echo "HDFS engine $libhdfs"
1443 ##########################################
1444 # Check whether we have MTD
1448 #include <mtd/mtd-user.h>
1449 #include <sys/ioctl.h>
1450 int main(int argc, char **argv)
1452 struct mtd_write_req ops;
1453 struct mtd_info_user info;
1454 memset(&ops, 0, sizeof(ops));
1455 info.type = MTD_MLCNANDFLASH;
1456 return ioctl(0, MEMGETINFO, &info);
1459 if compile_prog "" "" "mtd"; then
1464 # Check if we have lex/yacc available
1469 if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
1470 if test "$targetos" != "SunOS" ; then
1471 LEX=$(which lex 2> /dev/null)
1472 if test -x "$LEX" ; then
1475 YACC=$(which bison 2> /dev/null)
1476 if test -x "$YACC" ; then
1480 YACC=$(which yacc 2> /dev/null)
1481 if test -x "$YACC" ; then
1485 if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1489 if test "$arith" = "yes" ; then
1491 extern int yywrap(void);
1493 int main(int argc, char **argv)
1499 if compile_prog "" "-ll" "lex"; then
1508 # Check if lex fails using -o
1509 if test "$arith" = "yes" ; then
1510 if test "$force_no_lex_o" = "yes" ; then
1513 $LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1514 if test "$?" = "0" ; then
1522 echo "lex/yacc for arithmetic $arith"
1524 ##########################################
1525 # Check whether we have setmntent/getmntent
1530 int main(int argc, char **argv)
1532 FILE *mtab = setmntent(NULL, "r");
1533 struct mntent *mnt = getmntent(mtab);
1538 if compile_prog "" "" "getmntent"; then
1541 echo "getmntent $getmntent"
1543 ##########################################
1544 # Check whether we have getmntinfo
1548 #include <sys/param.h>
1549 #include <sys/mount.h>
1550 int main(int argc, char **argv)
1553 return getmntinfo(&st, MNT_NOWAIT);
1556 if compile_prog "" "" "getmntinfo"; then
1559 echo "getmntinfo $getmntinfo"
1561 ##########################################
1562 # Check whether we have _Static_assert
1568 #ifdef __compiler_offsetof
1569 #define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
1571 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1574 #define container_of(ptr, type, member) ({ \
1575 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
1576 (type *)( (char *)__mptr - offsetof(type,member) );})
1582 int main(int argc, char **argv)
1584 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
1588 if compile_prog "" "" "static_assert"; then
1591 echo "Static Assert $static_assert"
1593 ##########################################
1594 # Check whether we have bool / stdbool.h
1597 #include <stdbool.h>
1598 int main(int argc, char **argv)
1601 return var != false;
1604 if compile_prog "" "" "bool"; then
1607 echo "bool $have_bool"
1609 #############################################################################
1611 if test "$wordsize" = "64" ; then
1612 output_sym "CONFIG_64BIT"
1613 elif test "$wordsize" = "32" ; then
1614 output_sym "CONFIG_32BIT"
1616 fatal "Unknown wordsize!"
1618 if test "$bigendian" = "yes" ; then
1619 output_sym "CONFIG_BIG_ENDIAN"
1621 output_sym "CONFIG_LITTLE_ENDIAN"
1623 if test "$zlib" = "yes" ; then
1624 output_sym "CONFIG_ZLIB"
1626 if test "$libaio" = "yes" ; then
1627 output_sym "CONFIG_LIBAIO"
1629 if test "$posix_aio" = "yes" ; then
1630 output_sym "CONFIG_POSIXAIO"
1632 if test "$posix_aio_fsync" = "yes" ; then
1633 output_sym "CONFIG_POSIXAIO_FSYNC"
1635 if test "$linux_fallocate" = "yes" ; then
1636 output_sym "CONFIG_LINUX_FALLOCATE"
1638 if test "$posix_fallocate" = "yes" ; then
1639 output_sym "CONFIG_POSIX_FALLOCATE"
1641 if test "$fdatasync" = "yes" ; then
1642 output_sym "CONFIG_FDATASYNC"
1644 if test "$sync_file_range" = "yes" ; then
1645 output_sym "CONFIG_SYNC_FILE_RANGE"
1647 if test "$sfaa" = "yes" ; then
1648 output_sym "CONFIG_SFAA"
1650 if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
1651 output_sym "CONFIG_RDMA"
1653 if test "$clock_gettime" = "yes" ; then
1654 output_sym "CONFIG_CLOCK_GETTIME"
1656 if test "$clock_monotonic" = "yes" ; then
1657 output_sym "CONFIG_CLOCK_MONOTONIC"
1659 if test "$clock_monotonic_raw" = "yes" ; then
1660 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
1662 if test "$clock_monotonic_precise" = "yes" ; then
1663 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
1665 if test "$gettimeofday" = "yes" ; then
1666 output_sym "CONFIG_GETTIMEOFDAY"
1668 if test "$posix_fadvise" = "yes" ; then
1669 output_sym "CONFIG_POSIX_FADVISE"
1671 if test "$linux_3arg_affinity" = "yes" ; then
1672 output_sym "CONFIG_3ARG_AFFINITY"
1673 elif test "$linux_2arg_affinity" = "yes" ; then
1674 output_sym "CONFIG_2ARG_AFFINITY"
1676 if test "$strsep" = "yes" ; then
1677 output_sym "CONFIG_STRSEP"
1679 if test "$strcasestr" = "yes" ; then
1680 output_sym "CONFIG_STRCASESTR"
1682 if test "$strlcat" = "yes" ; then
1683 output_sym "CONFIG_STRLCAT"
1685 if test "$getopt_long_only" = "yes" ; then
1686 output_sym "CONFIG_GETOPT_LONG_ONLY"
1688 if test "$inet_aton" = "yes" ; then
1689 output_sym "CONFIG_INET_ATON"
1691 if test "$socklen_t" = "yes" ; then
1692 output_sym "CONFIG_SOCKLEN_T"
1694 if test "$ext4_me" = "yes" ; then
1695 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1697 if test "$linux_splice" = "yes" ; then
1698 output_sym "CONFIG_LINUX_SPLICE"
1700 if test "$guasi" = "yes" ; then
1701 output_sym "CONFIG_GUASI"
1703 if test "$fusion_aw" = "yes" ; then
1704 output_sym "CONFIG_FUSION_AW"
1706 if test "$libnuma_v2" = "yes" ; then
1707 output_sym "CONFIG_LIBNUMA"
1709 if test "$solaris_aio" = "yes" ; then
1710 output_sym "CONFIG_SOLARISAIO"
1712 if test "$tls_thread" = "yes" ; then
1713 output_sym "CONFIG_TLS_THREAD"
1715 if test "$rusage_thread" = "yes" ; then
1716 output_sym "CONFIG_RUSAGE_THREAD"
1718 if test "$gfio" = "yes" ; then
1719 echo "CONFIG_GFIO=y" >> $config_host_mak
1721 if test "$esx" = "yes" ; then
1722 output_sym "CONFIG_ESX"
1723 output_sym "CONFIG_NO_SHM"
1725 if test "$sched_idle" = "yes" ; then
1726 output_sym "CONFIG_SCHED_IDLE"
1728 if test "$tcp_nodelay" = "yes" ; then
1729 output_sym "CONFIG_TCP_NODELAY"
1731 if test "$window_size" = "yes" ; then
1732 output_sym "CONFIG_NET_WINDOWSIZE"
1734 if test "$mss" = "yes" ; then
1735 output_sym "CONFIG_NET_MSS"
1737 if test "$rlimit_memlock" = "yes" ; then
1738 output_sym "CONFIG_RLIMIT_MEMLOCK"
1740 if test "$pwritev" = "yes" ; then
1741 output_sym "CONFIG_PWRITEV"
1743 if test "$ipv6" = "yes" ; then
1744 output_sym "CONFIG_IPV6"
1746 if test "$rbd" = "yes" ; then
1747 output_sym "CONFIG_RBD"
1749 if test "$rbd_inval" = "yes" ; then
1750 output_sym "CONFIG_RBD_INVAL"
1752 if test "$setvbuf" = "yes" ; then
1753 output_sym "CONFIG_SETVBUF"
1755 if test "$s390_z196_facilities" = "yes" ; then
1756 output_sym "CONFIG_S390_Z196_FACILITIES"
1757 CFLAGS="$CFLAGS -march=z9-109"
1759 if test "$gfapi" = "yes" ; then
1760 output_sym "CONFIG_GFAPI"
1762 if test "$gf_fadvise" = "yes" ; then
1763 output_sym "CONFIG_GF_FADVISE"
1765 if test "$gf_trim" = "yes" ; then
1766 output_sym "CONFIG_GF_TRIM"
1768 if test "$libhdfs" = "yes" ; then
1769 output_sym "CONFIG_LIBHDFS"
1770 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
1771 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
1772 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
1774 if test "$mtd" = "yes" ; then
1775 output_sym "CONFIG_MTD"
1777 if test "$arith" = "yes" ; then
1778 output_sym "CONFIG_ARITHMETIC"
1779 if test "$yacc_is_bison" = "yes" ; then
1780 echo "YACC=$YACC -y" >> $config_host_mak
1782 echo "YACC=$YACC" >> $config_host_mak
1784 if test "$lex_use_o" = "yes" ; then
1785 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
1788 if test "$getmntent" = "yes" ; then
1789 output_sym "CONFIG_GETMNTENT"
1791 if test "$getmntinfo" = "yes" ; then
1792 output_sym "CONFIG_GETMNTINFO"
1794 if test "$static_assert" = "yes" ; then
1795 output_sym "CONFIG_STATIC_ASSERT"
1797 if test "$have_bool" = "yes" ; then
1798 output_sym "CONFIG_HAVE_BOOL"
1801 if test "$zlib" = "no" ; then
1802 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
1805 echo "LIBS+=$LIBS" >> $config_host_mak
1806 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
1807 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
1808 echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
1809 echo "CC=$cc" >> $config_host_mak
1810 echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
1811 echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
1813 if [ `dirname $0` != "." -a ! -e Makefile ]; then
1814 cat > Makefile <<EOF
1815 SRCDIR:=`dirname $0`
1816 include \$(SRCDIR)/Makefile