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}"
130 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
132 --cpu=*) cpu="$optarg"
136 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
138 --build-32bit-win=*) build_32bit_win="$optarg"
144 echo "Bad option $opt"
150 if test "$show_help" = "yes" ; then
151 echo "--cpu= Specify target CPU if auto-detect fails"
152 echo "--cc= Specify compiler to use"
153 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
154 echo "--build-32bit-win= Specify yes for a 32-bit build on Windows"
158 if check_define __linux__ ; then
160 elif check_define __OpenBSD__ ; then
162 elif check_define __sun__ ; then
168 # Some host OSes need non-standard checks for which CPU to use.
169 # Note that these checks are broken for cross-compilation: if you're
170 # cross-compiling to one of these OSes then you'll need to specify
171 # the correct CPU with the --cpu option.
174 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
175 # we can run 64-bit userspace code.
176 # If the user didn't specify a CPU explicitly and the kernel says this is
177 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
179 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
184 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
185 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
190 echo "Forcing known good options on Windows"
191 if test -z "$CC" ; then
192 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
193 CC="i686-w64-mingw32-gcc"
195 CC="x86_64-w64-mingw32-gcc"
198 output_sym "CONFIG_LITTLE_ENDIAN"
199 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
200 output_sym "CONFIG_32BIT"
202 output_sym "CONFIG_64BIT_LLP64"
204 output_sym "CONFIG_FADVISE"
205 output_sym "CONFIG_SOCKLEN_T"
206 output_sym "CONFIG_FADVISE"
207 output_sym "CONFIG_SFAA"
208 output_sym "CONFIG_RUSAGE_THREAD"
209 output_sym "CONFIG_WINDOWSAIO"
210 output_sym "CONFIG_FDATASYNC"
211 output_sym "CONFIG_CLOCK_MONOTONIC"
212 output_sym "CONFIG_GETTIMEOFDAY"
213 output_sym "CONFIG_CLOCK_GETTIME"
214 output_sym "CONFIG_SCHED_IDLE"
215 output_sym "CONFIG_TCP_NODELAY"
216 echo "CC=$CC" >> $config_host_mak
217 echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
221 if test ! -z "$cpu" ; then
222 # command line argument
224 elif check_define __i386__ ; then
226 elif check_define __x86_64__ ; then
228 elif check_define __sparc__ ; then
229 if check_define __arch64__ ; then
234 elif check_define _ARCH_PPC ; then
235 if check_define _ARCH_PPC64 ; then
240 elif check_define __mips__ ; then
242 elif check_define __ia64__ ; then
244 elif check_define __s390__ ; then
245 if check_define __s390x__ ; then
250 elif check_define __arm__ ; then
252 elif check_define __hppa__ ; then
258 # Normalise host CPU name and set ARCH.
260 ia64|ppc|ppc64|s390|s390x|sparc64)
263 i386|i486|i586|i686|i86pc|BePC)
272 hppa|parisc|parisc64)
286 if test -z "$CC" ; then
287 if test "$targetos" = "FreeBSD"; then
296 cc="${CC-${cross_prefix}gcc}"
298 ##########################################
302 #include <inttypes.h>
305 volatile uint32_t i=0x01234567;
306 return (*((uint8_t*)(&i))) == 0x67;
309 if compile_prog "" "" "endian"; then
310 $TMPE && bigendian="yes"
314 echo "Operating system $targetos"
316 echo "Big endian $bigendian"
320 ##########################################
327 unsigned int wsize = sizeof(long) * 8;
328 printf("%d\n", wsize);
332 if compile_prog "" "" "wordsize"; then
335 echo "Wordsize $wordsize"
337 ##########################################
349 if compile_prog "" "-laio" "libaio" ; then
353 if test "$libaio" = "yes" ; then
354 feature_not_found "linux AIO"
358 echo "Linux AIO support $libaio"
360 ##########################################
373 if compile_prog "" "" "posixaio" ; then
375 elif compile_prog "" "-lrt" "posixaio"; then
380 echo "POSIX AIO support $posix_aio"
381 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
383 ##########################################
384 # posix aio fsync probe
386 if test "$posix_aio" = "yes" ; then
393 return aio_fsync(O_SYNC, &cb);
397 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
401 echo "POSIX AIO fsync $posix_aio_fsync"
403 ##########################################
407 #include <sys/types.h>
408 #include <sys/asynch.h>
413 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
417 if compile_prog "" "-laio" "solarisaio" ; then
421 echo "Solaris AIO support $solaris_aio"
423 ##########################################
424 # __sync_fetch_and_and test
427 static int sfaa(int *ptr)
429 return __sync_fetch_and_and(ptr, 0);
432 int main(int argc, char **argv)
439 if compile_prog "" "" "__sync_fetch_and_add()" ; then
442 echo "__sync_fetch_and add $sfaa"
444 ##########################################
449 #include <infiniband/arch.h>
450 int main(int argc, char **argv)
452 struct ibv_pd *pd = ibv_alloc_pd(NULL);
456 if compile_prog "" "-libverbs" "libverbs" ; then
458 LIBS="-libverbs $LIBS"
460 echo "libverbs $libverbs"
462 ##########################################
467 #include <rdma/rdma_cma.h>
468 int main(int argc, char **argv)
470 rdma_destroy_qp(NULL);
474 if compile_prog "" "-lrdmacm" "rdma"; then
476 LIBS="-lrdmacm $LIBS"
478 echo "rdmacm $rdmacm"
480 ##########################################
481 # Linux fallocate probe
485 #include <linux/falloc.h>
486 int main(int argc, char **argv)
488 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
492 if compile_prog "" "" "linux_fallocate"; then
493 linux_fallocate="yes"
495 echo "Linux fallocate $linux_fallocate"
497 ##########################################
498 # POSIX fadvise probe
503 int main(int argc, char **argv)
505 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
509 if compile_prog "" "" "posix_fadvise"; then
512 echo "POSIX fadvise $posix_fadvise"
514 ##########################################
515 # POSIX fallocate probe
520 int main(int argc, char **argv)
522 int r = posix_fallocate(0, 0, 1024);
526 if compile_prog "" "" "posix_fallocate"; then
527 posix_fallocate="yes"
529 echo "POSIX fallocate $posix_fallocate"
531 ##########################################
532 # sched_set/getaffinity 2 or 3 argument test
533 linux_2arg_affinity="no"
534 linux_3arg_affinity="no"
537 int main(int argc, char **argv)
540 return sched_setaffinity(0, sizeof(mask), &mask);
543 if compile_prog "" "" "sched_setaffinity(,,)"; then
544 linux_3arg_affinity="yes"
548 int main(int argc, char **argv)
551 return sched_setaffinity(0, &mask);
554 if compile_prog "" "" "sched_setaffinity(,)"; then
555 linux_2arg_affinity="yes"
558 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
559 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
561 ##########################################
562 # clock_gettime probe
567 int main(int argc, char **argv)
569 return clock_gettime(0, NULL);
572 if compile_prog "" "" "clock_gettime"; then
574 elif compile_prog "" "-lrt" "clock_gettime"; then
578 echo "clock_gettime $clock_gettime"
580 ##########################################
581 # CLOCK_MONOTONIC probe
583 if test "$clock_gettime" = "yes" ; then
587 int main(int argc, char **argv)
589 return clock_gettime(CLOCK_MONOTONIC, NULL);
592 if compile_prog "" "$LIBS" "clock monotonic"; then
593 clock_monotonic="yes"
596 echo "CLOCK_MONOTONIC $clock_monotonic"
598 ##########################################
599 # CLOCK_MONOTONIC_PRECISE probe
600 clock_monotonic_precise="no"
601 if test "$clock_gettime" = "yes" ; then
605 int main(int argc, char **argv)
607 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
610 if compile_prog "" "$LIBS" "clock monotonic precise"; then
611 clock_monotonic_precise="yes"
614 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
616 ##########################################
617 # gettimeofday() probe
620 #include <sys/time.h>
622 int main(int argc, char **argv)
625 return gettimeofday(&tv, NULL);
628 if compile_prog "" "" "gettimeofday"; then
631 echo "gettimeofday $gettimeofday"
633 ##########################################
639 int main(int argc, char **argv)
644 if compile_prog "" "" "fdatasync"; then
647 echo "fdatasync $fdatasync"
649 ##########################################
650 # sync_file_range() probe
656 #include <linux/fs.h>
657 int main(int argc, char **argv)
659 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
660 SYNC_FILE_RANGE_WAIT_AFTER;
661 return sync_file_range(0, 0, 0, flags);
664 if compile_prog "" "" "sync_file_range"; then
665 sync_file_range="yes"
667 echo "sync_file_range $sync_file_range"
669 ##########################################
670 # ext4 move extent probe
674 #include <sys/ioctl.h>
675 int main(int argc, char **argv)
677 struct move_extent me;
678 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
681 if compile_prog "" "" "ext4 move extent" ; then
683 elif test $targetos = "Linux" ; then
684 # On Linux, just default to it on and let it error at runtime if we really
685 # don't have it. None of my updated systems have it defined, but it does
686 # work. Takes a while to bubble back.
689 echo "EXT4 move extent $ext4_me"
691 ##########################################
697 int main(int argc, char **argv)
699 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
702 if compile_prog "" "" "linux splice"; then
705 echo "Linux splice(2) $linux_splice"
707 ##########################################
712 #include <guasi_syscalls.h>
713 int main(int argc, char **argv)
715 guasi_t ctx = guasi_create(0, 0, 0);
719 if compile_prog "" "" "guasi"; then
724 ##########################################
728 #include <nvm/vectored_write.h>
729 int main(int argc, char **argv)
731 struct vsl_iovec iov;
732 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
735 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
736 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
739 echo "Fusion-io atomic engine $fusion_aw"
741 ##########################################
746 int main(int argc, char **argv)
748 return numa_available();
751 if compile_prog "" "-lnuma" "libnuma"; then
755 echo "libnuma $libnuma"
757 ##########################################
762 int main(int argc, char **argv)
768 if compile_prog "" "" "strsep"; then
771 echo "strsep $strsep"
773 ##########################################
774 # getopt_long_only() probe
775 getopt_long_only="no"
779 int main(int argc, char **argv)
781 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
785 if compile_prog "" "" "getopt_long_only"; then
786 getopt_long_only="yes"
788 echo "getopt_long_only() $getopt_long_only"
790 ##########################################
794 #include <sys/socket.h>
795 #include <arpa/inet.h>
797 int main(int argc, char **argv)
800 return inet_aton(NULL, &in);
803 if compile_prog "" "" "inet_aton"; then
806 echo "inet_aton $inet_aton"
808 ##########################################
813 #include <netinet/in.h>
814 int main(int argc, char **argv)
820 if compile_prog "" "" "socklen_t"; then
823 echo "socklen_t $socklen_t"
825 ##########################################
826 # Whether or not __thread is supported for TLS
830 static int __thread ret;
831 int main(int argc, char **argv)
836 if compile_prog "" "" "__thread"; then
839 echo "__thread $tls_thread"
841 ##########################################
842 # Check whether we have getrusage(RUSAGE_THREAD)
845 #include <sys/time.h>
846 #include <sys/resource.h>
847 int main(int argc, char **argv)
850 getrusage(RUSAGE_THREAD, &ru);
854 if compile_prog "" "" "RUSAGE_THREAD"; then
857 echo "RUSAGE_THREAD $rusage_thread"
859 ##########################################
860 # Check whether we have SCHED_IDLE
864 int main(int argc, char **argv)
866 struct sched_param p;
867 return sched_setscheduler(0, SCHED_IDLE, &p);
870 if compile_prog "" "" "SCHED_IDLE"; then
873 echo "SCHED_IDLE $sched_idle"
875 ##########################################
876 # Check whether we have TCP_NODELAY
880 #include <sys/types.h>
881 #include <sys/socket.h>
882 #include <netinet/tcp.h>
883 int main(int argc, char **argv)
885 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
888 if compile_prog "" "" "TCP_NODELAY"; then
891 echo "TCP_NODELAY $tcp_nodelay"
893 #############################################################################
895 echo "# Automatically generated by configure - do not modify" > $config_host_mak
896 printf "# Configured with:" >> $config_host_mak
897 printf " '%s'" "$0" "$@" >> $config_host_mak
898 echo >> $config_host_mak
900 if test "$wordsize" = "64" ; then
901 output_sym "CONFIG_64BIT"
902 elif test "$wordsize" = "32" ; then
903 output_sym "CONFIG_32BIT"
905 echo "Unknown wordsize!"
908 if test "$bigendian" = "yes" ; then
909 output_sym "CONFIG_BIG_ENDIAN"
911 output_sym "CONFIG_LITTLE_ENDIAN"
913 if test "$libaio" = "yes" ; then
914 output_sym "CONFIG_LIBAIO"
916 if test "$posix_aio" = "yes" ; then
917 output_sym "CONFIG_POSIXAIO"
919 if test "$posix_aio_fsync" = "yes" ; then
920 output_sym "CONFIG_POSIXAIO_FSYNC"
922 if test "$linux_fallocate" = "yes" ; then
923 output_sym "CONFIG_LINUX_FALLOCATE"
925 if test "$posix_fallocate" = "yes" ; then
926 output_sym "CONFIG_POSIX_FALLOCATE"
928 if test "$fdatasync" = "yes" ; then
929 output_sym "CONFIG_FDATASYNC"
931 if test "$sync_file_range" = "yes" ; then
932 output_sym "CONFIG_SYNC_FILE_RANGE"
934 if test "$sfaa" = "yes" ; then
935 output_sym "CONFIG_SFAA"
937 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
938 output_sym "CONFIG_RDMA"
940 if test "$clock_gettime" = "yes" ; then
941 output_sym "CONFIG_CLOCK_GETTIME"
943 if test "$clock_monotonic" = "yes" ; then
944 output_sym "CONFIG_CLOCK_MONOTONIC"
946 if test "$clock_monotonic_precise" = "yes" ; then
947 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
949 if test "$gettimeofday" = "yes" ; then
950 output_sym "CONFIG_GETTIMEOFDAY"
952 if test "$posix_fadvise" = "yes" ; then
953 output_sym "CONFIG_POSIX_FADVISE"
955 if test "$linux_3arg_affinity" = "yes" ; then
956 output_sym "CONFIG_3ARG_AFFINITY"
957 elif test "$linux_2arg_affinity" = "yes" ; then
958 output_sym "CONFIG_2ARG_AFFINITY"
960 if test "$strsep" = "yes" ; then
961 output_sym "CONFIG_STRSEP"
963 if test "$getopt_long_only" = "yes" ; then
964 output_sym "CONFIG_GETOPT_LONG_ONLY"
966 if test "$inet_aton" = "yes" ; then
967 output_sym "CONFIG_INET_ATON"
969 if test "$socklen_t" = "yes" ; then
970 output_sym "CONFIG_SOCKLEN_T"
972 if test "$ext4_me" = "yes" ; then
973 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
975 if test "$linux_splice" = "yes" ; then
976 output_sym "CONFIG_LINUX_SPLICE"
978 if test "$guasi" = "yes" ; then
979 output_sym "CONFIG_GUASI"
981 if test "$fusion_aw" = "yes" ; then
982 output_sym "CONFIG_FUSION_AW"
984 if test "$libnuma" = "yes" ; then
985 output_sym "CONFIG_LIBNUMA"
987 if test "$solaris_aio" = "yes" ; then
988 output_sym "CONFIG_SOLARISAIO"
990 if test "$tls_thread" = "yes" ; then
991 output_sym "CONFIG_TLS_THREAD"
993 if test "$rusage_thread" = "yes" ; then
994 output_sym "CONFIG_RUSAGE_THREAD"
996 if test "$sched_idle" = "yes" ; then
997 output_sym "CONFIG_SCHED_IDLE"
999 if test "$tcp_nodelay" = "yes" ; then
1000 output_sym "CONFIG_TCP_NODELAY"
1003 echo "LIBS+=$LIBS" >> $config_host_mak
1004 echo "CC=$cc" >> $config_host_mak
1005 echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak