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}"
110 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
119 echo "Bad option $opt"
124 if check_define __linux__ ; then
126 elif check_define __OpenBSD__ ; then
128 elif check_define __sun__ ; then
134 # Some host OSes need non-standard checks for which CPU to use.
135 # Note that these checks are broken for cross-compilation: if you're
136 # cross-compiling to one of these OSes then you'll need to specify
137 # the correct CPU with the --cpu option.
140 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
141 # we can run 64-bit userspace code.
142 # If the user didn't specify a CPU explicitly and the kernel says this is
143 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
145 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
150 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
151 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
156 echo "Forcing known good options on Windows"
157 if test -z "$CC" ; then
158 CC="x86_64-w64-mingw32-gcc"
160 echo "CC=$CC" > $config_host_mak
161 echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
162 echo "CONFIG_64BIT_LLP64=y" >> $config_host_mak
163 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
164 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
165 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
166 echo "CONFIG_FADVISE=y" >> $config_host_mak
167 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
168 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
169 echo "CONFIG_FADVISE=y" >> $config_host_mak
170 echo "CONFIG_SFAA=y" >> $config_host_mak
174 if test ! -z "$cpu" ; then
175 # command line argument
177 elif check_define __i386__ ; then
179 elif check_define __x86_64__ ; then
181 elif check_define __sparc__ ; then
182 if check_define __arch64__ ; then
187 elif check_define _ARCH_PPC ; then
188 if check_define _ARCH_PPC64 ; then
193 elif check_define __mips__ ; then
195 elif check_define __ia64__ ; then
197 elif check_define __s390__ ; then
198 if check_define __s390x__ ; then
203 elif check_define __arm__ ; then
205 elif check_define __hppa__ ; then
211 # Normalise host CPU name and set ARCH.
213 ia64|ppc|ppc64|s390|s390x|sparc64)
216 i386|i486|i586|i686|i86pc|BePC)
225 hppa|parisc|parisc64)
241 if test "$targetos" = "FreeBSD"; then
250 cc="${CC-${cross_prefix}gcc}"
252 ##########################################
256 #include <inttypes.h>
259 volatile uint32_t i=0x01234567;
260 return (*((uint8_t*)(&i))) == 0x67;
263 if compile_prog "" "" "endian"; then
264 $TMPE && bigendian="yes"
268 echo "Operating system $targetos"
270 echo "Big endian $bigendian"
274 ##########################################
281 unsigned int wsize = sizeof(long) * 8;
282 printf("%d\n", wsize);
286 if compile_prog "" "" "wordsize"; then
289 echo "Wordsize $wordsize"
291 ##########################################
303 if compile_prog "" "-laio" "libaio" ; then
307 if test "$libaio" = "yes" ; then
308 feature_not_found "linux AIO"
312 echo "Linux AIO support $libaio"
314 ##########################################
327 if compile_prog "" "" "posixaio" ; then
329 elif compile_prog "" "-lrt" "posixaio"; then
334 echo "POSIX AIO support $posix_aio"
335 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
337 ##########################################
338 # posix aio fsync probe
340 if test "$posix_aio" = "yes" ; then
347 return aio_fsync(O_SYNC, &cb);
351 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
355 echo "POSIX AIO fsync $posix_aio_fsync"
357 ##########################################
361 #include <sys/types.h>
362 #include <sys/asynch.h>
367 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
371 if compile_prog "" "-laio" "solarisaio" ; then
375 echo "Solaris AIO support $solaris_aio"
377 ##########################################
378 # __sync_fetch_and_and test
381 static int sfaa(int *ptr)
383 return __sync_fetch_and_and(ptr, 0);
386 int main(int argc, char **argv)
393 if compile_prog "" "" "__sync_fetch_and_add()" ; then
396 echo "__sync_fetch_and add $sfaa"
398 ##########################################
403 #include <infiniband/arch.h>
404 int main(int argc, char **argv)
406 struct ibv_pd *pd = ibv_alloc_pd(NULL);
410 if compile_prog "" "-libverbs" "libverbs" ; then
412 LIBS="-libverbs $LIBS"
414 echo "libverbs $libverbs"
416 ##########################################
421 #include <rdma/rdma_cma.h>
422 int main(int argc, char **argv)
424 rdma_destroy_qp(NULL);
428 if compile_prog "" "-lrdmacm" "rdma"; then
430 LIBS="-lrdmacm $LIBS"
432 echo "rdmacm $rdmacm"
434 ##########################################
435 # Linux fallocate probe
439 #include <linux/falloc.h>
440 int main(int argc, char **argv)
442 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
446 if compile_prog "" "" "linux_fallocate"; then
447 linux_fallocate="yes"
449 echo "Linux fallocate $linux_fallocate"
451 ##########################################
452 # POSIX fadvise probe
457 int main(int argc, char **argv)
459 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
463 if compile_prog "" "" "posix_fadvise"; then
466 echo "POSIX fadvise $posix_fadvise"
468 ##########################################
469 # POSIX fallocate probe
474 int main(int argc, char **argv)
476 int r = posix_fallocate(0, 0, 1024);
480 if compile_prog "" "" "posix_fallocate"; then
481 posix_fallocate="yes"
483 echo "POSIX fallocate $posix_fallocate"
485 ##########################################
486 # sched_set/getaffinity 2 or 3 argument test
487 linux_2arg_affinity="no"
488 linux_3arg_affinity="no"
492 int main(int argc, char **argv)
495 return sched_setaffinity(0, sizeof(mask), &mask);
498 if compile_prog "" "" "sched_setaffinity(,,)"; then
499 linux_3arg_affinity="yes"
504 int main(int argc, char **argv)
507 return sched_setaffinity(0, &mask);
510 if compile_prog "" "" "sched_setaffinity(,)"; then
511 linux_2arg_affinity="yes"
514 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
515 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
517 ##########################################
518 # clock_gettime probe
523 int main(int argc, char **argv)
525 return clock_gettime(0, NULL);
528 if compile_prog "" "" "clock_gettime"; then
530 elif compile_prog "" "-lrt" "clock_gettime"; then
534 echo "clock_gettime $clock_gettime"
536 ##########################################
537 # CLOCK_MONOTONIC probe
539 if test "$clock_gettime" = "yes" ; then
543 int main(int argc, char **argv)
545 return clock_gettime(CLOCK_MONOTONIC, NULL);
548 if compile_prog "" "$LIBS" "clock monotonic"; then
549 clock_monotonic="yes"
552 echo "CLOCK_MONOTONIC $clock_monotonic"
554 ##########################################
555 # CLOCK_MONOTONIC_PRECISE probe
556 clock_monotonic_precise="no"
557 if test "$clock_gettime" = "yes" ; then
561 int main(int argc, char **argv)
563 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
566 if compile_prog "" "$LIBS" "clock monotonic precise"; then
567 clock_monotonic_precise="yes"
570 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
572 ##########################################
573 # gettimeofday() probe
576 #include <sys/time.h>
578 int main(int argc, char **argv)
581 return gettimeofday(&tv, NULL);
584 if compile_prog "" "" "gettimeofday"; then
587 echo "gettimeofday $gettimeofday"
589 ##########################################
595 int main(int argc, char **argv)
600 if compile_prog "" "" "fdatasync"; then
603 echo "fdatasync $fdatasync"
605 ##########################################
606 # sync_file_range() probe
613 #include <linux/fs.h>
614 int main(int argc, char **argv)
616 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
617 SYNC_FILE_RANGE_WAIT_AFTER;
618 return sync_file_range(0, 0, 0, flags);
621 if compile_prog "" "" "sync_file_range"; then
622 sync_file_range="yes"
624 echo "sync_file_range $sync_file_range"
626 ##########################################
627 # ext4 move extent probe
631 #include <sys/ioctl.h>
632 int main(int argc, char **argv)
634 struct move_extent me;
635 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
638 if compile_prog "" "" "ext4 move extent" ; then
640 elif test $targetos = "Linux" ; then
641 # On Linux, just default to it on and let it error at runtime if we really
642 # don't have it. None of my updated systems have it defined, but it does
643 # work. Takes a while to bubble back.
646 echo "EXT4 move extent $ext4_me"
648 ##########################################
655 int main(int argc, char **argv)
657 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
660 if compile_prog "" "" "linux splice"; then
663 echo "Linux splice(2) $linux_splice"
665 ##########################################
670 #include <guasi_syscalls.h>
671 int main(int argc, char **argv)
673 guasi_t ctx = guasi_create(0, 0, 0);
677 if compile_prog "" "" "guasi"; then
682 ##########################################
686 #include <nvm/vectored_write.h>
687 int main(int argc, char **argv)
689 struct vsl_iovec iov;
690 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
693 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
694 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
697 echo "Fusion-io atomic engine $fusion_aw"
699 ##########################################
704 int main(int argc, char **argv)
706 return numa_available();
709 if compile_prog "" "-lnuma" "libnuma"; then
713 echo "libnuma $libnuma"
715 ##########################################
720 int main(int argc, char **argv)
726 if compile_prog "" "" "strsep"; then
729 echo "strsep $strsep"
731 ##########################################
732 # getopt_long_only() probe
733 getopt_long_only="no"
737 int main(int argc, char **argv)
739 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
743 if compile_prog "" "" "getopt_long_only"; then
744 getopt_long_only="yes"
746 echo "getopt_long_only() $getopt_long_only"
748 ##########################################
752 #include <sys/socket.h>
753 #include <arpa/inet.h>
755 int main(int argc, char **argv)
758 return inet_aton(NULL, &in);
761 if compile_prog "" "" "inet_aton"; then
764 echo "inet_aton $inet_aton"
766 ##########################################
771 #include <netinet/in.h>
772 int main(int argc, char **argv)
778 if compile_prog "" "" "socklen_t"; then
781 echo "socklen_t $socklen_t"
783 ##########################################
784 # Whether or not __thread is supported for TLS
788 static int __thread ret;
789 int main(int argc, char **argv)
794 if compile_prog "" "" "__thread"; then
797 echo "__thread $tls_thread"
799 ##########################################
800 # Whether or not __thread is supported for TLS
801 if test "$gfio" = "yes" ; then
814 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
815 if test "$?" != "0" ; then
816 echo "configure: gtk and gthread not found"
819 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
820 if test "$?" != "0" ; then
821 echo "configure: gtk and gthread not found"
824 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio"; then
826 LIBS="$LIBS $GTK_LIBS"
827 CFLAGS="$CFLAGS $GTK_CFLAGS"
829 echo "Please install gtk and gdk libraries"
836 #############################################################################
838 echo "# Automatically generated by configure - do not modify" > $config_host_mak
839 printf "# Configured with:" >> $config_host_mak
840 printf " '%s'" "$0" "$@" >> $config_host_mak
841 echo >> $config_host_mak
843 if test "$wordsize" = "64" ; then
844 echo "CONFIG_64BIT=y" >> $config_host_mak
845 elif test "$wordsize" = "32" ; then
846 echo "CONFIG_32BIT=y" >> $config_host_mak
848 echo "Unknown wordsize!"
851 if test "$bigendian" = "yes" ; then
852 echo "CONFIG_BIG_ENDIAN=y" >> $config_host_mak
854 echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
856 if test "$libaio" = "yes" ; then
857 echo "CONFIG_LIBAIO=y" >> $config_host_mak
859 if test "$posix_aio" = "yes" ; then
860 echo "CONFIG_POSIXAIO=y" >> $config_host_mak
862 if test "$posix_aio_fsync" = "yes" ; then
863 echo "CONFIG_POSIXAIO_FSYNC=y" >> $config_host_mak
865 if test "$linux_fallocate" = "yes" ; then
866 echo "CONFIG_LINUX_FALLOCATE=y" >> $config_host_mak
868 if test "$posix_fallocate" = "yes" ; then
869 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
871 if test "$fdatasync" = "yes" ; then
872 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
874 if test "$sync_file_range" = "yes" ; then
875 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
877 if test "$sfaa" = "yes" ; then
878 echo "CONFIG_SFAA=y" >> $config_host_mak
880 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
881 echo "CONFIG_RDMA=y" >> $config_host_mak
883 if test "$clock_gettime" = "yes" ; then
884 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
886 if test "$clock_monotonic" = "yes" ; then
887 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
889 if test "$clock_monotonic_precise" = "yes" ; then
890 echo "CONFIG_CLOCK_MONOTONIC_PRECISE=y" >> $config_host_mak
892 if test "$gettimeofday" = "yes" ; then
893 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
895 if test "$posix_fadvise" = "yes" ; then
896 echo "CONFIG_POSIX_FADVISE=y" >> $config_host_mak
898 if test "$linux_3arg_affinity" = "yes" ; then
899 echo "CONFIG_3ARG_AFFINITY=y" >> $config_host_mak
900 elif test "$linux_2arg_affinity" = "yes" ; then
901 echo "CONFIG_2ARG_AFFINITY=y" >> $config_host_mak
903 if test "$strsep" = "yes" ; then
904 echo "CONFIG_STRSEP=y" >> $config_host_mak
906 if test "$getopt_long_only" = "yes" ; then
907 echo "CONFIG_GETOPT_LONG_ONLY=y" >> $config_host_mak
909 if test "$inet_aton" = "yes" ; then
910 echo "CONFIG_INET_ATON=y" >> $config_host_mak
912 if test "$socklen_t" = "yes" ; then
913 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
915 if test "$ext4_me" = "yes" ; then
916 echo "CONFIG_LINUX_EXT4_MOVE_EXTENT=y" >> $config_host_mak
918 if test "$linux_splice" = "yes" ; then
919 echo "CONFIG_LINUX_SPLICE=y" >> $config_host_mak
921 if test "$guasi" = "yes" ; then
922 echo "CONFIG_GUASI=y" >> $config_host_mak
924 if test "$fusion_aw" = "yes" ; then
925 echo "CONFIG_FUSION_AW=y" >> $config_host_mak
927 if test "$libnuma" = "yes" ; then
928 echo "CONFIG_LIBNUMA=y" >> $config_host_mak
930 if test "$solaris_aio" = "yes" ; then
931 echo "CONFIG_SOLARISAIO=y" >> $config_host_mak
933 if test "$tls_thread" = "yes" ; then
934 echo "CONFIG_TLS_THREAD=y" >> $config_host_mak
936 if test "$gfio" = "yes" ; then
937 echo "CONFIG_GFIO=y" >> $config_host_mak
940 echo "LIBS+=$LIBS" >> $config_host_mak
941 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
942 echo "CC=$cc" >> $config_host_mak