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
168 echo "CONFIG_WINDOWSAIO=y" >> $config_host_mak
169 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
173 if test ! -z "$cpu" ; then
174 # command line argument
176 elif check_define __i386__ ; then
178 elif check_define __x86_64__ ; then
180 elif check_define __sparc__ ; then
181 if check_define __arch64__ ; then
186 elif check_define _ARCH_PPC ; then
187 if check_define _ARCH_PPC64 ; then
192 elif check_define __mips__ ; then
194 elif check_define __ia64__ ; then
196 elif check_define __s390__ ; then
197 if check_define __s390x__ ; then
202 elif check_define __arm__ ; then
204 elif check_define __hppa__ ; then
210 # Normalise host CPU name and set ARCH.
212 ia64|ppc|ppc64|s390|s390x|sparc64)
215 i386|i486|i586|i686|i86pc|BePC)
224 hppa|parisc|parisc64)
240 if test "$targetos" = "FreeBSD"; then
249 cc="${CC-${cross_prefix}gcc}"
251 ##########################################
255 #include <inttypes.h>
258 volatile uint32_t i=0x01234567;
259 return (*((uint8_t*)(&i))) == 0x67;
262 if compile_prog "" "" "endian"; then
263 $TMPE && bigendian="yes"
267 echo "Operating system $targetos"
269 echo "Big endian $bigendian"
273 ##########################################
280 unsigned int wsize = sizeof(long) * 8;
281 printf("%d\n", wsize);
285 if compile_prog "" "" "wordsize"; then
288 echo "Wordsize $wordsize"
290 ##########################################
302 if compile_prog "" "-laio" "libaio" ; then
306 if test "$libaio" = "yes" ; then
307 feature_not_found "linux AIO"
311 echo "Linux AIO support $libaio"
313 ##########################################
326 if compile_prog "" "" "posixaio" ; then
328 elif compile_prog "" "-lrt" "posixaio"; then
333 echo "POSIX AIO support $posix_aio"
334 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
336 ##########################################
337 # posix aio fsync probe
339 if test "$posix_aio" = "yes" ; then
346 return aio_fsync(O_SYNC, &cb);
350 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
354 echo "POSIX AIO fsync $posix_aio_fsync"
356 ##########################################
360 #include <sys/types.h>
361 #include <sys/asynch.h>
366 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
370 if compile_prog "" "-laio" "solarisaio" ; then
374 echo "Solaris AIO support $solaris_aio"
376 ##########################################
377 # __sync_fetch_and_and test
380 static int sfaa(int *ptr)
382 return __sync_fetch_and_and(ptr, 0);
385 int main(int argc, char **argv)
392 if compile_prog "" "" "__sync_fetch_and_add()" ; then
395 echo "__sync_fetch_and add $sfaa"
397 ##########################################
402 #include <infiniband/arch.h>
403 int main(int argc, char **argv)
405 struct ibv_pd *pd = ibv_alloc_pd(NULL);
409 if compile_prog "" "-libverbs" "libverbs" ; then
411 LIBS="-libverbs $LIBS"
413 echo "libverbs $libverbs"
415 ##########################################
420 #include <rdma/rdma_cma.h>
421 int main(int argc, char **argv)
423 rdma_destroy_qp(NULL);
427 if compile_prog "" "-lrdmacm" "rdma"; then
429 LIBS="-lrdmacm $LIBS"
431 echo "rdmacm $rdmacm"
433 ##########################################
434 # Linux fallocate probe
438 #include <linux/falloc.h>
439 int main(int argc, char **argv)
441 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
445 if compile_prog "" "" "linux_fallocate"; then
446 linux_fallocate="yes"
448 echo "Linux fallocate $linux_fallocate"
450 ##########################################
451 # POSIX fadvise probe
456 int main(int argc, char **argv)
458 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
462 if compile_prog "" "" "posix_fadvise"; then
465 echo "POSIX fadvise $posix_fadvise"
467 ##########################################
468 # POSIX fallocate probe
473 int main(int argc, char **argv)
475 int r = posix_fallocate(0, 0, 1024);
479 if compile_prog "" "" "posix_fallocate"; then
480 posix_fallocate="yes"
482 echo "POSIX fallocate $posix_fallocate"
484 ##########################################
485 # sched_set/getaffinity 2 or 3 argument test
486 linux_2arg_affinity="no"
487 linux_3arg_affinity="no"
490 int main(int argc, char **argv)
493 return sched_setaffinity(0, sizeof(mask), &mask);
496 if compile_prog "" "" "sched_setaffinity(,,)"; then
497 linux_3arg_affinity="yes"
501 int main(int argc, char **argv)
504 return sched_setaffinity(0, &mask);
507 if compile_prog "" "" "sched_setaffinity(,)"; then
508 linux_2arg_affinity="yes"
511 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
512 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
514 ##########################################
515 # clock_gettime probe
520 int main(int argc, char **argv)
522 return clock_gettime(0, NULL);
525 if compile_prog "" "" "clock_gettime"; then
527 elif compile_prog "" "-lrt" "clock_gettime"; then
531 echo "clock_gettime $clock_gettime"
533 ##########################################
534 # CLOCK_MONOTONIC probe
536 if test "$clock_gettime" = "yes" ; then
540 int main(int argc, char **argv)
542 return clock_gettime(CLOCK_MONOTONIC, NULL);
545 if compile_prog "" "$LIBS" "clock monotonic"; then
546 clock_monotonic="yes"
549 echo "CLOCK_MONOTONIC $clock_monotonic"
551 ##########################################
552 # CLOCK_MONOTONIC_PRECISE probe
553 clock_monotonic_precise="no"
554 if test "$clock_gettime" = "yes" ; then
558 int main(int argc, char **argv)
560 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
563 if compile_prog "" "$LIBS" "clock monotonic precise"; then
564 clock_monotonic_precise="yes"
567 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
569 ##########################################
570 # gettimeofday() probe
573 #include <sys/time.h>
575 int main(int argc, char **argv)
578 return gettimeofday(&tv, NULL);
581 if compile_prog "" "" "gettimeofday"; then
584 echo "gettimeofday $gettimeofday"
586 ##########################################
592 int main(int argc, char **argv)
597 if compile_prog "" "" "fdatasync"; then
600 echo "fdatasync $fdatasync"
602 ##########################################
603 # sync_file_range() probe
609 #include <linux/fs.h>
610 int main(int argc, char **argv)
612 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
613 SYNC_FILE_RANGE_WAIT_AFTER;
614 return sync_file_range(0, 0, 0, flags);
617 if compile_prog "" "" "sync_file_range"; then
618 sync_file_range="yes"
620 echo "sync_file_range $sync_file_range"
622 ##########################################
623 # ext4 move extent probe
627 #include <sys/ioctl.h>
628 int main(int argc, char **argv)
630 struct move_extent me;
631 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
634 if compile_prog "" "" "ext4 move extent" ; then
636 elif test $targetos = "Linux" ; then
637 # On Linux, just default to it on and let it error at runtime if we really
638 # don't have it. None of my updated systems have it defined, but it does
639 # work. Takes a while to bubble back.
642 echo "EXT4 move extent $ext4_me"
644 ##########################################
650 int main(int argc, char **argv)
652 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
655 if compile_prog "" "" "linux splice"; then
658 echo "Linux splice(2) $linux_splice"
660 ##########################################
665 #include <guasi_syscalls.h>
666 int main(int argc, char **argv)
668 guasi_t ctx = guasi_create(0, 0, 0);
672 if compile_prog "" "" "guasi"; then
677 ##########################################
681 #include <nvm/vectored_write.h>
682 int main(int argc, char **argv)
684 struct vsl_iovec iov;
685 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
688 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
689 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
692 echo "Fusion-io atomic engine $fusion_aw"
694 ##########################################
699 int main(int argc, char **argv)
701 return numa_available();
704 if compile_prog "" "-lnuma" "libnuma"; then
708 echo "libnuma $libnuma"
710 ##########################################
715 int main(int argc, char **argv)
721 if compile_prog "" "" "strsep"; then
724 echo "strsep $strsep"
726 ##########################################
727 # getopt_long_only() probe
728 getopt_long_only="no"
732 int main(int argc, char **argv)
734 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
738 if compile_prog "" "" "getopt_long_only"; then
739 getopt_long_only="yes"
741 echo "getopt_long_only() $getopt_long_only"
743 ##########################################
747 #include <sys/socket.h>
748 #include <arpa/inet.h>
750 int main(int argc, char **argv)
753 return inet_aton(NULL, &in);
756 if compile_prog "" "" "inet_aton"; then
759 echo "inet_aton $inet_aton"
761 ##########################################
766 #include <netinet/in.h>
767 int main(int argc, char **argv)
773 if compile_prog "" "" "socklen_t"; then
776 echo "socklen_t $socklen_t"
778 ##########################################
779 # Whether or not __thread is supported for TLS
783 static int __thread ret;
784 int main(int argc, char **argv)
789 if compile_prog "" "" "__thread"; then
792 echo "__thread $tls_thread"
794 ##########################################
795 # Check whether we have getrusage(RUSAGE_THREAD)
798 #include <sys/time.h>
799 #include <sys/resource.h>
800 int main(int argc, char **argv)
803 getrusage(RUSAGE_THREAD, &ru);
807 if compile_prog "" "" "RUSAGE_THREAD"; then
810 echo "RUSAGE_THREAD $rusage_thread"
812 #############################################################################
814 echo "# Automatically generated by configure - do not modify" > $config_host_mak
815 printf "# Configured with:" >> $config_host_mak
816 printf " '%s'" "$0" "$@" >> $config_host_mak
817 echo >> $config_host_mak
819 if test "$wordsize" = "64" ; then
820 echo "CONFIG_64BIT=y" >> $config_host_mak
821 elif test "$wordsize" = "32" ; then
822 echo "CONFIG_32BIT=y" >> $config_host_mak
824 echo "Unknown wordsize!"
827 if test "$bigendian" = "yes" ; then
828 echo "CONFIG_BIG_ENDIAN=y" >> $config_host_mak
830 echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
832 if test "$libaio" = "yes" ; then
833 echo "CONFIG_LIBAIO=y" >> $config_host_mak
835 if test "$posix_aio" = "yes" ; then
836 echo "CONFIG_POSIXAIO=y" >> $config_host_mak
838 if test "$posix_aio_fsync" = "yes" ; then
839 echo "CONFIG_POSIXAIO_FSYNC=y" >> $config_host_mak
841 if test "$linux_fallocate" = "yes" ; then
842 echo "CONFIG_LINUX_FALLOCATE=y" >> $config_host_mak
844 if test "$posix_fallocate" = "yes" ; then
845 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
847 if test "$fdatasync" = "yes" ; then
848 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
850 if test "$sync_file_range" = "yes" ; then
851 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
853 if test "$sfaa" = "yes" ; then
854 echo "CONFIG_SFAA=y" >> $config_host_mak
856 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
857 echo "CONFIG_RDMA=y" >> $config_host_mak
859 if test "$clock_gettime" = "yes" ; then
860 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
862 if test "$clock_monotonic" = "yes" ; then
863 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
865 if test "$clock_monotonic_precise" = "yes" ; then
866 echo "CONFIG_CLOCK_MONOTONIC_PRECISE=y" >> $config_host_mak
868 if test "$gettimeofday" = "yes" ; then
869 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
871 if test "$posix_fadvise" = "yes" ; then
872 echo "CONFIG_POSIX_FADVISE=y" >> $config_host_mak
874 if test "$linux_3arg_affinity" = "yes" ; then
875 echo "CONFIG_3ARG_AFFINITY=y" >> $config_host_mak
876 elif test "$linux_2arg_affinity" = "yes" ; then
877 echo "CONFIG_2ARG_AFFINITY=y" >> $config_host_mak
879 if test "$strsep" = "yes" ; then
880 echo "CONFIG_STRSEP=y" >> $config_host_mak
882 if test "$getopt_long_only" = "yes" ; then
883 echo "CONFIG_GETOPT_LONG_ONLY=y" >> $config_host_mak
885 if test "$inet_aton" = "yes" ; then
886 echo "CONFIG_INET_ATON=y" >> $config_host_mak
888 if test "$socklen_t" = "yes" ; then
889 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
891 if test "$ext4_me" = "yes" ; then
892 echo "CONFIG_LINUX_EXT4_MOVE_EXTENT=y" >> $config_host_mak
894 if test "$linux_splice" = "yes" ; then
895 echo "CONFIG_LINUX_SPLICE=y" >> $config_host_mak
897 if test "$guasi" = "yes" ; then
898 echo "CONFIG_GUASI=y" >> $config_host_mak
900 if test "$fusion_aw" = "yes" ; then
901 echo "CONFIG_FUSION_AW=y" >> $config_host_mak
903 if test "$libnuma" = "yes" ; then
904 echo "CONFIG_LIBNUMA=y" >> $config_host_mak
906 if test "$solaris_aio" = "yes" ; then
907 echo "CONFIG_SOLARISAIO=y" >> $config_host_mak
909 if test "$tls_thread" = "yes" ; then
910 echo "CONFIG_TLS_THREAD=y" >> $config_host_mak
912 if test "$rusage_thread" = "yes" ; then
913 echo "CONFIG_RUSAGE_THREAD=y" >> $config_host_mak
916 echo "LIBS+=$LIBS" >> $config_host_mak
917 echo "CC=$cc" >> $config_host_mak
918 echo "CFLAGS=$CFLAGS" >> $config_host_mak