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 EXTFLAGS="-include config-host.h -D_GNU_SOURCE"
35 # Print a helpful header at the top of config.log
36 echo "# FIO configure log $(date)" >> config.log
37 printf "# Configured with:" >> config.log
38 printf " '%s'" "$0" "$@" >> config.log
40 echo "#" >> config.log
43 # Run the compiler, capturing its output to the log.
44 echo $cc "$@" >> config.log
45 $cc "$@" >> config.log 2>&1 || return $?
46 # Test passed. If this is an --enable-werror build, rerun
47 # the test with -Werror and bail out if it fails. This
48 # makes warning-generating-errors in configure test code
49 # obvious to developers.
50 if test "$werror" != "yes"; then
53 # Don't bother rerunning the compile if we were already using -Werror
59 echo $cc -Werror "$@" >> config.log
60 $cc -Werror "$@" >> config.log 2>&1 && return $?
61 echo "ERROR: configure test passed without -Werror but failed with -Werror."
62 echo "This is probably a bug in the configure script. The failing command"
63 echo "will be at the bottom of config.log."
64 echo "You can run configure with --disable-werror to bypass this check."
69 do_cc $CFLAGS -c -o $TMPO $TMPC
75 echo "Compiling test case $3" >> config.log
76 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
83 echo "ERROR: User requested feature $feature"
84 echo "ERROR: configure was not able to find it"
90 type "$1" >/dev/null 2>&1
107 echo "$1=y" >> $config_host_mak
108 echo "#define $1" >> $config_host_h
114 cc="${CC-${cross_prefix}gcc}"
118 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
123 echo "Bad option $opt"
128 if check_define __linux__ ; then
130 elif check_define __OpenBSD__ ; then
132 elif check_define __sun__ ; then
138 # Some host OSes need non-standard checks for which CPU to use.
139 # Note that these checks are broken for cross-compilation: if you're
140 # cross-compiling to one of these OSes then you'll need to specify
141 # the correct CPU with the --cpu option.
144 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
145 # we can run 64-bit userspace code.
146 # If the user didn't specify a CPU explicitly and the kernel says this is
147 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
149 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
154 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
155 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
160 echo "Forcing known good options on Windows"
161 if test -z "$CC" ; then
162 CC="x86_64-w64-mingw32-gcc"
164 output_sym "CONFIG_LITTLE_ENDIAN"
165 output_sym "CONFIG_64BIT_LLP64"
166 output_sym "CONFIG_CLOCK_GETTIME"
167 output_sym "CONFIG_CLOCK_MONOTONIC"
168 output_sym "CONFIG_GETTIMEOFDAY"
169 output_sym "CONFIG_FADVISE"
170 output_sym "CONFIG_SOCKLEN_T"
171 output_sym "CONFIG_POSIX_FALLOCATE"
172 output_sym "CONFIG_FADVISE"
173 output_sym "CONFIG_SFAA"
174 output_sym "CONFIG_RUSAGE_THREAD"
175 output_sym "CONFIG_WINDOWSAIO"
176 output_sym "CONFIG_FDATASYNC"
177 echo "CC=$CC" >> $config_host_mak
181 if test ! -z "$cpu" ; then
182 # command line argument
184 elif check_define __i386__ ; then
186 elif check_define __x86_64__ ; then
188 elif check_define __sparc__ ; then
189 if check_define __arch64__ ; then
194 elif check_define _ARCH_PPC ; then
195 if check_define _ARCH_PPC64 ; then
200 elif check_define __mips__ ; then
202 elif check_define __ia64__ ; then
204 elif check_define __s390__ ; then
205 if check_define __s390x__ ; then
210 elif check_define __arm__ ; then
212 elif check_define __hppa__ ; then
218 # Normalise host CPU name and set ARCH.
220 ia64|ppc|ppc64|s390|s390x|sparc64)
223 i386|i486|i586|i686|i86pc|BePC)
232 hppa|parisc|parisc64)
248 if test "$targetos" = "FreeBSD"; then
257 cc="${CC-${cross_prefix}gcc}"
259 ##########################################
263 #include <inttypes.h>
266 volatile uint32_t i=0x01234567;
267 return (*((uint8_t*)(&i))) == 0x67;
270 if compile_prog "" "" "endian"; then
271 $TMPE && bigendian="yes"
275 echo "Operating system $targetos"
277 echo "Big endian $bigendian"
281 ##########################################
288 unsigned int wsize = sizeof(long) * 8;
289 printf("%d\n", wsize);
293 if compile_prog "" "" "wordsize"; then
296 echo "Wordsize $wordsize"
298 ##########################################
310 if compile_prog "" "-laio" "libaio" ; then
314 if test "$libaio" = "yes" ; then
315 feature_not_found "linux AIO"
319 echo "Linux AIO support $libaio"
321 ##########################################
334 if compile_prog "" "" "posixaio" ; then
336 elif compile_prog "" "-lrt" "posixaio"; then
341 echo "POSIX AIO support $posix_aio"
342 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
344 ##########################################
345 # posix aio fsync probe
347 if test "$posix_aio" = "yes" ; then
354 return aio_fsync(O_SYNC, &cb);
358 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
362 echo "POSIX AIO fsync $posix_aio_fsync"
364 ##########################################
368 #include <sys/types.h>
369 #include <sys/asynch.h>
374 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
378 if compile_prog "" "-laio" "solarisaio" ; then
382 echo "Solaris AIO support $solaris_aio"
384 ##########################################
385 # __sync_fetch_and_and test
388 static int sfaa(int *ptr)
390 return __sync_fetch_and_and(ptr, 0);
393 int main(int argc, char **argv)
400 if compile_prog "" "" "__sync_fetch_and_add()" ; then
403 echo "__sync_fetch_and add $sfaa"
405 ##########################################
410 #include <infiniband/arch.h>
411 int main(int argc, char **argv)
413 struct ibv_pd *pd = ibv_alloc_pd(NULL);
417 if compile_prog "" "-libverbs" "libverbs" ; then
419 LIBS="-libverbs $LIBS"
421 echo "libverbs $libverbs"
423 ##########################################
428 #include <rdma/rdma_cma.h>
429 int main(int argc, char **argv)
431 rdma_destroy_qp(NULL);
435 if compile_prog "" "-lrdmacm" "rdma"; then
437 LIBS="-lrdmacm $LIBS"
439 echo "rdmacm $rdmacm"
441 ##########################################
442 # Linux fallocate probe
446 #include <linux/falloc.h>
447 int main(int argc, char **argv)
449 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
453 if compile_prog "" "" "linux_fallocate"; then
454 linux_fallocate="yes"
456 echo "Linux fallocate $linux_fallocate"
458 ##########################################
459 # POSIX fadvise probe
464 int main(int argc, char **argv)
466 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
470 if compile_prog "" "" "posix_fadvise"; then
473 echo "POSIX fadvise $posix_fadvise"
475 ##########################################
476 # POSIX fallocate probe
481 int main(int argc, char **argv)
483 int r = posix_fallocate(0, 0, 1024);
487 if compile_prog "" "" "posix_fallocate"; then
488 posix_fallocate="yes"
490 echo "POSIX fallocate $posix_fallocate"
492 ##########################################
493 # sched_set/getaffinity 2 or 3 argument test
494 linux_2arg_affinity="no"
495 linux_3arg_affinity="no"
498 int main(int argc, char **argv)
501 return sched_setaffinity(0, sizeof(mask), &mask);
504 if compile_prog "" "" "sched_setaffinity(,,)"; then
505 linux_3arg_affinity="yes"
509 int main(int argc, char **argv)
512 return sched_setaffinity(0, &mask);
515 if compile_prog "" "" "sched_setaffinity(,)"; then
516 linux_2arg_affinity="yes"
519 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
520 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
522 ##########################################
523 # clock_gettime probe
528 int main(int argc, char **argv)
530 return clock_gettime(0, NULL);
533 if compile_prog "" "" "clock_gettime"; then
535 elif compile_prog "" "-lrt" "clock_gettime"; then
539 echo "clock_gettime $clock_gettime"
541 ##########################################
542 # CLOCK_MONOTONIC probe
544 if test "$clock_gettime" = "yes" ; then
548 int main(int argc, char **argv)
550 return clock_gettime(CLOCK_MONOTONIC, NULL);
553 if compile_prog "" "$LIBS" "clock monotonic"; then
554 clock_monotonic="yes"
557 echo "CLOCK_MONOTONIC $clock_monotonic"
559 ##########################################
560 # CLOCK_MONOTONIC_PRECISE probe
561 clock_monotonic_precise="no"
562 if test "$clock_gettime" = "yes" ; then
566 int main(int argc, char **argv)
568 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
571 if compile_prog "" "$LIBS" "clock monotonic precise"; then
572 clock_monotonic_precise="yes"
575 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
577 ##########################################
578 # gettimeofday() probe
581 #include <sys/time.h>
583 int main(int argc, char **argv)
586 return gettimeofday(&tv, NULL);
589 if compile_prog "" "" "gettimeofday"; then
592 echo "gettimeofday $gettimeofday"
594 ##########################################
600 int main(int argc, char **argv)
605 if compile_prog "" "" "fdatasync"; then
608 echo "fdatasync $fdatasync"
610 ##########################################
611 # sync_file_range() probe
617 #include <linux/fs.h>
618 int main(int argc, char **argv)
620 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
621 SYNC_FILE_RANGE_WAIT_AFTER;
622 return sync_file_range(0, 0, 0, flags);
625 if compile_prog "" "" "sync_file_range"; then
626 sync_file_range="yes"
628 echo "sync_file_range $sync_file_range"
630 ##########################################
631 # ext4 move extent probe
635 #include <sys/ioctl.h>
636 int main(int argc, char **argv)
638 struct move_extent me;
639 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
642 if compile_prog "" "" "ext4 move extent" ; then
644 elif test $targetos = "Linux" ; then
645 # On Linux, just default to it on and let it error at runtime if we really
646 # don't have it. None of my updated systems have it defined, but it does
647 # work. Takes a while to bubble back.
650 echo "EXT4 move extent $ext4_me"
652 ##########################################
658 int main(int argc, char **argv)
660 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
663 if compile_prog "" "" "linux splice"; then
666 echo "Linux splice(2) $linux_splice"
668 ##########################################
673 #include <guasi_syscalls.h>
674 int main(int argc, char **argv)
676 guasi_t ctx = guasi_create(0, 0, 0);
680 if compile_prog "" "" "guasi"; then
685 ##########################################
689 #include <nvm/vectored_write.h>
690 int main(int argc, char **argv)
692 struct vsl_iovec iov;
693 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
696 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
697 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
700 echo "Fusion-io atomic engine $fusion_aw"
702 ##########################################
707 int main(int argc, char **argv)
709 return numa_available();
712 if compile_prog "" "-lnuma" "libnuma"; then
716 echo "libnuma $libnuma"
718 ##########################################
723 int main(int argc, char **argv)
729 if compile_prog "" "" "strsep"; then
732 echo "strsep $strsep"
734 ##########################################
735 # getopt_long_only() probe
736 getopt_long_only="no"
740 int main(int argc, char **argv)
742 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
746 if compile_prog "" "" "getopt_long_only"; then
747 getopt_long_only="yes"
749 echo "getopt_long_only() $getopt_long_only"
751 ##########################################
755 #include <sys/socket.h>
756 #include <arpa/inet.h>
758 int main(int argc, char **argv)
761 return inet_aton(NULL, &in);
764 if compile_prog "" "" "inet_aton"; then
767 echo "inet_aton $inet_aton"
769 ##########################################
774 #include <netinet/in.h>
775 int main(int argc, char **argv)
781 if compile_prog "" "" "socklen_t"; then
784 echo "socklen_t $socklen_t"
786 ##########################################
787 # Whether or not __thread is supported for TLS
791 static int __thread ret;
792 int main(int argc, char **argv)
797 if compile_prog "" "" "__thread"; then
800 echo "__thread $tls_thread"
802 ##########################################
803 # Check whether we have getrusage(RUSAGE_THREAD)
806 #include <sys/time.h>
807 #include <sys/resource.h>
808 int main(int argc, char **argv)
811 getrusage(RUSAGE_THREAD, &ru);
815 if compile_prog "" "" "RUSAGE_THREAD"; then
818 echo "RUSAGE_THREAD $rusage_thread"
820 #############################################################################
822 echo "# Automatically generated by configure - do not modify" > $config_host_mak
823 printf "# Configured with:" >> $config_host_mak
824 printf " '%s'" "$0" "$@" >> $config_host_mak
825 echo >> $config_host_mak
827 if test "$wordsize" = "64" ; then
828 output_sym "CONFIG_64BIT"
829 elif test "$wordsize" = "32" ; then
830 output_sym "CONFIG_32BIT"
832 echo "Unknown wordsize!"
835 if test "$bigendian" = "yes" ; then
836 output_sym "CONFIG_BIG_ENDIAN"
838 output_sym "CONFIG_LITTLE_ENDIAN"
840 if test "$libaio" = "yes" ; then
841 output_sym "CONFIG_LIBAIO"
843 if test "$posix_aio" = "yes" ; then
844 output_sym "CONFIG_POSIXAIO"
846 if test "$posix_aio_fsync" = "yes" ; then
847 output_sym "CONFIG_POSIXAIO_FSYNC"
849 if test "$linux_fallocate" = "yes" ; then
850 output_sym "CONFIG_LINUX_FALLOCATE"
852 if test "$posix_fallocate" = "yes" ; then
853 output_sym "CONFIG_POSIX_FALLOCATE"
855 if test "$fdatasync" = "yes" ; then
856 output_sym "CONFIG_FDATASYNC"
858 if test "$sync_file_range" = "yes" ; then
859 output_sym "CONFIG_SYNC_FILE_RANGE"
861 if test "$sfaa" = "yes" ; then
862 output_sym "CONFIG_SFAA"
864 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
865 output_sym "CONFIG_RDMA"
867 if test "$clock_gettime" = "yes" ; then
868 output_sym "CONFIG_CLOCK_GETTIME"
870 if test "$clock_monotonic" = "yes" ; then
871 output_sym "CONFIG_CLOCK_MONOTONIC"
873 if test "$clock_monotonic_precise" = "yes" ; then
874 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
876 if test "$gettimeofday" = "yes" ; then
877 output_sym "CONFIG_GETTIMEOFDAY"
879 if test "$posix_fadvise" = "yes" ; then
880 output_sym "CONFIG_POSIX_FADVISE"
882 if test "$linux_3arg_affinity" = "yes" ; then
883 output_sym "CONFIG_3ARG_AFFINITY"
884 elif test "$linux_2arg_affinity" = "yes" ; then
885 output_sym "CONFIG_2ARG_AFFINITY"
887 if test "$strsep" = "yes" ; then
888 output_sym "CONFIG_STRSEP"
890 if test "$getopt_long_only" = "yes" ; then
891 output_sym "CONFIG_GETOPT_LONG_ONLY"
893 if test "$inet_aton" = "yes" ; then
894 output_sym "CONFIG_INET_ATON"
896 if test "$socklen_t" = "yes" ; then
897 output_sym "CONFIG_SOCKLEN_T"
899 if test "$ext4_me" = "yes" ; then
900 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
902 if test "$linux_splice" = "yes" ; then
903 output_sym "CONFIG_LINUX_SPLICE"
905 if test "$guasi" = "yes" ; then
906 output_sym "CONFIG_GUASI"
908 if test "$fusion_aw" = "yes" ; then
909 output_sym "CONFIG_FUSION_AW"
911 if test "$libnuma" = "yes" ; then
912 output_sym "CONFIG_LIBNUMA"
914 if test "$solaris_aio" = "yes" ; then
915 output_sym "CONFIG_SOLARISAIO"
917 if test "$tls_thread" = "yes" ; then
918 output_sym "CONFIG_TLS_THREAD"
920 if test "$rusage_thread" = "yes" ; then
921 output_sym "CONFIG_RUSAGE_THREAD"
924 echo "LIBS+=$LIBS" >> $config_host_mak
925 echo "CC=$cc" >> $config_host_mak
926 echo "EXTFLAGS=$EXTFLAGS" >> $config_host_mak