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 output_sym "CONFIG_SCHED_IDLE"
204 output_sym "CONFIG_TCP_NODELAY"
205 echo "CC=$CC" >> $config_host_mak
206 echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
210 if test ! -z "$cpu" ; then
211 # command line argument
213 elif check_define __i386__ ; then
215 elif check_define __x86_64__ ; then
217 elif check_define __sparc__ ; then
218 if check_define __arch64__ ; then
223 elif check_define _ARCH_PPC ; then
224 if check_define _ARCH_PPC64 ; then
229 elif check_define __mips__ ; then
231 elif check_define __ia64__ ; then
233 elif check_define __s390__ ; then
234 if check_define __s390x__ ; then
239 elif check_define __arm__ ; then
241 elif check_define __hppa__ ; then
247 # Normalise host CPU name and set ARCH.
249 ia64|ppc|ppc64|s390|s390x|sparc64)
252 i386|i486|i586|i686|i86pc|BePC)
261 hppa|parisc|parisc64)
276 if test -z "$CC" ; then
277 if test "$targetos" = "FreeBSD"; then
286 cc="${CC-${cross_prefix}gcc}"
288 ##########################################
292 #include <inttypes.h>
295 volatile uint32_t i=0x01234567;
296 return (*((uint8_t*)(&i))) == 0x67;
299 if compile_prog "" "" "endian"; then
300 $TMPE && bigendian="yes"
304 echo "Operating system $targetos"
306 echo "Big endian $bigendian"
310 ##########################################
317 unsigned int wsize = sizeof(long) * 8;
318 printf("%d\n", wsize);
322 if compile_prog "" "" "wordsize"; then
325 echo "Wordsize $wordsize"
327 ##########################################
339 if compile_prog "" "-laio" "libaio" ; then
343 if test "$libaio" = "yes" ; then
344 feature_not_found "linux AIO"
348 echo "Linux AIO support $libaio"
350 ##########################################
363 if compile_prog "" "" "posixaio" ; then
365 elif compile_prog "" "-lrt" "posixaio"; then
370 echo "POSIX AIO support $posix_aio"
371 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
373 ##########################################
374 # posix aio fsync probe
376 if test "$posix_aio" = "yes" ; then
383 return aio_fsync(O_SYNC, &cb);
387 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
391 echo "POSIX AIO fsync $posix_aio_fsync"
393 ##########################################
397 #include <sys/types.h>
398 #include <sys/asynch.h>
403 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
407 if compile_prog "" "-laio" "solarisaio" ; then
411 echo "Solaris AIO support $solaris_aio"
413 ##########################################
414 # __sync_fetch_and_and test
417 static int sfaa(int *ptr)
419 return __sync_fetch_and_and(ptr, 0);
422 int main(int argc, char **argv)
429 if compile_prog "" "" "__sync_fetch_and_add()" ; then
432 echo "__sync_fetch_and add $sfaa"
434 ##########################################
439 #include <infiniband/arch.h>
440 int main(int argc, char **argv)
442 struct ibv_pd *pd = ibv_alloc_pd(NULL);
446 if compile_prog "" "-libverbs" "libverbs" ; then
448 LIBS="-libverbs $LIBS"
450 echo "libverbs $libverbs"
452 ##########################################
457 #include <rdma/rdma_cma.h>
458 int main(int argc, char **argv)
460 rdma_destroy_qp(NULL);
464 if compile_prog "" "-lrdmacm" "rdma"; then
466 LIBS="-lrdmacm $LIBS"
468 echo "rdmacm $rdmacm"
470 ##########################################
471 # Linux fallocate probe
475 #include <linux/falloc.h>
476 int main(int argc, char **argv)
478 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
482 if compile_prog "" "" "linux_fallocate"; then
483 linux_fallocate="yes"
485 echo "Linux fallocate $linux_fallocate"
487 ##########################################
488 # POSIX fadvise probe
493 int main(int argc, char **argv)
495 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
499 if compile_prog "" "" "posix_fadvise"; then
502 echo "POSIX fadvise $posix_fadvise"
504 ##########################################
505 # POSIX fallocate probe
510 int main(int argc, char **argv)
512 int r = posix_fallocate(0, 0, 1024);
516 if compile_prog "" "" "posix_fallocate"; then
517 posix_fallocate="yes"
519 echo "POSIX fallocate $posix_fallocate"
521 ##########################################
522 # sched_set/getaffinity 2 or 3 argument test
523 linux_2arg_affinity="no"
524 linux_3arg_affinity="no"
527 int main(int argc, char **argv)
530 return sched_setaffinity(0, sizeof(mask), &mask);
533 if compile_prog "" "" "sched_setaffinity(,,)"; then
534 linux_3arg_affinity="yes"
538 int main(int argc, char **argv)
541 return sched_setaffinity(0, &mask);
544 if compile_prog "" "" "sched_setaffinity(,)"; then
545 linux_2arg_affinity="yes"
548 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
549 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
551 ##########################################
552 # clock_gettime probe
557 int main(int argc, char **argv)
559 return clock_gettime(0, NULL);
562 if compile_prog "" "" "clock_gettime"; then
564 elif compile_prog "" "-lrt" "clock_gettime"; then
568 echo "clock_gettime $clock_gettime"
570 ##########################################
571 # CLOCK_MONOTONIC probe
573 if test "$clock_gettime" = "yes" ; then
577 int main(int argc, char **argv)
579 return clock_gettime(CLOCK_MONOTONIC, NULL);
582 if compile_prog "" "$LIBS" "clock monotonic"; then
583 clock_monotonic="yes"
586 echo "CLOCK_MONOTONIC $clock_monotonic"
588 ##########################################
589 # CLOCK_MONOTONIC_PRECISE probe
590 clock_monotonic_precise="no"
591 if test "$clock_gettime" = "yes" ; then
595 int main(int argc, char **argv)
597 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
600 if compile_prog "" "$LIBS" "clock monotonic precise"; then
601 clock_monotonic_precise="yes"
604 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
606 ##########################################
607 # gettimeofday() probe
610 #include <sys/time.h>
612 int main(int argc, char **argv)
615 return gettimeofday(&tv, NULL);
618 if compile_prog "" "" "gettimeofday"; then
621 echo "gettimeofday $gettimeofday"
623 ##########################################
629 int main(int argc, char **argv)
634 if compile_prog "" "" "fdatasync"; then
637 echo "fdatasync $fdatasync"
639 ##########################################
640 # sync_file_range() probe
646 #include <linux/fs.h>
647 int main(int argc, char **argv)
649 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
650 SYNC_FILE_RANGE_WAIT_AFTER;
651 return sync_file_range(0, 0, 0, flags);
654 if compile_prog "" "" "sync_file_range"; then
655 sync_file_range="yes"
657 echo "sync_file_range $sync_file_range"
659 ##########################################
660 # ext4 move extent probe
664 #include <sys/ioctl.h>
665 int main(int argc, char **argv)
667 struct move_extent me;
668 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
671 if compile_prog "" "" "ext4 move extent" ; then
673 elif test $targetos = "Linux" ; then
674 # On Linux, just default to it on and let it error at runtime if we really
675 # don't have it. None of my updated systems have it defined, but it does
676 # work. Takes a while to bubble back.
679 echo "EXT4 move extent $ext4_me"
681 ##########################################
687 int main(int argc, char **argv)
689 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
692 if compile_prog "" "" "linux splice"; then
695 echo "Linux splice(2) $linux_splice"
697 ##########################################
702 #include <guasi_syscalls.h>
703 int main(int argc, char **argv)
705 guasi_t ctx = guasi_create(0, 0, 0);
709 if compile_prog "" "" "guasi"; then
714 ##########################################
718 #include <nvm/vectored_write.h>
719 int main(int argc, char **argv)
721 struct vsl_iovec iov;
722 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
725 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
726 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
729 echo "Fusion-io atomic engine $fusion_aw"
731 ##########################################
736 int main(int argc, char **argv)
738 return numa_available();
741 if compile_prog "" "-lnuma" "libnuma"; then
745 echo "libnuma $libnuma"
747 ##########################################
752 int main(int argc, char **argv)
758 if compile_prog "" "" "strsep"; then
761 echo "strsep $strsep"
763 ##########################################
764 # getopt_long_only() probe
765 getopt_long_only="no"
769 int main(int argc, char **argv)
771 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
775 if compile_prog "" "" "getopt_long_only"; then
776 getopt_long_only="yes"
778 echo "getopt_long_only() $getopt_long_only"
780 ##########################################
784 #include <sys/socket.h>
785 #include <arpa/inet.h>
787 int main(int argc, char **argv)
790 return inet_aton(NULL, &in);
793 if compile_prog "" "" "inet_aton"; then
796 echo "inet_aton $inet_aton"
798 ##########################################
803 #include <netinet/in.h>
804 int main(int argc, char **argv)
810 if compile_prog "" "" "socklen_t"; then
813 echo "socklen_t $socklen_t"
815 ##########################################
816 # Whether or not __thread is supported for TLS
820 static int __thread ret;
821 int main(int argc, char **argv)
826 if compile_prog "" "" "__thread"; then
829 echo "__thread $tls_thread"
831 ##########################################
832 # Check whether we have getrusage(RUSAGE_THREAD)
835 #include <sys/time.h>
836 #include <sys/resource.h>
837 int main(int argc, char **argv)
840 getrusage(RUSAGE_THREAD, &ru);
844 if compile_prog "" "" "RUSAGE_THREAD"; then
847 echo "RUSAGE_THREAD $rusage_thread"
849 ##########################################
850 # Check whether we have SCHED_IDLE
854 int main(int argc, char **argv)
856 struct sched_param p;
857 return sched_setscheduler(0, SCHED_IDLE, &p);
860 if compile_prog "" "" "SCHED_IDLE"; then
863 echo "SCHED_IDLE $sched_idle"
865 ##########################################
866 # Check whether we have TCP_NODELAY
870 #include <sys/types.h>
871 #include <sys/socket.h>
872 #include <netinet/tcp.h>
873 int main(int argc, char **argv)
875 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
878 if compile_prog "" "" "TCP_NODELAY"; then
881 echo "TCP_NODELAY $tcp_nodelay"
883 #############################################################################
885 echo "# Automatically generated by configure - do not modify" > $config_host_mak
886 printf "# Configured with:" >> $config_host_mak
887 printf " '%s'" "$0" "$@" >> $config_host_mak
888 echo >> $config_host_mak
890 if test "$wordsize" = "64" ; then
891 output_sym "CONFIG_64BIT"
892 elif test "$wordsize" = "32" ; then
893 output_sym "CONFIG_32BIT"
895 echo "Unknown wordsize!"
898 if test "$bigendian" = "yes" ; then
899 output_sym "CONFIG_BIG_ENDIAN"
901 output_sym "CONFIG_LITTLE_ENDIAN"
903 if test "$libaio" = "yes" ; then
904 output_sym "CONFIG_LIBAIO"
906 if test "$posix_aio" = "yes" ; then
907 output_sym "CONFIG_POSIXAIO"
909 if test "$posix_aio_fsync" = "yes" ; then
910 output_sym "CONFIG_POSIXAIO_FSYNC"
912 if test "$linux_fallocate" = "yes" ; then
913 output_sym "CONFIG_LINUX_FALLOCATE"
915 if test "$posix_fallocate" = "yes" ; then
916 output_sym "CONFIG_POSIX_FALLOCATE"
918 if test "$fdatasync" = "yes" ; then
919 output_sym "CONFIG_FDATASYNC"
921 if test "$sync_file_range" = "yes" ; then
922 output_sym "CONFIG_SYNC_FILE_RANGE"
924 if test "$sfaa" = "yes" ; then
925 output_sym "CONFIG_SFAA"
927 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
928 output_sym "CONFIG_RDMA"
930 if test "$clock_gettime" = "yes" ; then
931 output_sym "CONFIG_CLOCK_GETTIME"
933 if test "$clock_monotonic" = "yes" ; then
934 output_sym "CONFIG_CLOCK_MONOTONIC"
936 if test "$clock_monotonic_precise" = "yes" ; then
937 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
939 if test "$gettimeofday" = "yes" ; then
940 output_sym "CONFIG_GETTIMEOFDAY"
942 if test "$posix_fadvise" = "yes" ; then
943 output_sym "CONFIG_POSIX_FADVISE"
945 if test "$linux_3arg_affinity" = "yes" ; then
946 output_sym "CONFIG_3ARG_AFFINITY"
947 elif test "$linux_2arg_affinity" = "yes" ; then
948 output_sym "CONFIG_2ARG_AFFINITY"
950 if test "$strsep" = "yes" ; then
951 output_sym "CONFIG_STRSEP"
953 if test "$getopt_long_only" = "yes" ; then
954 output_sym "CONFIG_GETOPT_LONG_ONLY"
956 if test "$inet_aton" = "yes" ; then
957 output_sym "CONFIG_INET_ATON"
959 if test "$socklen_t" = "yes" ; then
960 output_sym "CONFIG_SOCKLEN_T"
962 if test "$ext4_me" = "yes" ; then
963 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
965 if test "$linux_splice" = "yes" ; then
966 output_sym "CONFIG_LINUX_SPLICE"
968 if test "$guasi" = "yes" ; then
969 output_sym "CONFIG_GUASI"
971 if test "$fusion_aw" = "yes" ; then
972 output_sym "CONFIG_FUSION_AW"
974 if test "$libnuma" = "yes" ; then
975 output_sym "CONFIG_LIBNUMA"
977 if test "$solaris_aio" = "yes" ; then
978 output_sym "CONFIG_SOLARISAIO"
980 if test "$tls_thread" = "yes" ; then
981 output_sym "CONFIG_TLS_THREAD"
983 if test "$rusage_thread" = "yes" ; then
984 output_sym "CONFIG_RUSAGE_THREAD"
986 if test "$sched_idle" = "yes" ; then
987 output_sym "CONFIG_SCHED_IDLE"
989 if test "$tcp_nodelay" = "yes" ; then
990 output_sym "CONFIG_TCP_NODELAY"
993 echo "LIBS+=$LIBS" >> $config_host_mak
994 echo "CC=$cc" >> $config_host_mak
995 echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak