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"
29 # Print a helpful header at the top of config.log
30 echo "# FIO configure log $(date)" >> config.log
31 printf "# Configured with:" >> config.log
32 printf " '%s'" "$0" "$@" >> config.log
34 echo "#" >> config.log
37 # Run the compiler, capturing its output to the log.
38 echo $cc "$@" >> config.log
39 $cc "$@" >> config.log 2>&1 || return $?
40 # Test passed. If this is an --enable-werror build, rerun
41 # the test with -Werror and bail out if it fails. This
42 # makes warning-generating-errors in configure test code
43 # obvious to developers.
44 if test "$werror" != "yes"; then
47 # Don't bother rerunning the compile if we were already using -Werror
53 echo $cc -Werror "$@" >> config.log
54 $cc -Werror "$@" >> config.log 2>&1 && return $?
55 echo "ERROR: configure test passed without -Werror but failed with -Werror."
56 echo "This is probably a bug in the configure script. The failing command"
57 echo "will be at the bottom of config.log."
58 echo "You can run configure with --disable-werror to bypass this check."
63 do_cc $CFLAGS -c -o $TMPO $TMPC
69 echo "Compiling test case $3" >> config.log
70 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
77 echo "ERROR: User requested feature $feature"
78 echo "ERROR: configure was not able to find it"
84 type "$1" >/dev/null 2>&1
103 cc="${CC-${cross_prefix}gcc}"
105 if check_define __linux__ ; then
107 elif test `uname -o` = Cygwin ; then
108 echo "Forcing known good options on Windows"
109 echo "CC=x86_64-w64-mingw32-gcc" >> $config_host_mak
110 echo "CONFIG_64BIT_LLP64=y" >> $config_host_mak
111 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
112 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
113 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
114 echo "CONFIG_FADVISE=y" >> $config_host_mak
115 echo "CONFIG_STRSEP=y" >> $config_host_mak
116 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
117 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
118 echo "CONFIG_FADVISE=y" >> $config_host_mak
119 echo "CONFIG_SFAA=y" >> $config_host_mak
121 elif check_define __OpenBSD__ ; then
123 elif check_define __sun__ ; then
129 # Some host OSes need non-standard checks for which CPU to use.
130 # Note that these checks are broken for cross-compilation: if you're
131 # cross-compiling to one of these OSes then you'll need to specify
132 # the correct CPU with the --cpu option.
135 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
136 # we can run 64-bit userspace code.
137 # If the user didn't specify a CPU explicitly and the kernel says this is
138 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
140 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
145 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
146 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
151 if test ! -z "$cpu" ; then
152 # command line argument
154 elif check_define __i386__ ; then
156 elif check_define __x86_64__ ; then
158 elif check_define __sparc__ ; then
159 if check_define __arch64__ ; then
164 elif check_define _ARCH_PPC ; then
165 if check_define _ARCH_PPC64 ; then
170 elif check_define __mips__ ; then
172 elif check_define __ia64__ ; then
174 elif check_define __s390__ ; then
175 if check_define __s390x__ ; then
180 elif check_define __arm__ ; then
182 elif check_define __hppa__ ; then
188 # Normalise host CPU name and set ARCH.
190 ia64|ppc|ppc64|s390|s390x|sparc64)
193 i386|i486|i586|i686|i86pc|BePC)
202 hppa|parisc|parisc64)
218 if test "$targetos" = "FreeBSD"; then
227 cc="${CC-${cross_prefix}gcc}"
229 echo "Operating system $targetos"
234 ##########################################
241 unsigned int wsize = sizeof(long) * 8;
242 printf("%d\n", wsize);
246 if compile_prog "" "" "wordsize"; then
249 echo "Wordsize $wordsize"
251 ##########################################
263 if compile_prog "" "-laio" "libaio" ; then
267 if test "$libaio" = "yes" ; then
268 feature_not_found "linux AIO"
272 echo "Linux AIO support $libaio"
274 ##########################################
287 if compile_prog "" "" "posixaio" ; then
289 elif compile_prog "" "-lrt" "posixaio"; then
294 echo "POSIX AIO support $posix_aio"
295 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
297 ##########################################
298 # posix aio fsync probe
300 if test "$posix_aio" = "yes" ; then
307 return aio_fsync(O_SYNC, &cb);
311 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
315 echo "POSIX AIO fsync $posix_aio_fsync"
317 ##########################################
321 #include <sys/types.h>
322 #include <sys/asynch.h>
327 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
331 if compile_prog "" "-laio" "solarisaio" ; then
335 echo "Solaris AIO support $solaris_aio"
337 ##########################################
338 # __sync_fetch_and_and test
341 static int sfaa(int *ptr)
343 return __sync_fetch_and_and(ptr, 0);
346 int main(int argc, char **argv)
353 if compile_prog "" "" "__sync_fetch_and_add()" ; then
356 echo "__sync_fetch_and add $sfaa"
358 ##########################################
363 #include <infiniband/arch.h>
364 int main(int argc, char **argv)
366 struct ibv_pd *pd = ibv_alloc_pd(NULL);
370 if compile_prog "" "-libverbs" "libverbs" ; then
372 LIBS="-libverbs $LIBS"
374 echo "libverbs $libverbs"
376 ##########################################
381 #include <rdma/rdma_cma.h>
382 int main(int argc, char **argv)
384 rdma_destroy_qp(NULL);
388 if compile_prog "" "-lrdmacm" "rdma"; then
390 LIBS="-lrdmacm $LIBS"
392 echo "rdmacm $rdmacm"
394 ##########################################
395 # Linux fallocate probe
399 #include <linux/falloc.h>
400 int main(int argc, char **argv)
402 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
406 if compile_prog "" "" "linux_fallocate"; then
407 linux_fallocate="yes"
409 echo "Linux fallocate $linux_fallocate"
411 ##########################################
412 # POSIX fadvise probe
417 int main(int argc, char **argv)
419 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
423 if compile_prog "" "" "posix_fadvise"; then
426 echo "POSIX fadvise $posix_fadvise"
428 ##########################################
429 # POSIX fallocate probe
434 int main(int argc, char **argv)
436 int r = posix_fallocate(0, 0, 1024);
440 if compile_prog "" "" "posix_fallocate"; then
441 posix_fallocate="yes"
443 echo "POSIX fallocate $posix_fallocate"
445 ##########################################
446 # sched_set/getaffinity 2 or 3 argument test
447 linux_2arg_affinity="no"
448 linux_3arg_affinity="no"
452 int main(int argc, char **argv)
455 return sched_setaffinity(0, sizeof(mask), &mask);
458 if compile_prog "" "" "sched_setaffinity(,,)"; then
459 linux_3arg_affinity="yes"
464 int main(int argc, char **argv)
467 return sched_setaffinity(0, &mask);
470 if compile_prog "" "" "sched_setaffinity(,)"; then
471 linux_2arg_affinity="yes"
474 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
475 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
477 ##########################################
478 # clock_gettime probe
483 int main(int argc, char **argv)
485 return clock_gettime(0, NULL);
488 if compile_prog "" "" "clock_gettime"; then
490 elif compile_prog "" "-lrt" "clock_gettime"; then
494 echo "clock_gettime $clock_gettime"
496 ##########################################
497 # CLOCK_MONOTONIC probe
499 if test "$clock_gettime" = "yes" ; then
503 int main(int argc, char **argv)
505 return clock_gettime(CLOCK_MONOTONIC, NULL);
508 if compile_prog "" "$LIBS" "clock monotonic"; then
509 clock_monotonic="yes"
512 echo "CLOCK_MONOTONIC $clock_monotonic"
514 ##########################################
515 # CLOCK_MONOTONIC_PRECISE probe
516 clock_monotonic_precise="no"
517 if test "$clock_gettime" = "yes" ; then
521 int main(int argc, char **argv)
523 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
526 if compile_prog "" "$LIBS" "clock monotonic precise"; then
527 clock_monotonic_precise="yes"
530 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
532 ##########################################
533 # gettimeofday() probe
536 #include <sys/time.h>
538 int main(int argc, char **argv)
541 return gettimeofday(&tv, NULL);
544 if compile_prog "" "" "gettimeofday"; then
547 echo "gettimeofday $gettimeofday"
549 ##########################################
555 int main(int argc, char **argv)
560 if compile_prog "" "" "fdatasync"; then
563 echo "fdatasync $fdatasync"
565 ##########################################
566 # sync_file_range() probe
573 #include <linux/fs.h>
574 int main(int argc, char **argv)
576 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
577 SYNC_FILE_RANGE_WAIT_AFTER;
578 return sync_file_range(0, 0, 0, flags);
581 if compile_prog "" "" "sync_file_range"; then
582 sync_file_range="yes"
584 echo "sync_file_range $sync_file_range"
586 ##########################################
587 # ext4 move extent probe
591 #include <sys/ioctl.h>
592 int main(int argc, char **argv)
594 struct move_extent me;
595 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
598 if compile_prog "" "" "ext4 move extent" ; then
600 elif test $targetos = "Linux" ; then
601 # On Linux, just default to it on and let it error at runtime if we really
602 # don't have it. None of my updated systems have it defined, but it does
603 # work. Takes a while to bubble back.
606 echo "EXT4 move extent $ext4_me"
608 ##########################################
615 int main(int argc, char **argv)
617 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
620 if compile_prog "" "" "linux splice"; then
623 echo "Linux splice(2) $linux_splice"
625 ##########################################
630 #include <guasi_syscalls.h>
631 int main(int argc, char **argv)
633 guasi_t ctx = guasi_create(0, 0, 0);
637 if compile_prog "" "" "guasi"; then
642 ##########################################
646 #include <vsl_dp_experimental/vectored_write.h>
647 int main(int argc, char **argv)
649 struct vsl_iovec iov;
650 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
653 if compile_prog "" "-lvsldpexp" "fusion-aw"; then
656 echo "Fusion-io atomic engine $fusion_aw"
658 ##########################################
663 int main(int argc, char **argv)
665 return numa_available();
668 if compile_prog "" "-lnuma" "libnuma"; then
672 echo "libnuma $libnuma"
674 ##########################################
679 int main(int argc, char **argv)
685 if compile_prog "" "" "strsep"; then
688 echo "strsep $strsep"
690 ##########################################
691 # getopt_long_only() probe
692 getopt_long_only="no"
696 int main(int argc, char **argv)
698 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
702 if compile_prog "" "" "getopt_long_only"; then
703 getopt_long_only="yes"
705 echo "getopt_long_only() $getopt_long_only"
707 ##########################################
711 #include <sys/socket.h>
712 #include <arpa/inet.h>
714 int main(int argc, char **argv)
717 return inet_aton(NULL, &in);
720 if compile_prog "" "" "inet_aton"; then
723 echo "inet_aton $inet_aton"
725 ##########################################
730 #include <netinet/in.h>
731 int main(int argc, char **argv)
737 if compile_prog "" "" "socklen_t"; then
740 echo "socklen_t $socklen_t"
742 ##########################################
743 # Whether or not __thread is supported for TLS
747 static int __thread ret;
748 int main(int argc, char **argv)
753 if compile_prog "" "" "__thread"; then
756 echo "__thread $tls_thread"
758 #############################################################################
760 echo "# Automatically generated by configure - do not modify" > $config_host_mak
761 printf "# Configured with:" >> $config_host_mak
762 printf " '%s'" "$0" "$@" >> $config_host_mak
763 echo >> $config_host_mak
765 if test "$wordsize" = "64" ; then
766 echo "CONFIG_64BIT=y" >> $config_host_mak
767 elif test "$wordsize" = "32" ; then
768 echo "CONFIG_32BIT=y" >> $config_host_mak
770 echo "Unknown wordsize!"
773 if test "$libaio" = "yes" ; then
774 echo "CONFIG_LIBAIO=y" >> $config_host_mak
776 if test "$posix_aio" = "yes" ; then
777 echo "CONFIG_POSIXAIO=y" >> $config_host_mak
779 if test "$posix_aio_fsync" = "yes" ; then
780 echo "CONFIG_POSIXAIO_FSYNC=y" >> $config_host_mak
782 if test "$linux_fallocate" = "yes" ; then
783 echo "CONFIG_LINUX_FALLOCATE=y" >> $config_host_mak
785 if test "$posix_fallocate" = "yes" ; then
786 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
788 if test "$fdatasync" = "yes" ; then
789 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
791 if test "$sync_file_range" = "yes" ; then
792 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
794 if test "$sfaa" = "yes" ; then
795 echo "CONFIG_SFAA=y" >> $config_host_mak
797 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
798 echo "CONFIG_RDMA=y" >> $config_host_mak
800 if test "$clock_gettime" = "yes" ; then
801 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
803 if test "$clock_monotonic" = "yes" ; then
804 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
806 if test "$clock_monotonic_precise" = "yes" ; then
807 echo "CONFIG_CLOCK_MONOTONIC_PRECISE=y" >> $config_host_mak
809 if test "$gettimeofday" = "yes" ; then
810 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
812 if test "$posix_fadvise" = "yes" ; then
813 echo "CONFIG_POSIX_FADVISE=y" >> $config_host_mak
815 if test "$linux_3arg_affinity" = "yes" ; then
816 echo "CONFIG_3ARG_AFFINITY=y" >> $config_host_mak
817 elif test "$linux_2arg_affinity" = "yes" ; then
818 echo "CONFIG_2ARG_AFFINITY=y" >> $config_host_mak
820 if test "$strsep" = "yes" ; then
821 echo "CONFIG_STRSEP=y" >> $config_host_mak
823 if test "$getopt_long_only" = "yes" ; then
824 echo "CONFIG_GETOPT_LONG_ONLY=y" >> $config_host_mak
826 if test "$inet_aton" = "yes" ; then
827 echo "CONFIG_INET_ATON=y" >> $config_host_mak
829 if test "$socklen_t" = "yes" ; then
830 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
832 if test "$ext4_me" = "yes" ; then
833 echo "CONFIG_LINUX_EXT4_MOVE_EXTENT=y" >> $config_host_mak
835 if test "$linux_splice" = "yes" ; then
836 echo "CONFIG_LINUX_SPLICE=y" >> $config_host_mak
838 if test "$guasi" = "yes" ; then
839 echo "CONFIG_GUASI=y" >> $config_host_mak
841 if test "$fusion_aw" = "yes" ; then
842 echo "CONFIG_FUSION_AW=y" >> $config_host_mak
844 if test "$libnuma" = "yes" ; then
845 echo "CONFIG_LIBNUMA=y" >> $config_host_mak
847 if test "$solaris_aio" = "yes" ; then
848 echo "CONFIG_SOLARISAIO=y" >> $config_host_mak
850 if test "$tls_thread" = "yes" ; then
851 echo "CONFIG_TLS_THREAD=y" >> $config_host_mak
854 echo "LIBS+=$LIBS" >> $config_host_mak
855 echo "CC=$cc" >> $config_host_mak