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}"
107 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
112 echo "Bad option $opt"
117 if check_define __linux__ ; then
119 elif check_define __OpenBSD__ ; then
121 elif check_define __sun__ ; then
127 # Some host OSes need non-standard checks for which CPU to use.
128 # Note that these checks are broken for cross-compilation: if you're
129 # cross-compiling to one of these OSes then you'll need to specify
130 # the correct CPU with the --cpu option.
133 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
134 # we can run 64-bit userspace code.
135 # If the user didn't specify a CPU explicitly and the kernel says this is
136 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
138 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
143 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
144 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
149 echo "Forcing known good options on Windows"
150 if test -z "$CC" ; then
151 CC="x86_64-w64-mingw32-gcc"
153 echo "CC=$CC" > $config_host_mak
154 echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
155 echo "CONFIG_64BIT_LLP64=y" >> $config_host_mak
156 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
157 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
158 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
159 echo "CONFIG_FADVISE=y" >> $config_host_mak
160 echo "CONFIG_STRSEP=y" >> $config_host_mak
161 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
162 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
163 echo "CONFIG_FADVISE=y" >> $config_host_mak
164 echo "CONFIG_SFAA=y" >> $config_host_mak
168 if test ! -z "$cpu" ; then
169 # command line argument
171 elif check_define __i386__ ; then
173 elif check_define __x86_64__ ; then
175 elif check_define __sparc__ ; then
176 if check_define __arch64__ ; then
181 elif check_define _ARCH_PPC ; then
182 if check_define _ARCH_PPC64 ; then
187 elif check_define __mips__ ; then
189 elif check_define __ia64__ ; then
191 elif check_define __s390__ ; then
192 if check_define __s390x__ ; then
197 elif check_define __arm__ ; then
199 elif check_define __hppa__ ; then
205 # Normalise host CPU name and set ARCH.
207 ia64|ppc|ppc64|s390|s390x|sparc64)
210 i386|i486|i586|i686|i86pc|BePC)
219 hppa|parisc|parisc64)
235 if test "$targetos" = "FreeBSD"; then
244 cc="${CC-${cross_prefix}gcc}"
246 ##########################################
250 #include <inttypes.h>
253 volatile uint32_t i=0x01234567;
254 return (*((uint8_t*)(&i))) == 0x67;
257 if compile_prog "" "" "endian"; then
258 $TMPE && bigendian="yes"
262 echo "Operating system $targetos"
264 echo "Big endian $bigendian"
268 ##########################################
275 unsigned int wsize = sizeof(long) * 8;
276 printf("%d\n", wsize);
280 if compile_prog "" "" "wordsize"; then
283 echo "Wordsize $wordsize"
285 ##########################################
297 if compile_prog "" "-laio" "libaio" ; then
301 if test "$libaio" = "yes" ; then
302 feature_not_found "linux AIO"
306 echo "Linux AIO support $libaio"
308 ##########################################
321 if compile_prog "" "" "posixaio" ; then
323 elif compile_prog "" "-lrt" "posixaio"; then
328 echo "POSIX AIO support $posix_aio"
329 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
331 ##########################################
332 # posix aio fsync probe
334 if test "$posix_aio" = "yes" ; then
341 return aio_fsync(O_SYNC, &cb);
345 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
349 echo "POSIX AIO fsync $posix_aio_fsync"
351 ##########################################
355 #include <sys/types.h>
356 #include <sys/asynch.h>
361 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
365 if compile_prog "" "-laio" "solarisaio" ; then
369 echo "Solaris AIO support $solaris_aio"
371 ##########################################
372 # __sync_fetch_and_and test
375 static int sfaa(int *ptr)
377 return __sync_fetch_and_and(ptr, 0);
380 int main(int argc, char **argv)
387 if compile_prog "" "" "__sync_fetch_and_add()" ; then
390 echo "__sync_fetch_and add $sfaa"
392 ##########################################
397 #include <infiniband/arch.h>
398 int main(int argc, char **argv)
400 struct ibv_pd *pd = ibv_alloc_pd(NULL);
404 if compile_prog "" "-libverbs" "libverbs" ; then
406 LIBS="-libverbs $LIBS"
408 echo "libverbs $libverbs"
410 ##########################################
415 #include <rdma/rdma_cma.h>
416 int main(int argc, char **argv)
418 rdma_destroy_qp(NULL);
422 if compile_prog "" "-lrdmacm" "rdma"; then
424 LIBS="-lrdmacm $LIBS"
426 echo "rdmacm $rdmacm"
428 ##########################################
429 # Linux fallocate probe
433 #include <linux/falloc.h>
434 int main(int argc, char **argv)
436 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
440 if compile_prog "" "" "linux_fallocate"; then
441 linux_fallocate="yes"
443 echo "Linux fallocate $linux_fallocate"
445 ##########################################
446 # POSIX fadvise probe
451 int main(int argc, char **argv)
453 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
457 if compile_prog "" "" "posix_fadvise"; then
460 echo "POSIX fadvise $posix_fadvise"
462 ##########################################
463 # POSIX fallocate probe
468 int main(int argc, char **argv)
470 int r = posix_fallocate(0, 0, 1024);
474 if compile_prog "" "" "posix_fallocate"; then
475 posix_fallocate="yes"
477 echo "POSIX fallocate $posix_fallocate"
479 ##########################################
480 # sched_set/getaffinity 2 or 3 argument test
481 linux_2arg_affinity="no"
482 linux_3arg_affinity="no"
486 int main(int argc, char **argv)
489 return sched_setaffinity(0, sizeof(mask), &mask);
492 if compile_prog "" "" "sched_setaffinity(,,)"; then
493 linux_3arg_affinity="yes"
498 int main(int argc, char **argv)
501 return sched_setaffinity(0, &mask);
504 if compile_prog "" "" "sched_setaffinity(,)"; then
505 linux_2arg_affinity="yes"
508 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
509 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
511 ##########################################
512 # clock_gettime probe
517 int main(int argc, char **argv)
519 return clock_gettime(0, NULL);
522 if compile_prog "" "" "clock_gettime"; then
524 elif compile_prog "" "-lrt" "clock_gettime"; then
528 echo "clock_gettime $clock_gettime"
530 ##########################################
531 # CLOCK_MONOTONIC probe
533 if test "$clock_gettime" = "yes" ; then
537 int main(int argc, char **argv)
539 return clock_gettime(CLOCK_MONOTONIC, NULL);
542 if compile_prog "" "$LIBS" "clock monotonic"; then
543 clock_monotonic="yes"
546 echo "CLOCK_MONOTONIC $clock_monotonic"
548 ##########################################
549 # CLOCK_MONOTONIC_PRECISE probe
550 clock_monotonic_precise="no"
551 if test "$clock_gettime" = "yes" ; then
555 int main(int argc, char **argv)
557 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
560 if compile_prog "" "$LIBS" "clock monotonic precise"; then
561 clock_monotonic_precise="yes"
564 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
566 ##########################################
567 # gettimeofday() probe
570 #include <sys/time.h>
572 int main(int argc, char **argv)
575 return gettimeofday(&tv, NULL);
578 if compile_prog "" "" "gettimeofday"; then
581 echo "gettimeofday $gettimeofday"
583 ##########################################
589 int main(int argc, char **argv)
594 if compile_prog "" "" "fdatasync"; then
597 echo "fdatasync $fdatasync"
599 ##########################################
600 # 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 ##########################################
649 int main(int argc, char **argv)
651 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
654 if compile_prog "" "" "linux splice"; then
657 echo "Linux splice(2) $linux_splice"
659 ##########################################
664 #include <guasi_syscalls.h>
665 int main(int argc, char **argv)
667 guasi_t ctx = guasi_create(0, 0, 0);
671 if compile_prog "" "" "guasi"; then
676 ##########################################
680 #include <nvm/vectored_write.h>
681 int main(int argc, char **argv)
683 struct vsl_iovec iov;
684 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
687 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
688 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
691 echo "Fusion-io atomic engine $fusion_aw"
693 ##########################################
698 int main(int argc, char **argv)
700 return numa_available();
703 if compile_prog "" "-lnuma" "libnuma"; then
707 echo "libnuma $libnuma"
709 ##########################################
714 int main(int argc, char **argv)
720 if compile_prog "" "" "strsep"; then
723 echo "strsep $strsep"
725 ##########################################
726 # getopt_long_only() probe
727 getopt_long_only="no"
731 int main(int argc, char **argv)
733 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
737 if compile_prog "" "" "getopt_long_only"; then
738 getopt_long_only="yes"
740 echo "getopt_long_only() $getopt_long_only"
742 ##########################################
746 #include <sys/socket.h>
747 #include <arpa/inet.h>
749 int main(int argc, char **argv)
752 return inet_aton(NULL, &in);
755 if compile_prog "" "" "inet_aton"; then
758 echo "inet_aton $inet_aton"
760 ##########################################
765 #include <netinet/in.h>
766 int main(int argc, char **argv)
772 if compile_prog "" "" "socklen_t"; then
775 echo "socklen_t $socklen_t"
777 ##########################################
778 # Whether or not __thread is supported for TLS
782 static int __thread ret;
783 int main(int argc, char **argv)
788 if compile_prog "" "" "__thread"; then
791 echo "__thread $tls_thread"
793 #############################################################################
795 echo "# Automatically generated by configure - do not modify" > $config_host_mak
796 printf "# Configured with:" >> $config_host_mak
797 printf " '%s'" "$0" "$@" >> $config_host_mak
798 echo >> $config_host_mak
800 if test "$wordsize" = "64" ; then
801 echo "CONFIG_64BIT=y" >> $config_host_mak
802 elif test "$wordsize" = "32" ; then
803 echo "CONFIG_32BIT=y" >> $config_host_mak
805 echo "Unknown wordsize!"
808 if test "$bigendian" = "yes" ; then
809 echo "CONFIG_BIG_ENDIAN=y" >> $config_host_mak
811 echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
813 if test "$libaio" = "yes" ; then
814 echo "CONFIG_LIBAIO=y" >> $config_host_mak
816 if test "$posix_aio" = "yes" ; then
817 echo "CONFIG_POSIXAIO=y" >> $config_host_mak
819 if test "$posix_aio_fsync" = "yes" ; then
820 echo "CONFIG_POSIXAIO_FSYNC=y" >> $config_host_mak
822 if test "$linux_fallocate" = "yes" ; then
823 echo "CONFIG_LINUX_FALLOCATE=y" >> $config_host_mak
825 if test "$posix_fallocate" = "yes" ; then
826 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
828 if test "$fdatasync" = "yes" ; then
829 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
831 if test "$sync_file_range" = "yes" ; then
832 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
834 if test "$sfaa" = "yes" ; then
835 echo "CONFIG_SFAA=y" >> $config_host_mak
837 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
838 echo "CONFIG_RDMA=y" >> $config_host_mak
840 if test "$clock_gettime" = "yes" ; then
841 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
843 if test "$clock_monotonic" = "yes" ; then
844 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
846 if test "$clock_monotonic_precise" = "yes" ; then
847 echo "CONFIG_CLOCK_MONOTONIC_PRECISE=y" >> $config_host_mak
849 if test "$gettimeofday" = "yes" ; then
850 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
852 if test "$posix_fadvise" = "yes" ; then
853 echo "CONFIG_POSIX_FADVISE=y" >> $config_host_mak
855 if test "$linux_3arg_affinity" = "yes" ; then
856 echo "CONFIG_3ARG_AFFINITY=y" >> $config_host_mak
857 elif test "$linux_2arg_affinity" = "yes" ; then
858 echo "CONFIG_2ARG_AFFINITY=y" >> $config_host_mak
860 if test "$strsep" = "yes" ; then
861 echo "CONFIG_STRSEP=y" >> $config_host_mak
863 if test "$getopt_long_only" = "yes" ; then
864 echo "CONFIG_GETOPT_LONG_ONLY=y" >> $config_host_mak
866 if test "$inet_aton" = "yes" ; then
867 echo "CONFIG_INET_ATON=y" >> $config_host_mak
869 if test "$socklen_t" = "yes" ; then
870 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
872 if test "$ext4_me" = "yes" ; then
873 echo "CONFIG_LINUX_EXT4_MOVE_EXTENT=y" >> $config_host_mak
875 if test "$linux_splice" = "yes" ; then
876 echo "CONFIG_LINUX_SPLICE=y" >> $config_host_mak
878 if test "$guasi" = "yes" ; then
879 echo "CONFIG_GUASI=y" >> $config_host_mak
881 if test "$fusion_aw" = "yes" ; then
882 echo "CONFIG_FUSION_AW=y" >> $config_host_mak
884 if test "$libnuma" = "yes" ; then
885 echo "CONFIG_LIBNUMA=y" >> $config_host_mak
887 if test "$solaris_aio" = "yes" ; then
888 echo "CONFIG_SOLARISAIO=y" >> $config_host_mak
890 if test "$tls_thread" = "yes" ; then
891 echo "CONFIG_TLS_THREAD=y" >> $config_host_mak
894 echo "LIBS+=$LIBS" >> $config_host_mak
895 echo "CC=$cc" >> $config_host_mak