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 _WIN32 ; then
120 echo "Forcing known good options on Windows"
121 echo "CONFIG_64BIT_LLP64=y" >> $config_host_mak
122 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
123 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
124 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
125 echo "CONFIG_FADVISE=y" >> $config_host_mak
126 echo "CONFIG_STRSEP=y" >> $config_host_mak
127 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
128 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
129 echo "CONFIG_FADVISE=y" >> $config_host_mak
130 echo "CONFIG_SFAA=y" >> $config_host_mak
132 elif check_define __OpenBSD__ ; then
134 elif check_define __sun__ ; then
140 # Some host OSes need non-standard checks for which CPU to use.
141 # Note that these checks are broken for cross-compilation: if you're
142 # cross-compiling to one of these OSes then you'll need to specify
143 # the correct CPU with the --cpu option.
146 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
147 # we can run 64-bit userspace code.
148 # If the user didn't specify a CPU explicitly and the kernel says this is
149 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
151 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
156 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
157 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
162 if test ! -z "$cpu" ; then
163 # command line argument
165 elif check_define __i386__ ; then
167 elif check_define __x86_64__ ; then
169 elif check_define __sparc__ ; then
170 if check_define __arch64__ ; then
175 elif check_define _ARCH_PPC ; then
176 if check_define _ARCH_PPC64 ; then
181 elif check_define __mips__ ; then
183 elif check_define __ia64__ ; then
185 elif check_define __s390__ ; then
186 if check_define __s390x__ ; then
191 elif check_define __arm__ ; then
193 elif check_define __hppa__ ; then
199 # Normalise host CPU name and set ARCH.
201 ia64|ppc|ppc64|s390|s390x|sparc64)
204 i386|i486|i586|i686|i86pc|BePC)
213 hppa|parisc|parisc64)
229 if test "$targetos" = "FreeBSD"; then
238 cc="${CC-${cross_prefix}gcc}"
240 echo "Operating system $targetos"
245 ##########################################
252 unsigned int wsize = sizeof(long) * 8;
253 printf("%d\n", wsize);
257 if compile_prog "" "" "wordsize"; then
260 echo "Wordsize $wordsize"
262 ##########################################
274 if compile_prog "" "-laio" "libaio" ; then
278 if test "$libaio" = "yes" ; then
279 feature_not_found "linux AIO"
283 echo "Linux AIO support $libaio"
285 ##########################################
298 if compile_prog "" "" "posixaio" ; then
300 elif compile_prog "" "-lrt" "posixaio"; then
305 echo "POSIX AIO support $posix_aio"
306 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
308 ##########################################
309 # posix aio fsync probe
311 if test "$posix_aio" = "yes" ; then
318 return aio_fsync(O_SYNC, &cb);
322 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
326 echo "POSIX AIO fsync $posix_aio_fsync"
328 ##########################################
332 #include <sys/types.h>
333 #include <sys/asynch.h>
338 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
342 if compile_prog "" "-laio" "solarisaio" ; then
346 echo "Solaris AIO support $solaris_aio"
348 ##########################################
349 # __sync_fetch_and_and test
352 static int sfaa(int *ptr)
354 return __sync_fetch_and_and(ptr, 0);
357 int main(int argc, char **argv)
364 if compile_prog "" "" "__sync_fetch_and_add()" ; then
367 echo "__sync_fetch_and add $sfaa"
369 ##########################################
374 #include <infiniband/arch.h>
375 int main(int argc, char **argv)
377 struct ibv_pd *pd = ibv_alloc_pd(NULL);
381 if compile_prog "" "-libverbs" "libverbs" ; then
383 LIBS="-libverbs $LIBS"
385 echo "libverbs $libverbs"
387 ##########################################
392 #include <rdma/rdma_cma.h>
393 int main(int argc, char **argv)
395 rdma_destroy_qp(NULL);
399 if compile_prog "" "-lrdmacm" "rdma"; then
401 LIBS="-lrdmacm $LIBS"
403 echo "rdmacm $rdmacm"
405 ##########################################
406 # Linux fallocate probe
410 #include <linux/falloc.h>
411 int main(int argc, char **argv)
413 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
417 if compile_prog "" "" "linux_fallocate"; then
418 linux_fallocate="yes"
420 echo "Linux fallocate $linux_fallocate"
422 ##########################################
423 # POSIX fadvise probe
428 int main(int argc, char **argv)
430 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
434 if compile_prog "" "" "posix_fadvise"; then
437 echo "POSIX fadvise $posix_fadvise"
439 ##########################################
440 # POSIX fallocate probe
445 int main(int argc, char **argv)
447 int r = posix_fallocate(0, 0, 1024);
451 if compile_prog "" "" "posix_fallocate"; then
452 posix_fallocate="yes"
454 echo "POSIX fallocate $posix_fallocate"
456 ##########################################
457 # sched_set/getaffinity 2 or 3 argument test
458 linux_2arg_affinity="no"
459 linux_3arg_affinity="no"
463 int main(int argc, char **argv)
466 return sched_setaffinity(0, sizeof(mask), &mask);
469 if compile_prog "" "" "sched_setaffinity(,,)"; then
470 linux_3arg_affinity="yes"
475 int main(int argc, char **argv)
478 return sched_setaffinity(0, &mask);
481 if compile_prog "" "" "sched_setaffinity(,)"; then
482 linux_2arg_affinity="yes"
485 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
486 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
488 ##########################################
489 # clock_gettime probe
494 int main(int argc, char **argv)
496 return clock_gettime(0, NULL);
499 if compile_prog "" "" "clock_gettime"; then
501 elif compile_prog "" "-lrt" "clock_gettime"; then
505 echo "clock_gettime $clock_gettime"
507 ##########################################
508 # CLOCK_MONOTONIC probe
510 if test "$clock_gettime" = "yes" ; then
514 int main(int argc, char **argv)
516 return clock_gettime(CLOCK_MONOTONIC, NULL);
519 if compile_prog "" "$LIBS" "clock monotonic"; then
520 clock_monotonic="yes"
523 echo "CLOCK_MONOTONIC $clock_monotonic"
525 ##########################################
526 # CLOCK_MONOTONIC_PRECISE probe
527 clock_monotonic_precise="no"
528 if test "$clock_gettime" = "yes" ; then
532 int main(int argc, char **argv)
534 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
537 if compile_prog "" "$LIBS" "clock monotonic precise"; then
538 clock_monotonic_precise="yes"
541 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
543 ##########################################
544 # gettimeofday() probe
547 #include <sys/time.h>
549 int main(int argc, char **argv)
552 return gettimeofday(&tv, NULL);
555 if compile_prog "" "" "gettimeofday"; then
558 echo "gettimeofday $gettimeofday"
560 ##########################################
566 int main(int argc, char **argv)
571 if compile_prog "" "" "fdatasync"; then
574 echo "fdatasync $fdatasync"
576 ##########################################
577 # sync_file_range() probe
584 #include <linux/fs.h>
585 int main(int argc, char **argv)
587 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
588 SYNC_FILE_RANGE_WAIT_AFTER;
589 return sync_file_range(0, 0, 0, flags);
592 if compile_prog "" "" "sync_file_range"; then
593 sync_file_range="yes"
595 echo "sync_file_range $sync_file_range"
597 ##########################################
598 # ext4 move extent probe
602 #include <sys/ioctl.h>
603 int main(int argc, char **argv)
605 struct move_extent me;
606 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
609 if compile_prog "" "" "ext4 move extent" ; then
611 elif test $targetos = "Linux" ; then
612 # On Linux, just default to it on and let it error at runtime if we really
613 # don't have it. None of my updated systems have it defined, but it does
614 # work. Takes a while to bubble back.
617 echo "EXT4 move extent $ext4_me"
619 ##########################################
626 int main(int argc, char **argv)
628 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
631 if compile_prog "" "" "linux splice"; then
634 echo "Linux splice(2) $linux_splice"
636 ##########################################
641 #include <guasi_syscalls.h>
642 int main(int argc, char **argv)
644 guasi_t ctx = guasi_create(0, 0, 0);
648 if compile_prog "" "" "guasi"; then
653 ##########################################
657 #include <nvm/vectored_write.h>
658 int main(int argc, char **argv)
660 struct vsl_iovec iov;
661 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
664 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
665 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
668 echo "Fusion-io atomic engine $fusion_aw"
670 ##########################################
675 int main(int argc, char **argv)
677 return numa_available();
680 if compile_prog "" "-lnuma" "libnuma"; then
684 echo "libnuma $libnuma"
686 ##########################################
691 int main(int argc, char **argv)
697 if compile_prog "" "" "strsep"; then
700 echo "strsep $strsep"
702 ##########################################
703 # getopt_long_only() probe
704 getopt_long_only="no"
708 int main(int argc, char **argv)
710 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
714 if compile_prog "" "" "getopt_long_only"; then
715 getopt_long_only="yes"
717 echo "getopt_long_only() $getopt_long_only"
719 ##########################################
723 #include <sys/socket.h>
724 #include <arpa/inet.h>
726 int main(int argc, char **argv)
729 return inet_aton(NULL, &in);
732 if compile_prog "" "" "inet_aton"; then
735 echo "inet_aton $inet_aton"
737 ##########################################
742 #include <netinet/in.h>
743 int main(int argc, char **argv)
749 if compile_prog "" "" "socklen_t"; then
752 echo "socklen_t $socklen_t"
754 ##########################################
755 # Whether or not __thread is supported for TLS
759 static int __thread ret;
760 int main(int argc, char **argv)
765 if compile_prog "" "" "__thread"; then
768 echo "__thread $tls_thread"
770 #############################################################################
772 echo "# Automatically generated by configure - do not modify" > $config_host_mak
773 printf "# Configured with:" >> $config_host_mak
774 printf " '%s'" "$0" "$@" >> $config_host_mak
775 echo >> $config_host_mak
777 if test "$wordsize" = "64" ; then
778 echo "CONFIG_64BIT=y" >> $config_host_mak
779 elif test "$wordsize" = "32" ; then
780 echo "CONFIG_32BIT=y" >> $config_host_mak
782 echo "Unknown wordsize!"
785 if test "$libaio" = "yes" ; then
786 echo "CONFIG_LIBAIO=y" >> $config_host_mak
788 if test "$posix_aio" = "yes" ; then
789 echo "CONFIG_POSIXAIO=y" >> $config_host_mak
791 if test "$posix_aio_fsync" = "yes" ; then
792 echo "CONFIG_POSIXAIO_FSYNC=y" >> $config_host_mak
794 if test "$linux_fallocate" = "yes" ; then
795 echo "CONFIG_LINUX_FALLOCATE=y" >> $config_host_mak
797 if test "$posix_fallocate" = "yes" ; then
798 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
800 if test "$fdatasync" = "yes" ; then
801 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
803 if test "$sync_file_range" = "yes" ; then
804 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
806 if test "$sfaa" = "yes" ; then
807 echo "CONFIG_SFAA=y" >> $config_host_mak
809 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
810 echo "CONFIG_RDMA=y" >> $config_host_mak
812 if test "$clock_gettime" = "yes" ; then
813 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
815 if test "$clock_monotonic" = "yes" ; then
816 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
818 if test "$clock_monotonic_precise" = "yes" ; then
819 echo "CONFIG_CLOCK_MONOTONIC_PRECISE=y" >> $config_host_mak
821 if test "$gettimeofday" = "yes" ; then
822 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
824 if test "$posix_fadvise" = "yes" ; then
825 echo "CONFIG_POSIX_FADVISE=y" >> $config_host_mak
827 if test "$linux_3arg_affinity" = "yes" ; then
828 echo "CONFIG_3ARG_AFFINITY=y" >> $config_host_mak
829 elif test "$linux_2arg_affinity" = "yes" ; then
830 echo "CONFIG_2ARG_AFFINITY=y" >> $config_host_mak
832 if test "$strsep" = "yes" ; then
833 echo "CONFIG_STRSEP=y" >> $config_host_mak
835 if test "$getopt_long_only" = "yes" ; then
836 echo "CONFIG_GETOPT_LONG_ONLY=y" >> $config_host_mak
838 if test "$inet_aton" = "yes" ; then
839 echo "CONFIG_INET_ATON=y" >> $config_host_mak
841 if test "$socklen_t" = "yes" ; then
842 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
844 if test "$ext4_me" = "yes" ; then
845 echo "CONFIG_LINUX_EXT4_MOVE_EXTENT=y" >> $config_host_mak
847 if test "$linux_splice" = "yes" ; then
848 echo "CONFIG_LINUX_SPLICE=y" >> $config_host_mak
850 if test "$guasi" = "yes" ; then
851 echo "CONFIG_GUASI=y" >> $config_host_mak
853 if test "$fusion_aw" = "yes" ; then
854 echo "CONFIG_FUSION_AW=y" >> $config_host_mak
856 if test "$libnuma" = "yes" ; then
857 echo "CONFIG_LIBNUMA=y" >> $config_host_mak
859 if test "$solaris_aio" = "yes" ; then
860 echo "CONFIG_SOLARISAIO=y" >> $config_host_mak
862 if test "$tls_thread" = "yes" ; then
863 echo "CONFIG_TLS_THREAD=y" >> $config_host_mak
866 echo "LIBS+=$LIBS" >> $config_host_mak
867 echo "CC=$cc" >> $config_host_mak