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
33 CFLAGS="-D_GNU_SOURCE"
34 EXTFLAGS="-include config-host.h"
36 # Print a helpful header at the top of config.log
37 echo "# FIO configure log $(date)" >> config.log
38 printf "# Configured with:" >> config.log
39 printf " '%s'" "$0" "$@" >> config.log
41 echo "#" >> config.log
43 # Print configure header at the top of $config_host_h
44 echo "/*" > $config_host_h
45 echo " * Automatically generated by configure - do not modify" >> $config_host_h
46 printf " * Configured with:" >> $config_host_h
47 printf " * '%s'" "$0" "$@" >> $config_host_h
48 echo "" >> $config_host_h
49 echo " */" >> $config_host_h
52 # Run the compiler, capturing its output to the log.
53 echo $cc "$@" >> config.log
54 $cc "$@" >> config.log 2>&1 || return $?
55 # Test passed. If this is an --enable-werror build, rerun
56 # the test with -Werror and bail out if it fails. This
57 # makes warning-generating-errors in configure test code
58 # obvious to developers.
59 if test "$werror" != "yes"; then
62 # Don't bother rerunning the compile if we were already using -Werror
68 echo $cc -Werror "$@" >> config.log
69 $cc -Werror "$@" >> config.log 2>&1 && return $?
70 echo "ERROR: configure test passed without -Werror but failed with -Werror."
71 echo "This is probably a bug in the configure script. The failing command"
72 echo "will be at the bottom of config.log."
73 echo "You can run configure with --disable-werror to bypass this check."
78 do_cc $CFLAGS -c -o $TMPO $TMPC
84 echo "Compiling test case $3" >> config.log
85 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
92 echo "ERROR: User requested feature $feature"
93 echo "ERROR: configure was not able to find it"
99 type "$1" >/dev/null 2>&1
105 #error $1 not defined
116 echo "$1=y" >> $config_host_mak
117 echo "#define $1" >> $config_host_h
123 cc="${CC-${cross_prefix}gcc}"
130 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
134 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
140 echo "Bad option $opt"
146 if test "$show_help" = "yes" ; then
147 echo "--cc= Specify compiler to use"
148 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
152 if check_define __linux__ ; then
154 elif check_define __OpenBSD__ ; then
156 elif check_define __sun__ ; then
162 # Some host OSes need non-standard checks for which CPU to use.
163 # Note that these checks are broken for cross-compilation: if you're
164 # cross-compiling to one of these OSes then you'll need to specify
165 # the correct CPU with the --cpu option.
168 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
169 # we can run 64-bit userspace code.
170 # If the user didn't specify a CPU explicitly and the kernel says this is
171 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
173 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
178 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
179 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
184 echo "Forcing known good options on Windows"
185 if test -z "$CC" ; then
186 CC="x86_64-w64-mingw32-gcc"
188 output_sym "CONFIG_LITTLE_ENDIAN"
189 output_sym "CONFIG_64BIT_LLP64"
190 output_sym "CONFIG_CLOCK_GETTIME"
191 output_sym "CONFIG_CLOCK_MONOTONIC"
192 output_sym "CONFIG_GETTIMEOFDAY"
193 output_sym "CONFIG_FADVISE"
194 output_sym "CONFIG_SOCKLEN_T"
195 output_sym "CONFIG_POSIX_FALLOCATE"
196 output_sym "CONFIG_FADVISE"
197 output_sym "CONFIG_SFAA"
198 output_sym "CONFIG_RUSAGE_THREAD"
199 output_sym "CONFIG_WINDOWSAIO"
200 output_sym "CONFIG_FDATASYNC"
201 output_sym "CONFIG_GETTIMEOFDAY"
202 output_sym "CONFIG_CLOCK_GETTIME"
203 echo "CC=$CC" >> $config_host_mak
204 echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
208 if test ! -z "$cpu" ; then
209 # command line argument
211 elif check_define __i386__ ; then
213 elif check_define __x86_64__ ; then
215 elif check_define __sparc__ ; then
216 if check_define __arch64__ ; then
221 elif check_define _ARCH_PPC ; then
222 if check_define _ARCH_PPC64 ; then
227 elif check_define __mips__ ; then
229 elif check_define __ia64__ ; then
231 elif check_define __s390__ ; then
232 if check_define __s390x__ ; then
237 elif check_define __arm__ ; then
239 elif check_define __hppa__ ; then
245 # Normalise host CPU name and set ARCH.
247 ia64|ppc|ppc64|s390|s390x|sparc64)
250 i386|i486|i586|i686|i86pc|BePC)
259 hppa|parisc|parisc64)
274 if test -z "$CC" ; then
275 if test "$targetos" = "FreeBSD"; then
284 cc="${CC-${cross_prefix}gcc}"
286 ##########################################
290 #include <inttypes.h>
293 volatile uint32_t i=0x01234567;
294 return (*((uint8_t*)(&i))) == 0x67;
297 if compile_prog "" "" "endian"; then
298 $TMPE && bigendian="yes"
302 echo "Operating system $targetos"
304 echo "Big endian $bigendian"
308 ##########################################
315 unsigned int wsize = sizeof(long) * 8;
316 printf("%d\n", wsize);
320 if compile_prog "" "" "wordsize"; then
323 echo "Wordsize $wordsize"
325 ##########################################
337 if compile_prog "" "-laio" "libaio" ; then
341 if test "$libaio" = "yes" ; then
342 feature_not_found "linux AIO"
346 echo "Linux AIO support $libaio"
348 ##########################################
361 if compile_prog "" "" "posixaio" ; then
363 elif compile_prog "" "-lrt" "posixaio"; then
368 echo "POSIX AIO support $posix_aio"
369 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
371 ##########################################
372 # posix aio fsync probe
374 if test "$posix_aio" = "yes" ; then
381 return aio_fsync(O_SYNC, &cb);
385 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
389 echo "POSIX AIO fsync $posix_aio_fsync"
391 ##########################################
395 #include <sys/types.h>
396 #include <sys/asynch.h>
401 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
405 if compile_prog "" "-laio" "solarisaio" ; then
409 echo "Solaris AIO support $solaris_aio"
411 ##########################################
412 # __sync_fetch_and_and test
415 static int sfaa(int *ptr)
417 return __sync_fetch_and_and(ptr, 0);
420 int main(int argc, char **argv)
427 if compile_prog "" "" "__sync_fetch_and_add()" ; then
430 echo "__sync_fetch_and add $sfaa"
432 ##########################################
437 #include <infiniband/arch.h>
438 int main(int argc, char **argv)
440 struct ibv_pd *pd = ibv_alloc_pd(NULL);
444 if compile_prog "" "-libverbs" "libverbs" ; then
446 LIBS="-libverbs $LIBS"
448 echo "libverbs $libverbs"
450 ##########################################
455 #include <rdma/rdma_cma.h>
456 int main(int argc, char **argv)
458 rdma_destroy_qp(NULL);
462 if compile_prog "" "-lrdmacm" "rdma"; then
464 LIBS="-lrdmacm $LIBS"
466 echo "rdmacm $rdmacm"
468 ##########################################
469 # Linux fallocate probe
473 #include <linux/falloc.h>
474 int main(int argc, char **argv)
476 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
480 if compile_prog "" "" "linux_fallocate"; then
481 linux_fallocate="yes"
483 echo "Linux fallocate $linux_fallocate"
485 ##########################################
486 # POSIX fadvise probe
491 int main(int argc, char **argv)
493 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
497 if compile_prog "" "" "posix_fadvise"; then
500 echo "POSIX fadvise $posix_fadvise"
502 ##########################################
503 # POSIX fallocate probe
508 int main(int argc, char **argv)
510 int r = posix_fallocate(0, 0, 1024);
514 if compile_prog "" "" "posix_fallocate"; then
515 posix_fallocate="yes"
517 echo "POSIX fallocate $posix_fallocate"
519 ##########################################
520 # sched_set/getaffinity 2 or 3 argument test
521 linux_2arg_affinity="no"
522 linux_3arg_affinity="no"
525 int main(int argc, char **argv)
528 return sched_setaffinity(0, sizeof(mask), &mask);
531 if compile_prog "" "" "sched_setaffinity(,,)"; then
532 linux_3arg_affinity="yes"
536 int main(int argc, char **argv)
539 return sched_setaffinity(0, &mask);
542 if compile_prog "" "" "sched_setaffinity(,)"; then
543 linux_2arg_affinity="yes"
546 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
547 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
549 ##########################################
550 # clock_gettime probe
555 int main(int argc, char **argv)
557 return clock_gettime(0, NULL);
560 if compile_prog "" "" "clock_gettime"; then
562 elif compile_prog "" "-lrt" "clock_gettime"; then
566 echo "clock_gettime $clock_gettime"
568 ##########################################
569 # CLOCK_MONOTONIC probe
571 if test "$clock_gettime" = "yes" ; then
575 int main(int argc, char **argv)
577 return clock_gettime(CLOCK_MONOTONIC, NULL);
580 if compile_prog "" "$LIBS" "clock monotonic"; then
581 clock_monotonic="yes"
584 echo "CLOCK_MONOTONIC $clock_monotonic"
586 ##########################################
587 # CLOCK_MONOTONIC_PRECISE probe
588 clock_monotonic_precise="no"
589 if test "$clock_gettime" = "yes" ; then
593 int main(int argc, char **argv)
595 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
598 if compile_prog "" "$LIBS" "clock monotonic precise"; then
599 clock_monotonic_precise="yes"
602 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
604 ##########################################
605 # gettimeofday() probe
608 #include <sys/time.h>
610 int main(int argc, char **argv)
613 return gettimeofday(&tv, NULL);
616 if compile_prog "" "" "gettimeofday"; then
619 echo "gettimeofday $gettimeofday"
621 ##########################################
627 int main(int argc, char **argv)
632 if compile_prog "" "" "fdatasync"; then
635 echo "fdatasync $fdatasync"
637 ##########################################
638 # sync_file_range() probe
644 #include <linux/fs.h>
645 int main(int argc, char **argv)
647 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
648 SYNC_FILE_RANGE_WAIT_AFTER;
649 return sync_file_range(0, 0, 0, flags);
652 if compile_prog "" "" "sync_file_range"; then
653 sync_file_range="yes"
655 echo "sync_file_range $sync_file_range"
657 ##########################################
658 # ext4 move extent probe
662 #include <sys/ioctl.h>
663 int main(int argc, char **argv)
665 struct move_extent me;
666 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
669 if compile_prog "" "" "ext4 move extent" ; then
671 elif test $targetos = "Linux" ; then
672 # On Linux, just default to it on and let it error at runtime if we really
673 # don't have it. None of my updated systems have it defined, but it does
674 # work. Takes a while to bubble back.
677 echo "EXT4 move extent $ext4_me"
679 ##########################################
685 int main(int argc, char **argv)
687 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
690 if compile_prog "" "" "linux splice"; then
693 echo "Linux splice(2) $linux_splice"
695 ##########################################
700 #include <guasi_syscalls.h>
701 int main(int argc, char **argv)
703 guasi_t ctx = guasi_create(0, 0, 0);
707 if compile_prog "" "" "guasi"; then
712 ##########################################
716 #include <nvm/vectored_write.h>
717 int main(int argc, char **argv)
719 struct vsl_iovec iov;
720 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
723 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
724 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
727 echo "Fusion-io atomic engine $fusion_aw"
729 ##########################################
734 int main(int argc, char **argv)
736 return numa_available();
739 if compile_prog "" "-lnuma" "libnuma"; then
743 echo "libnuma $libnuma"
745 ##########################################
750 int main(int argc, char **argv)
756 if compile_prog "" "" "strsep"; then
759 echo "strsep $strsep"
761 ##########################################
762 # getopt_long_only() probe
763 getopt_long_only="no"
767 int main(int argc, char **argv)
769 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
773 if compile_prog "" "" "getopt_long_only"; then
774 getopt_long_only="yes"
776 echo "getopt_long_only() $getopt_long_only"
778 ##########################################
782 #include <sys/socket.h>
783 #include <arpa/inet.h>
785 int main(int argc, char **argv)
788 return inet_aton(NULL, &in);
791 if compile_prog "" "" "inet_aton"; then
794 echo "inet_aton $inet_aton"
796 ##########################################
801 #include <netinet/in.h>
802 int main(int argc, char **argv)
808 if compile_prog "" "" "socklen_t"; then
811 echo "socklen_t $socklen_t"
813 ##########################################
814 # Whether or not __thread is supported for TLS
818 static int __thread ret;
819 int main(int argc, char **argv)
824 if compile_prog "" "" "__thread"; then
827 echo "__thread $tls_thread"
829 ##########################################
830 # Check whether we have getrusage(RUSAGE_THREAD)
833 #include <sys/time.h>
834 #include <sys/resource.h>
835 int main(int argc, char **argv)
838 getrusage(RUSAGE_THREAD, &ru);
842 if compile_prog "" "" "RUSAGE_THREAD"; then
845 echo "RUSAGE_THREAD $rusage_thread"
847 #############################################################################
849 echo "# Automatically generated by configure - do not modify" > $config_host_mak
850 printf "# Configured with:" >> $config_host_mak
851 printf " '%s'" "$0" "$@" >> $config_host_mak
852 echo >> $config_host_mak
854 if test "$wordsize" = "64" ; then
855 output_sym "CONFIG_64BIT"
856 elif test "$wordsize" = "32" ; then
857 output_sym "CONFIG_32BIT"
859 echo "Unknown wordsize!"
862 if test "$bigendian" = "yes" ; then
863 output_sym "CONFIG_BIG_ENDIAN"
865 output_sym "CONFIG_LITTLE_ENDIAN"
867 if test "$libaio" = "yes" ; then
868 output_sym "CONFIG_LIBAIO"
870 if test "$posix_aio" = "yes" ; then
871 output_sym "CONFIG_POSIXAIO"
873 if test "$posix_aio_fsync" = "yes" ; then
874 output_sym "CONFIG_POSIXAIO_FSYNC"
876 if test "$linux_fallocate" = "yes" ; then
877 output_sym "CONFIG_LINUX_FALLOCATE"
879 if test "$posix_fallocate" = "yes" ; then
880 output_sym "CONFIG_POSIX_FALLOCATE"
882 if test "$fdatasync" = "yes" ; then
883 output_sym "CONFIG_FDATASYNC"
885 if test "$sync_file_range" = "yes" ; then
886 output_sym "CONFIG_SYNC_FILE_RANGE"
888 if test "$sfaa" = "yes" ; then
889 output_sym "CONFIG_SFAA"
891 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
892 output_sym "CONFIG_RDMA"
894 if test "$clock_gettime" = "yes" ; then
895 output_sym "CONFIG_CLOCK_GETTIME"
897 if test "$clock_monotonic" = "yes" ; then
898 output_sym "CONFIG_CLOCK_MONOTONIC"
900 if test "$clock_monotonic_precise" = "yes" ; then
901 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
903 if test "$gettimeofday" = "yes" ; then
904 output_sym "CONFIG_GETTIMEOFDAY"
906 if test "$posix_fadvise" = "yes" ; then
907 output_sym "CONFIG_POSIX_FADVISE"
909 if test "$linux_3arg_affinity" = "yes" ; then
910 output_sym "CONFIG_3ARG_AFFINITY"
911 elif test "$linux_2arg_affinity" = "yes" ; then
912 output_sym "CONFIG_2ARG_AFFINITY"
914 if test "$strsep" = "yes" ; then
915 output_sym "CONFIG_STRSEP"
917 if test "$getopt_long_only" = "yes" ; then
918 output_sym "CONFIG_GETOPT_LONG_ONLY"
920 if test "$inet_aton" = "yes" ; then
921 output_sym "CONFIG_INET_ATON"
923 if test "$socklen_t" = "yes" ; then
924 output_sym "CONFIG_SOCKLEN_T"
926 if test "$ext4_me" = "yes" ; then
927 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
929 if test "$linux_splice" = "yes" ; then
930 output_sym "CONFIG_LINUX_SPLICE"
932 if test "$guasi" = "yes" ; then
933 output_sym "CONFIG_GUASI"
935 if test "$fusion_aw" = "yes" ; then
936 output_sym "CONFIG_FUSION_AW"
938 if test "$libnuma" = "yes" ; then
939 output_sym "CONFIG_LIBNUMA"
941 if test "$solaris_aio" = "yes" ; then
942 output_sym "CONFIG_SOLARISAIO"
944 if test "$tls_thread" = "yes" ; then
945 output_sym "CONFIG_TLS_THREAD"
947 if test "$rusage_thread" = "yes" ; then
948 output_sym "CONFIG_RUSAGE_THREAD"
951 echo "LIBS+=$LIBS" >> $config_host_mak
952 echo "CC=$cc" >> $config_host_mak
953 echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak