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}"
132 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
138 CFLAGS="$CFLAGS $optarg"
147 echo "Bad option $opt"
153 if test "$show_help" = "yes" ; then
154 echo "--cc= Specify compiler to use"
155 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
156 echo "--enable-gfio Enable building of gtk gfio"
160 if check_define __linux__ ; then
162 elif check_define __OpenBSD__ ; then
164 elif check_define __sun__ ; then
170 # Some host OSes need non-standard checks for which CPU to use.
171 # Note that these checks are broken for cross-compilation: if you're
172 # cross-compiling to one of these OSes then you'll need to specify
173 # the correct CPU with the --cpu option.
176 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
177 # we can run 64-bit userspace code.
178 # If the user didn't specify a CPU explicitly and the kernel says this is
179 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
181 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
186 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
187 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
192 echo "Forcing known good options on Windows"
193 if test -z "$CC" ; then
194 CC="x86_64-w64-mingw32-gcc"
196 output_sym "CONFIG_LITTLE_ENDIAN"
197 output_sym "CONFIG_64BIT_LLP64"
198 output_sym "CONFIG_FADVISE"
199 output_sym "CONFIG_SOCKLEN_T"
200 output_sym "CONFIG_POSIX_FALLOCATE"
201 output_sym "CONFIG_FADVISE"
202 output_sym "CONFIG_SFAA"
203 output_sym "CONFIG_RUSAGE_THREAD"
204 output_sym "CONFIG_WINDOWSAIO"
205 output_sym "CONFIG_FDATASYNC"
206 output_sym "CONFIG_CLOCK_MONOTONIC"
207 output_sym "CONFIG_GETTIMEOFDAY"
208 output_sym "CONFIG_CLOCK_GETTIME"
209 output_sym "CONFIG_SCHED_IDLE"
210 output_sym "CONFIG_TCP_NODELAY"
211 echo "CC=$CC" >> $config_host_mak
212 echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
216 if test ! -z "$cpu" ; then
217 # command line argument
219 elif check_define __i386__ ; then
221 elif check_define __x86_64__ ; then
223 elif check_define __sparc__ ; then
224 if check_define __arch64__ ; then
229 elif check_define _ARCH_PPC ; then
230 if check_define _ARCH_PPC64 ; then
235 elif check_define __mips__ ; then
237 elif check_define __ia64__ ; then
239 elif check_define __s390__ ; then
240 if check_define __s390x__ ; then
245 elif check_define __arm__ ; then
247 elif check_define __hppa__ ; then
253 # Normalise host CPU name and set ARCH.
255 ia64|ppc|ppc64|s390|s390x|sparc64)
258 i386|i486|i586|i686|i86pc|BePC)
267 hppa|parisc|parisc64)
282 if test -z "$CC" ; then
283 if test "$targetos" = "FreeBSD"; then
292 cc="${CC-${cross_prefix}gcc}"
294 ##########################################
298 #include <inttypes.h>
301 volatile uint32_t i=0x01234567;
302 return (*((uint8_t*)(&i))) == 0x67;
305 if compile_prog "" "" "endian"; then
306 $TMPE && bigendian="yes"
310 echo "Operating system $targetos"
312 echo "Big endian $bigendian"
316 ##########################################
323 unsigned int wsize = sizeof(long) * 8;
324 printf("%d\n", wsize);
328 if compile_prog "" "" "wordsize"; then
331 echo "Wordsize $wordsize"
333 ##########################################
345 if compile_prog "" "-laio" "libaio" ; then
349 if test "$libaio" = "yes" ; then
350 feature_not_found "linux AIO"
354 echo "Linux AIO support $libaio"
356 ##########################################
369 if compile_prog "" "" "posixaio" ; then
371 elif compile_prog "" "-lrt" "posixaio"; then
376 echo "POSIX AIO support $posix_aio"
377 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
379 ##########################################
380 # posix aio fsync probe
382 if test "$posix_aio" = "yes" ; then
389 return aio_fsync(O_SYNC, &cb);
393 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
397 echo "POSIX AIO fsync $posix_aio_fsync"
399 ##########################################
403 #include <sys/types.h>
404 #include <sys/asynch.h>
409 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
413 if compile_prog "" "-laio" "solarisaio" ; then
417 echo "Solaris AIO support $solaris_aio"
419 ##########################################
420 # __sync_fetch_and_and test
423 static int sfaa(int *ptr)
425 return __sync_fetch_and_and(ptr, 0);
428 int main(int argc, char **argv)
435 if compile_prog "" "" "__sync_fetch_and_add()" ; then
438 echo "__sync_fetch_and add $sfaa"
440 ##########################################
445 #include <infiniband/arch.h>
446 int main(int argc, char **argv)
448 struct ibv_pd *pd = ibv_alloc_pd(NULL);
452 if compile_prog "" "-libverbs" "libverbs" ; then
454 LIBS="-libverbs $LIBS"
456 echo "libverbs $libverbs"
458 ##########################################
463 #include <rdma/rdma_cma.h>
464 int main(int argc, char **argv)
466 rdma_destroy_qp(NULL);
470 if compile_prog "" "-lrdmacm" "rdma"; then
472 LIBS="-lrdmacm $LIBS"
474 echo "rdmacm $rdmacm"
476 ##########################################
477 # Linux fallocate probe
481 #include <linux/falloc.h>
482 int main(int argc, char **argv)
484 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
488 if compile_prog "" "" "linux_fallocate"; then
489 linux_fallocate="yes"
491 echo "Linux fallocate $linux_fallocate"
493 ##########################################
494 # POSIX fadvise probe
499 int main(int argc, char **argv)
501 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
505 if compile_prog "" "" "posix_fadvise"; then
508 echo "POSIX fadvise $posix_fadvise"
510 ##########################################
511 # POSIX fallocate probe
516 int main(int argc, char **argv)
518 int r = posix_fallocate(0, 0, 1024);
522 if compile_prog "" "" "posix_fallocate"; then
523 posix_fallocate="yes"
525 echo "POSIX fallocate $posix_fallocate"
527 ##########################################
528 # sched_set/getaffinity 2 or 3 argument test
529 linux_2arg_affinity="no"
530 linux_3arg_affinity="no"
533 int main(int argc, char **argv)
536 return sched_setaffinity(0, sizeof(mask), &mask);
539 if compile_prog "" "" "sched_setaffinity(,,)"; then
540 linux_3arg_affinity="yes"
544 int main(int argc, char **argv)
547 return sched_setaffinity(0, &mask);
550 if compile_prog "" "" "sched_setaffinity(,)"; then
551 linux_2arg_affinity="yes"
554 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
555 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
557 ##########################################
558 # clock_gettime probe
563 int main(int argc, char **argv)
565 return clock_gettime(0, NULL);
568 if compile_prog "" "" "clock_gettime"; then
570 elif compile_prog "" "-lrt" "clock_gettime"; then
574 echo "clock_gettime $clock_gettime"
576 ##########################################
577 # CLOCK_MONOTONIC probe
579 if test "$clock_gettime" = "yes" ; then
583 int main(int argc, char **argv)
585 return clock_gettime(CLOCK_MONOTONIC, NULL);
588 if compile_prog "" "$LIBS" "clock monotonic"; then
589 clock_monotonic="yes"
592 echo "CLOCK_MONOTONIC $clock_monotonic"
594 ##########################################
595 # CLOCK_MONOTONIC_PRECISE probe
596 clock_monotonic_precise="no"
597 if test "$clock_gettime" = "yes" ; then
601 int main(int argc, char **argv)
603 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
606 if compile_prog "" "$LIBS" "clock monotonic precise"; then
607 clock_monotonic_precise="yes"
610 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
612 ##########################################
613 # gettimeofday() probe
616 #include <sys/time.h>
618 int main(int argc, char **argv)
621 return gettimeofday(&tv, NULL);
624 if compile_prog "" "" "gettimeofday"; then
627 echo "gettimeofday $gettimeofday"
629 ##########################################
635 int main(int argc, char **argv)
640 if compile_prog "" "" "fdatasync"; then
643 echo "fdatasync $fdatasync"
645 ##########################################
646 # sync_file_range() probe
652 #include <linux/fs.h>
653 int main(int argc, char **argv)
655 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
656 SYNC_FILE_RANGE_WAIT_AFTER;
657 return sync_file_range(0, 0, 0, flags);
660 if compile_prog "" "" "sync_file_range"; then
661 sync_file_range="yes"
663 echo "sync_file_range $sync_file_range"
665 ##########################################
666 # ext4 move extent probe
670 #include <sys/ioctl.h>
671 int main(int argc, char **argv)
673 struct move_extent me;
674 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
677 if compile_prog "" "" "ext4 move extent" ; then
679 elif test $targetos = "Linux" ; then
680 # On Linux, just default to it on and let it error at runtime if we really
681 # don't have it. None of my updated systems have it defined, but it does
682 # work. Takes a while to bubble back.
685 echo "EXT4 move extent $ext4_me"
687 ##########################################
693 int main(int argc, char **argv)
695 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
698 if compile_prog "" "" "linux splice"; then
701 echo "Linux splice(2) $linux_splice"
703 ##########################################
708 #include <guasi_syscalls.h>
709 int main(int argc, char **argv)
711 guasi_t ctx = guasi_create(0, 0, 0);
715 if compile_prog "" "" "guasi"; then
720 ##########################################
724 #include <nvm/vectored_write.h>
725 int main(int argc, char **argv)
727 struct vsl_iovec iov;
728 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
731 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
732 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
735 echo "Fusion-io atomic engine $fusion_aw"
737 ##########################################
742 int main(int argc, char **argv)
744 return numa_available();
747 if compile_prog "" "-lnuma" "libnuma"; then
751 echo "libnuma $libnuma"
753 ##########################################
758 int main(int argc, char **argv)
764 if compile_prog "" "" "strsep"; then
767 echo "strsep $strsep"
769 ##########################################
770 # getopt_long_only() probe
771 getopt_long_only="no"
775 int main(int argc, char **argv)
777 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
781 if compile_prog "" "" "getopt_long_only"; then
782 getopt_long_only="yes"
784 echo "getopt_long_only() $getopt_long_only"
786 ##########################################
790 #include <sys/socket.h>
791 #include <arpa/inet.h>
793 int main(int argc, char **argv)
796 return inet_aton(NULL, &in);
799 if compile_prog "" "" "inet_aton"; then
802 echo "inet_aton $inet_aton"
804 ##########################################
809 #include <netinet/in.h>
810 int main(int argc, char **argv)
816 if compile_prog "" "" "socklen_t"; then
819 echo "socklen_t $socklen_t"
821 ##########################################
822 # Whether or not __thread is supported for TLS
826 static int __thread ret;
827 int main(int argc, char **argv)
832 if compile_prog "" "" "__thread"; then
835 echo "__thread $tls_thread"
837 ##########################################
838 # Whether or not __thread is supported for TLS
839 if test "$gfio" = "yes" ; then
849 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
852 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
853 if test "$?" != "0" ; then
854 echo "configure: gtk and gthread not found"
857 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
858 if test "$?" != "0" ; then
859 echo "configure: gtk and gthread not found"
862 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
864 if test "$r" != "0" ; then
866 LIBS="$LIBS $GTK_LIBS"
867 CFLAGS="$CFLAGS $GTK_CFLAGS"
869 echo "GTK found, but need version 2.18 or higher"
873 echo "Please install gtk and gdk libraries"
880 # Check whether we have getrusage(RUSAGE_THREAD)
883 #include <sys/time.h>
884 #include <sys/resource.h>
885 int main(int argc, char **argv)
888 getrusage(RUSAGE_THREAD, &ru);
892 if compile_prog "" "" "RUSAGE_THREAD"; then
895 echo "RUSAGE_THREAD $rusage_thread"
897 ##########################################
898 # Check whether we have SCHED_IDLE
902 int main(int argc, char **argv)
904 struct sched_param p;
905 return sched_setscheduler(0, SCHED_IDLE, &p);
908 if compile_prog "" "" "SCHED_IDLE"; then
911 echo "SCHED_IDLE $sched_idle"
913 ##########################################
914 # Check whether we have TCP_NODELAY
918 #include <sys/types.h>
919 #include <sys/socket.h>
920 #include <netinet/tcp.h>
921 int main(int argc, char **argv)
923 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
926 if compile_prog "" "" "TCP_NODELAY"; then
929 echo "TCP_NODELAY $tcp_nodelay"
931 #############################################################################
933 echo "# Automatically generated by configure - do not modify" > $config_host_mak
934 printf "# Configured with:" >> $config_host_mak
935 printf " '%s'" "$0" "$@" >> $config_host_mak
936 echo >> $config_host_mak
938 if test "$wordsize" = "64" ; then
939 output_sym "CONFIG_64BIT"
940 elif test "$wordsize" = "32" ; then
941 output_sym "CONFIG_32BIT"
943 echo "Unknown wordsize!"
946 if test "$bigendian" = "yes" ; then
947 output_sym "CONFIG_BIG_ENDIAN"
949 output_sym "CONFIG_LITTLE_ENDIAN"
951 if test "$libaio" = "yes" ; then
952 output_sym "CONFIG_LIBAIO"
954 if test "$posix_aio" = "yes" ; then
955 output_sym "CONFIG_POSIXAIO"
957 if test "$posix_aio_fsync" = "yes" ; then
958 output_sym "CONFIG_POSIXAIO_FSYNC"
960 if test "$linux_fallocate" = "yes" ; then
961 output_sym "CONFIG_LINUX_FALLOCATE"
963 if test "$posix_fallocate" = "yes" ; then
964 output_sym "CONFIG_POSIX_FALLOCATE"
966 if test "$fdatasync" = "yes" ; then
967 output_sym "CONFIG_FDATASYNC"
969 if test "$sync_file_range" = "yes" ; then
970 output_sym "CONFIG_SYNC_FILE_RANGE"
972 if test "$sfaa" = "yes" ; then
973 output_sym "CONFIG_SFAA"
975 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
976 output_sym "CONFIG_RDMA"
978 if test "$clock_gettime" = "yes" ; then
979 output_sym "CONFIG_CLOCK_GETTIME"
981 if test "$clock_monotonic" = "yes" ; then
982 output_sym "CONFIG_CLOCK_MONOTONIC"
984 if test "$clock_monotonic_precise" = "yes" ; then
985 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
987 if test "$gettimeofday" = "yes" ; then
988 output_sym "CONFIG_GETTIMEOFDAY"
990 if test "$posix_fadvise" = "yes" ; then
991 output_sym "CONFIG_POSIX_FADVISE"
993 if test "$linux_3arg_affinity" = "yes" ; then
994 output_sym "CONFIG_3ARG_AFFINITY"
995 elif test "$linux_2arg_affinity" = "yes" ; then
996 output_sym "CONFIG_2ARG_AFFINITY"
998 if test "$strsep" = "yes" ; then
999 output_sym "CONFIG_STRSEP"
1001 if test "$getopt_long_only" = "yes" ; then
1002 output_sym "CONFIG_GETOPT_LONG_ONLY"
1004 if test "$inet_aton" = "yes" ; then
1005 output_sym "CONFIG_INET_ATON"
1007 if test "$socklen_t" = "yes" ; then
1008 output_sym "CONFIG_SOCKLEN_T"
1010 if test "$ext4_me" = "yes" ; then
1011 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1013 if test "$linux_splice" = "yes" ; then
1014 output_sym "CONFIG_LINUX_SPLICE"
1016 if test "$guasi" = "yes" ; then
1017 output_sym "CONFIG_GUASI"
1019 if test "$fusion_aw" = "yes" ; then
1020 output_sym "CONFIG_FUSION_AW"
1022 if test "$libnuma" = "yes" ; then
1023 output_sym "CONFIG_LIBNUMA"
1025 if test "$solaris_aio" = "yes" ; then
1026 output_sym "CONFIG_SOLARISAIO"
1028 if test "$tls_thread" = "yes" ; then
1029 output_sym "CONFIG_TLS_THREAD"
1031 if test "$rusage_thread" = "yes" ; then
1032 output_sym "CONFIG_RUSAGE_THREAD"
1034 if test "$gfio" = "yes" ; then
1035 echo "CONFIG_GFIO=y" >> $config_host_mak
1037 if test "$sched_idle" = "yes" ; then
1038 output_sym "CONFIG_SCHED_IDLE"
1040 if test "$tcp_nodelay" = "yes" ; then
1041 output_sym "CONFIG_TCP_NODELAY"
1044 echo "LIBS+=$LIBS" >> $config_host_mak
1045 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
1046 echo "CC=$cc" >> $config_host_mak
1047 echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak