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 CFLAGS="-D_GNU_SOURCE"
34 EXTFLAGS="-include config-host.h"
36 # Print a helpful header at the top of config.log
37 echo "# FIO configure log $(date)" >> config.log
38 printf "# Configured with:" >> config.log
39 printf " '%s'" "$0" "$@" >> config.log
41 echo "#" >> config.log
43 # Print configure header at the top of $config_host_h
44 echo "/*" > $config_host_h
45 echo " * Automatically generated by configure - do not modify" >> $config_host_h
46 printf " * Configured with:" >> $config_host_h
47 printf " * '%s'" "$0" "$@" >> $config_host_h
48 echo "" >> $config_host_h
49 echo " */" >> $config_host_h
52 # Run the compiler, capturing its output to the log.
53 echo $cc "$@" >> config.log
54 $cc "$@" >> config.log 2>&1 || return $?
55 # Test passed. If this is an --enable-werror build, rerun
56 # the test with -Werror and bail out if it fails. This
57 # makes warning-generating-errors in configure test code
58 # obvious to developers.
59 if test "$werror" != "yes"; then
62 # Don't bother rerunning the compile if we were already using -Werror
68 echo $cc -Werror "$@" >> config.log
69 $cc -Werror "$@" >> config.log 2>&1 && return $?
70 echo "ERROR: configure test passed without -Werror but failed with -Werror."
71 echo "This is probably a bug in the configure script. The failing command"
72 echo "will be at the bottom of config.log."
73 echo "You can run configure with --disable-werror to bypass this check."
78 do_cc $CFLAGS -c -o $TMPO $TMPC
84 echo "Compiling test case $3" >> config.log
85 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
92 echo "ERROR: User requested feature $feature"
93 echo "ERROR: configure was not able to find it"
99 type "$1" >/dev/null 2>&1
105 #error $1 not defined
116 echo "$1=y" >> $config_host_mak
117 echo "#define $1" >> $config_host_h
123 cc="${CC-${cross_prefix}gcc}"
127 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
131 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
134 echo "Bad option $opt"
139 if check_define __linux__ ; then
141 elif check_define __OpenBSD__ ; then
143 elif check_define __sun__ ; then
149 # Some host OSes need non-standard checks for which CPU to use.
150 # Note that these checks are broken for cross-compilation: if you're
151 # cross-compiling to one of these OSes then you'll need to specify
152 # the correct CPU with the --cpu option.
155 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
156 # we can run 64-bit userspace code.
157 # If the user didn't specify a CPU explicitly and the kernel says this is
158 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
160 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
165 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
166 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
171 echo "Forcing known good options on Windows"
172 if test -z "$CC" ; then
173 CC="x86_64-w64-mingw32-gcc"
175 output_sym "CONFIG_LITTLE_ENDIAN"
176 output_sym "CONFIG_64BIT_LLP64"
177 output_sym "CONFIG_CLOCK_GETTIME"
178 output_sym "CONFIG_CLOCK_MONOTONIC"
179 output_sym "CONFIG_GETTIMEOFDAY"
180 output_sym "CONFIG_FADVISE"
181 output_sym "CONFIG_SOCKLEN_T"
182 output_sym "CONFIG_POSIX_FALLOCATE"
183 output_sym "CONFIG_FADVISE"
184 output_sym "CONFIG_SFAA"
185 output_sym "CONFIG_RUSAGE_THREAD"
186 output_sym "CONFIG_WINDOWSAIO"
187 output_sym "CONFIG_FDATASYNC"
188 output_sym "CONFIG_GETTIMEOFDAY"
189 output_sym "CONFIG_CLOCK_GETTIME"
190 echo "CC=$CC" >> $config_host_mak
191 echo "EXTFLAGS=-include config-host.h -D_GNU_SOURCE" >> $config_host_mak
195 if test ! -z "$cpu" ; then
196 # command line argument
198 elif check_define __i386__ ; then
200 elif check_define __x86_64__ ; then
202 elif check_define __sparc__ ; then
203 if check_define __arch64__ ; then
208 elif check_define _ARCH_PPC ; then
209 if check_define _ARCH_PPC64 ; then
214 elif check_define __mips__ ; then
216 elif check_define __ia64__ ; then
218 elif check_define __s390__ ; then
219 if check_define __s390x__ ; then
224 elif check_define __arm__ ; then
226 elif check_define __hppa__ ; then
232 # Normalise host CPU name and set ARCH.
234 ia64|ppc|ppc64|s390|s390x|sparc64)
237 i386|i486|i586|i686|i86pc|BePC)
246 hppa|parisc|parisc64)
261 if test -z "$CC" ; then
262 if test "$targetos" = "FreeBSD"; then
271 cc="${CC-${cross_prefix}gcc}"
273 ##########################################
277 #include <inttypes.h>
280 volatile uint32_t i=0x01234567;
281 return (*((uint8_t*)(&i))) == 0x67;
284 if compile_prog "" "" "endian"; then
285 $TMPE && bigendian="yes"
289 echo "Operating system $targetos"
291 echo "Big endian $bigendian"
295 ##########################################
302 unsigned int wsize = sizeof(long) * 8;
303 printf("%d\n", wsize);
307 if compile_prog "" "" "wordsize"; then
310 echo "Wordsize $wordsize"
312 ##########################################
324 if compile_prog "" "-laio" "libaio" ; then
328 if test "$libaio" = "yes" ; then
329 feature_not_found "linux AIO"
333 echo "Linux AIO support $libaio"
335 ##########################################
348 if compile_prog "" "" "posixaio" ; then
350 elif compile_prog "" "-lrt" "posixaio"; then
355 echo "POSIX AIO support $posix_aio"
356 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
358 ##########################################
359 # posix aio fsync probe
361 if test "$posix_aio" = "yes" ; then
368 return aio_fsync(O_SYNC, &cb);
372 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
376 echo "POSIX AIO fsync $posix_aio_fsync"
378 ##########################################
382 #include <sys/types.h>
383 #include <sys/asynch.h>
388 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
392 if compile_prog "" "-laio" "solarisaio" ; then
396 echo "Solaris AIO support $solaris_aio"
398 ##########################################
399 # __sync_fetch_and_and test
402 static int sfaa(int *ptr)
404 return __sync_fetch_and_and(ptr, 0);
407 int main(int argc, char **argv)
414 if compile_prog "" "" "__sync_fetch_and_add()" ; then
417 echo "__sync_fetch_and add $sfaa"
419 ##########################################
424 #include <infiniband/arch.h>
425 int main(int argc, char **argv)
427 struct ibv_pd *pd = ibv_alloc_pd(NULL);
431 if compile_prog "" "-libverbs" "libverbs" ; then
433 LIBS="-libverbs $LIBS"
435 echo "libverbs $libverbs"
437 ##########################################
442 #include <rdma/rdma_cma.h>
443 int main(int argc, char **argv)
445 rdma_destroy_qp(NULL);
449 if compile_prog "" "-lrdmacm" "rdma"; then
451 LIBS="-lrdmacm $LIBS"
453 echo "rdmacm $rdmacm"
455 ##########################################
456 # Linux fallocate probe
460 #include <linux/falloc.h>
461 int main(int argc, char **argv)
463 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
467 if compile_prog "" "" "linux_fallocate"; then
468 linux_fallocate="yes"
470 echo "Linux fallocate $linux_fallocate"
472 ##########################################
473 # POSIX fadvise probe
478 int main(int argc, char **argv)
480 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
484 if compile_prog "" "" "posix_fadvise"; then
487 echo "POSIX fadvise $posix_fadvise"
489 ##########################################
490 # POSIX fallocate probe
495 int main(int argc, char **argv)
497 int r = posix_fallocate(0, 0, 1024);
501 if compile_prog "" "" "posix_fallocate"; then
502 posix_fallocate="yes"
504 echo "POSIX fallocate $posix_fallocate"
506 ##########################################
507 # sched_set/getaffinity 2 or 3 argument test
508 linux_2arg_affinity="no"
509 linux_3arg_affinity="no"
512 int main(int argc, char **argv)
515 return sched_setaffinity(0, sizeof(mask), &mask);
518 if compile_prog "" "" "sched_setaffinity(,,)"; then
519 linux_3arg_affinity="yes"
523 int main(int argc, char **argv)
526 return sched_setaffinity(0, &mask);
529 if compile_prog "" "" "sched_setaffinity(,)"; then
530 linux_2arg_affinity="yes"
533 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
534 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
536 ##########################################
537 # clock_gettime probe
542 int main(int argc, char **argv)
544 return clock_gettime(0, NULL);
547 if compile_prog "" "" "clock_gettime"; then
549 elif compile_prog "" "-lrt" "clock_gettime"; then
553 echo "clock_gettime $clock_gettime"
555 ##########################################
556 # CLOCK_MONOTONIC probe
558 if test "$clock_gettime" = "yes" ; then
562 int main(int argc, char **argv)
564 return clock_gettime(CLOCK_MONOTONIC, NULL);
567 if compile_prog "" "$LIBS" "clock monotonic"; then
568 clock_monotonic="yes"
571 echo "CLOCK_MONOTONIC $clock_monotonic"
573 ##########################################
574 # CLOCK_MONOTONIC_PRECISE probe
575 clock_monotonic_precise="no"
576 if test "$clock_gettime" = "yes" ; then
580 int main(int argc, char **argv)
582 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
585 if compile_prog "" "$LIBS" "clock monotonic precise"; then
586 clock_monotonic_precise="yes"
589 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
591 ##########################################
592 # gettimeofday() probe
595 #include <sys/time.h>
597 int main(int argc, char **argv)
600 return gettimeofday(&tv, NULL);
603 if compile_prog "" "" "gettimeofday"; then
606 echo "gettimeofday $gettimeofday"
608 ##########################################
614 int main(int argc, char **argv)
619 if compile_prog "" "" "fdatasync"; then
622 echo "fdatasync $fdatasync"
624 ##########################################
625 # sync_file_range() probe
631 #include <linux/fs.h>
632 int main(int argc, char **argv)
634 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
635 SYNC_FILE_RANGE_WAIT_AFTER;
636 return sync_file_range(0, 0, 0, flags);
639 if compile_prog "" "" "sync_file_range"; then
640 sync_file_range="yes"
642 echo "sync_file_range $sync_file_range"
644 ##########################################
645 # ext4 move extent probe
649 #include <sys/ioctl.h>
650 int main(int argc, char **argv)
652 struct move_extent me;
653 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
656 if compile_prog "" "" "ext4 move extent" ; then
658 elif test $targetos = "Linux" ; then
659 # On Linux, just default to it on and let it error at runtime if we really
660 # don't have it. None of my updated systems have it defined, but it does
661 # work. Takes a while to bubble back.
664 echo "EXT4 move extent $ext4_me"
666 ##########################################
672 int main(int argc, char **argv)
674 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
677 if compile_prog "" "" "linux splice"; then
680 echo "Linux splice(2) $linux_splice"
682 ##########################################
687 #include <guasi_syscalls.h>
688 int main(int argc, char **argv)
690 guasi_t ctx = guasi_create(0, 0, 0);
694 if compile_prog "" "" "guasi"; then
699 ##########################################
703 #include <nvm/vectored_write.h>
704 int main(int argc, char **argv)
706 struct vsl_iovec iov;
707 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
710 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
711 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
714 echo "Fusion-io atomic engine $fusion_aw"
716 ##########################################
721 int main(int argc, char **argv)
723 return numa_available();
726 if compile_prog "" "-lnuma" "libnuma"; then
730 echo "libnuma $libnuma"
732 ##########################################
737 int main(int argc, char **argv)
743 if compile_prog "" "" "strsep"; then
746 echo "strsep $strsep"
748 ##########################################
749 # getopt_long_only() probe
750 getopt_long_only="no"
754 int main(int argc, char **argv)
756 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
760 if compile_prog "" "" "getopt_long_only"; then
761 getopt_long_only="yes"
763 echo "getopt_long_only() $getopt_long_only"
765 ##########################################
769 #include <sys/socket.h>
770 #include <arpa/inet.h>
772 int main(int argc, char **argv)
775 return inet_aton(NULL, &in);
778 if compile_prog "" "" "inet_aton"; then
781 echo "inet_aton $inet_aton"
783 ##########################################
788 #include <netinet/in.h>
789 int main(int argc, char **argv)
795 if compile_prog "" "" "socklen_t"; then
798 echo "socklen_t $socklen_t"
800 ##########################################
801 # Whether or not __thread is supported for TLS
805 static int __thread ret;
806 int main(int argc, char **argv)
811 if compile_prog "" "" "__thread"; then
814 echo "__thread $tls_thread"
816 ##########################################
817 # Check whether we have getrusage(RUSAGE_THREAD)
820 #include <sys/time.h>
821 #include <sys/resource.h>
822 int main(int argc, char **argv)
825 getrusage(RUSAGE_THREAD, &ru);
829 if compile_prog "" "" "RUSAGE_THREAD"; then
832 echo "RUSAGE_THREAD $rusage_thread"
834 #############################################################################
836 echo "# Automatically generated by configure - do not modify" > $config_host_mak
837 printf "# Configured with:" >> $config_host_mak
838 printf " '%s'" "$0" "$@" >> $config_host_mak
839 echo >> $config_host_mak
841 if test "$wordsize" = "64" ; then
842 output_sym "CONFIG_64BIT"
843 elif test "$wordsize" = "32" ; then
844 output_sym "CONFIG_32BIT"
846 echo "Unknown wordsize!"
849 if test "$bigendian" = "yes" ; then
850 output_sym "CONFIG_BIG_ENDIAN"
852 output_sym "CONFIG_LITTLE_ENDIAN"
854 if test "$libaio" = "yes" ; then
855 output_sym "CONFIG_LIBAIO"
857 if test "$posix_aio" = "yes" ; then
858 output_sym "CONFIG_POSIXAIO"
860 if test "$posix_aio_fsync" = "yes" ; then
861 output_sym "CONFIG_POSIXAIO_FSYNC"
863 if test "$linux_fallocate" = "yes" ; then
864 output_sym "CONFIG_LINUX_FALLOCATE"
866 if test "$posix_fallocate" = "yes" ; then
867 output_sym "CONFIG_POSIX_FALLOCATE"
869 if test "$fdatasync" = "yes" ; then
870 output_sym "CONFIG_FDATASYNC"
872 if test "$sync_file_range" = "yes" ; then
873 output_sym "CONFIG_SYNC_FILE_RANGE"
875 if test "$sfaa" = "yes" ; then
876 output_sym "CONFIG_SFAA"
878 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
879 output_sym "CONFIG_RDMA"
881 if test "$clock_gettime" = "yes" ; then
882 output_sym "CONFIG_CLOCK_GETTIME"
884 if test "$clock_monotonic" = "yes" ; then
885 output_sym "CONFIG_CLOCK_MONOTONIC"
887 if test "$clock_monotonic_precise" = "yes" ; then
888 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
890 if test "$gettimeofday" = "yes" ; then
891 output_sym "CONFIG_GETTIMEOFDAY"
893 if test "$posix_fadvise" = "yes" ; then
894 output_sym "CONFIG_POSIX_FADVISE"
896 if test "$linux_3arg_affinity" = "yes" ; then
897 output_sym "CONFIG_3ARG_AFFINITY"
898 elif test "$linux_2arg_affinity" = "yes" ; then
899 output_sym "CONFIG_2ARG_AFFINITY"
901 if test "$strsep" = "yes" ; then
902 output_sym "CONFIG_STRSEP"
904 if test "$getopt_long_only" = "yes" ; then
905 output_sym "CONFIG_GETOPT_LONG_ONLY"
907 if test "$inet_aton" = "yes" ; then
908 output_sym "CONFIG_INET_ATON"
910 if test "$socklen_t" = "yes" ; then
911 output_sym "CONFIG_SOCKLEN_T"
913 if test "$ext4_me" = "yes" ; then
914 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
916 if test "$linux_splice" = "yes" ; then
917 output_sym "CONFIG_LINUX_SPLICE"
919 if test "$guasi" = "yes" ; then
920 output_sym "CONFIG_GUASI"
922 if test "$fusion_aw" = "yes" ; then
923 output_sym "CONFIG_FUSION_AW"
925 if test "$libnuma" = "yes" ; then
926 output_sym "CONFIG_LIBNUMA"
928 if test "$solaris_aio" = "yes" ; then
929 output_sym "CONFIG_SOLARISAIO"
931 if test "$tls_thread" = "yes" ; then
932 output_sym "CONFIG_TLS_THREAD"
934 if test "$rusage_thread" = "yes" ; then
935 output_sym "CONFIG_RUSAGE_THREAD"
938 echo "LIBS+=$LIBS" >> $config_host_mak
939 echo "CC=$cc" >> $config_host_mak
940 echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak