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
90 local_ldflags="$2 $LIBS"
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
196 LIBS="-lnsl -lsocket"
199 echo "Forcing known good options on Windows"
200 if test -z "$CC" ; then
201 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
202 CC="i686-w64-mingw32-gcc"
204 CC="x86_64-w64-mingw32-gcc"
207 output_sym "CONFIG_LITTLE_ENDIAN"
208 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
209 output_sym "CONFIG_32BIT"
211 output_sym "CONFIG_64BIT_LLP64"
213 output_sym "CONFIG_FADVISE"
214 output_sym "CONFIG_SOCKLEN_T"
215 output_sym "CONFIG_FADVISE"
216 output_sym "CONFIG_SFAA"
217 output_sym "CONFIG_RUSAGE_THREAD"
218 output_sym "CONFIG_WINDOWSAIO"
219 output_sym "CONFIG_FDATASYNC"
220 output_sym "CONFIG_CLOCK_MONOTONIC"
221 output_sym "CONFIG_GETTIMEOFDAY"
222 output_sym "CONFIG_CLOCK_GETTIME"
223 output_sym "CONFIG_SCHED_IDLE"
224 output_sym "CONFIG_TCP_NODELAY"
225 echo "CC=$CC" >> $config_host_mak
226 echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
230 output_sym "CONFIG_32BIT"
231 output_sym "CONFIG_LITTLE_ENDIAN"
232 output_sym "CONFIG_SOCKLEN_T"
233 output_sym "CONFIG_GETTIMEOFDAY"
234 output_sym "CONFIG_CLOCK_GETTIME"
235 output_sym "CONFIG_CLOCK_MONOTONIC"
236 echo "CC=$cc" >> $config_host_mak
237 echo "EXTFLAGS=$CFLAGS -include config-host.h -DFIO_NO_HAVE_SHM_H -D_GNU_SOURCE" >> $config_host_mak
241 if test ! -z "$cpu" ; then
242 # command line argument
244 elif check_define __i386__ ; then
246 elif check_define __x86_64__ ; then
248 elif check_define __sparc__ ; then
249 if check_define __arch64__ ; then
254 elif check_define _ARCH_PPC ; then
255 if check_define _ARCH_PPC64 ; then
260 elif check_define __mips__ ; then
262 elif check_define __ia64__ ; then
264 elif check_define __s390__ ; then
265 if check_define __s390x__ ; then
270 elif check_define __arm__ ; then
272 elif check_define __hppa__ ; then
278 # Normalise host CPU name and set ARCH.
280 ia64|ppc|ppc64|s390|s390x|sparc64)
283 i386|i486|i586|i686|i86pc|BePC)
292 hppa|parisc|parisc64)
306 if test -z "$CC" ; then
307 if test "$targetos" = "FreeBSD"; then
316 cc="${CC-${cross_prefix}gcc}"
318 ##########################################
322 #include <inttypes.h>
325 volatile uint32_t i=0x01234567;
326 return (*((uint8_t*)(&i))) == 0x67;
329 if compile_prog "" "" "endian"; then
330 $TMPE && bigendian="yes"
334 echo "Operating system $targetos"
336 echo "Big endian $bigendian"
340 ##########################################
347 unsigned int wsize = sizeof(long) * 8;
348 printf("%d\n", wsize);
352 if compile_prog "" "" "wordsize"; then
355 echo "Wordsize $wordsize"
357 ##########################################
369 if compile_prog "" "-laio" "libaio" ; then
373 if test "$libaio" = "yes" ; then
374 feature_not_found "linux AIO"
378 echo "Linux AIO support $libaio"
380 ##########################################
393 if compile_prog "" "" "posixaio" ; then
395 elif compile_prog "" "-lrt" "posixaio"; then
400 echo "POSIX AIO support $posix_aio"
401 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
403 ##########################################
404 # posix aio fsync probe
406 if test "$posix_aio" = "yes" ; then
413 return aio_fsync(O_SYNC, &cb);
417 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
421 echo "POSIX AIO fsync $posix_aio_fsync"
423 ##########################################
427 #include <sys/types.h>
428 #include <sys/asynch.h>
433 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
437 if compile_prog "" "-laio" "solarisaio" ; then
441 echo "Solaris AIO support $solaris_aio"
443 ##########################################
444 # __sync_fetch_and_and test
447 static int sfaa(int *ptr)
449 return __sync_fetch_and_add(ptr, 0);
452 int main(int argc, char **argv)
459 if compile_prog "" "" "__sync_fetch_and_add()" ; then
462 echo "__sync_fetch_and_add $sfaa"
464 ##########################################
469 #include <infiniband/arch.h>
470 int main(int argc, char **argv)
472 struct ibv_pd *pd = ibv_alloc_pd(NULL);
476 if compile_prog "" "-libverbs" "libverbs" ; then
478 LIBS="-libverbs $LIBS"
480 echo "libverbs $libverbs"
482 ##########################################
487 #include <rdma/rdma_cma.h>
488 int main(int argc, char **argv)
490 rdma_destroy_qp(NULL);
494 if compile_prog "" "-lrdmacm" "rdma"; then
496 LIBS="-lrdmacm $LIBS"
498 echo "rdmacm $rdmacm"
500 ##########################################
501 # Linux fallocate probe
505 #include <linux/falloc.h>
506 int main(int argc, char **argv)
508 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
512 if compile_prog "" "" "linux_fallocate"; then
513 linux_fallocate="yes"
515 echo "Linux fallocate $linux_fallocate"
517 ##########################################
518 # POSIX fadvise probe
523 int main(int argc, char **argv)
525 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
529 if compile_prog "" "" "posix_fadvise"; then
532 echo "POSIX fadvise $posix_fadvise"
534 ##########################################
535 # POSIX fallocate probe
540 int main(int argc, char **argv)
542 int r = posix_fallocate(0, 0, 1024);
546 if compile_prog "" "" "posix_fallocate"; then
547 posix_fallocate="yes"
549 echo "POSIX fallocate $posix_fallocate"
551 ##########################################
552 # sched_set/getaffinity 2 or 3 argument test
553 linux_2arg_affinity="no"
554 linux_3arg_affinity="no"
557 int main(int argc, char **argv)
560 return sched_setaffinity(0, sizeof(mask), &mask);
563 if compile_prog "" "" "sched_setaffinity(,,)"; then
564 linux_3arg_affinity="yes"
568 int main(int argc, char **argv)
571 return sched_setaffinity(0, &mask);
574 if compile_prog "" "" "sched_setaffinity(,)"; then
575 linux_2arg_affinity="yes"
578 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
579 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
581 ##########################################
582 # clock_gettime probe
587 int main(int argc, char **argv)
589 return clock_gettime(0, NULL);
592 if compile_prog "" "" "clock_gettime"; then
594 elif compile_prog "" "-lrt" "clock_gettime"; then
598 echo "clock_gettime $clock_gettime"
600 ##########################################
601 # CLOCK_MONOTONIC probe
603 if test "$clock_gettime" = "yes" ; then
607 int main(int argc, char **argv)
609 return clock_gettime(CLOCK_MONOTONIC, NULL);
612 if compile_prog "" "$LIBS" "clock monotonic"; then
613 clock_monotonic="yes"
616 echo "CLOCK_MONOTONIC $clock_monotonic"
618 ##########################################
619 # CLOCK_MONOTONIC_PRECISE probe
620 clock_monotonic_precise="no"
621 if test "$clock_gettime" = "yes" ; then
625 int main(int argc, char **argv)
627 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
630 if compile_prog "" "$LIBS" "clock monotonic precise"; then
631 clock_monotonic_precise="yes"
634 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
636 ##########################################
637 # gettimeofday() probe
640 #include <sys/time.h>
642 int main(int argc, char **argv)
645 return gettimeofday(&tv, NULL);
648 if compile_prog "" "" "gettimeofday"; then
651 echo "gettimeofday $gettimeofday"
653 ##########################################
659 int main(int argc, char **argv)
664 if compile_prog "" "" "fdatasync"; then
667 echo "fdatasync $fdatasync"
669 ##########################################
670 # sync_file_range() probe
676 #include <linux/fs.h>
677 int main(int argc, char **argv)
679 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
680 SYNC_FILE_RANGE_WAIT_AFTER;
681 return sync_file_range(0, 0, 0, flags);
684 if compile_prog "" "" "sync_file_range"; then
685 sync_file_range="yes"
687 echo "sync_file_range $sync_file_range"
689 ##########################################
690 # ext4 move extent probe
694 #include <sys/ioctl.h>
695 int main(int argc, char **argv)
697 struct move_extent me;
698 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
701 if compile_prog "" "" "ext4 move extent" ; then
703 elif test $targetos = "Linux" ; then
704 # On Linux, just default to it on and let it error at runtime if we really
705 # don't have it. None of my updated systems have it defined, but it does
706 # work. Takes a while to bubble back.
709 echo "EXT4 move extent $ext4_me"
711 ##########################################
717 int main(int argc, char **argv)
719 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
722 if compile_prog "" "" "linux splice"; then
725 echo "Linux splice(2) $linux_splice"
727 ##########################################
732 #include <guasi_syscalls.h>
733 int main(int argc, char **argv)
735 guasi_t ctx = guasi_create(0, 0, 0);
739 if compile_prog "" "" "guasi"; then
744 ##########################################
748 #include <nvm/vectored_write.h>
749 int main(int argc, char **argv)
751 struct vsl_iovec iov;
752 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
755 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
756 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
759 echo "Fusion-io atomic engine $fusion_aw"
761 ##########################################
766 int main(int argc, char **argv)
768 return numa_available();
771 if compile_prog "" "-lnuma" "libnuma"; then
775 echo "libnuma $libnuma"
777 ##########################################
782 int main(int argc, char **argv)
788 if compile_prog "" "" "strsep"; then
791 echo "strsep $strsep"
793 ##########################################
794 # getopt_long_only() probe
795 getopt_long_only="no"
799 int main(int argc, char **argv)
801 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
805 if compile_prog "" "" "getopt_long_only"; then
806 getopt_long_only="yes"
808 echo "getopt_long_only() $getopt_long_only"
810 ##########################################
814 #include <sys/socket.h>
815 #include <arpa/inet.h>
817 int main(int argc, char **argv)
820 return inet_aton(NULL, &in);
823 if compile_prog "" "" "inet_aton"; then
826 echo "inet_aton $inet_aton"
828 ##########################################
833 #include <netinet/in.h>
834 int main(int argc, char **argv)
840 if compile_prog "" "" "socklen_t"; then
843 echo "socklen_t $socklen_t"
845 ##########################################
846 # Whether or not __thread is supported for TLS
850 static int __thread ret;
851 int main(int argc, char **argv)
856 if compile_prog "" "" "__thread"; then
859 echo "__thread $tls_thread"
861 ##########################################
862 # Check whether we have getrusage(RUSAGE_THREAD)
865 #include <sys/time.h>
866 #include <sys/resource.h>
867 int main(int argc, char **argv)
870 getrusage(RUSAGE_THREAD, &ru);
874 if compile_prog "" "" "RUSAGE_THREAD"; then
877 echo "RUSAGE_THREAD $rusage_thread"
879 ##########################################
880 # Check whether we have SCHED_IDLE
884 int main(int argc, char **argv)
886 struct sched_param p;
887 return sched_setscheduler(0, SCHED_IDLE, &p);
890 if compile_prog "" "" "SCHED_IDLE"; then
893 echo "SCHED_IDLE $sched_idle"
895 ##########################################
896 # Check whether we have TCP_NODELAY
900 #include <sys/types.h>
901 #include <sys/socket.h>
902 #include <netinet/tcp.h>
903 int main(int argc, char **argv)
905 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
908 if compile_prog "" "" "TCP_NODELAY"; then
911 echo "TCP_NODELAY $tcp_nodelay"
913 ##########################################
914 # Check whether we have RLIMIT_MEMLOCK
917 #include <sys/time.h>
918 #include <sys/resource.h>
919 int main(int argc, char **argv)
922 return getrlimit(RLIMIT_MEMLOCK, &rl);
925 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
928 echo "RLIMIT_MEMLOCK $rlimit_memlock"
930 #############################################################################
932 echo "# Automatically generated by configure - do not modify" > $config_host_mak
933 printf "# Configured with:" >> $config_host_mak
934 printf " '%s'" "$0" "$@" >> $config_host_mak
935 echo >> $config_host_mak
937 if test "$wordsize" = "64" ; then
938 output_sym "CONFIG_64BIT"
939 elif test "$wordsize" = "32" ; then
940 output_sym "CONFIG_32BIT"
942 fatal "Unknown wordsize!"
944 if test "$bigendian" = "yes" ; then
945 output_sym "CONFIG_BIG_ENDIAN"
947 output_sym "CONFIG_LITTLE_ENDIAN"
949 if test "$libaio" = "yes" ; then
950 output_sym "CONFIG_LIBAIO"
952 if test "$posix_aio" = "yes" ; then
953 output_sym "CONFIG_POSIXAIO"
955 if test "$posix_aio_fsync" = "yes" ; then
956 output_sym "CONFIG_POSIXAIO_FSYNC"
958 if test "$linux_fallocate" = "yes" ; then
959 output_sym "CONFIG_LINUX_FALLOCATE"
961 if test "$posix_fallocate" = "yes" ; then
962 output_sym "CONFIG_POSIX_FALLOCATE"
964 if test "$fdatasync" = "yes" ; then
965 output_sym "CONFIG_FDATASYNC"
967 if test "$sync_file_range" = "yes" ; then
968 output_sym "CONFIG_SYNC_FILE_RANGE"
970 if test "$sfaa" = "yes" ; then
971 output_sym "CONFIG_SFAA"
973 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
974 output_sym "CONFIG_RDMA"
976 if test "$clock_gettime" = "yes" ; then
977 output_sym "CONFIG_CLOCK_GETTIME"
979 if test "$clock_monotonic" = "yes" ; then
980 output_sym "CONFIG_CLOCK_MONOTONIC"
982 if test "$clock_monotonic_precise" = "yes" ; then
983 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
985 if test "$gettimeofday" = "yes" ; then
986 output_sym "CONFIG_GETTIMEOFDAY"
988 if test "$posix_fadvise" = "yes" ; then
989 output_sym "CONFIG_POSIX_FADVISE"
991 if test "$linux_3arg_affinity" = "yes" ; then
992 output_sym "CONFIG_3ARG_AFFINITY"
993 elif test "$linux_2arg_affinity" = "yes" ; then
994 output_sym "CONFIG_2ARG_AFFINITY"
996 if test "$strsep" = "yes" ; then
997 output_sym "CONFIG_STRSEP"
999 if test "$getopt_long_only" = "yes" ; then
1000 output_sym "CONFIG_GETOPT_LONG_ONLY"
1002 if test "$inet_aton" = "yes" ; then
1003 output_sym "CONFIG_INET_ATON"
1005 if test "$socklen_t" = "yes" ; then
1006 output_sym "CONFIG_SOCKLEN_T"
1008 if test "$ext4_me" = "yes" ; then
1009 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1011 if test "$linux_splice" = "yes" ; then
1012 output_sym "CONFIG_LINUX_SPLICE"
1014 if test "$guasi" = "yes" ; then
1015 output_sym "CONFIG_GUASI"
1017 if test "$fusion_aw" = "yes" ; then
1018 output_sym "CONFIG_FUSION_AW"
1020 if test "$libnuma" = "yes" ; then
1021 output_sym "CONFIG_LIBNUMA"
1023 if test "$solaris_aio" = "yes" ; then
1024 output_sym "CONFIG_SOLARISAIO"
1026 if test "$tls_thread" = "yes" ; then
1027 output_sym "CONFIG_TLS_THREAD"
1029 if test "$rusage_thread" = "yes" ; then
1030 output_sym "CONFIG_RUSAGE_THREAD"
1032 if test "$sched_idle" = "yes" ; then
1033 output_sym "CONFIG_SCHED_IDLE"
1035 if test "$tcp_nodelay" = "yes" ; then
1036 output_sym "CONFIG_TCP_NODELAY"
1038 if test "$rlimit_memlock" = "yes" ; then
1039 output_sym "CONFIG_RLIMIT_MEMLOCK"
1042 echo "LIBS+=$LIBS" >> $config_host_mak
1043 echo "CC=$cc" >> $config_host_mak
1044 echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak