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_h="config-host.h"
29 rm -rf $config_host_mak
33 EXTFLAGS="-include config-host.h -D_GNU_SOURCE"
35 # Print a helpful header at the top of config.log
36 echo "# FIO configure log $(date)" >> config.log
37 printf "# Configured with:" >> config.log
38 printf " '%s'" "$0" "$@" >> config.log
40 echo "#" >> config.log
42 # Print configure header at the top of $config_host_h
43 echo "/*" > $config_host_h
44 echo " * Automatically generated by configure - do not modify" >> $config_host_h
45 printf " * Configured with:" >> $config_host_h
46 printf " * '%s'" "$0" "$@" >> $config_host_h
47 echo "" >> $config_host_h
48 echo " */" >> $config_host_h
51 # Run the compiler, capturing its output to the log.
52 echo $cc "$@" >> config.log
53 $cc "$@" >> config.log 2>&1 || return $?
54 # Test passed. If this is an --enable-werror build, rerun
55 # the test with -Werror and bail out if it fails. This
56 # makes warning-generating-errors in configure test code
57 # obvious to developers.
58 if test "$werror" != "yes"; then
61 # Don't bother rerunning the compile if we were already using -Werror
67 echo $cc -Werror "$@" >> config.log
68 $cc -Werror "$@" >> config.log 2>&1 && return $?
69 echo "ERROR: configure test passed without -Werror but failed with -Werror."
70 echo "This is probably a bug in the configure script. The failing command"
71 echo "will be at the bottom of config.log."
72 echo "You can run configure with --disable-werror to bypass this check."
77 do_cc $CFLAGS -c -o $TMPO $TMPC
83 echo "Compiling test case $3" >> config.log
84 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
91 echo "ERROR: User requested feature $feature"
92 echo "ERROR: configure was not able to find it"
98 type "$1" >/dev/null 2>&1
104 #error $1 not defined
115 echo "$1=y" >> $config_host_mak
116 echo "#define $1" >> $config_host_h
122 cc="${CC-${cross_prefix}gcc}"
126 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
131 echo "Bad option $opt"
136 if check_define __linux__ ; then
138 elif check_define __OpenBSD__ ; then
140 elif check_define __sun__ ; then
146 # Some host OSes need non-standard checks for which CPU to use.
147 # Note that these checks are broken for cross-compilation: if you're
148 # cross-compiling to one of these OSes then you'll need to specify
149 # the correct CPU with the --cpu option.
152 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
153 # we can run 64-bit userspace code.
154 # If the user didn't specify a CPU explicitly and the kernel says this is
155 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
157 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
162 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
163 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
168 echo "Forcing known good options on Windows"
169 if test -z "$CC" ; then
170 CC="x86_64-w64-mingw32-gcc"
172 output_sym "CONFIG_LITTLE_ENDIAN"
173 output_sym "CONFIG_64BIT_LLP64"
174 output_sym "CONFIG_CLOCK_GETTIME"
175 output_sym "CONFIG_CLOCK_MONOTONIC"
176 output_sym "CONFIG_GETTIMEOFDAY"
177 output_sym "CONFIG_FADVISE"
178 output_sym "CONFIG_SOCKLEN_T"
179 output_sym "CONFIG_POSIX_FALLOCATE"
180 output_sym "CONFIG_FADVISE"
181 output_sym "CONFIG_SFAA"
182 output_sym "CONFIG_RUSAGE_THREAD"
183 output_sym "CONFIG_WINDOWSAIO"
184 output_sym "CONFIG_FDATASYNC"
185 output_sym "CONFIG_GETTIMEOFDAY"
186 output_sym "CONFIG_CLOCK_GETTIME"
187 echo "CC=$CC" >> $config_host_mak
188 echo "EXTFLAGS=-include config-host.h -D_GNU_SOURCE" >> $config_host_mak
192 if test ! -z "$cpu" ; then
193 # command line argument
195 elif check_define __i386__ ; then
197 elif check_define __x86_64__ ; then
199 elif check_define __sparc__ ; then
200 if check_define __arch64__ ; then
205 elif check_define _ARCH_PPC ; then
206 if check_define _ARCH_PPC64 ; then
211 elif check_define __mips__ ; then
213 elif check_define __ia64__ ; then
215 elif check_define __s390__ ; then
216 if check_define __s390x__ ; then
221 elif check_define __arm__ ; then
223 elif check_define __hppa__ ; then
229 # Normalise host CPU name and set ARCH.
231 ia64|ppc|ppc64|s390|s390x|sparc64)
234 i386|i486|i586|i686|i86pc|BePC)
243 hppa|parisc|parisc64)
258 if test -z "$CC" ; then
259 if test "$targetos" = "FreeBSD"; then
268 cc="${CC-${cross_prefix}gcc}"
270 ##########################################
274 #include <inttypes.h>
277 volatile uint32_t i=0x01234567;
278 return (*((uint8_t*)(&i))) == 0x67;
281 if compile_prog "" "" "endian"; then
282 $TMPE && bigendian="yes"
286 echo "Operating system $targetos"
288 echo "Big endian $bigendian"
292 ##########################################
299 unsigned int wsize = sizeof(long) * 8;
300 printf("%d\n", wsize);
304 if compile_prog "" "" "wordsize"; then
307 echo "Wordsize $wordsize"
309 ##########################################
321 if compile_prog "" "-laio" "libaio" ; then
325 if test "$libaio" = "yes" ; then
326 feature_not_found "linux AIO"
330 echo "Linux AIO support $libaio"
332 ##########################################
345 if compile_prog "" "" "posixaio" ; then
347 elif compile_prog "" "-lrt" "posixaio"; then
352 echo "POSIX AIO support $posix_aio"
353 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
355 ##########################################
356 # posix aio fsync probe
358 if test "$posix_aio" = "yes" ; then
365 return aio_fsync(O_SYNC, &cb);
369 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
373 echo "POSIX AIO fsync $posix_aio_fsync"
375 ##########################################
379 #include <sys/types.h>
380 #include <sys/asynch.h>
385 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
389 if compile_prog "" "-laio" "solarisaio" ; then
393 echo "Solaris AIO support $solaris_aio"
395 ##########################################
396 # __sync_fetch_and_and test
399 static int sfaa(int *ptr)
401 return __sync_fetch_and_and(ptr, 0);
404 int main(int argc, char **argv)
411 if compile_prog "" "" "__sync_fetch_and_add()" ; then
414 echo "__sync_fetch_and add $sfaa"
416 ##########################################
421 #include <infiniband/arch.h>
422 int main(int argc, char **argv)
424 struct ibv_pd *pd = ibv_alloc_pd(NULL);
428 if compile_prog "" "-libverbs" "libverbs" ; then
430 LIBS="-libverbs $LIBS"
432 echo "libverbs $libverbs"
434 ##########################################
439 #include <rdma/rdma_cma.h>
440 int main(int argc, char **argv)
442 rdma_destroy_qp(NULL);
446 if compile_prog "" "-lrdmacm" "rdma"; then
448 LIBS="-lrdmacm $LIBS"
450 echo "rdmacm $rdmacm"
452 ##########################################
453 # Linux fallocate probe
457 #include <linux/falloc.h>
458 int main(int argc, char **argv)
460 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
464 if compile_prog "" "" "linux_fallocate"; then
465 linux_fallocate="yes"
467 echo "Linux fallocate $linux_fallocate"
469 ##########################################
470 # POSIX fadvise probe
475 int main(int argc, char **argv)
477 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
481 if compile_prog "" "" "posix_fadvise"; then
484 echo "POSIX fadvise $posix_fadvise"
486 ##########################################
487 # POSIX fallocate probe
492 int main(int argc, char **argv)
494 int r = posix_fallocate(0, 0, 1024);
498 if compile_prog "" "" "posix_fallocate"; then
499 posix_fallocate="yes"
501 echo "POSIX fallocate $posix_fallocate"
503 ##########################################
504 # sched_set/getaffinity 2 or 3 argument test
505 linux_2arg_affinity="no"
506 linux_3arg_affinity="no"
509 int main(int argc, char **argv)
512 return sched_setaffinity(0, sizeof(mask), &mask);
515 if compile_prog "" "" "sched_setaffinity(,,)"; then
516 linux_3arg_affinity="yes"
520 int main(int argc, char **argv)
523 return sched_setaffinity(0, &mask);
526 if compile_prog "" "" "sched_setaffinity(,)"; then
527 linux_2arg_affinity="yes"
530 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
531 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
533 ##########################################
534 # clock_gettime probe
539 int main(int argc, char **argv)
541 return clock_gettime(0, NULL);
544 if compile_prog "" "" "clock_gettime"; then
546 elif compile_prog "" "-lrt" "clock_gettime"; then
550 echo "clock_gettime $clock_gettime"
552 ##########################################
553 # CLOCK_MONOTONIC probe
555 if test "$clock_gettime" = "yes" ; then
559 int main(int argc, char **argv)
561 return clock_gettime(CLOCK_MONOTONIC, NULL);
564 if compile_prog "" "$LIBS" "clock monotonic"; then
565 clock_monotonic="yes"
568 echo "CLOCK_MONOTONIC $clock_monotonic"
570 ##########################################
571 # CLOCK_MONOTONIC_PRECISE probe
572 clock_monotonic_precise="no"
573 if test "$clock_gettime" = "yes" ; then
577 int main(int argc, char **argv)
579 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
582 if compile_prog "" "$LIBS" "clock monotonic precise"; then
583 clock_monotonic_precise="yes"
586 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
588 ##########################################
589 # gettimeofday() probe
592 #include <sys/time.h>
594 int main(int argc, char **argv)
597 return gettimeofday(&tv, NULL);
600 if compile_prog "" "" "gettimeofday"; then
603 echo "gettimeofday $gettimeofday"
605 ##########################################
611 int main(int argc, char **argv)
616 if compile_prog "" "" "fdatasync"; then
619 echo "fdatasync $fdatasync"
621 ##########################################
622 # sync_file_range() probe
628 #include <linux/fs.h>
629 int main(int argc, char **argv)
631 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
632 SYNC_FILE_RANGE_WAIT_AFTER;
633 return sync_file_range(0, 0, 0, flags);
636 if compile_prog "" "" "sync_file_range"; then
637 sync_file_range="yes"
639 echo "sync_file_range $sync_file_range"
641 ##########################################
642 # ext4 move extent probe
646 #include <sys/ioctl.h>
647 int main(int argc, char **argv)
649 struct move_extent me;
650 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
653 if compile_prog "" "" "ext4 move extent" ; then
655 elif test $targetos = "Linux" ; then
656 # On Linux, just default to it on and let it error at runtime if we really
657 # don't have it. None of my updated systems have it defined, but it does
658 # work. Takes a while to bubble back.
661 echo "EXT4 move extent $ext4_me"
663 ##########################################
669 int main(int argc, char **argv)
671 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
674 if compile_prog "" "" "linux splice"; then
677 echo "Linux splice(2) $linux_splice"
679 ##########################################
684 #include <guasi_syscalls.h>
685 int main(int argc, char **argv)
687 guasi_t ctx = guasi_create(0, 0, 0);
691 if compile_prog "" "" "guasi"; then
696 ##########################################
700 #include <nvm/vectored_write.h>
701 int main(int argc, char **argv)
703 struct vsl_iovec iov;
704 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
707 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
708 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
711 echo "Fusion-io atomic engine $fusion_aw"
713 ##########################################
718 int main(int argc, char **argv)
720 return numa_available();
723 if compile_prog "" "-lnuma" "libnuma"; then
727 echo "libnuma $libnuma"
729 ##########################################
734 int main(int argc, char **argv)
740 if compile_prog "" "" "strsep"; then
743 echo "strsep $strsep"
745 ##########################################
746 # getopt_long_only() probe
747 getopt_long_only="no"
751 int main(int argc, char **argv)
753 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
757 if compile_prog "" "" "getopt_long_only"; then
758 getopt_long_only="yes"
760 echo "getopt_long_only() $getopt_long_only"
762 ##########################################
766 #include <sys/socket.h>
767 #include <arpa/inet.h>
769 int main(int argc, char **argv)
772 return inet_aton(NULL, &in);
775 if compile_prog "" "" "inet_aton"; then
778 echo "inet_aton $inet_aton"
780 ##########################################
785 #include <netinet/in.h>
786 int main(int argc, char **argv)
792 if compile_prog "" "" "socklen_t"; then
795 echo "socklen_t $socklen_t"
797 ##########################################
798 # Whether or not __thread is supported for TLS
802 static int __thread ret;
803 int main(int argc, char **argv)
808 if compile_prog "" "" "__thread"; then
811 echo "__thread $tls_thread"
813 ##########################################
814 # Check whether we have getrusage(RUSAGE_THREAD)
817 #include <sys/time.h>
818 #include <sys/resource.h>
819 int main(int argc, char **argv)
822 getrusage(RUSAGE_THREAD, &ru);
826 if compile_prog "" "" "RUSAGE_THREAD"; then
829 echo "RUSAGE_THREAD $rusage_thread"
831 #############################################################################
833 echo "# Automatically generated by configure - do not modify" > $config_host_mak
834 printf "# Configured with:" >> $config_host_mak
835 printf " '%s'" "$0" "$@" >> $config_host_mak
836 echo >> $config_host_mak
838 if test "$wordsize" = "64" ; then
839 output_sym "CONFIG_64BIT"
840 elif test "$wordsize" = "32" ; then
841 output_sym "CONFIG_32BIT"
843 echo "Unknown wordsize!"
846 if test "$bigendian" = "yes" ; then
847 output_sym "CONFIG_BIG_ENDIAN"
849 output_sym "CONFIG_LITTLE_ENDIAN"
851 if test "$libaio" = "yes" ; then
852 output_sym "CONFIG_LIBAIO"
854 if test "$posix_aio" = "yes" ; then
855 output_sym "CONFIG_POSIXAIO"
857 if test "$posix_aio_fsync" = "yes" ; then
858 output_sym "CONFIG_POSIXAIO_FSYNC"
860 if test "$linux_fallocate" = "yes" ; then
861 output_sym "CONFIG_LINUX_FALLOCATE"
863 if test "$posix_fallocate" = "yes" ; then
864 output_sym "CONFIG_POSIX_FALLOCATE"
866 if test "$fdatasync" = "yes" ; then
867 output_sym "CONFIG_FDATASYNC"
869 if test "$sync_file_range" = "yes" ; then
870 output_sym "CONFIG_SYNC_FILE_RANGE"
872 if test "$sfaa" = "yes" ; then
873 output_sym "CONFIG_SFAA"
875 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
876 output_sym "CONFIG_RDMA"
878 if test "$clock_gettime" = "yes" ; then
879 output_sym "CONFIG_CLOCK_GETTIME"
881 if test "$clock_monotonic" = "yes" ; then
882 output_sym "CONFIG_CLOCK_MONOTONIC"
884 if test "$clock_monotonic_precise" = "yes" ; then
885 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
887 if test "$gettimeofday" = "yes" ; then
888 output_sym "CONFIG_GETTIMEOFDAY"
890 if test "$posix_fadvise" = "yes" ; then
891 output_sym "CONFIG_POSIX_FADVISE"
893 if test "$linux_3arg_affinity" = "yes" ; then
894 output_sym "CONFIG_3ARG_AFFINITY"
895 elif test "$linux_2arg_affinity" = "yes" ; then
896 output_sym "CONFIG_2ARG_AFFINITY"
898 if test "$strsep" = "yes" ; then
899 output_sym "CONFIG_STRSEP"
901 if test "$getopt_long_only" = "yes" ; then
902 output_sym "CONFIG_GETOPT_LONG_ONLY"
904 if test "$inet_aton" = "yes" ; then
905 output_sym "CONFIG_INET_ATON"
907 if test "$socklen_t" = "yes" ; then
908 output_sym "CONFIG_SOCKLEN_T"
910 if test "$ext4_me" = "yes" ; then
911 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
913 if test "$linux_splice" = "yes" ; then
914 output_sym "CONFIG_LINUX_SPLICE"
916 if test "$guasi" = "yes" ; then
917 output_sym "CONFIG_GUASI"
919 if test "$fusion_aw" = "yes" ; then
920 output_sym "CONFIG_FUSION_AW"
922 if test "$libnuma" = "yes" ; then
923 output_sym "CONFIG_LIBNUMA"
925 if test "$solaris_aio" = "yes" ; then
926 output_sym "CONFIG_SOLARISAIO"
928 if test "$tls_thread" = "yes" ; then
929 output_sym "CONFIG_TLS_THREAD"
931 if test "$rusage_thread" = "yes" ; then
932 output_sym "CONFIG_RUSAGE_THREAD"
935 echo "LIBS+=$LIBS" >> $config_host_mak
936 echo "CC=$cc" >> $config_host_mak
937 echo "EXTFLAGS=$EXTFLAGS" >> $config_host_mak