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"
30 CFLAGS="-D_GNU_SOURCE"
32 # Print a helpful header at the top of config.log
33 echo "# FIO configure log $(date)" >> config.log
34 printf "# Configured with:" >> config.log
35 printf " '%s'" "$0" "$@" >> config.log
37 echo "#" >> config.log
40 # Run the compiler, capturing its output to the log.
41 echo $cc "$@" >> config.log
42 $cc "$@" >> config.log 2>&1 || return $?
43 # Test passed. If this is an --enable-werror build, rerun
44 # the test with -Werror and bail out if it fails. This
45 # makes warning-generating-errors in configure test code
46 # obvious to developers.
47 if test "$werror" != "yes"; then
50 # Don't bother rerunning the compile if we were already using -Werror
56 echo $cc -Werror "$@" >> config.log
57 $cc -Werror "$@" >> config.log 2>&1 && return $?
58 echo "ERROR: configure test passed without -Werror but failed with -Werror."
59 echo "This is probably a bug in the configure script. The failing command"
60 echo "will be at the bottom of config.log."
61 echo "You can run configure with --disable-werror to bypass this check."
66 do_cc $CFLAGS -c -o $TMPO $TMPC
72 echo "Compiling test case $3" >> config.log
73 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
80 echo "ERROR: User requested feature $feature"
81 echo "ERROR: configure was not able to find it"
87 type "$1" >/dev/null 2>&1
106 cc="${CC-${cross_prefix}gcc}"
110 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
115 echo "Bad option $opt"
120 if check_define __linux__ ; then
122 elif check_define __OpenBSD__ ; then
124 elif check_define __sun__ ; then
130 # Some host OSes need non-standard checks for which CPU to use.
131 # Note that these checks are broken for cross-compilation: if you're
132 # cross-compiling to one of these OSes then you'll need to specify
133 # the correct CPU with the --cpu option.
136 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
137 # we can run 64-bit userspace code.
138 # If the user didn't specify a CPU explicitly and the kernel says this is
139 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
141 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
146 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
147 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
152 echo "Forcing known good options on Windows"
153 if test -z "$CC" ; then
154 CC="x86_64-w64-mingw32-gcc"
156 echo "CC=$CC" > $config_host_mak
157 echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
158 echo "CONFIG_64BIT_LLP64=y" >> $config_host_mak
159 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
160 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
161 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
162 echo "CONFIG_FADVISE=y" >> $config_host_mak
163 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
164 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
165 echo "CONFIG_FADVISE=y" >> $config_host_mak
166 echo "CONFIG_SFAA=y" >> $config_host_mak
170 if test ! -z "$cpu" ; then
171 # command line argument
173 elif check_define __i386__ ; then
175 elif check_define __x86_64__ ; then
177 elif check_define __sparc__ ; then
178 if check_define __arch64__ ; then
183 elif check_define _ARCH_PPC ; then
184 if check_define _ARCH_PPC64 ; then
189 elif check_define __mips__ ; then
191 elif check_define __ia64__ ; then
193 elif check_define __s390__ ; then
194 if check_define __s390x__ ; then
199 elif check_define __arm__ ; then
201 elif check_define __hppa__ ; then
207 # Normalise host CPU name and set ARCH.
209 ia64|ppc|ppc64|s390|s390x|sparc64)
212 i386|i486|i586|i686|i86pc|BePC)
221 hppa|parisc|parisc64)
237 if test "$targetos" = "FreeBSD"; then
246 cc="${CC-${cross_prefix}gcc}"
248 ##########################################
252 #include <inttypes.h>
255 volatile uint32_t i=0x01234567;
256 return (*((uint8_t*)(&i))) == 0x67;
259 if compile_prog "" "" "endian"; then
260 $TMPE && bigendian="yes"
264 echo "Operating system $targetos"
266 echo "Big endian $bigendian"
270 ##########################################
277 unsigned int wsize = sizeof(long) * 8;
278 printf("%d\n", wsize);
282 if compile_prog "" "" "wordsize"; then
285 echo "Wordsize $wordsize"
287 ##########################################
299 if compile_prog "" "-laio" "libaio" ; then
303 if test "$libaio" = "yes" ; then
304 feature_not_found "linux AIO"
308 echo "Linux AIO support $libaio"
310 ##########################################
323 if compile_prog "" "" "posixaio" ; then
325 elif compile_prog "" "-lrt" "posixaio"; then
330 echo "POSIX AIO support $posix_aio"
331 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
333 ##########################################
334 # posix aio fsync probe
336 if test "$posix_aio" = "yes" ; then
343 return aio_fsync(O_SYNC, &cb);
347 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
351 echo "POSIX AIO fsync $posix_aio_fsync"
353 ##########################################
357 #include <sys/types.h>
358 #include <sys/asynch.h>
363 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
367 if compile_prog "" "-laio" "solarisaio" ; then
371 echo "Solaris AIO support $solaris_aio"
373 ##########################################
374 # __sync_fetch_and_and test
377 static int sfaa(int *ptr)
379 return __sync_fetch_and_and(ptr, 0);
382 int main(int argc, char **argv)
389 if compile_prog "" "" "__sync_fetch_and_add()" ; then
392 echo "__sync_fetch_and add $sfaa"
394 ##########################################
399 #include <infiniband/arch.h>
400 int main(int argc, char **argv)
402 struct ibv_pd *pd = ibv_alloc_pd(NULL);
406 if compile_prog "" "-libverbs" "libverbs" ; then
408 LIBS="-libverbs $LIBS"
410 echo "libverbs $libverbs"
412 ##########################################
417 #include <rdma/rdma_cma.h>
418 int main(int argc, char **argv)
420 rdma_destroy_qp(NULL);
424 if compile_prog "" "-lrdmacm" "rdma"; then
426 LIBS="-lrdmacm $LIBS"
428 echo "rdmacm $rdmacm"
430 ##########################################
431 # Linux fallocate probe
435 #include <linux/falloc.h>
436 int main(int argc, char **argv)
438 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
442 if compile_prog "" "" "linux_fallocate"; then
443 linux_fallocate="yes"
445 echo "Linux fallocate $linux_fallocate"
447 ##########################################
448 # POSIX fadvise probe
453 int main(int argc, char **argv)
455 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
459 if compile_prog "" "" "posix_fadvise"; then
462 echo "POSIX fadvise $posix_fadvise"
464 ##########################################
465 # POSIX fallocate probe
470 int main(int argc, char **argv)
472 int r = posix_fallocate(0, 0, 1024);
476 if compile_prog "" "" "posix_fallocate"; then
477 posix_fallocate="yes"
479 echo "POSIX fallocate $posix_fallocate"
481 ##########################################
482 # sched_set/getaffinity 2 or 3 argument test
483 linux_2arg_affinity="no"
484 linux_3arg_affinity="no"
487 int main(int argc, char **argv)
490 return sched_setaffinity(0, sizeof(mask), &mask);
493 if compile_prog "" "" "sched_setaffinity(,,)"; then
494 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
606 #include <linux/fs.h>
607 int main(int argc, char **argv)
609 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
610 SYNC_FILE_RANGE_WAIT_AFTER;
611 return sync_file_range(0, 0, 0, flags);
614 if compile_prog "" "" "sync_file_range"; then
615 sync_file_range="yes"
617 echo "sync_file_range $sync_file_range"
619 ##########################################
620 # ext4 move extent probe
624 #include <sys/ioctl.h>
625 int main(int argc, char **argv)
627 struct move_extent me;
628 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
631 if compile_prog "" "" "ext4 move extent" ; then
633 elif test $targetos = "Linux" ; then
634 # On Linux, just default to it on and let it error at runtime if we really
635 # don't have it. None of my updated systems have it defined, but it does
636 # work. Takes a while to bubble back.
639 echo "EXT4 move extent $ext4_me"
641 ##########################################
647 int main(int argc, char **argv)
649 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
652 if compile_prog "" "" "linux splice"; then
655 echo "Linux splice(2) $linux_splice"
657 ##########################################
662 #include <guasi_syscalls.h>
663 int main(int argc, char **argv)
665 guasi_t ctx = guasi_create(0, 0, 0);
669 if compile_prog "" "" "guasi"; then
674 ##########################################
678 #include <nvm/vectored_write.h>
679 int main(int argc, char **argv)
681 struct vsl_iovec iov;
682 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
685 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
686 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
689 echo "Fusion-io atomic engine $fusion_aw"
691 ##########################################
696 int main(int argc, char **argv)
698 return numa_available();
701 if compile_prog "" "-lnuma" "libnuma"; then
705 echo "libnuma $libnuma"
707 ##########################################
712 int main(int argc, char **argv)
718 if compile_prog "" "" "strsep"; then
721 echo "strsep $strsep"
723 ##########################################
724 # getopt_long_only() probe
725 getopt_long_only="no"
729 int main(int argc, char **argv)
731 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
735 if compile_prog "" "" "getopt_long_only"; then
736 getopt_long_only="yes"
738 echo "getopt_long_only() $getopt_long_only"
740 ##########################################
744 #include <sys/socket.h>
745 #include <arpa/inet.h>
747 int main(int argc, char **argv)
750 return inet_aton(NULL, &in);
753 if compile_prog "" "" "inet_aton"; then
756 echo "inet_aton $inet_aton"
758 ##########################################
763 #include <netinet/in.h>
764 int main(int argc, char **argv)
770 if compile_prog "" "" "socklen_t"; then
773 echo "socklen_t $socklen_t"
775 ##########################################
776 # Whether or not __thread is supported for TLS
780 static int __thread ret;
781 int main(int argc, char **argv)
786 if compile_prog "" "" "__thread"; then
789 echo "__thread $tls_thread"
791 ##########################################
792 # Check whether we have getrusage(RUSAGE_THREAD)
795 #include <sys/time.h>
796 #include <sys/resource.h>
797 int main(int argc, char **argv)
800 getrusage(RUSAGE_THREAD, &ru);
804 if compile_prog "" "" "RUSAGE_THREAD"; then
807 echo "RUSAGE_THREAD $rusage_thread"
809 #############################################################################
811 echo "# Automatically generated by configure - do not modify" > $config_host_mak
812 printf "# Configured with:" >> $config_host_mak
813 printf " '%s'" "$0" "$@" >> $config_host_mak
814 echo >> $config_host_mak
816 if test "$wordsize" = "64" ; then
817 echo "CONFIG_64BIT=y" >> $config_host_mak
818 elif test "$wordsize" = "32" ; then
819 echo "CONFIG_32BIT=y" >> $config_host_mak
821 echo "Unknown wordsize!"
824 if test "$bigendian" = "yes" ; then
825 echo "CONFIG_BIG_ENDIAN=y" >> $config_host_mak
827 echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
829 if test "$libaio" = "yes" ; then
830 echo "CONFIG_LIBAIO=y" >> $config_host_mak
832 if test "$posix_aio" = "yes" ; then
833 echo "CONFIG_POSIXAIO=y" >> $config_host_mak
835 if test "$posix_aio_fsync" = "yes" ; then
836 echo "CONFIG_POSIXAIO_FSYNC=y" >> $config_host_mak
838 if test "$linux_fallocate" = "yes" ; then
839 echo "CONFIG_LINUX_FALLOCATE=y" >> $config_host_mak
841 if test "$posix_fallocate" = "yes" ; then
842 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
844 if test "$fdatasync" = "yes" ; then
845 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
847 if test "$sync_file_range" = "yes" ; then
848 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
850 if test "$sfaa" = "yes" ; then
851 echo "CONFIG_SFAA=y" >> $config_host_mak
853 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
854 echo "CONFIG_RDMA=y" >> $config_host_mak
856 if test "$clock_gettime" = "yes" ; then
857 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
859 if test "$clock_monotonic" = "yes" ; then
860 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
862 if test "$clock_monotonic_precise" = "yes" ; then
863 echo "CONFIG_CLOCK_MONOTONIC_PRECISE=y" >> $config_host_mak
865 if test "$gettimeofday" = "yes" ; then
866 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
868 if test "$posix_fadvise" = "yes" ; then
869 echo "CONFIG_POSIX_FADVISE=y" >> $config_host_mak
871 if test "$linux_3arg_affinity" = "yes" ; then
872 echo "CONFIG_3ARG_AFFINITY=y" >> $config_host_mak
873 elif test "$linux_2arg_affinity" = "yes" ; then
874 echo "CONFIG_2ARG_AFFINITY=y" >> $config_host_mak
876 if test "$strsep" = "yes" ; then
877 echo "CONFIG_STRSEP=y" >> $config_host_mak
879 if test "$getopt_long_only" = "yes" ; then
880 echo "CONFIG_GETOPT_LONG_ONLY=y" >> $config_host_mak
882 if test "$inet_aton" = "yes" ; then
883 echo "CONFIG_INET_ATON=y" >> $config_host_mak
885 if test "$socklen_t" = "yes" ; then
886 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
888 if test "$ext4_me" = "yes" ; then
889 echo "CONFIG_LINUX_EXT4_MOVE_EXTENT=y" >> $config_host_mak
891 if test "$linux_splice" = "yes" ; then
892 echo "CONFIG_LINUX_SPLICE=y" >> $config_host_mak
894 if test "$guasi" = "yes" ; then
895 echo "CONFIG_GUASI=y" >> $config_host_mak
897 if test "$fusion_aw" = "yes" ; then
898 echo "CONFIG_FUSION_AW=y" >> $config_host_mak
900 if test "$libnuma" = "yes" ; then
901 echo "CONFIG_LIBNUMA=y" >> $config_host_mak
903 if test "$solaris_aio" = "yes" ; then
904 echo "CONFIG_SOLARISAIO=y" >> $config_host_mak
906 if test "$tls_thread" = "yes" ; then
907 echo "CONFIG_TLS_THREAD=y" >> $config_host_mak
909 if test "$rusage_thread" = "yes" ; then
910 echo "CONFIG_RUSAGE_THREAD=y" >> $config_host_mak
913 echo "LIBS+=$LIBS" >> $config_host_mak
914 echo "CC=$cc" >> $config_host_mak
915 echo "CFLAGS=$CFLAGS" >> $config_host_mak