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 __linux__ ; then
166 elif check_define __OpenBSD__ ; then
168 elif check_define __sun__ ; then
174 # Some host OSes need non-standard checks for which CPU to use.
175 # Note that these checks are broken for cross-compilation: if you're
176 # cross-compiling to one of these OSes then you'll need to specify
177 # the correct CPU with the --cpu option.
180 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
181 # we can run 64-bit userspace code.
182 # If the user didn't specify a CPU explicitly and the kernel says this is
183 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
185 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
190 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
191 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
196 echo "Forcing known good options on Windows"
197 if test -z "$CC" ; then
198 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
199 CC="i686-w64-mingw32-gcc"
201 CC="x86_64-w64-mingw32-gcc"
204 output_sym "CONFIG_LITTLE_ENDIAN"
205 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
206 output_sym "CONFIG_32BIT"
208 output_sym "CONFIG_64BIT_LLP64"
210 output_sym "CONFIG_FADVISE"
211 output_sym "CONFIG_SOCKLEN_T"
212 output_sym "CONFIG_FADVISE"
213 output_sym "CONFIG_SFAA"
214 output_sym "CONFIG_RUSAGE_THREAD"
215 output_sym "CONFIG_WINDOWSAIO"
216 output_sym "CONFIG_FDATASYNC"
217 output_sym "CONFIG_CLOCK_MONOTONIC"
218 output_sym "CONFIG_GETTIMEOFDAY"
219 output_sym "CONFIG_CLOCK_GETTIME"
220 output_sym "CONFIG_SCHED_IDLE"
221 output_sym "CONFIG_TCP_NODELAY"
222 echo "CC=$CC" >> $config_host_mak
223 echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
227 if test ! -z "$cpu" ; then
228 # command line argument
230 elif check_define __i386__ ; then
232 elif check_define __x86_64__ ; then
234 elif check_define __sparc__ ; then
235 if check_define __arch64__ ; then
240 elif check_define _ARCH_PPC ; then
241 if check_define _ARCH_PPC64 ; then
246 elif check_define __mips__ ; then
248 elif check_define __ia64__ ; then
250 elif check_define __s390__ ; then
251 if check_define __s390x__ ; then
256 elif check_define __arm__ ; then
258 elif check_define __hppa__ ; then
264 # Normalise host CPU name and set ARCH.
266 ia64|ppc|ppc64|s390|s390x|sparc64)
269 i386|i486|i586|i686|i86pc|BePC)
278 hppa|parisc|parisc64)
292 if test -z "$CC" ; then
293 if test "$targetos" = "FreeBSD"; then
302 cc="${CC-${cross_prefix}gcc}"
304 ##########################################
308 #include <inttypes.h>
311 volatile uint32_t i=0x01234567;
312 return (*((uint8_t*)(&i))) == 0x67;
315 if compile_prog "" "" "endian"; then
316 $TMPE && bigendian="yes"
320 echo "Operating system $targetos"
322 echo "Big endian $bigendian"
326 ##########################################
333 unsigned int wsize = sizeof(long) * 8;
334 printf("%d\n", wsize);
338 if compile_prog "" "" "wordsize"; then
341 echo "Wordsize $wordsize"
343 ##########################################
355 if compile_prog "" "-laio" "libaio" ; then
359 if test "$libaio" = "yes" ; then
360 feature_not_found "linux AIO"
364 echo "Linux AIO support $libaio"
366 ##########################################
379 if compile_prog "" "" "posixaio" ; then
381 elif compile_prog "" "-lrt" "posixaio"; then
386 echo "POSIX AIO support $posix_aio"
387 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
389 ##########################################
390 # posix aio fsync probe
392 if test "$posix_aio" = "yes" ; then
399 return aio_fsync(O_SYNC, &cb);
403 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
407 echo "POSIX AIO fsync $posix_aio_fsync"
409 ##########################################
413 #include <sys/types.h>
414 #include <sys/asynch.h>
419 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
423 if compile_prog "" "-laio" "solarisaio" ; then
427 echo "Solaris AIO support $solaris_aio"
429 ##########################################
430 # __sync_fetch_and_and test
433 static int sfaa(int *ptr)
435 return __sync_fetch_and_and(ptr, 0);
438 int main(int argc, char **argv)
445 if compile_prog "" "" "__sync_fetch_and_add()" ; then
448 echo "__sync_fetch_and add $sfaa"
450 ##########################################
455 #include <infiniband/arch.h>
456 int main(int argc, char **argv)
458 struct ibv_pd *pd = ibv_alloc_pd(NULL);
462 if compile_prog "" "-libverbs" "libverbs" ; then
464 LIBS="-libverbs $LIBS"
466 echo "libverbs $libverbs"
468 ##########################################
473 #include <rdma/rdma_cma.h>
474 int main(int argc, char **argv)
476 rdma_destroy_qp(NULL);
480 if compile_prog "" "-lrdmacm" "rdma"; then
482 LIBS="-lrdmacm $LIBS"
484 echo "rdmacm $rdmacm"
486 ##########################################
487 # Linux fallocate probe
491 #include <linux/falloc.h>
492 int main(int argc, char **argv)
494 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
498 if compile_prog "" "" "linux_fallocate"; then
499 linux_fallocate="yes"
501 echo "Linux fallocate $linux_fallocate"
503 ##########################################
504 # POSIX fadvise probe
509 int main(int argc, char **argv)
511 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
515 if compile_prog "" "" "posix_fadvise"; then
518 echo "POSIX fadvise $posix_fadvise"
520 ##########################################
521 # POSIX fallocate probe
526 int main(int argc, char **argv)
528 int r = posix_fallocate(0, 0, 1024);
532 if compile_prog "" "" "posix_fallocate"; then
533 posix_fallocate="yes"
535 echo "POSIX fallocate $posix_fallocate"
537 ##########################################
538 # sched_set/getaffinity 2 or 3 argument test
539 linux_2arg_affinity="no"
540 linux_3arg_affinity="no"
543 int main(int argc, char **argv)
546 return sched_setaffinity(0, sizeof(mask), &mask);
549 if compile_prog "" "" "sched_setaffinity(,,)"; then
550 linux_3arg_affinity="yes"
554 int main(int argc, char **argv)
557 return sched_setaffinity(0, &mask);
560 if compile_prog "" "" "sched_setaffinity(,)"; then
561 linux_2arg_affinity="yes"
564 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
565 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
567 ##########################################
568 # clock_gettime probe
573 int main(int argc, char **argv)
575 return clock_gettime(0, NULL);
578 if compile_prog "" "" "clock_gettime"; then
580 elif compile_prog "" "-lrt" "clock_gettime"; then
584 echo "clock_gettime $clock_gettime"
586 ##########################################
587 # CLOCK_MONOTONIC probe
589 if test "$clock_gettime" = "yes" ; then
593 int main(int argc, char **argv)
595 return clock_gettime(CLOCK_MONOTONIC, NULL);
598 if compile_prog "" "$LIBS" "clock monotonic"; then
599 clock_monotonic="yes"
602 echo "CLOCK_MONOTONIC $clock_monotonic"
604 ##########################################
605 # CLOCK_MONOTONIC_PRECISE probe
606 clock_monotonic_precise="no"
607 if test "$clock_gettime" = "yes" ; then
611 int main(int argc, char **argv)
613 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
616 if compile_prog "" "$LIBS" "clock monotonic precise"; then
617 clock_monotonic_precise="yes"
620 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
622 ##########################################
623 # gettimeofday() probe
626 #include <sys/time.h>
628 int main(int argc, char **argv)
631 return gettimeofday(&tv, NULL);
634 if compile_prog "" "" "gettimeofday"; then
637 echo "gettimeofday $gettimeofday"
639 ##########################################
645 int main(int argc, char **argv)
650 if compile_prog "" "" "fdatasync"; then
653 echo "fdatasync $fdatasync"
655 ##########################################
656 # sync_file_range() probe
662 #include <linux/fs.h>
663 int main(int argc, char **argv)
665 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
666 SYNC_FILE_RANGE_WAIT_AFTER;
667 return sync_file_range(0, 0, 0, flags);
670 if compile_prog "" "" "sync_file_range"; then
671 sync_file_range="yes"
673 echo "sync_file_range $sync_file_range"
675 ##########################################
676 # ext4 move extent probe
680 #include <sys/ioctl.h>
681 int main(int argc, char **argv)
683 struct move_extent me;
684 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
687 if compile_prog "" "" "ext4 move extent" ; then
689 elif test $targetos = "Linux" ; then
690 # On Linux, just default to it on and let it error at runtime if we really
691 # don't have it. None of my updated systems have it defined, but it does
692 # work. Takes a while to bubble back.
695 echo "EXT4 move extent $ext4_me"
697 ##########################################
703 int main(int argc, char **argv)
705 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
708 if compile_prog "" "" "linux splice"; then
711 echo "Linux splice(2) $linux_splice"
713 ##########################################
718 #include <guasi_syscalls.h>
719 int main(int argc, char **argv)
721 guasi_t ctx = guasi_create(0, 0, 0);
725 if compile_prog "" "" "guasi"; then
730 ##########################################
734 #include <nvm/vectored_write.h>
735 int main(int argc, char **argv)
737 struct vsl_iovec iov;
738 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
741 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
742 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
745 echo "Fusion-io atomic engine $fusion_aw"
747 ##########################################
752 int main(int argc, char **argv)
754 return numa_available();
757 if compile_prog "" "-lnuma" "libnuma"; then
761 echo "libnuma $libnuma"
763 ##########################################
768 int main(int argc, char **argv)
774 if compile_prog "" "" "strsep"; then
777 echo "strsep $strsep"
779 ##########################################
780 # getopt_long_only() probe
781 getopt_long_only="no"
785 int main(int argc, char **argv)
787 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
791 if compile_prog "" "" "getopt_long_only"; then
792 getopt_long_only="yes"
794 echo "getopt_long_only() $getopt_long_only"
796 ##########################################
800 #include <sys/socket.h>
801 #include <arpa/inet.h>
803 int main(int argc, char **argv)
806 return inet_aton(NULL, &in);
809 if compile_prog "" "" "inet_aton"; then
812 echo "inet_aton $inet_aton"
814 ##########################################
819 #include <netinet/in.h>
820 int main(int argc, char **argv)
826 if compile_prog "" "" "socklen_t"; then
829 echo "socklen_t $socklen_t"
831 ##########################################
832 # Whether or not __thread is supported for TLS
836 static int __thread ret;
837 int main(int argc, char **argv)
842 if compile_prog "" "" "__thread"; then
845 echo "__thread $tls_thread"
847 ##########################################
848 # Check whether we have getrusage(RUSAGE_THREAD)
851 #include <sys/time.h>
852 #include <sys/resource.h>
853 int main(int argc, char **argv)
856 getrusage(RUSAGE_THREAD, &ru);
860 if compile_prog "" "" "RUSAGE_THREAD"; then
863 echo "RUSAGE_THREAD $rusage_thread"
865 ##########################################
866 # Check whether we have SCHED_IDLE
870 int main(int argc, char **argv)
872 struct sched_param p;
873 return sched_setscheduler(0, SCHED_IDLE, &p);
876 if compile_prog "" "" "SCHED_IDLE"; then
879 echo "SCHED_IDLE $sched_idle"
881 ##########################################
882 # Check whether we have TCP_NODELAY
886 #include <sys/types.h>
887 #include <sys/socket.h>
888 #include <netinet/tcp.h>
889 int main(int argc, char **argv)
891 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
894 if compile_prog "" "" "TCP_NODELAY"; then
897 echo "TCP_NODELAY $tcp_nodelay"
899 #############################################################################
901 echo "# Automatically generated by configure - do not modify" > $config_host_mak
902 printf "# Configured with:" >> $config_host_mak
903 printf " '%s'" "$0" "$@" >> $config_host_mak
904 echo >> $config_host_mak
906 if test "$wordsize" = "64" ; then
907 output_sym "CONFIG_64BIT"
908 elif test "$wordsize" = "32" ; then
909 output_sym "CONFIG_32BIT"
911 fatal "Unknown wordsize!"
913 if test "$bigendian" = "yes" ; then
914 output_sym "CONFIG_BIG_ENDIAN"
916 output_sym "CONFIG_LITTLE_ENDIAN"
918 if test "$libaio" = "yes" ; then
919 output_sym "CONFIG_LIBAIO"
921 if test "$posix_aio" = "yes" ; then
922 output_sym "CONFIG_POSIXAIO"
924 if test "$posix_aio_fsync" = "yes" ; then
925 output_sym "CONFIG_POSIXAIO_FSYNC"
927 if test "$linux_fallocate" = "yes" ; then
928 output_sym "CONFIG_LINUX_FALLOCATE"
930 if test "$posix_fallocate" = "yes" ; then
931 output_sym "CONFIG_POSIX_FALLOCATE"
933 if test "$fdatasync" = "yes" ; then
934 output_sym "CONFIG_FDATASYNC"
936 if test "$sync_file_range" = "yes" ; then
937 output_sym "CONFIG_SYNC_FILE_RANGE"
939 if test "$sfaa" = "yes" ; then
940 output_sym "CONFIG_SFAA"
942 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
943 output_sym "CONFIG_RDMA"
945 if test "$clock_gettime" = "yes" ; then
946 output_sym "CONFIG_CLOCK_GETTIME"
948 if test "$clock_monotonic" = "yes" ; then
949 output_sym "CONFIG_CLOCK_MONOTONIC"
951 if test "$clock_monotonic_precise" = "yes" ; then
952 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
954 if test "$gettimeofday" = "yes" ; then
955 output_sym "CONFIG_GETTIMEOFDAY"
957 if test "$posix_fadvise" = "yes" ; then
958 output_sym "CONFIG_POSIX_FADVISE"
960 if test "$linux_3arg_affinity" = "yes" ; then
961 output_sym "CONFIG_3ARG_AFFINITY"
962 elif test "$linux_2arg_affinity" = "yes" ; then
963 output_sym "CONFIG_2ARG_AFFINITY"
965 if test "$strsep" = "yes" ; then
966 output_sym "CONFIG_STRSEP"
968 if test "$getopt_long_only" = "yes" ; then
969 output_sym "CONFIG_GETOPT_LONG_ONLY"
971 if test "$inet_aton" = "yes" ; then
972 output_sym "CONFIG_INET_ATON"
974 if test "$socklen_t" = "yes" ; then
975 output_sym "CONFIG_SOCKLEN_T"
977 if test "$ext4_me" = "yes" ; then
978 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
980 if test "$linux_splice" = "yes" ; then
981 output_sym "CONFIG_LINUX_SPLICE"
983 if test "$guasi" = "yes" ; then
984 output_sym "CONFIG_GUASI"
986 if test "$fusion_aw" = "yes" ; then
987 output_sym "CONFIG_FUSION_AW"
989 if test "$libnuma" = "yes" ; then
990 output_sym "CONFIG_LIBNUMA"
992 if test "$solaris_aio" = "yes" ; then
993 output_sym "CONFIG_SOLARISAIO"
995 if test "$tls_thread" = "yes" ; then
996 output_sym "CONFIG_TLS_THREAD"
998 if test "$rusage_thread" = "yes" ; then
999 output_sym "CONFIG_RUSAGE_THREAD"
1001 if test "$sched_idle" = "yes" ; then
1002 output_sym "CONFIG_SCHED_IDLE"
1004 if test "$tcp_nodelay" = "yes" ; then
1005 output_sym "CONFIG_TCP_NODELAY"
1008 echo "LIBS+=$LIBS" >> $config_host_mak
1009 echo "CC=$cc" >> $config_host_mak
1010 echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak