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 --disable-shm) no_shm="yes"
176 --disable-optimizations) disable_opt="yes"
182 echo "Bad option $opt"
188 if test "$show_help" = "yes" ; then
189 echo "--prefix= Use this directory as installation prefix"
190 echo "--cpu= Specify target CPU if auto-detect fails"
191 echo "--cc= Specify compiler to use"
192 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
193 echo "--build-32bit-win Enable 32-bit build on Windows"
194 echo "--build-static Build a static fio"
195 echo "--esx Configure build options for esx"
196 echo "--enable-gfio Enable building of gtk gfio"
197 echo "--disable-numa Disable libnuma even if found"
198 echo "--disable-gfapi Disable gfapi"
199 echo "--enable-libhdfs Enable hdfs support"
200 echo "--disable-lex Disable use of lex/yacc for math"
201 echo "--disable-shm Disable SHM support"
202 echo "--disable-optimizations Don't enable compiler optimizations"
206 cross_prefix=${cross_prefix-${CROSS_COMPILE}}
207 cc="${CC-${cross_prefix}gcc}"
209 if check_define __ANDROID__ ; then
211 elif check_define __linux__ ; then
213 elif check_define __OpenBSD__ ; then
215 elif check_define __sun__ ; then
217 CFLAGS="$CFLAGS -D_REENTRANT"
218 elif check_define _WIN32 ; then
224 echo "# Automatically generated by configure - do not modify" > $config_host_mak
225 printf "# Configured with:" >> $config_host_mak
226 printf " '%s'" "$0" "$@" >> $config_host_mak
227 echo >> $config_host_mak
228 echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
230 if test "$no_shm" = "yes" ; then
231 output_sym "CONFIG_NO_SHM"
234 if test "$disable_opt" = "yes" ; then
235 output_sym "CONFIG_FIO_NO_OPT"
238 # Some host OSes need non-standard checks for which CPU to use.
239 # Note that these checks are broken for cross-compilation: if you're
240 # cross-compiling to one of these OSes then you'll need to specify
241 # the correct CPU with the --cpu option.
244 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
245 # we can run 64-bit userspace code.
246 # If the user didn't specify a CPU explicitly and the kernel says this is
247 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
249 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
254 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
255 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
258 LIBS="-lnsl -lsocket"
261 echo "Forcing known good options on Windows"
262 if test -z "$CC" ; then
263 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
264 CC="i686-w64-mingw32-gcc"
266 CC="x86_64-w64-mingw32-gcc"
269 output_sym "CONFIG_LITTLE_ENDIAN"
270 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
271 output_sym "CONFIG_32BIT"
273 output_sym "CONFIG_64BIT_LLP64"
275 output_sym "CONFIG_FADVISE"
276 output_sym "CONFIG_SOCKLEN_T"
277 output_sym "CONFIG_FADVISE"
278 output_sym "CONFIG_SFAA"
279 output_sym "CONFIG_RUSAGE_THREAD"
280 output_sym "CONFIG_WINDOWSAIO"
281 output_sym "CONFIG_FDATASYNC"
282 output_sym "CONFIG_CLOCK_MONOTONIC"
283 output_sym "CONFIG_GETTIMEOFDAY"
284 output_sym "CONFIG_CLOCK_GETTIME"
285 output_sym "CONFIG_SCHED_IDLE"
286 output_sym "CONFIG_TCP_NODELAY"
287 output_sym "CONFIG_TLS_THREAD"
288 output_sym "CONFIG_IPV6"
289 echo "CC=$CC" >> $config_host_mak
290 echo "BUILD_CFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
295 if test ! -z "$cpu" ; then
296 # command line argument
298 elif check_define __i386__ ; then
300 elif check_define __x86_64__ ; then
302 elif check_define __sparc__ ; then
303 if check_define __arch64__ ; then
308 elif check_define _ARCH_PPC ; then
309 if check_define _ARCH_PPC64 ; then
314 elif check_define __mips__ ; then
316 elif check_define __ia64__ ; then
318 elif check_define __s390__ ; then
319 if check_define __s390x__ ; then
324 elif check_define __arm__ ; then
326 elif check_define __hppa__ ; then
332 # Normalise host CPU name and set ARCH.
334 ia64|ppc|ppc64|s390|s390x|sparc64)
337 i386|i486|i586|i686|i86pc|BePC)
346 hppa|parisc|parisc64)
360 if test -z "$CC" ; then
361 if test "$targetos" = "FreeBSD"; then
370 cc="${CC-${cross_prefix}gcc}"
372 ##########################################
373 # check cross compile
382 if compile_prog "" "" "cross"; then
383 $TMPE 2>/dev/null || cross_compile="yes"
385 fatal "compile test failed"
388 ##########################################
391 if test "$cross_compile" = "no" ; then
393 #include <inttypes.h>
396 volatile uint32_t i=0x01234567;
397 return (*((uint8_t*)(&i))) == 0x67;
400 if compile_prog "" "" "endian"; then
401 $TMPE && bigendian="yes"
404 # If we're cross compiling, try our best to work it out and rely on the
405 # run-time check to fail if we get it wrong.
410 #if __BYTE_ORDER != __BIG_ENDIAN
411 # error "Unknown endianness"
415 compile_prog "" "" "endian" && bigendian="yes"
416 check_define "__ARMEB__" && bigendian="yes"
417 check_define "__MIPSEB__" && bigendian="yes"
421 echo "Operating system $targetos"
423 echo "Big endian $bigendian"
425 echo "Cross compile $cross_compile"
428 ##########################################
429 # See if we need to build a static build
430 if test "$build_static" = "yes" ; then
431 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
432 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
436 echo "Static build $build_static"
438 ##########################################
443 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
446 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
450 if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
452 elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
455 fatal "Unknown wordsize"
457 echo "Wordsize $wordsize"
459 ##########################################
467 if (inflateInit(&stream) != Z_OK)
472 if compile_prog "" "-lz" "zlib" ; then
478 ##########################################
490 if compile_prog "" "-laio" "libaio" ; then
494 if test "$libaio" = "yes" ; then
495 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
499 echo "Linux AIO support $libaio"
501 ##########################################
514 if compile_prog "" "" "posixaio" ; then
516 elif compile_prog "" "-lrt" "posixaio"; then
521 echo "POSIX AIO support $posix_aio"
522 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
524 ##########################################
525 # posix aio fsync probe
527 if test "$posix_aio" = "yes" ; then
534 return aio_fsync(O_SYNC, &cb);
538 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
542 echo "POSIX AIO fsync $posix_aio_fsync"
544 ##########################################
548 #include <sys/types.h>
549 #include <sys/asynch.h>
554 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
558 if compile_prog "" "-laio" "solarisaio" ; then
562 echo "Solaris AIO support $solaris_aio"
564 ##########################################
565 # __sync_fetch_and_add test
568 #include <inttypes.h>
569 static int sfaa(uint64_t *ptr)
571 return __sync_fetch_and_add(ptr, 0);
574 int main(int argc, char **argv)
581 if compile_prog "" "" "__sync_fetch_and_add()" ; then
584 echo "__sync_fetch_and_add $sfaa"
586 ##########################################
591 #include <infiniband/arch.h>
592 int main(int argc, char **argv)
594 struct ibv_pd *pd = ibv_alloc_pd(NULL);
598 if compile_prog "" "-libverbs" "libverbs" ; then
600 LIBS="-libverbs $LIBS"
602 echo "libverbs $libverbs"
604 ##########################################
609 #include <rdma/rdma_cma.h>
610 int main(int argc, char **argv)
612 rdma_destroy_qp(NULL);
616 if compile_prog "" "-lrdmacm" "rdma"; then
618 LIBS="-lrdmacm $LIBS"
620 echo "rdmacm $rdmacm"
622 ##########################################
623 # Linux fallocate probe
628 #include <linux/falloc.h>
629 int main(int argc, char **argv)
631 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
635 if compile_prog "" "" "linux_fallocate"; then
636 linux_fallocate="yes"
638 echo "Linux fallocate $linux_fallocate"
640 ##########################################
641 # POSIX fadvise probe
646 int main(int argc, char **argv)
648 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
652 if compile_prog "" "" "posix_fadvise"; then
655 echo "POSIX fadvise $posix_fadvise"
657 ##########################################
658 # POSIX fallocate probe
663 int main(int argc, char **argv)
665 int r = posix_fallocate(0, 0, 1024);
669 if compile_prog "" "" "posix_fallocate"; then
670 posix_fallocate="yes"
672 echo "POSIX fallocate $posix_fallocate"
674 ##########################################
675 # sched_set/getaffinity 2 or 3 argument test
676 linux_2arg_affinity="no"
677 linux_3arg_affinity="no"
680 int main(int argc, char **argv)
683 return sched_setaffinity(0, sizeof(mask), &mask);
686 if compile_prog "" "" "sched_setaffinity(,,)"; then
687 linux_3arg_affinity="yes"
691 int main(int argc, char **argv)
694 return sched_setaffinity(0, &mask);
697 if compile_prog "" "" "sched_setaffinity(,)"; then
698 linux_2arg_affinity="yes"
701 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
702 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
704 ##########################################
705 # clock_gettime probe
710 int main(int argc, char **argv)
712 return clock_gettime(0, NULL);
715 if compile_prog "" "" "clock_gettime"; then
717 elif compile_prog "" "-lrt" "clock_gettime"; then
721 echo "clock_gettime $clock_gettime"
723 ##########################################
724 # CLOCK_MONOTONIC probe
726 if test "$clock_gettime" = "yes" ; then
730 int main(int argc, char **argv)
732 return clock_gettime(CLOCK_MONOTONIC, NULL);
735 if compile_prog "" "$LIBS" "clock monotonic"; then
736 clock_monotonic="yes"
739 echo "CLOCK_MONOTONIC $clock_monotonic"
741 ##########################################
742 # CLOCK_MONOTONIC_RAW probe
743 clock_monotonic_raw="no"
744 if test "$clock_gettime" = "yes" ; then
748 int main(int argc, char **argv)
750 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
753 if compile_prog "" "$LIBS" "clock monotonic"; then
754 clock_monotonic_raw="yes"
757 echo "CLOCK_MONOTONIC_RAW $clock_monotonic_raw"
759 ##########################################
760 # CLOCK_MONOTONIC_PRECISE probe
761 clock_monotonic_precise="no"
762 if test "$clock_gettime" = "yes" ; then
766 int main(int argc, char **argv)
768 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
771 if compile_prog "" "$LIBS" "clock monotonic precise"; then
772 clock_monotonic_precise="yes"
775 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
777 ##########################################
778 # gettimeofday() probe
781 #include <sys/time.h>
783 int main(int argc, char **argv)
786 return gettimeofday(&tv, NULL);
789 if compile_prog "" "" "gettimeofday"; then
792 echo "gettimeofday $gettimeofday"
794 ##########################################
800 int main(int argc, char **argv)
805 if compile_prog "" "" "fdatasync"; then
808 echo "fdatasync $fdatasync"
810 ##########################################
811 # sync_file_range() probe
817 #include <linux/fs.h>
818 int main(int argc, char **argv)
820 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
821 SYNC_FILE_RANGE_WAIT_AFTER;
822 return sync_file_range(0, 0, 0, flags);
825 if compile_prog "" "" "sync_file_range"; then
826 sync_file_range="yes"
828 echo "sync_file_range $sync_file_range"
830 ##########################################
831 # ext4 move extent probe
835 #include <sys/ioctl.h>
836 int main(int argc, char **argv)
838 struct move_extent me;
839 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
842 if compile_prog "" "" "ext4 move extent" ; then
844 elif test $targetos = "Linux" ; then
845 # On Linux, just default to it on and let it error at runtime if we really
846 # don't have it. None of my updated systems have it defined, but it does
847 # work. Takes a while to bubble back.
850 echo "EXT4 move extent $ext4_me"
852 ##########################################
858 int main(int argc, char **argv)
860 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
863 if compile_prog "" "" "linux splice"; then
866 echo "Linux splice(2) $linux_splice"
868 ##########################################
873 #include <guasi_syscalls.h>
874 int main(int argc, char **argv)
876 guasi_t ctx = guasi_create(0, 0, 0);
880 if compile_prog "" "" "guasi"; then
885 ##########################################
889 #include <nvm/nvm_primitives.h>
890 int main(int argc, char **argv)
892 nvm_version_t ver_info;
895 handle = nvm_get_handle(0, &ver_info);
896 return nvm_atomic_write(handle, 0, 0, 0);
899 if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
900 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
903 echo "Fusion-io atomic engine $fusion_aw"
905 ##########################################
910 int main(int argc, char **argv)
912 return numa_available();
915 if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
919 echo "libnuma $libnuma"
921 ##########################################
922 # libnuma 2.x version API
923 if test "$libnuma" = "yes" ; then
927 int main(int argc, char **argv)
929 struct bitmask *mask = numa_parse_nodestring(NULL);
930 return mask->size == 0;
933 if compile_prog "" "" "libnuma api"; then
936 echo "libnuma v2 $libnuma_v2"
939 ##########################################
944 int main(int argc, char **argv)
946 static char *string = "This is a string";
947 strsep(&string, "needle");
951 if compile_prog "" "" "strsep"; then
954 echo "strsep $strsep"
956 ##########################################
961 int main(int argc, char **argv)
963 return strcasestr(argv[0], argv[1]) != NULL;
966 if compile_prog "" "" "strcasestr"; then
969 echo "strcasestr $strcasestr"
971 ##########################################
976 int main(int argc, char **argv)
979 static char *string = "This is a string";
980 memset(dst, 0, sizeof(dst));
981 strlcat(dst, string, sizeof(dst));
985 if compile_prog "" "" "strlcat"; then
988 echo "strlcat $strlcat"
990 ##########################################
991 # getopt_long_only() probe
992 getopt_long_only="no"
997 int main(int argc, char **argv)
999 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1003 if compile_prog "" "" "getopt_long_only"; then
1004 getopt_long_only="yes"
1006 echo "getopt_long_only() $getopt_long_only"
1008 ##########################################
1012 #include <sys/socket.h>
1013 #include <arpa/inet.h>
1015 int main(int argc, char **argv)
1018 return inet_aton(NULL, &in);
1021 if compile_prog "" "" "inet_aton"; then
1024 echo "inet_aton $inet_aton"
1026 ##########################################
1030 #include <sys/socket.h>
1031 int main(int argc, char **argv)
1037 if compile_prog "" "" "socklen_t"; then
1040 echo "socklen_t $socklen_t"
1042 ##########################################
1043 # Whether or not __thread is supported for TLS
1047 static __thread int ret;
1048 int main(int argc, char **argv)
1053 if compile_prog "" "" "__thread"; then
1056 echo "__thread $tls_thread"
1058 ##########################################
1059 # Check if we have required gtk/glib support for gfio
1061 if test "$gfio_check" = "yes" ; then
1065 #include <gtk/gtk.h>
1068 gdk_threads_enter();
1069 gdk_threads_leave();
1071 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
1074 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1075 ORG_LDFLAGS=$LDFLAGS
1076 LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1077 if test "$?" != "0" ; then
1078 echo "configure: gtk and gthread not found"
1081 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1082 if test "$?" != "0" ; then
1083 echo "configure: gtk and gthread not found"
1086 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1088 if test "$r" != "0" ; then
1090 GFIO_LIBS="$LIBS $GTK_LIBS"
1091 CFLAGS="$CFLAGS $GTK_CFLAGS"
1093 echo "GTK found, but need version 2.18 or higher"
1097 echo "Please install gtk and gdk libraries"
1100 LDFLAGS=$ORG_LDFLAGS
1103 if test "$gfio_check" = "yes" ; then
1104 echo "gtk 2.18 or higher $gfio"
1107 # Check whether we have getrusage(RUSAGE_THREAD)
1110 #include <sys/time.h>
1111 #include <sys/resource.h>
1112 int main(int argc, char **argv)
1115 getrusage(RUSAGE_THREAD, &ru);
1119 if compile_prog "" "" "RUSAGE_THREAD"; then
1122 echo "RUSAGE_THREAD $rusage_thread"
1124 ##########################################
1125 # Check whether we have SCHED_IDLE
1129 int main(int argc, char **argv)
1131 struct sched_param p;
1132 return sched_setscheduler(0, SCHED_IDLE, &p);
1135 if compile_prog "" "" "SCHED_IDLE"; then
1138 echo "SCHED_IDLE $sched_idle"
1140 ##########################################
1141 # Check whether we have TCP_NODELAY
1145 #include <sys/types.h>
1146 #include <sys/socket.h>
1147 #include <netinet/tcp.h>
1148 int main(int argc, char **argv)
1150 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1153 if compile_prog "" "" "TCP_NODELAY"; then
1156 echo "TCP_NODELAY $tcp_nodelay"
1158 ##########################################
1159 # Check whether we have SO_SNDBUF
1163 #include <sys/types.h>
1164 #include <sys/socket.h>
1165 #include <netinet/tcp.h>
1166 int main(int argc, char **argv)
1168 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1169 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1172 if compile_prog "" "" "SO_SNDBUF"; then
1175 echo "Net engine window_size $window_size"
1177 ##########################################
1178 # Check whether we have TCP_MAXSEG
1182 #include <sys/types.h>
1183 #include <sys/socket.h>
1184 #include <netinet/tcp.h>
1185 #include <arpa/inet.h>
1186 #include <netinet/in.h>
1187 int main(int argc, char **argv)
1189 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1192 if compile_prog "" "" "TCP_MAXSEG"; then
1195 echo "TCP_MAXSEG $mss"
1197 ##########################################
1198 # Check whether we have RLIMIT_MEMLOCK
1201 #include <sys/time.h>
1202 #include <sys/resource.h>
1203 int main(int argc, char **argv)
1206 return getrlimit(RLIMIT_MEMLOCK, &rl);
1209 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1210 rlimit_memlock="yes"
1212 echo "RLIMIT_MEMLOCK $rlimit_memlock"
1214 ##########################################
1215 # Check whether we have pwritev/preadv
1219 #include <sys/uio.h>
1220 int main(int argc, char **argv)
1222 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1225 if compile_prog "" "" "pwritev"; then
1228 echo "pwritev/preadv $pwritev"
1230 ##########################################
1231 # Check whether we have the required functions for ipv6
1234 #include <sys/types.h>
1235 #include <sys/socket.h>
1236 #include <netinet/in.h>
1239 int main(int argc, char **argv)
1241 struct addrinfo hints;
1242 struct in6_addr addr;
1245 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1247 printf("%s\n", gai_strerror(ret));
1252 if compile_prog "" "" "ipv6"; then
1255 echo "IPv6 helpers $ipv6"
1257 ##########################################
1261 #include <rbd/librbd.h>
1263 int main(int argc, char **argv)
1267 rados_ioctx_t io_ctx;
1268 const char pool[] = "rbd";
1270 int major, minor, extra;
1271 rbd_version(&major, &minor, &extra);
1273 rados_ioctx_create(cluster, pool, &io_ctx);
1277 if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
1278 LIBS="-lrbd -lrados $LIBS"
1281 echo "Rados Block Device engine $rbd"
1283 ##########################################
1284 # check for rbd_invaidate_cache()
1286 if test "$rbd" = "yes"; then
1288 #include <rbd/librbd.h>
1290 int main(int argc, char **argv)
1294 return rbd_invalidate_cache(image);
1297 if compile_prog "" "-lrbd -lrados" "rbd"; then
1300 echo "rbd_invalidate_cache $rbd_inval"
1303 ##########################################
1304 # Check whether we have setvbuf
1308 int main(int argc, char **argv)
1312 setvbuf(f, buf, _IOFBF, sizeof(buf));
1316 if compile_prog "" "" "setvbuf"; then
1319 echo "setvbuf $setvbuf"
1324 #include <glusterfs/api/glfs.h>
1326 int main(int argc, char **argv)
1329 glfs_t *g = glfs_new("foo");
1334 if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1335 LIBS="-lgfapi -lglusterfs $LIBS"
1338 echo "Gluster API engine $gfapi"
1340 ##########################################
1341 # check for gfapi fadvise support
1342 if test "$gfapi" = "yes" ; then
1345 #include <glusterfs/api/glfs.h>
1347 int main(int argc, char **argv)
1350 int ret = glfs_fadvise(fd, 0, 0, 1);
1355 if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1358 echo "Gluster API use fadvise $gf_fadvise"
1361 ##########################################
1362 # check for gfapi trim support
1364 if test "$gfapi" = "yes" ; then
1366 #include <glusterfs/api/glfs.h>
1368 int main(int argc, char **argv)
1370 return glfs_discard_async(NULL, 0, 0);
1373 if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1376 echo "Gluster API trim support $gf_trim"
1379 ##########################################
1380 # Check if we support stckf on s390
1381 s390_z196_facilities="no"
1383 #define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1384 int main(int argc, char **argv)
1386 /* We want just 1 double word to be returned. */
1387 register unsigned long reg0 asm("0") = 0;
1388 unsigned long stfle_bits;
1389 asm volatile(".machine push" "\n\t"
1390 ".machine \"z9-109\"" "\n\t"
1393 : "=QS" (stfle_bits), "+d" (reg0)
1396 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1402 if compile_prog "" "" "s390_z196_facilities"; then
1404 if [[ $? -eq 0 ]]; then
1405 s390_z196_facilities="yes"
1408 echo "s390_z196_facilities $s390_z196_facilities"
1410 ##########################################
1411 # Check if we have required environment variables configured for libhdfs
1412 if test "$libhdfs" = "yes" ; then
1414 if test "$JAVA_HOME" = "" ; then
1415 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1418 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1419 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1422 if test "$FIO_LIBHDFS_LIB" = "" ; then
1423 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1426 if test "$hdfs_conf_error" = "1" ; then
1430 echo "HDFS engine $libhdfs"
1432 ##########################################
1433 # Check whether we have MTD
1437 #include <mtd/mtd-user.h>
1438 #include <sys/ioctl.h>
1439 int main(int argc, char **argv)
1441 struct mtd_write_req ops;
1442 struct mtd_info_user info;
1443 memset(&ops, 0, sizeof(ops));
1444 info.type = MTD_MLCNANDFLASH;
1445 return ioctl(0, MEMGETINFO, &info);
1448 if compile_prog "" "" "mtd"; then
1453 # Check if we have lex/yacc available
1458 if test "$disable_lex" = "no"; then
1459 if test "$targetos" != "SunOS" ; then
1460 LEX=$(which lex 2> /dev/null)
1461 if test -x "$LEX" ; then
1464 YACC=$(which bison 2> /dev/null)
1465 if test -x "$YACC" ; then
1469 YACC=$(which yacc 2> /dev/null)
1470 if test -x "$YACC" ; then
1474 if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1478 if test "$arith" = "yes" ; then
1480 extern int yywrap(void);
1482 int main(int argc, char **argv)
1488 if compile_prog "" "-ll" "lex"; then
1497 echo "lex/yacc for arithmetic $arith"
1499 ##########################################
1500 # Check whether we have setmntent/getmntent
1505 int main(int argc, char **argv)
1507 FILE *mtab = setmntent(NULL, "r");
1508 struct mntent *mnt = getmntent(mtab);
1513 if compile_prog "" "" "getmntent"; then
1516 echo "getmntent $getmntent"
1518 ##########################################
1519 # Check whether we have getmntinfo
1523 #include <sys/param.h>
1524 #include <sys/mount.h>
1525 int main(int argc, char **argv)
1528 return getmntinfo(&st, MNT_NOWAIT);
1531 if compile_prog "" "" "getmntinfo"; then
1534 echo "getmntinfo $getmntinfo"
1536 ##########################################
1537 # Check whether we have _Static_assert
1543 #ifdef __compiler_offsetof
1544 #define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
1546 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1549 #define container_of(ptr, type, member) ({ \
1550 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
1551 (type *)( (char *)__mptr - offsetof(type,member) );})
1557 int main(int argc, char **argv)
1559 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
1563 if compile_prog "" "" "static_assert"; then
1566 echo "Static Assert $static_assert"
1568 ##########################################
1569 # Check whether we have bool / stdbool.h
1572 #include <stdbool.h>
1573 int main(int argc, char **argv)
1576 return var != false;
1579 if compile_prog "" "" "bool"; then
1582 echo "bool $have_bool"
1584 #############################################################################
1586 if test "$wordsize" = "64" ; then
1587 output_sym "CONFIG_64BIT"
1588 elif test "$wordsize" = "32" ; then
1589 output_sym "CONFIG_32BIT"
1591 fatal "Unknown wordsize!"
1593 if test "$bigendian" = "yes" ; then
1594 output_sym "CONFIG_BIG_ENDIAN"
1596 output_sym "CONFIG_LITTLE_ENDIAN"
1598 if test "$zlib" = "yes" ; then
1599 output_sym "CONFIG_ZLIB"
1601 if test "$libaio" = "yes" ; then
1602 output_sym "CONFIG_LIBAIO"
1604 if test "$posix_aio" = "yes" ; then
1605 output_sym "CONFIG_POSIXAIO"
1607 if test "$posix_aio_fsync" = "yes" ; then
1608 output_sym "CONFIG_POSIXAIO_FSYNC"
1610 if test "$linux_fallocate" = "yes" ; then
1611 output_sym "CONFIG_LINUX_FALLOCATE"
1613 if test "$posix_fallocate" = "yes" ; then
1614 output_sym "CONFIG_POSIX_FALLOCATE"
1616 if test "$fdatasync" = "yes" ; then
1617 output_sym "CONFIG_FDATASYNC"
1619 if test "$sync_file_range" = "yes" ; then
1620 output_sym "CONFIG_SYNC_FILE_RANGE"
1622 if test "$sfaa" = "yes" ; then
1623 output_sym "CONFIG_SFAA"
1625 if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
1626 output_sym "CONFIG_RDMA"
1628 if test "$clock_gettime" = "yes" ; then
1629 output_sym "CONFIG_CLOCK_GETTIME"
1631 if test "$clock_monotonic" = "yes" ; then
1632 output_sym "CONFIG_CLOCK_MONOTONIC"
1634 if test "$clock_monotonic_raw" = "yes" ; then
1635 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
1637 if test "$clock_monotonic_precise" = "yes" ; then
1638 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
1640 if test "$gettimeofday" = "yes" ; then
1641 output_sym "CONFIG_GETTIMEOFDAY"
1643 if test "$posix_fadvise" = "yes" ; then
1644 output_sym "CONFIG_POSIX_FADVISE"
1646 if test "$linux_3arg_affinity" = "yes" ; then
1647 output_sym "CONFIG_3ARG_AFFINITY"
1648 elif test "$linux_2arg_affinity" = "yes" ; then
1649 output_sym "CONFIG_2ARG_AFFINITY"
1651 if test "$strsep" = "yes" ; then
1652 output_sym "CONFIG_STRSEP"
1654 if test "$strcasestr" = "yes" ; then
1655 output_sym "CONFIG_STRCASESTR"
1657 if test "$strlcat" = "yes" ; then
1658 output_sym "CONFIG_STRLCAT"
1660 if test "$getopt_long_only" = "yes" ; then
1661 output_sym "CONFIG_GETOPT_LONG_ONLY"
1663 if test "$inet_aton" = "yes" ; then
1664 output_sym "CONFIG_INET_ATON"
1666 if test "$socklen_t" = "yes" ; then
1667 output_sym "CONFIG_SOCKLEN_T"
1669 if test "$ext4_me" = "yes" ; then
1670 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1672 if test "$linux_splice" = "yes" ; then
1673 output_sym "CONFIG_LINUX_SPLICE"
1675 if test "$guasi" = "yes" ; then
1676 output_sym "CONFIG_GUASI"
1678 if test "$fusion_aw" = "yes" ; then
1679 output_sym "CONFIG_FUSION_AW"
1681 if test "$libnuma_v2" = "yes" ; then
1682 output_sym "CONFIG_LIBNUMA"
1684 if test "$solaris_aio" = "yes" ; then
1685 output_sym "CONFIG_SOLARISAIO"
1687 if test "$tls_thread" = "yes" ; then
1688 output_sym "CONFIG_TLS_THREAD"
1690 if test "$rusage_thread" = "yes" ; then
1691 output_sym "CONFIG_RUSAGE_THREAD"
1693 if test "$gfio" = "yes" ; then
1694 echo "CONFIG_GFIO=y" >> $config_host_mak
1696 if test "$esx" = "yes" ; then
1697 output_sym "CONFIG_ESX"
1698 output_sym "CONFIG_NO_SHM"
1700 if test "$sched_idle" = "yes" ; then
1701 output_sym "CONFIG_SCHED_IDLE"
1703 if test "$tcp_nodelay" = "yes" ; then
1704 output_sym "CONFIG_TCP_NODELAY"
1706 if test "$window_size" = "yes" ; then
1707 output_sym "CONFIG_NET_WINDOWSIZE"
1709 if test "$mss" = "yes" ; then
1710 output_sym "CONFIG_NET_MSS"
1712 if test "$rlimit_memlock" = "yes" ; then
1713 output_sym "CONFIG_RLIMIT_MEMLOCK"
1715 if test "$pwritev" = "yes" ; then
1716 output_sym "CONFIG_PWRITEV"
1718 if test "$ipv6" = "yes" ; then
1719 output_sym "CONFIG_IPV6"
1721 if test "$rbd" = "yes" ; then
1722 output_sym "CONFIG_RBD"
1724 if test "$rbd_inval" = "yes" ; then
1725 output_sym "CONFIG_RBD_INVAL"
1727 if test "$setvbuf" = "yes" ; then
1728 output_sym "CONFIG_SETVBUF"
1730 if test "$s390_z196_facilities" = "yes" ; then
1731 output_sym "CONFIG_S390_Z196_FACILITIES"
1732 CFLAGS="$CFLAGS -march=z9-109"
1734 if test "$gfapi" = "yes" ; then
1735 output_sym "CONFIG_GFAPI"
1737 if test "$gf_fadvise" = "yes" ; then
1738 output_sym "CONFIG_GF_FADVISE"
1740 if test "$gf_trim" = "yes" ; then
1741 output_sym "CONFIG_GF_TRIM"
1743 if test "$libhdfs" = "yes" ; then
1744 output_sym "CONFIG_LIBHDFS"
1745 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
1746 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
1747 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
1749 if test "$mtd" = "yes" ; then
1750 output_sym "CONFIG_MTD"
1752 if test "$arith" = "yes" ; then
1753 output_sym "CONFIG_ARITHMETIC"
1754 if test "$yacc_is_bison" = "yes" ; then
1755 echo "YACC=$YACC -y" >> $config_host_mak
1757 echo "YACC=$YACC" >> $config_host_mak
1760 if test "$getmntent" = "yes" ; then
1761 output_sym "CONFIG_GETMNTENT"
1763 if test "$getmntinfo" = "yes" ; then
1764 output_sym "CONFIG_GETMNTINFO"
1766 if test "$static_assert" = "yes" ; then
1767 output_sym "CONFIG_STATIC_ASSERT"
1769 if test "$have_bool" = "yes" ; then
1770 output_sym "CONFIG_HAVE_BOOL"
1773 if test "$zlib" = "no" ; then
1774 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
1777 echo "LIBS+=$LIBS" >> $config_host_mak
1778 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
1779 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
1780 echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
1781 echo "CC=$cc" >> $config_host_mak
1782 echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
1783 echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
1785 if [ `dirname $0` != "." -a ! -e Makefile ]; then
1786 cat > Makefile <<EOF
1787 SRCDIR:=`dirname $0`
1788 include \$(SRCDIR)/Makefile