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_ld="config-host.ld"
30 CFLAGS="-D_GNU_SOURCE"
32 # Print a helpful header at the top of config.log
33 echo "# FIO configure log $(date)" >> config.log
34 printf "# Configured with:" >> config.log
35 printf " '%s'" "$0" "$@" >> config.log
37 echo "#" >> config.log
40 # Run the compiler, capturing its output to the log.
41 echo $cc "$@" >> config.log
42 $cc "$@" >> config.log 2>&1 || return $?
43 # Test passed. If this is an --enable-werror build, rerun
44 # the test with -Werror and bail out if it fails. This
45 # makes warning-generating-errors in configure test code
46 # obvious to developers.
47 if test "$werror" != "yes"; then
50 # Don't bother rerunning the compile if we were already using -Werror
56 echo $cc -Werror "$@" >> config.log
57 $cc -Werror "$@" >> config.log 2>&1 && return $?
58 echo "ERROR: configure test passed without -Werror but failed with -Werror."
59 echo "This is probably a bug in the configure script. The failing command"
60 echo "will be at the bottom of config.log."
61 echo "You can run configure with --disable-werror to bypass this check."
66 do_cc $CFLAGS -c -o $TMPO $TMPC
72 echo "Compiling test case $3" >> config.log
73 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
80 echo "ERROR: User requested feature $feature"
81 echo "ERROR: configure was not able to find it"
87 type "$1" >/dev/null 2>&1
106 cc="${CC-${cross_prefix}gcc}"
110 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
115 echo "Bad option $opt"
120 if check_define __linux__ ; then
122 elif check_define __OpenBSD__ ; then
124 elif check_define __sun__ ; then
130 # Some host OSes need non-standard checks for which CPU to use.
131 # Note that these checks are broken for cross-compilation: if you're
132 # cross-compiling to one of these OSes then you'll need to specify
133 # the correct CPU with the --cpu option.
136 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
137 # we can run 64-bit userspace code.
138 # If the user didn't specify a CPU explicitly and the kernel says this is
139 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
141 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
146 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
147 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
152 echo "Forcing known good options on Windows"
153 if test -z "$CC" ; then
154 CC="x86_64-w64-mingw32-gcc"
156 echo "CC=$CC" > $config_host_mak
157 echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
158 echo "CONFIG_64BIT_LLP64=y" >> $config_host_mak
159 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
160 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
161 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
162 echo "CONFIG_FADVISE=y" >> $config_host_mak
163 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
164 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
165 echo "CONFIG_FADVISE=y" >> $config_host_mak
166 echo "CONFIG_SFAA=y" >> $config_host_mak
167 echo "CONFIG_RUSAGE_THREAD=y" >> $config_host_mak
171 if test ! -z "$cpu" ; then
172 # command line argument
174 elif check_define __i386__ ; then
176 elif check_define __x86_64__ ; then
178 elif check_define __sparc__ ; then
179 if check_define __arch64__ ; then
184 elif check_define _ARCH_PPC ; then
185 if check_define _ARCH_PPC64 ; then
190 elif check_define __mips__ ; then
192 elif check_define __ia64__ ; then
194 elif check_define __s390__ ; then
195 if check_define __s390x__ ; then
200 elif check_define __arm__ ; then
202 elif check_define __hppa__ ; then
208 # Normalise host CPU name and set ARCH.
210 ia64|ppc|ppc64|s390|s390x|sparc64)
213 i386|i486|i586|i686|i86pc|BePC)
222 hppa|parisc|parisc64)
238 if test "$targetos" = "FreeBSD"; then
247 cc="${CC-${cross_prefix}gcc}"
249 ##########################################
253 #include <inttypes.h>
256 volatile uint32_t i=0x01234567;
257 return (*((uint8_t*)(&i))) == 0x67;
260 if compile_prog "" "" "endian"; then
261 $TMPE && bigendian="yes"
265 echo "Operating system $targetos"
267 echo "Big endian $bigendian"
271 ##########################################
278 unsigned int wsize = sizeof(long) * 8;
279 printf("%d\n", wsize);
283 if compile_prog "" "" "wordsize"; then
286 echo "Wordsize $wordsize"
288 ##########################################
300 if compile_prog "" "-laio" "libaio" ; then
304 if test "$libaio" = "yes" ; then
305 feature_not_found "linux AIO"
309 echo "Linux AIO support $libaio"
311 ##########################################
324 if compile_prog "" "" "posixaio" ; then
326 elif compile_prog "" "-lrt" "posixaio"; then
331 echo "POSIX AIO support $posix_aio"
332 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
334 ##########################################
335 # posix aio fsync probe
337 if test "$posix_aio" = "yes" ; then
344 return aio_fsync(O_SYNC, &cb);
348 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
352 echo "POSIX AIO fsync $posix_aio_fsync"
354 ##########################################
358 #include <sys/types.h>
359 #include <sys/asynch.h>
364 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
368 if compile_prog "" "-laio" "solarisaio" ; then
372 echo "Solaris AIO support $solaris_aio"
374 ##########################################
375 # __sync_fetch_and_and test
378 static int sfaa(int *ptr)
380 return __sync_fetch_and_and(ptr, 0);
383 int main(int argc, char **argv)
390 if compile_prog "" "" "__sync_fetch_and_add()" ; then
393 echo "__sync_fetch_and add $sfaa"
395 ##########################################
400 #include <infiniband/arch.h>
401 int main(int argc, char **argv)
403 struct ibv_pd *pd = ibv_alloc_pd(NULL);
407 if compile_prog "" "-libverbs" "libverbs" ; then
409 LIBS="-libverbs $LIBS"
411 echo "libverbs $libverbs"
413 ##########################################
418 #include <rdma/rdma_cma.h>
419 int main(int argc, char **argv)
421 rdma_destroy_qp(NULL);
425 if compile_prog "" "-lrdmacm" "rdma"; then
427 LIBS="-lrdmacm $LIBS"
429 echo "rdmacm $rdmacm"
431 ##########################################
432 # Linux fallocate probe
436 #include <linux/falloc.h>
437 int main(int argc, char **argv)
439 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
443 if compile_prog "" "" "linux_fallocate"; then
444 linux_fallocate="yes"
446 echo "Linux fallocate $linux_fallocate"
448 ##########################################
449 # POSIX fadvise probe
454 int main(int argc, char **argv)
456 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
460 if compile_prog "" "" "posix_fadvise"; then
463 echo "POSIX fadvise $posix_fadvise"
465 ##########################################
466 # POSIX fallocate probe
471 int main(int argc, char **argv)
473 int r = posix_fallocate(0, 0, 1024);
477 if compile_prog "" "" "posix_fallocate"; then
478 posix_fallocate="yes"
480 echo "POSIX fallocate $posix_fallocate"
482 ##########################################
483 # sched_set/getaffinity 2 or 3 argument test
484 linux_2arg_affinity="no"
485 linux_3arg_affinity="no"
488 int main(int argc, char **argv)
491 return sched_setaffinity(0, sizeof(mask), &mask);
494 if compile_prog "" "" "sched_setaffinity(,,)"; then
495 linux_3arg_affinity="yes"
499 int main(int argc, char **argv)
502 return sched_setaffinity(0, &mask);
505 if compile_prog "" "" "sched_setaffinity(,)"; then
506 linux_2arg_affinity="yes"
509 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
510 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
512 ##########################################
513 # clock_gettime probe
518 int main(int argc, char **argv)
520 return clock_gettime(0, NULL);
523 if compile_prog "" "" "clock_gettime"; then
525 elif compile_prog "" "-lrt" "clock_gettime"; then
529 echo "clock_gettime $clock_gettime"
531 ##########################################
532 # CLOCK_MONOTONIC probe
534 if test "$clock_gettime" = "yes" ; then
538 int main(int argc, char **argv)
540 return clock_gettime(CLOCK_MONOTONIC, NULL);
543 if compile_prog "" "$LIBS" "clock monotonic"; then
544 clock_monotonic="yes"
547 echo "CLOCK_MONOTONIC $clock_monotonic"
549 ##########################################
550 # CLOCK_MONOTONIC_PRECISE probe
551 clock_monotonic_precise="no"
552 if test "$clock_gettime" = "yes" ; then
556 int main(int argc, char **argv)
558 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
561 if compile_prog "" "$LIBS" "clock monotonic precise"; then
562 clock_monotonic_precise="yes"
565 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
567 ##########################################
568 # gettimeofday() probe
571 #include <sys/time.h>
573 int main(int argc, char **argv)
576 return gettimeofday(&tv, NULL);
579 if compile_prog "" "" "gettimeofday"; then
582 echo "gettimeofday $gettimeofday"
584 ##########################################
590 int main(int argc, char **argv)
595 if compile_prog "" "" "fdatasync"; then
598 echo "fdatasync $fdatasync"
600 ##########################################
601 # sync_file_range() probe
607 #include <linux/fs.h>
608 int main(int argc, char **argv)
610 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
611 SYNC_FILE_RANGE_WAIT_AFTER;
612 return sync_file_range(0, 0, 0, flags);
615 if compile_prog "" "" "sync_file_range"; then
616 sync_file_range="yes"
618 echo "sync_file_range $sync_file_range"
620 ##########################################
621 # ext4 move extent probe
625 #include <sys/ioctl.h>
626 int main(int argc, char **argv)
628 struct move_extent me;
629 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
632 if compile_prog "" "" "ext4 move extent" ; then
634 elif test $targetos = "Linux" ; then
635 # On Linux, just default to it on and let it error at runtime if we really
636 # don't have it. None of my updated systems have it defined, but it does
637 # work. Takes a while to bubble back.
640 echo "EXT4 move extent $ext4_me"
642 ##########################################
648 int main(int argc, char **argv)
650 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
653 if compile_prog "" "" "linux splice"; then
656 echo "Linux splice(2) $linux_splice"
658 ##########################################
663 #include <guasi_syscalls.h>
664 int main(int argc, char **argv)
666 guasi_t ctx = guasi_create(0, 0, 0);
670 if compile_prog "" "" "guasi"; then
675 ##########################################
679 #include <nvm/vectored_write.h>
680 int main(int argc, char **argv)
682 struct vsl_iovec iov;
683 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
686 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
687 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
690 echo "Fusion-io atomic engine $fusion_aw"
692 ##########################################
697 int main(int argc, char **argv)
699 return numa_available();
702 if compile_prog "" "-lnuma" "libnuma"; then
706 echo "libnuma $libnuma"
708 ##########################################
713 int main(int argc, char **argv)
719 if compile_prog "" "" "strsep"; then
722 echo "strsep $strsep"
724 ##########################################
725 # getopt_long_only() probe
726 getopt_long_only="no"
730 int main(int argc, char **argv)
732 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
736 if compile_prog "" "" "getopt_long_only"; then
737 getopt_long_only="yes"
739 echo "getopt_long_only() $getopt_long_only"
741 ##########################################
745 #include <sys/socket.h>
746 #include <arpa/inet.h>
748 int main(int argc, char **argv)
751 return inet_aton(NULL, &in);
754 if compile_prog "" "" "inet_aton"; then
757 echo "inet_aton $inet_aton"
759 ##########################################
764 #include <netinet/in.h>
765 int main(int argc, char **argv)
771 if compile_prog "" "" "socklen_t"; then
774 echo "socklen_t $socklen_t"
776 ##########################################
777 # Whether or not __thread is supported for TLS
781 static int __thread ret;
782 int main(int argc, char **argv)
787 if compile_prog "" "" "__thread"; then
790 echo "__thread $tls_thread"
792 ##########################################
793 # Check whether we have getrusage(RUSAGE_THREAD)
796 #include <sys/time.h>
797 #include <sys/resource.h>
798 int main(int argc, char **argv)
801 getrusage(RUSAGE_THREAD, &ru);
805 if compile_prog "" "" "RUSAGE_THREAD"; then
808 echo "RUSAGE_THREAD $rusage_thread"
810 #############################################################################
812 echo "# Automatically generated by configure - do not modify" > $config_host_mak
813 printf "# Configured with:" >> $config_host_mak
814 printf " '%s'" "$0" "$@" >> $config_host_mak
815 echo >> $config_host_mak
817 if test "$wordsize" = "64" ; then
818 echo "CONFIG_64BIT=y" >> $config_host_mak
819 elif test "$wordsize" = "32" ; then
820 echo "CONFIG_32BIT=y" >> $config_host_mak
822 echo "Unknown wordsize!"
825 if test "$bigendian" = "yes" ; then
826 echo "CONFIG_BIG_ENDIAN=y" >> $config_host_mak
828 echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
830 if test "$libaio" = "yes" ; then
831 echo "CONFIG_LIBAIO=y" >> $config_host_mak
833 if test "$posix_aio" = "yes" ; then
834 echo "CONFIG_POSIXAIO=y" >> $config_host_mak
836 if test "$posix_aio_fsync" = "yes" ; then
837 echo "CONFIG_POSIXAIO_FSYNC=y" >> $config_host_mak
839 if test "$linux_fallocate" = "yes" ; then
840 echo "CONFIG_LINUX_FALLOCATE=y" >> $config_host_mak
842 if test "$posix_fallocate" = "yes" ; then
843 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
845 if test "$fdatasync" = "yes" ; then
846 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
848 if test "$sync_file_range" = "yes" ; then
849 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
851 if test "$sfaa" = "yes" ; then
852 echo "CONFIG_SFAA=y" >> $config_host_mak
854 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
855 echo "CONFIG_RDMA=y" >> $config_host_mak
857 if test "$clock_gettime" = "yes" ; then
858 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
860 if test "$clock_monotonic" = "yes" ; then
861 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
863 if test "$clock_monotonic_precise" = "yes" ; then
864 echo "CONFIG_CLOCK_MONOTONIC_PRECISE=y" >> $config_host_mak
866 if test "$gettimeofday" = "yes" ; then
867 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
869 if test "$posix_fadvise" = "yes" ; then
870 echo "CONFIG_POSIX_FADVISE=y" >> $config_host_mak
872 if test "$linux_3arg_affinity" = "yes" ; then
873 echo "CONFIG_3ARG_AFFINITY=y" >> $config_host_mak
874 elif test "$linux_2arg_affinity" = "yes" ; then
875 echo "CONFIG_2ARG_AFFINITY=y" >> $config_host_mak
877 if test "$strsep" = "yes" ; then
878 echo "CONFIG_STRSEP=y" >> $config_host_mak
880 if test "$getopt_long_only" = "yes" ; then
881 echo "CONFIG_GETOPT_LONG_ONLY=y" >> $config_host_mak
883 if test "$inet_aton" = "yes" ; then
884 echo "CONFIG_INET_ATON=y" >> $config_host_mak
886 if test "$socklen_t" = "yes" ; then
887 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
889 if test "$ext4_me" = "yes" ; then
890 echo "CONFIG_LINUX_EXT4_MOVE_EXTENT=y" >> $config_host_mak
892 if test "$linux_splice" = "yes" ; then
893 echo "CONFIG_LINUX_SPLICE=y" >> $config_host_mak
895 if test "$guasi" = "yes" ; then
896 echo "CONFIG_GUASI=y" >> $config_host_mak
898 if test "$fusion_aw" = "yes" ; then
899 echo "CONFIG_FUSION_AW=y" >> $config_host_mak
901 if test "$libnuma" = "yes" ; then
902 echo "CONFIG_LIBNUMA=y" >> $config_host_mak
904 if test "$solaris_aio" = "yes" ; then
905 echo "CONFIG_SOLARISAIO=y" >> $config_host_mak
907 if test "$tls_thread" = "yes" ; then
908 echo "CONFIG_TLS_THREAD=y" >> $config_host_mak
910 if test "$rusage_thread" = "yes" ; then
911 echo "CONFIG_RUSAGE_THREAD=y" >> $config_host_mak
914 echo "LIBS+=$LIBS" >> $config_host_mak
915 echo "CC=$cc" >> $config_host_mak
916 echo "CFLAGS=$CFLAGS" >> $config_host_mak