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}"
105 if check_define __linux__ ; then
107 elif check_define _WIN32 ; then
109 elif check_define __OpenBSD__ ; then
111 elif check_define __sun__ ; then
117 # Some host OSes need non-standard checks for which CPU to use.
118 # Note that these checks are broken for cross-compilation: if you're
119 # cross-compiling to one of these OSes then you'll need to specify
120 # the correct CPU with the --cpu option.
123 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
124 # we can run 64-bit userspace code.
125 # If the user didn't specify a CPU explicitly and the kernel says this is
126 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
128 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
133 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
134 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
139 if test ! -z "$cpu" ; then
140 # command line argument
142 elif check_define __i386__ ; then
144 elif check_define __x86_64__ ; then
146 elif check_define __sparc__ ; then
147 if check_define __arch64__ ; then
152 elif check_define _ARCH_PPC ; then
153 if check_define _ARCH_PPC64 ; then
158 elif check_define __mips__ ; then
160 elif check_define __ia64__ ; then
162 elif check_define __s390__ ; then
163 if check_define __s390x__ ; then
168 elif check_define __arm__ ; then
170 elif check_define __hppa__ ; then
176 # Normalise host CPU name and set ARCH.
178 ia64|ppc|ppc64|s390|s390x|sparc64)
181 i386|i486|i586|i686|i86pc|BePC)
190 hppa|parisc|parisc64)
206 if test "$targetos" = "FreeBSD"; then
212 elif test "$targetos" = "MINGW32"; then
213 CC=x86_64-w64-mingw32-gcc
217 cc="${CC-${cross_prefix}gcc}"
219 echo "Operating system $targetos"
224 ##########################################
231 unsigned int wsize = sizeof(long) * 8;
232 printf("%d\n", wsize);
236 if compile_prog "" "" "wordsize"; then
239 echo "Wordsize $wordsize"
241 ##########################################
253 if compile_prog "" "-laio" "libaio" ; then
257 if test "$libaio" = "yes" ; then
258 feature_not_found "linux AIO"
262 echo "Linux AIO support $libaio"
264 ##########################################
277 if compile_prog "" "" "posixaio" ; then
279 elif compile_prog "" "-lrt" "posixaio"; then
284 echo "POSIX AIO support $posix_aio"
285 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
287 ##########################################
288 # posix aio fsync probe
290 if test "$posix_aio" = "yes" ; then
297 return aio_fsync(O_SYNC, &cb);
301 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
305 echo "POSIX AIO fsync $posix_aio_fsync"
307 ##########################################
311 #include <sys/types.h>
312 #include <sys/asynch.h>
317 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
321 if compile_prog "" "-laio" "solarisaio" ; then
325 echo "Solaris AIO support $solaris_aio"
327 ##########################################
328 # __sync_fetch_and_and test
331 static int sfaa(int *ptr)
333 return __sync_fetch_and_and(ptr, 0);
336 int main(int argc, char **argv)
343 if compile_prog "" "" "__sync_fetch_and_add()" ; then
346 echo "__sync_fetch_and add $sfaa"
348 ##########################################
353 #include <infiniband/arch.h>
354 int main(int argc, char **argv)
356 struct ibv_pd *pd = ibv_alloc_pd(NULL);
360 if compile_prog "" "-libverbs" "libverbs" ; then
362 LIBS="-libverbs $LIBS"
364 echo "libverbs $libverbs"
366 ##########################################
371 #include <rdma/rdma_cma.h>
372 int main(int argc, char **argv)
374 rdma_destroy_qp(NULL);
378 if compile_prog "" "-lrdmacm" "rdma"; then
380 LIBS="-lrdmacm $LIBS"
382 echo "rdmacm $rdmacm"
384 ##########################################
385 # Linux fallocate probe
389 #include <linux/falloc.h>
390 int main(int argc, char **argv)
392 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
396 if compile_prog "" "" "linux_fallocate"; then
397 linux_fallocate="yes"
399 echo "Linux fallocate $linux_fallocate"
401 ##########################################
402 # POSIX fadvise probe
407 int main(int argc, char **argv)
409 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
413 if compile_prog "" "" "posix_fadvise"; then
416 echo "POSIX fadvise $posix_fadvise"
418 ##########################################
419 # POSIX fallocate probe
424 int main(int argc, char **argv)
426 int r = posix_fallocate(0, 0, 1024);
430 if compile_prog "" "" "posix_fallocate"; then
431 posix_fallocate="yes"
433 echo "POSIX fallocate $posix_fallocate"
435 ##########################################
436 # sched_set/getaffinity 2 or 3 argument test
437 linux_2arg_affinity="no"
438 linux_3arg_affinity="no"
442 int main(int argc, char **argv)
445 return sched_setaffinity(0, sizeof(mask), &mask);
448 if compile_prog "" "" "sched_setaffinity(,,)"; then
449 linux_3arg_affinity="yes"
454 int main(int argc, char **argv)
457 return sched_setaffinity(0, &mask);
460 if compile_prog "" "" "sched_setaffinity(,)"; then
461 linux_2arg_affinity="yes"
464 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
465 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
467 ##########################################
468 # clock_gettime probe
473 int main(int argc, char **argv)
475 return clock_gettime(0, NULL);
478 if compile_prog "" "" "clock_gettime"; then
480 elif compile_prog "" "-lrt" "clock_gettime"; then
484 echo "clock_gettime $clock_gettime"
486 ##########################################
487 # CLOCK_MONOTONIC probe
489 if test "$clock_gettime" = "yes" ; then
493 int main(int argc, char **argv)
495 return clock_gettime(CLOCK_MONOTONIC, NULL);
498 if compile_prog "" "$LIBS" "clock monotonic"; then
499 clock_monotonic="yes"
502 echo "CLOCK_MONOTONIC $clock_monotonic"
504 ##########################################
505 # CLOCK_MONOTONIC_PRECISE probe
506 clock_monotonic_precise="no"
507 if test "$clock_gettime" = "yes" ; then
511 int main(int argc, char **argv)
513 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
516 if compile_prog "" "$LIBS" "clock monotonic precise"; then
517 clock_monotonic_precise="yes"
520 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
522 ##########################################
523 # gettimeofday() probe
526 #include <sys/time.h>
528 int main(int argc, char **argv)
531 return gettimeofday(&tv, NULL);
534 if compile_prog "" "" "gettimeofday"; then
537 echo "gettimeofday $gettimeofday"
539 ##########################################
545 int main(int argc, char **argv)
550 if compile_prog "" "" "fdatasync"; then
553 echo "fdatasync $fdatasync"
555 ##########################################
556 # sync_file_range() probe
563 #include <linux/fs.h>
564 int main(int argc, char **argv)
566 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
567 SYNC_FILE_RANGE_WAIT_AFTER;
568 return sync_file_range(0, 0, 0, flags);
571 if compile_prog "" "" "sync_file_range"; then
572 sync_file_range="yes"
574 echo "sync_file_range $sync_file_range"
576 ##########################################
577 # ext4 move extent probe
581 #include <sys/ioctl.h>
582 int main(int argc, char **argv)
584 struct move_extent me;
585 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
588 if compile_prog "" "" "ext4 move extent"; then
591 echo "EXT4 move extent $ext4_me"
593 ##########################################
600 int main(int argc, char **argv)
602 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
605 if compile_prog "" "" "linux splice"; then
608 echo "Linux splice(2) $linux_splice"
610 ##########################################
615 #include <guasi_syscalls.h>
616 int main(int argc, char **argv)
618 guasi_t ctx = guasi_create(0, 0, 0);
622 if compile_prog "" "" "guasi"; then
627 ##########################################
631 #include <vsl_dp_experimental/vectored_write.h>
632 int main(int argc, char **argv)
634 struct vsl_iovec iov;
635 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
638 if compile_prog "" "" "fusion-aw"; then
641 echo "Fusion-io atomic engine $fusion_aw"
643 ##########################################
648 int main(int argc, char **argv)
650 return numa_available();
653 if compile_prog "" "-lnuma" "libnuma"; then
657 echo "libnuma $libnuma"
659 ##########################################
664 int main(int argc, char **argv)
670 if compile_prog "" "" "strsep"; then
673 echo "strsep $strsep"
675 ##########################################
676 # getopt_long_only() probe
677 getopt_long_only="no"
681 int main(int argc, char **argv)
683 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
687 if compile_prog "" "" "getopt_long_only"; then
688 getopt_long_only="yes"
690 echo "getopt_long_only() $getopt_long_only"
692 ##########################################
696 #include <sys/socket.h>
697 #include <arpa/inet.h>
699 int main(int argc, char **argv)
702 return inet_aton(NULL, &in);
705 if compile_prog "" "" "inet_aton"; then
708 echo "inet_aton $inet_aton"
710 ##########################################
715 #include <netinet/in.h>
716 int main(int argc, char **argv)
722 if compile_prog "" "" "socklen_t"; then
725 echo "socklen_t $socklen_t"
727 ##########################################
728 # Whether or not __thread is supported for TLS
732 static int __thread ret;
733 int main(int argc, char **argv)
738 if compile_prog "" "" "__thread"; then
741 echo "__thread $tls_thread"
743 #############################################################################
745 echo "# Automatically generated by configure - do not modify" > $config_host_mak
746 printf "# Configured with:" >> $config_host_mak
747 printf " '%s'" "$0" "$@" >> $config_host_mak
748 echo >> $config_host_mak
750 if test "$wordsize" = "64" ; then
751 echo "CONFIG_64BIT=y" >> $config_host_mak
752 elif test "$wordsize" = "32" ; then
753 echo "CONFIG_32BIT=y" >> $config_host_mak
755 echo "Unknown wordsize!"
758 if test "$libaio" = "yes" ; then
759 echo "CONFIG_LIBAIO=y" >> $config_host_mak
761 if test "$posix_aio" = "yes" ; then
762 echo "CONFIG_POSIXAIO=y" >> $config_host_mak
764 if test "$posix_aio_fsync" = "yes" ; then
765 echo "CONFIG_POSIXAIO_FSYNC=y" >> $config_host_mak
767 if test "$linux_fallocate" = "yes" ; then
768 echo "CONFIG_LINUX_FALLOCATE=y" >> $config_host_mak
770 if test "$posix_fallocate" = "yes" ; then
771 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
773 if test "$fdatasync" = "yes" ; then
774 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
776 if test "$sync_file_range" = "yes" ; then
777 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
779 if test "$sfaa" = "yes" ; then
780 echo "CONFIG_SFAA=y" >> $config_host_mak
782 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
783 echo "CONFIG_RDMA=y" >> $config_host_mak
785 if test "$clock_gettime" = "yes" ; then
786 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
788 if test "$clock_monotonic" = "yes" ; then
789 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
791 if test "$clock_monotonic_precise" = "yes" ; then
792 echo "CONFIG_CLOCK_MONOTONIC_PRECISE=y" >> $config_host_mak
794 if test "$gettimeofday" = "yes" ; then
795 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
797 if test "$posix_fadvise" = "yes" ; then
798 echo "CONFIG_POSIX_FADVISE=y" >> $config_host_mak
800 if test "$linux_3arg_affinity" = "yes" ; then
801 echo "CONFIG_3ARG_AFFINITY=y" >> $config_host_mak
802 elif test "$linux_2arg_affinity" = "yes" ; then
803 echo "CONFIG_2ARG_AFFINITY=y" >> $config_host_mak
805 if test "$strsep" = "yes" ; then
806 echo "CONFIG_STRSEP=y" >> $config_host_mak
808 if test "$getopt_long_only" = "yes" ; then
809 echo "CONFIG_GETOPT_LONG_ONLY=y" >> $config_host_mak
811 if test "$inet_aton" = "yes" ; then
812 echo "CONFIG_INET_ATON=y" >> $config_host_mak
814 if test "$socklen_t" = "yes" ; then
815 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
817 if test "$ext4_me" = "yes" ; then
818 echo "CONFIG_LINUX_EXT4_MOVE_EXTENT=y" >> $config_host_mak
820 if test "$linux_splice" = "yes" ; then
821 echo "CONFIG_LINUX_SPLICE=y" >> $config_host_mak
823 if test "$guasi" = "yes" ; then
824 echo "CONFIG_GUASI=y" >> $config_host_mak
826 if test "$fusion_aw" = "yes" ; then
827 echo "CONFIG_FUSION_AW=y" >> $config_host_mak
829 if test "$libnuma" = "yes" ; then
830 echo "CONFIG_LIBNUMA=y" >> $config_host_mak
832 if test "$solaris_aio" = "yes" ; then
833 echo "CONFIG_SOLARISAIO=y" >> $config_host_mak
835 if test "$tls_thread" = "yes" ; then
836 echo "CONFIG_TLS_THREAD=y" >> $config_host_mak
839 echo "LIBS+=$LIBS" >> $config_host_mak
840 echo "CC=$cc" >> $config_host_mak