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
42 # Print configure header at the top of $config_host_h
43 echo "/*" > $config_host_h
44 echo " * Automatically generated by configure - do not modify" >> $config_host_h
45 printf " * Configured with:" >> $config_host_h
46 printf " * '%s'" "$0" "$@" >> $config_host_h
47 echo "" >> $config_host_h
48 echo " */" >> $config_host_h
51 # Run the compiler, capturing its output to the log.
52 echo $cc "$@" >> config.log
53 $cc "$@" >> config.log 2>&1 || return $?
54 # Test passed. If this is an --enable-werror build, rerun
55 # the test with -Werror and bail out if it fails. This
56 # makes warning-generating-errors in configure test code
57 # obvious to developers.
58 if test "$werror" != "yes"; then
61 # Don't bother rerunning the compile if we were already using -Werror
67 echo $cc -Werror "$@" >> config.log
68 $cc -Werror "$@" >> config.log 2>&1 && return $?
69 echo "ERROR: configure test passed without -Werror but failed with -Werror."
70 echo "This is probably a bug in the configure script. The failing command"
71 echo "will be at the bottom of config.log."
72 echo "You can run configure with --disable-werror to bypass this check."
77 do_cc $CFLAGS -c -o $TMPO $TMPC
83 echo "Compiling test case $3" >> config.log
84 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
91 echo "ERROR: User requested feature $feature"
92 echo "ERROR: configure was not able to find it"
98 type "$1" >/dev/null 2>&1
104 #error $1 not defined
115 echo "$1=y" >> $config_host_mak
116 echo "#define $1" >> $config_host_h
122 cc="${CC-${cross_prefix}gcc}"
126 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
131 echo "Bad option $opt"
136 if check_define __linux__ ; then
138 elif check_define __OpenBSD__ ; then
140 elif check_define __sun__ ; then
146 # Some host OSes need non-standard checks for which CPU to use.
147 # Note that these checks are broken for cross-compilation: if you're
148 # cross-compiling to one of these OSes then you'll need to specify
149 # the correct CPU with the --cpu option.
152 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
153 # we can run 64-bit userspace code.
154 # If the user didn't specify a CPU explicitly and the kernel says this is
155 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
157 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
162 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
163 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
168 echo "Forcing known good options on Windows"
169 if test -z "$CC" ; then
170 CC="x86_64-w64-mingw32-gcc"
172 output_sym "CONFIG_LITTLE_ENDIAN"
173 output_sym "CONFIG_64BIT_LLP64"
174 output_sym "CONFIG_CLOCK_GETTIME"
175 output_sym "CONFIG_CLOCK_MONOTONIC"
176 output_sym "CONFIG_GETTIMEOFDAY"
177 output_sym "CONFIG_FADVISE"
178 output_sym "CONFIG_SOCKLEN_T"
179 output_sym "CONFIG_POSIX_FALLOCATE"
180 output_sym "CONFIG_FADVISE"
181 output_sym "CONFIG_SFAA"
182 output_sym "CONFIG_RUSAGE_THREAD"
183 output_sym "CONFIG_WINDOWSAIO"
184 output_sym "CONFIG_FDATASYNC"
185 echo "CC=$CC" >> $config_host_mak
189 if test ! -z "$cpu" ; then
190 # command line argument
192 elif check_define __i386__ ; then
194 elif check_define __x86_64__ ; then
196 elif check_define __sparc__ ; then
197 if check_define __arch64__ ; then
202 elif check_define _ARCH_PPC ; then
203 if check_define _ARCH_PPC64 ; then
208 elif check_define __mips__ ; then
210 elif check_define __ia64__ ; then
212 elif check_define __s390__ ; then
213 if check_define __s390x__ ; then
218 elif check_define __arm__ ; then
220 elif check_define __hppa__ ; then
226 # Normalise host CPU name and set ARCH.
228 ia64|ppc|ppc64|s390|s390x|sparc64)
231 i386|i486|i586|i686|i86pc|BePC)
240 hppa|parisc|parisc64)
256 if test "$targetos" = "FreeBSD"; then
265 cc="${CC-${cross_prefix}gcc}"
267 ##########################################
271 #include <inttypes.h>
274 volatile uint32_t i=0x01234567;
275 return (*((uint8_t*)(&i))) == 0x67;
278 if compile_prog "" "" "endian"; then
279 $TMPE && bigendian="yes"
283 echo "Operating system $targetos"
285 echo "Big endian $bigendian"
289 ##########################################
296 unsigned int wsize = sizeof(long) * 8;
297 printf("%d\n", wsize);
301 if compile_prog "" "" "wordsize"; then
304 echo "Wordsize $wordsize"
306 ##########################################
318 if compile_prog "" "-laio" "libaio" ; then
322 if test "$libaio" = "yes" ; then
323 feature_not_found "linux AIO"
327 echo "Linux AIO support $libaio"
329 ##########################################
342 if compile_prog "" "" "posixaio" ; then
344 elif compile_prog "" "-lrt" "posixaio"; then
349 echo "POSIX AIO support $posix_aio"
350 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
352 ##########################################
353 # posix aio fsync probe
355 if test "$posix_aio" = "yes" ; then
362 return aio_fsync(O_SYNC, &cb);
366 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
370 echo "POSIX AIO fsync $posix_aio_fsync"
372 ##########################################
376 #include <sys/types.h>
377 #include <sys/asynch.h>
382 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
386 if compile_prog "" "-laio" "solarisaio" ; then
390 echo "Solaris AIO support $solaris_aio"
392 ##########################################
393 # __sync_fetch_and_and test
396 static int sfaa(int *ptr)
398 return __sync_fetch_and_and(ptr, 0);
401 int main(int argc, char **argv)
408 if compile_prog "" "" "__sync_fetch_and_add()" ; then
411 echo "__sync_fetch_and add $sfaa"
413 ##########################################
418 #include <infiniband/arch.h>
419 int main(int argc, char **argv)
421 struct ibv_pd *pd = ibv_alloc_pd(NULL);
425 if compile_prog "" "-libverbs" "libverbs" ; then
427 LIBS="-libverbs $LIBS"
429 echo "libverbs $libverbs"
431 ##########################################
436 #include <rdma/rdma_cma.h>
437 int main(int argc, char **argv)
439 rdma_destroy_qp(NULL);
443 if compile_prog "" "-lrdmacm" "rdma"; then
445 LIBS="-lrdmacm $LIBS"
447 echo "rdmacm $rdmacm"
449 ##########################################
450 # Linux fallocate probe
454 #include <linux/falloc.h>
455 int main(int argc, char **argv)
457 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
461 if compile_prog "" "" "linux_fallocate"; then
462 linux_fallocate="yes"
464 echo "Linux fallocate $linux_fallocate"
466 ##########################################
467 # POSIX fadvise probe
472 int main(int argc, char **argv)
474 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
478 if compile_prog "" "" "posix_fadvise"; then
481 echo "POSIX fadvise $posix_fadvise"
483 ##########################################
484 # POSIX fallocate probe
489 int main(int argc, char **argv)
491 int r = posix_fallocate(0, 0, 1024);
495 if compile_prog "" "" "posix_fallocate"; then
496 posix_fallocate="yes"
498 echo "POSIX fallocate $posix_fallocate"
500 ##########################################
501 # sched_set/getaffinity 2 or 3 argument test
502 linux_2arg_affinity="no"
503 linux_3arg_affinity="no"
506 int main(int argc, char **argv)
509 return sched_setaffinity(0, sizeof(mask), &mask);
512 if compile_prog "" "" "sched_setaffinity(,,)"; then
513 linux_3arg_affinity="yes"
517 int main(int argc, char **argv)
520 return sched_setaffinity(0, &mask);
523 if compile_prog "" "" "sched_setaffinity(,)"; then
524 linux_2arg_affinity="yes"
527 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
528 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
530 ##########################################
531 # clock_gettime probe
536 int main(int argc, char **argv)
538 return clock_gettime(0, NULL);
541 if compile_prog "" "" "clock_gettime"; then
543 elif compile_prog "" "-lrt" "clock_gettime"; then
547 echo "clock_gettime $clock_gettime"
549 ##########################################
550 # CLOCK_MONOTONIC probe
552 if test "$clock_gettime" = "yes" ; then
556 int main(int argc, char **argv)
558 return clock_gettime(CLOCK_MONOTONIC, NULL);
561 if compile_prog "" "$LIBS" "clock monotonic"; then
562 clock_monotonic="yes"
565 echo "CLOCK_MONOTONIC $clock_monotonic"
567 ##########################################
568 # CLOCK_MONOTONIC_PRECISE probe
569 clock_monotonic_precise="no"
570 if test "$clock_gettime" = "yes" ; then
574 int main(int argc, char **argv)
576 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
579 if compile_prog "" "$LIBS" "clock monotonic precise"; then
580 clock_monotonic_precise="yes"
583 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
585 ##########################################
586 # gettimeofday() probe
589 #include <sys/time.h>
591 int main(int argc, char **argv)
594 return gettimeofday(&tv, NULL);
597 if compile_prog "" "" "gettimeofday"; then
600 echo "gettimeofday $gettimeofday"
602 ##########################################
608 int main(int argc, char **argv)
613 if compile_prog "" "" "fdatasync"; then
616 echo "fdatasync $fdatasync"
618 ##########################################
619 # sync_file_range() probe
625 #include <linux/fs.h>
626 int main(int argc, char **argv)
628 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
629 SYNC_FILE_RANGE_WAIT_AFTER;
630 return sync_file_range(0, 0, 0, flags);
633 if compile_prog "" "" "sync_file_range"; then
634 sync_file_range="yes"
636 echo "sync_file_range $sync_file_range"
638 ##########################################
639 # ext4 move extent probe
643 #include <sys/ioctl.h>
644 int main(int argc, char **argv)
646 struct move_extent me;
647 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
650 if compile_prog "" "" "ext4 move extent" ; then
652 elif test $targetos = "Linux" ; then
653 # On Linux, just default to it on and let it error at runtime if we really
654 # don't have it. None of my updated systems have it defined, but it does
655 # work. Takes a while to bubble back.
658 echo "EXT4 move extent $ext4_me"
660 ##########################################
666 int main(int argc, char **argv)
668 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
671 if compile_prog "" "" "linux splice"; then
674 echo "Linux splice(2) $linux_splice"
676 ##########################################
681 #include <guasi_syscalls.h>
682 int main(int argc, char **argv)
684 guasi_t ctx = guasi_create(0, 0, 0);
688 if compile_prog "" "" "guasi"; then
693 ##########################################
697 #include <nvm/vectored_write.h>
698 int main(int argc, char **argv)
700 struct vsl_iovec iov;
701 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
704 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
705 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
708 echo "Fusion-io atomic engine $fusion_aw"
710 ##########################################
715 int main(int argc, char **argv)
717 return numa_available();
720 if compile_prog "" "-lnuma" "libnuma"; then
724 echo "libnuma $libnuma"
726 ##########################################
731 int main(int argc, char **argv)
737 if compile_prog "" "" "strsep"; then
740 echo "strsep $strsep"
742 ##########################################
743 # getopt_long_only() probe
744 getopt_long_only="no"
748 int main(int argc, char **argv)
750 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
754 if compile_prog "" "" "getopt_long_only"; then
755 getopt_long_only="yes"
757 echo "getopt_long_only() $getopt_long_only"
759 ##########################################
763 #include <sys/socket.h>
764 #include <arpa/inet.h>
766 int main(int argc, char **argv)
769 return inet_aton(NULL, &in);
772 if compile_prog "" "" "inet_aton"; then
775 echo "inet_aton $inet_aton"
777 ##########################################
782 #include <netinet/in.h>
783 int main(int argc, char **argv)
789 if compile_prog "" "" "socklen_t"; then
792 echo "socklen_t $socklen_t"
794 ##########################################
795 # Whether or not __thread is supported for TLS
799 static int __thread ret;
800 int main(int argc, char **argv)
805 if compile_prog "" "" "__thread"; then
808 echo "__thread $tls_thread"
810 ##########################################
811 # Check whether we have getrusage(RUSAGE_THREAD)
814 #include <sys/time.h>
815 #include <sys/resource.h>
816 int main(int argc, char **argv)
819 getrusage(RUSAGE_THREAD, &ru);
823 if compile_prog "" "" "RUSAGE_THREAD"; then
826 echo "RUSAGE_THREAD $rusage_thread"
828 #############################################################################
830 echo "# Automatically generated by configure - do not modify" > $config_host_mak
831 printf "# Configured with:" >> $config_host_mak
832 printf " '%s'" "$0" "$@" >> $config_host_mak
833 echo >> $config_host_mak
835 if test "$wordsize" = "64" ; then
836 output_sym "CONFIG_64BIT"
837 elif test "$wordsize" = "32" ; then
838 output_sym "CONFIG_32BIT"
840 echo "Unknown wordsize!"
843 if test "$bigendian" = "yes" ; then
844 output_sym "CONFIG_BIG_ENDIAN"
846 output_sym "CONFIG_LITTLE_ENDIAN"
848 if test "$libaio" = "yes" ; then
849 output_sym "CONFIG_LIBAIO"
851 if test "$posix_aio" = "yes" ; then
852 output_sym "CONFIG_POSIXAIO"
854 if test "$posix_aio_fsync" = "yes" ; then
855 output_sym "CONFIG_POSIXAIO_FSYNC"
857 if test "$linux_fallocate" = "yes" ; then
858 output_sym "CONFIG_LINUX_FALLOCATE"
860 if test "$posix_fallocate" = "yes" ; then
861 output_sym "CONFIG_POSIX_FALLOCATE"
863 if test "$fdatasync" = "yes" ; then
864 output_sym "CONFIG_FDATASYNC"
866 if test "$sync_file_range" = "yes" ; then
867 output_sym "CONFIG_SYNC_FILE_RANGE"
869 if test "$sfaa" = "yes" ; then
870 output_sym "CONFIG_SFAA"
872 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
873 output_sym "CONFIG_RDMA"
875 if test "$clock_gettime" = "yes" ; then
876 output_sym "CONFIG_CLOCK_GETTIME"
878 if test "$clock_monotonic" = "yes" ; then
879 output_sym "CONFIG_CLOCK_MONOTONIC"
881 if test "$clock_monotonic_precise" = "yes" ; then
882 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
884 if test "$gettimeofday" = "yes" ; then
885 output_sym "CONFIG_GETTIMEOFDAY"
887 if test "$posix_fadvise" = "yes" ; then
888 output_sym "CONFIG_POSIX_FADVISE"
890 if test "$linux_3arg_affinity" = "yes" ; then
891 output_sym "CONFIG_3ARG_AFFINITY"
892 elif test "$linux_2arg_affinity" = "yes" ; then
893 output_sym "CONFIG_2ARG_AFFINITY"
895 if test "$strsep" = "yes" ; then
896 output_sym "CONFIG_STRSEP"
898 if test "$getopt_long_only" = "yes" ; then
899 output_sym "CONFIG_GETOPT_LONG_ONLY"
901 if test "$inet_aton" = "yes" ; then
902 output_sym "CONFIG_INET_ATON"
904 if test "$socklen_t" = "yes" ; then
905 output_sym "CONFIG_SOCKLEN_T"
907 if test "$ext4_me" = "yes" ; then
908 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
910 if test "$linux_splice" = "yes" ; then
911 output_sym "CONFIG_LINUX_SPLICE"
913 if test "$guasi" = "yes" ; then
914 output_sym "CONFIG_GUASI"
916 if test "$fusion_aw" = "yes" ; then
917 output_sym "CONFIG_FUSION_AW"
919 if test "$libnuma" = "yes" ; then
920 output_sym "CONFIG_LIBNUMA"
922 if test "$solaris_aio" = "yes" ; then
923 output_sym "CONFIG_SOLARISAIO"
925 if test "$tls_thread" = "yes" ; then
926 output_sym "CONFIG_TLS_THREAD"
928 if test "$rusage_thread" = "yes" ; then
929 output_sym "CONFIG_RUSAGE_THREAD"
932 echo "LIBS+=$LIBS" >> $config_host_mak
933 echo "CC=$cc" >> $config_host_mak
934 echo "EXTFLAGS=$EXTFLAGS" >> $config_host_mak