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"
29 # Print a helpful header at the top of config.log
30 echo "# FIO configure log $(date)" >> config.log
31 printf "# Configured with:" >> config.log
32 printf " '%s'" "$0" "$@" >> config.log
34 echo "#" >> config.log
37 # Run the compiler, capturing its output to the log.
38 echo $cc "$@" >> config.log
39 $cc "$@" >> config.log 2>&1 || return $?
40 # Test passed. If this is an --enable-werror build, rerun
41 # the test with -Werror and bail out if it fails. This
42 # makes warning-generating-errors in configure test code
43 # obvious to developers.
44 if test "$werror" != "yes"; then
47 # Don't bother rerunning the compile if we were already using -Werror
53 echo $cc -Werror "$@" >> config.log
54 $cc -Werror "$@" >> config.log 2>&1 && return $?
55 echo "ERROR: configure test passed without -Werror but failed with -Werror."
56 echo "This is probably a bug in the configure script. The failing command"
57 echo "will be at the bottom of config.log."
58 echo "You can run configure with --disable-werror to bypass this check."
63 do_cc $CFLAGS -c -o $TMPO $TMPC
69 echo "Compiling test case $3" >> config.log
70 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
77 echo "ERROR: User requested feature $feature"
78 echo "ERROR: configure was not able to find it"
84 type "$1" >/dev/null 2>&1
103 cc="${CC-${cross_prefix}gcc}"
107 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
112 echo "Bad option $opt"
117 if check_define __linux__ ; then
119 elif check_define __OpenBSD__ ; then
121 elif check_define __sun__ ; then
127 # Some host OSes need non-standard checks for which CPU to use.
128 # Note that these checks are broken for cross-compilation: if you're
129 # cross-compiling to one of these OSes then you'll need to specify
130 # the correct CPU with the --cpu option.
133 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
134 # we can run 64-bit userspace code.
135 # If the user didn't specify a CPU explicitly and the kernel says this is
136 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
138 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
143 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
144 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
149 echo "Forcing known good options on Windows"
150 if test -z "$CC" ; then
151 CC="x86_64-w64-mingw32-gcc"
153 echo "CC=$CC" > $config_host_mak
154 echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
155 echo "CONFIG_64BIT_LLP64=y" >> $config_host_mak
156 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
157 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
158 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
159 echo "CONFIG_FADVISE=y" >> $config_host_mak
160 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
161 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
162 echo "CONFIG_FADVISE=y" >> $config_host_mak
163 echo "CONFIG_SFAA=y" >> $config_host_mak
167 if test ! -z "$cpu" ; then
168 # command line argument
170 elif check_define __i386__ ; then
172 elif check_define __x86_64__ ; then
174 elif check_define __sparc__ ; then
175 if check_define __arch64__ ; then
180 elif check_define _ARCH_PPC ; then
181 if check_define _ARCH_PPC64 ; then
186 elif check_define __mips__ ; then
188 elif check_define __ia64__ ; then
190 elif check_define __s390__ ; then
191 if check_define __s390x__ ; then
196 elif check_define __arm__ ; then
198 elif check_define __hppa__ ; then
204 # Normalise host CPU name and set ARCH.
206 ia64|ppc|ppc64|s390|s390x|sparc64)
209 i386|i486|i586|i686|i86pc|BePC)
218 hppa|parisc|parisc64)
234 if test "$targetos" = "FreeBSD"; then
243 cc="${CC-${cross_prefix}gcc}"
245 ##########################################
249 #include <inttypes.h>
252 volatile uint32_t i=0x01234567;
253 return (*((uint8_t*)(&i))) == 0x67;
256 if compile_prog "" "" "endian"; then
257 $TMPE && bigendian="yes"
261 echo "Operating system $targetos"
263 echo "Big endian $bigendian"
267 ##########################################
274 unsigned int wsize = sizeof(long) * 8;
275 printf("%d\n", wsize);
279 if compile_prog "" "" "wordsize"; then
282 echo "Wordsize $wordsize"
284 ##########################################
296 if compile_prog "" "-laio" "libaio" ; then
300 if test "$libaio" = "yes" ; then
301 feature_not_found "linux AIO"
305 echo "Linux AIO support $libaio"
307 ##########################################
320 if compile_prog "" "" "posixaio" ; then
322 elif compile_prog "" "-lrt" "posixaio"; then
327 echo "POSIX AIO support $posix_aio"
328 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
330 ##########################################
331 # posix aio fsync probe
333 if test "$posix_aio" = "yes" ; then
340 return aio_fsync(O_SYNC, &cb);
344 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
348 echo "POSIX AIO fsync $posix_aio_fsync"
350 ##########################################
354 #include <sys/types.h>
355 #include <sys/asynch.h>
360 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
364 if compile_prog "" "-laio" "solarisaio" ; then
368 echo "Solaris AIO support $solaris_aio"
370 ##########################################
371 # __sync_fetch_and_and test
374 static int sfaa(int *ptr)
376 return __sync_fetch_and_and(ptr, 0);
379 int main(int argc, char **argv)
386 if compile_prog "" "" "__sync_fetch_and_add()" ; then
389 echo "__sync_fetch_and add $sfaa"
391 ##########################################
396 #include <infiniband/arch.h>
397 int main(int argc, char **argv)
399 struct ibv_pd *pd = ibv_alloc_pd(NULL);
403 if compile_prog "" "-libverbs" "libverbs" ; then
405 LIBS="-libverbs $LIBS"
407 echo "libverbs $libverbs"
409 ##########################################
414 #include <rdma/rdma_cma.h>
415 int main(int argc, char **argv)
417 rdma_destroy_qp(NULL);
421 if compile_prog "" "-lrdmacm" "rdma"; then
423 LIBS="-lrdmacm $LIBS"
425 echo "rdmacm $rdmacm"
427 ##########################################
428 # Linux fallocate probe
432 #include <linux/falloc.h>
433 int main(int argc, char **argv)
435 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
439 if compile_prog "" "" "linux_fallocate"; then
440 linux_fallocate="yes"
442 echo "Linux fallocate $linux_fallocate"
444 ##########################################
445 # POSIX fadvise probe
450 int main(int argc, char **argv)
452 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
456 if compile_prog "" "" "posix_fadvise"; then
459 echo "POSIX fadvise $posix_fadvise"
461 ##########################################
462 # POSIX fallocate probe
467 int main(int argc, char **argv)
469 int r = posix_fallocate(0, 0, 1024);
473 if compile_prog "" "" "posix_fallocate"; then
474 posix_fallocate="yes"
476 echo "POSIX fallocate $posix_fallocate"
478 ##########################################
479 # sched_set/getaffinity 2 or 3 argument test
480 linux_2arg_affinity="no"
481 linux_3arg_affinity="no"
485 int main(int argc, char **argv)
488 return sched_setaffinity(0, sizeof(mask), &mask);
491 if compile_prog "" "" "sched_setaffinity(,,)"; then
492 linux_3arg_affinity="yes"
497 int main(int argc, char **argv)
500 return sched_setaffinity(0, &mask);
503 if compile_prog "" "" "sched_setaffinity(,)"; then
504 linux_2arg_affinity="yes"
507 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
508 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
510 ##########################################
511 # clock_gettime probe
516 int main(int argc, char **argv)
518 return clock_gettime(0, NULL);
521 if compile_prog "" "" "clock_gettime"; then
523 elif compile_prog "" "-lrt" "clock_gettime"; then
527 echo "clock_gettime $clock_gettime"
529 ##########################################
530 # CLOCK_MONOTONIC probe
532 if test "$clock_gettime" = "yes" ; then
536 int main(int argc, char **argv)
538 return clock_gettime(CLOCK_MONOTONIC, NULL);
541 if compile_prog "" "$LIBS" "clock monotonic"; then
542 clock_monotonic="yes"
545 echo "CLOCK_MONOTONIC $clock_monotonic"
547 ##########################################
548 # CLOCK_MONOTONIC_PRECISE probe
549 clock_monotonic_precise="no"
550 if test "$clock_gettime" = "yes" ; then
554 int main(int argc, char **argv)
556 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
559 if compile_prog "" "$LIBS" "clock monotonic precise"; then
560 clock_monotonic_precise="yes"
563 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
565 ##########################################
566 # gettimeofday() probe
569 #include <sys/time.h>
571 int main(int argc, char **argv)
574 return gettimeofday(&tv, NULL);
577 if compile_prog "" "" "gettimeofday"; then
580 echo "gettimeofday $gettimeofday"
582 ##########################################
588 int main(int argc, char **argv)
593 if compile_prog "" "" "fdatasync"; then
596 echo "fdatasync $fdatasync"
598 ##########################################
599 # 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 ##########################################
648 int main(int argc, char **argv)
650 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
653 if compile_prog "" "" "linux splice"; then
656 echo "Linux splice(2) $linux_splice"
658 ##########################################
663 #include <guasi_syscalls.h>
664 int main(int argc, char **argv)
666 guasi_t ctx = guasi_create(0, 0, 0);
670 if compile_prog "" "" "guasi"; then
675 ##########################################
679 #include <nvm/vectored_write.h>
680 int main(int argc, char **argv)
682 struct vsl_iovec iov;
683 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
686 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
687 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
690 echo "Fusion-io atomic engine $fusion_aw"
692 ##########################################
697 int main(int argc, char **argv)
699 return numa_available();
702 if compile_prog "" "-lnuma" "libnuma"; then
706 echo "libnuma $libnuma"
708 ##########################################
713 int main(int argc, char **argv)
719 if compile_prog "" "" "strsep"; then
722 echo "strsep $strsep"
724 ##########################################
725 # getopt_long_only() probe
726 getopt_long_only="no"
730 int main(int argc, char **argv)
732 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
736 if compile_prog "" "" "getopt_long_only"; then
737 getopt_long_only="yes"
739 echo "getopt_long_only() $getopt_long_only"
741 ##########################################
745 #include <sys/socket.h>
746 #include <arpa/inet.h>
748 int main(int argc, char **argv)
751 return inet_aton(NULL, &in);
754 if compile_prog "" "" "inet_aton"; then
757 echo "inet_aton $inet_aton"
759 ##########################################
764 #include <netinet/in.h>
765 int main(int argc, char **argv)
771 if compile_prog "" "" "socklen_t"; then
774 echo "socklen_t $socklen_t"
776 ##########################################
777 # Whether or not __thread is supported for TLS
781 static int __thread ret;
782 int main(int argc, char **argv)
787 if compile_prog "" "" "__thread"; then
790 echo "__thread $tls_thread"
792 #############################################################################
794 echo "# Automatically generated by configure - do not modify" > $config_host_mak
795 printf "# Configured with:" >> $config_host_mak
796 printf " '%s'" "$0" "$@" >> $config_host_mak
797 echo >> $config_host_mak
799 if test "$wordsize" = "64" ; then
800 echo "CONFIG_64BIT=y" >> $config_host_mak
801 elif test "$wordsize" = "32" ; then
802 echo "CONFIG_32BIT=y" >> $config_host_mak
804 echo "Unknown wordsize!"
807 if test "$bigendian" = "yes" ; then
808 echo "CONFIG_BIG_ENDIAN=y" >> $config_host_mak
810 echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
812 if test "$libaio" = "yes" ; then
813 echo "CONFIG_LIBAIO=y" >> $config_host_mak
815 if test "$posix_aio" = "yes" ; then
816 echo "CONFIG_POSIXAIO=y" >> $config_host_mak
818 if test "$posix_aio_fsync" = "yes" ; then
819 echo "CONFIG_POSIXAIO_FSYNC=y" >> $config_host_mak
821 if test "$linux_fallocate" = "yes" ; then
822 echo "CONFIG_LINUX_FALLOCATE=y" >> $config_host_mak
824 if test "$posix_fallocate" = "yes" ; then
825 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
827 if test "$fdatasync" = "yes" ; then
828 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
830 if test "$sync_file_range" = "yes" ; then
831 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
833 if test "$sfaa" = "yes" ; then
834 echo "CONFIG_SFAA=y" >> $config_host_mak
836 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
837 echo "CONFIG_RDMA=y" >> $config_host_mak
839 if test "$clock_gettime" = "yes" ; then
840 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
842 if test "$clock_monotonic" = "yes" ; then
843 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
845 if test "$clock_monotonic_precise" = "yes" ; then
846 echo "CONFIG_CLOCK_MONOTONIC_PRECISE=y" >> $config_host_mak
848 if test "$gettimeofday" = "yes" ; then
849 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
851 if test "$posix_fadvise" = "yes" ; then
852 echo "CONFIG_POSIX_FADVISE=y" >> $config_host_mak
854 if test "$linux_3arg_affinity" = "yes" ; then
855 echo "CONFIG_3ARG_AFFINITY=y" >> $config_host_mak
856 elif test "$linux_2arg_affinity" = "yes" ; then
857 echo "CONFIG_2ARG_AFFINITY=y" >> $config_host_mak
859 if test "$strsep" = "yes" ; then
860 echo "CONFIG_STRSEP=y" >> $config_host_mak
862 if test "$getopt_long_only" = "yes" ; then
863 echo "CONFIG_GETOPT_LONG_ONLY=y" >> $config_host_mak
865 if test "$inet_aton" = "yes" ; then
866 echo "CONFIG_INET_ATON=y" >> $config_host_mak
868 if test "$socklen_t" = "yes" ; then
869 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
871 if test "$ext4_me" = "yes" ; then
872 echo "CONFIG_LINUX_EXT4_MOVE_EXTENT=y" >> $config_host_mak
874 if test "$linux_splice" = "yes" ; then
875 echo "CONFIG_LINUX_SPLICE=y" >> $config_host_mak
877 if test "$guasi" = "yes" ; then
878 echo "CONFIG_GUASI=y" >> $config_host_mak
880 if test "$fusion_aw" = "yes" ; then
881 echo "CONFIG_FUSION_AW=y" >> $config_host_mak
883 if test "$libnuma" = "yes" ; then
884 echo "CONFIG_LIBNUMA=y" >> $config_host_mak
886 if test "$solaris_aio" = "yes" ; then
887 echo "CONFIG_SOLARISAIO=y" >> $config_host_mak
889 if test "$tls_thread" = "yes" ; then
890 echo "CONFIG_TLS_THREAD=y" >> $config_host_mak
893 echo "LIBS+=$LIBS" >> $config_host_mak
894 echo "CC=$cc" >> $config_host_mak