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
34 echo "Configure failed, check config.log and/or the above output"
35 rm -rf $config_host_mak
41 CFLAGS="-D_GNU_SOURCE"
42 EXTFLAGS="-include config-host.h"
44 # Print a helpful header at the top of config.log
45 echo "# FIO configure log $(date)" >> config.log
46 printf "# Configured with:" >> config.log
47 printf " '%s'" "$0" "$@" >> config.log
49 echo "#" >> config.log
51 # Print configure header at the top of $config_host_h
52 echo "/*" > $config_host_h
53 echo " * Automatically generated by configure - do not modify" >> $config_host_h
54 printf " * Configured with:" >> $config_host_h
55 printf " * '%s'" "$0" "$@" >> $config_host_h
56 echo "" >> $config_host_h
57 echo " */" >> $config_host_h
60 # Run the compiler, capturing its output to the log.
61 echo $cc "$@" >> config.log
62 $cc "$@" >> config.log 2>&1 || return $?
63 # Test passed. If this is an --enable-werror build, rerun
64 # the test with -Werror and bail out if it fails. This
65 # makes warning-generating-errors in configure test code
66 # obvious to developers.
67 if test "$werror" != "yes"; then
70 # Don't bother rerunning the compile if we were already using -Werror
76 echo $cc -Werror "$@" >> config.log
77 $cc -Werror "$@" >> config.log 2>&1 && return $?
78 echo "ERROR: configure test passed without -Werror but failed with -Werror."
79 echo "This is probably a bug in the configure script. The failing command"
80 echo "will be at the bottom of config.log."
81 fatal "You can run configure with --disable-werror to bypass this check."
85 do_cc $CFLAGS -c -o $TMPO $TMPC
91 echo "Compiling test case $3" >> config.log
92 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
99 echo "ERROR: User requested feature $feature"
100 echo "ERROR: configure was not able to find it"
105 type "$1" >/dev/null 2>&1
111 #error $1 not defined
122 echo "$1=y" >> $config_host_mak
123 echo "#define $1" >> $config_host_h
129 cc="${CC-${cross_prefix}gcc}"
136 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
138 --cpu=*) cpu="$optarg"
142 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
144 --build-32bit-win=*) build_32bit_win="$optarg"
150 echo "Bad option $opt"
156 if test "$show_help" = "yes" ; then
157 echo "--cpu= Specify target CPU if auto-detect fails"
158 echo "--cc= Specify compiler to use"
159 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
160 echo "--build-32bit-win= Specify yes for a 32-bit build on Windows"
164 if check_define __ANDROID__ ; then
166 elif check_define __linux__ ; then
168 elif check_define __OpenBSD__ ; then
170 elif check_define __sun__ ; then
176 # Some host OSes need non-standard checks for which CPU to use.
177 # Note that these checks are broken for cross-compilation: if you're
178 # cross-compiling to one of these OSes then you'll need to specify
179 # the correct CPU with the --cpu option.
182 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
183 # we can run 64-bit userspace code.
184 # If the user didn't specify a CPU explicitly and the kernel says this is
185 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
187 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
192 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
193 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
198 echo "Forcing known good options on Windows"
199 if test -z "$CC" ; then
200 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
201 CC="i686-w64-mingw32-gcc"
203 CC="x86_64-w64-mingw32-gcc"
206 output_sym "CONFIG_LITTLE_ENDIAN"
207 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
208 output_sym "CONFIG_32BIT"
210 output_sym "CONFIG_64BIT_LLP64"
212 output_sym "CONFIG_FADVISE"
213 output_sym "CONFIG_SOCKLEN_T"
214 output_sym "CONFIG_FADVISE"
215 output_sym "CONFIG_SFAA"
216 output_sym "CONFIG_RUSAGE_THREAD"
217 output_sym "CONFIG_WINDOWSAIO"
218 output_sym "CONFIG_FDATASYNC"
219 output_sym "CONFIG_CLOCK_MONOTONIC"
220 output_sym "CONFIG_GETTIMEOFDAY"
221 output_sym "CONFIG_CLOCK_GETTIME"
222 output_sym "CONFIG_SCHED_IDLE"
223 output_sym "CONFIG_TCP_NODELAY"
224 echo "CC=$CC" >> $config_host_mak
225 echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
229 output_sym "CONFIG_32BIT"
230 output_sym "CONFIG_LITTLE_ENDIAN"
231 output_sym "CONFIG_SOCKLEN_T"
232 output_sym "CONFIG_GETTIMEOFDAY"
233 output_sym "CONFIG_CLOCK_GETTIME"
234 output_sym "CONFIG_CLOCK_MONOTONIC"
235 echo "CC=$cc" >> $config_host_mak
236 echo "EXTFLAGS=$CFLAGS -include config-host.h -DFIO_NO_HAVE_SHM_H -D_GNU_SOURCE" >> $config_host_mak
240 if test ! -z "$cpu" ; then
241 # command line argument
243 elif check_define __i386__ ; then
245 elif check_define __x86_64__ ; then
247 elif check_define __sparc__ ; then
248 if check_define __arch64__ ; then
253 elif check_define _ARCH_PPC ; then
254 if check_define _ARCH_PPC64 ; then
259 elif check_define __mips__ ; then
261 elif check_define __ia64__ ; then
263 elif check_define __s390__ ; then
264 if check_define __s390x__ ; then
269 elif check_define __arm__ ; then
271 elif check_define __hppa__ ; then
277 # Normalise host CPU name and set ARCH.
279 ia64|ppc|ppc64|s390|s390x|sparc64)
282 i386|i486|i586|i686|i86pc|BePC)
291 hppa|parisc|parisc64)
305 if test -z "$CC" ; then
306 if test "$targetos" = "FreeBSD"; then
315 cc="${CC-${cross_prefix}gcc}"
317 ##########################################
321 #include <inttypes.h>
324 volatile uint32_t i=0x01234567;
325 return (*((uint8_t*)(&i))) == 0x67;
328 if compile_prog "" "" "endian"; then
329 $TMPE && bigendian="yes"
333 echo "Operating system $targetos"
335 echo "Big endian $bigendian"
339 ##########################################
346 unsigned int wsize = sizeof(long) * 8;
347 printf("%d\n", wsize);
351 if compile_prog "" "" "wordsize"; then
354 echo "Wordsize $wordsize"
356 ##########################################
368 if compile_prog "" "-laio" "libaio" ; then
372 if test "$libaio" = "yes" ; then
373 feature_not_found "linux AIO"
377 echo "Linux AIO support $libaio"
379 ##########################################
392 if compile_prog "" "" "posixaio" ; then
394 elif compile_prog "" "-lrt" "posixaio"; then
399 echo "POSIX AIO support $posix_aio"
400 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
402 ##########################################
403 # posix aio fsync probe
405 if test "$posix_aio" = "yes" ; then
412 return aio_fsync(O_SYNC, &cb);
416 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
420 echo "POSIX AIO fsync $posix_aio_fsync"
422 ##########################################
426 #include <sys/types.h>
427 #include <sys/asynch.h>
432 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
436 if compile_prog "" "-laio" "solarisaio" ; then
440 echo "Solaris AIO support $solaris_aio"
442 ##########################################
443 # __sync_fetch_and_and test
446 static int sfaa(int *ptr)
448 return __sync_fetch_and_and(ptr, 0);
451 int main(int argc, char **argv)
458 if compile_prog "" "" "__sync_fetch_and_add()" ; then
461 echo "__sync_fetch_and add $sfaa"
463 ##########################################
468 #include <infiniband/arch.h>
469 int main(int argc, char **argv)
471 struct ibv_pd *pd = ibv_alloc_pd(NULL);
475 if compile_prog "" "-libverbs" "libverbs" ; then
477 LIBS="-libverbs $LIBS"
479 echo "libverbs $libverbs"
481 ##########################################
486 #include <rdma/rdma_cma.h>
487 int main(int argc, char **argv)
489 rdma_destroy_qp(NULL);
493 if compile_prog "" "-lrdmacm" "rdma"; then
495 LIBS="-lrdmacm $LIBS"
497 echo "rdmacm $rdmacm"
499 ##########################################
500 # Linux fallocate probe
504 #include <linux/falloc.h>
505 int main(int argc, char **argv)
507 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
511 if compile_prog "" "" "linux_fallocate"; then
512 linux_fallocate="yes"
514 echo "Linux fallocate $linux_fallocate"
516 ##########################################
517 # POSIX fadvise probe
522 int main(int argc, char **argv)
524 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
528 if compile_prog "" "" "posix_fadvise"; then
531 echo "POSIX fadvise $posix_fadvise"
533 ##########################################
534 # POSIX fallocate probe
539 int main(int argc, char **argv)
541 int r = posix_fallocate(0, 0, 1024);
545 if compile_prog "" "" "posix_fallocate"; then
546 posix_fallocate="yes"
548 echo "POSIX fallocate $posix_fallocate"
550 ##########################################
551 # sched_set/getaffinity 2 or 3 argument test
552 linux_2arg_affinity="no"
553 linux_3arg_affinity="no"
556 int main(int argc, char **argv)
559 return sched_setaffinity(0, sizeof(mask), &mask);
562 if compile_prog "" "" "sched_setaffinity(,,)"; then
563 linux_3arg_affinity="yes"
567 int main(int argc, char **argv)
570 return sched_setaffinity(0, &mask);
573 if compile_prog "" "" "sched_setaffinity(,)"; then
574 linux_2arg_affinity="yes"
577 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
578 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
580 ##########################################
581 # clock_gettime probe
586 int main(int argc, char **argv)
588 return clock_gettime(0, NULL);
591 if compile_prog "" "" "clock_gettime"; then
593 elif compile_prog "" "-lrt" "clock_gettime"; then
597 echo "clock_gettime $clock_gettime"
599 ##########################################
600 # CLOCK_MONOTONIC probe
602 if test "$clock_gettime" = "yes" ; then
606 int main(int argc, char **argv)
608 return clock_gettime(CLOCK_MONOTONIC, NULL);
611 if compile_prog "" "$LIBS" "clock monotonic"; then
612 clock_monotonic="yes"
615 echo "CLOCK_MONOTONIC $clock_monotonic"
617 ##########################################
618 # CLOCK_MONOTONIC_PRECISE probe
619 clock_monotonic_precise="no"
620 if test "$clock_gettime" = "yes" ; then
624 int main(int argc, char **argv)
626 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
629 if compile_prog "" "$LIBS" "clock monotonic precise"; then
630 clock_monotonic_precise="yes"
633 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
635 ##########################################
636 # gettimeofday() probe
639 #include <sys/time.h>
641 int main(int argc, char **argv)
644 return gettimeofday(&tv, NULL);
647 if compile_prog "" "" "gettimeofday"; then
650 echo "gettimeofday $gettimeofday"
652 ##########################################
658 int main(int argc, char **argv)
663 if compile_prog "" "" "fdatasync"; then
666 echo "fdatasync $fdatasync"
668 ##########################################
669 # sync_file_range() probe
675 #include <linux/fs.h>
676 int main(int argc, char **argv)
678 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
679 SYNC_FILE_RANGE_WAIT_AFTER;
680 return sync_file_range(0, 0, 0, flags);
683 if compile_prog "" "" "sync_file_range"; then
684 sync_file_range="yes"
686 echo "sync_file_range $sync_file_range"
688 ##########################################
689 # ext4 move extent probe
693 #include <sys/ioctl.h>
694 int main(int argc, char **argv)
696 struct move_extent me;
697 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
700 if compile_prog "" "" "ext4 move extent" ; then
702 elif test $targetos = "Linux" ; then
703 # On Linux, just default to it on and let it error at runtime if we really
704 # don't have it. None of my updated systems have it defined, but it does
705 # work. Takes a while to bubble back.
708 echo "EXT4 move extent $ext4_me"
710 ##########################################
716 int main(int argc, char **argv)
718 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
721 if compile_prog "" "" "linux splice"; then
724 echo "Linux splice(2) $linux_splice"
726 ##########################################
731 #include <guasi_syscalls.h>
732 int main(int argc, char **argv)
734 guasi_t ctx = guasi_create(0, 0, 0);
738 if compile_prog "" "" "guasi"; then
743 ##########################################
747 #include <nvm/vectored_write.h>
748 int main(int argc, char **argv)
750 struct vsl_iovec iov;
751 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
754 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
755 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
758 echo "Fusion-io atomic engine $fusion_aw"
760 ##########################################
765 int main(int argc, char **argv)
767 return numa_available();
770 if compile_prog "" "-lnuma" "libnuma"; then
774 echo "libnuma $libnuma"
776 ##########################################
781 int main(int argc, char **argv)
787 if compile_prog "" "" "strsep"; then
790 echo "strsep $strsep"
792 ##########################################
793 # getopt_long_only() probe
794 getopt_long_only="no"
798 int main(int argc, char **argv)
800 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
804 if compile_prog "" "" "getopt_long_only"; then
805 getopt_long_only="yes"
807 echo "getopt_long_only() $getopt_long_only"
809 ##########################################
813 #include <sys/socket.h>
814 #include <arpa/inet.h>
816 int main(int argc, char **argv)
819 return inet_aton(NULL, &in);
822 if compile_prog "" "" "inet_aton"; then
825 echo "inet_aton $inet_aton"
827 ##########################################
832 #include <netinet/in.h>
833 int main(int argc, char **argv)
839 if compile_prog "" "" "socklen_t"; then
842 echo "socklen_t $socklen_t"
844 ##########################################
845 # Whether or not __thread is supported for TLS
849 static int __thread ret;
850 int main(int argc, char **argv)
855 if compile_prog "" "" "__thread"; then
858 echo "__thread $tls_thread"
860 ##########################################
861 # Check whether we have getrusage(RUSAGE_THREAD)
864 #include <sys/time.h>
865 #include <sys/resource.h>
866 int main(int argc, char **argv)
869 getrusage(RUSAGE_THREAD, &ru);
873 if compile_prog "" "" "RUSAGE_THREAD"; then
876 echo "RUSAGE_THREAD $rusage_thread"
878 ##########################################
879 # Check whether we have SCHED_IDLE
883 int main(int argc, char **argv)
885 struct sched_param p;
886 return sched_setscheduler(0, SCHED_IDLE, &p);
889 if compile_prog "" "" "SCHED_IDLE"; then
892 echo "SCHED_IDLE $sched_idle"
894 ##########################################
895 # Check whether we have TCP_NODELAY
899 #include <sys/types.h>
900 #include <sys/socket.h>
901 #include <netinet/tcp.h>
902 int main(int argc, char **argv)
904 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
907 if compile_prog "" "" "TCP_NODELAY"; then
910 echo "TCP_NODELAY $tcp_nodelay"
912 #############################################################################
914 echo "# Automatically generated by configure - do not modify" > $config_host_mak
915 printf "# Configured with:" >> $config_host_mak
916 printf " '%s'" "$0" "$@" >> $config_host_mak
917 echo >> $config_host_mak
919 if test "$wordsize" = "64" ; then
920 output_sym "CONFIG_64BIT"
921 elif test "$wordsize" = "32" ; then
922 output_sym "CONFIG_32BIT"
924 fatal "Unknown wordsize!"
926 if test "$bigendian" = "yes" ; then
927 output_sym "CONFIG_BIG_ENDIAN"
929 output_sym "CONFIG_LITTLE_ENDIAN"
931 if test "$libaio" = "yes" ; then
932 output_sym "CONFIG_LIBAIO"
934 if test "$posix_aio" = "yes" ; then
935 output_sym "CONFIG_POSIXAIO"
937 if test "$posix_aio_fsync" = "yes" ; then
938 output_sym "CONFIG_POSIXAIO_FSYNC"
940 if test "$linux_fallocate" = "yes" ; then
941 output_sym "CONFIG_LINUX_FALLOCATE"
943 if test "$posix_fallocate" = "yes" ; then
944 output_sym "CONFIG_POSIX_FALLOCATE"
946 if test "$fdatasync" = "yes" ; then
947 output_sym "CONFIG_FDATASYNC"
949 if test "$sync_file_range" = "yes" ; then
950 output_sym "CONFIG_SYNC_FILE_RANGE"
952 if test "$sfaa" = "yes" ; then
953 output_sym "CONFIG_SFAA"
955 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
956 output_sym "CONFIG_RDMA"
958 if test "$clock_gettime" = "yes" ; then
959 output_sym "CONFIG_CLOCK_GETTIME"
961 if test "$clock_monotonic" = "yes" ; then
962 output_sym "CONFIG_CLOCK_MONOTONIC"
964 if test "$clock_monotonic_precise" = "yes" ; then
965 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
967 if test "$gettimeofday" = "yes" ; then
968 output_sym "CONFIG_GETTIMEOFDAY"
970 if test "$posix_fadvise" = "yes" ; then
971 output_sym "CONFIG_POSIX_FADVISE"
973 if test "$linux_3arg_affinity" = "yes" ; then
974 output_sym "CONFIG_3ARG_AFFINITY"
975 elif test "$linux_2arg_affinity" = "yes" ; then
976 output_sym "CONFIG_2ARG_AFFINITY"
978 if test "$strsep" = "yes" ; then
979 output_sym "CONFIG_STRSEP"
981 if test "$getopt_long_only" = "yes" ; then
982 output_sym "CONFIG_GETOPT_LONG_ONLY"
984 if test "$inet_aton" = "yes" ; then
985 output_sym "CONFIG_INET_ATON"
987 if test "$socklen_t" = "yes" ; then
988 output_sym "CONFIG_SOCKLEN_T"
990 if test "$ext4_me" = "yes" ; then
991 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
993 if test "$linux_splice" = "yes" ; then
994 output_sym "CONFIG_LINUX_SPLICE"
996 if test "$guasi" = "yes" ; then
997 output_sym "CONFIG_GUASI"
999 if test "$fusion_aw" = "yes" ; then
1000 output_sym "CONFIG_FUSION_AW"
1002 if test "$libnuma" = "yes" ; then
1003 output_sym "CONFIG_LIBNUMA"
1005 if test "$solaris_aio" = "yes" ; then
1006 output_sym "CONFIG_SOLARISAIO"
1008 if test "$tls_thread" = "yes" ; then
1009 output_sym "CONFIG_TLS_THREAD"
1011 if test "$rusage_thread" = "yes" ; then
1012 output_sym "CONFIG_RUSAGE_THREAD"
1014 if test "$sched_idle" = "yes" ; then
1015 output_sym "CONFIG_SCHED_IDLE"
1017 if test "$tcp_nodelay" = "yes" ; then
1018 output_sym "CONFIG_TCP_NODELAY"
1021 echo "LIBS+=$LIBS" >> $config_host_mak
1022 echo "CC=$cc" >> $config_host_mak
1023 echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak