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_CLOCK_GETTIME"
199 output_sym "CONFIG_CLOCK_MONOTONIC"
200 output_sym "CONFIG_GETTIMEOFDAY"
201 output_sym "CONFIG_FADVISE"
202 output_sym "CONFIG_SOCKLEN_T"
203 output_sym "CONFIG_POSIX_FALLOCATE"
204 output_sym "CONFIG_FADVISE"
205 output_sym "CONFIG_SFAA"
206 output_sym "CONFIG_RUSAGE_THREAD"
207 output_sym "CONFIG_WINDOWSAIO"
208 output_sym "CONFIG_FDATASYNC"
209 output_sym "CONFIG_GETTIMEOFDAY"
210 output_sym "CONFIG_CLOCK_GETTIME"
211 output_sym "CONFIG_SCHED_IDLE"
212 output_sym "CONFIG_TCP_NODELAY"
213 echo "CC=$CC" >> $config_host_mak
214 echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
218 if test ! -z "$cpu" ; then
219 # command line argument
221 elif check_define __i386__ ; then
223 elif check_define __x86_64__ ; then
225 elif check_define __sparc__ ; then
226 if check_define __arch64__ ; then
231 elif check_define _ARCH_PPC ; then
232 if check_define _ARCH_PPC64 ; then
237 elif check_define __mips__ ; then
239 elif check_define __ia64__ ; then
241 elif check_define __s390__ ; then
242 if check_define __s390x__ ; then
247 elif check_define __arm__ ; then
249 elif check_define __hppa__ ; then
255 # Normalise host CPU name and set ARCH.
257 ia64|ppc|ppc64|s390|s390x|sparc64)
260 i386|i486|i586|i686|i86pc|BePC)
269 hppa|parisc|parisc64)
284 if test -z "$CC" ; then
285 if test "$targetos" = "FreeBSD"; then
294 cc="${CC-${cross_prefix}gcc}"
296 ##########################################
300 #include <inttypes.h>
303 volatile uint32_t i=0x01234567;
304 return (*((uint8_t*)(&i))) == 0x67;
307 if compile_prog "" "" "endian"; then
308 $TMPE && bigendian="yes"
312 echo "Operating system $targetos"
314 echo "Big endian $bigendian"
318 ##########################################
325 unsigned int wsize = sizeof(long) * 8;
326 printf("%d\n", wsize);
330 if compile_prog "" "" "wordsize"; then
333 echo "Wordsize $wordsize"
335 ##########################################
347 if compile_prog "" "-laio" "libaio" ; then
351 if test "$libaio" = "yes" ; then
352 feature_not_found "linux AIO"
356 echo "Linux AIO support $libaio"
358 ##########################################
371 if compile_prog "" "" "posixaio" ; then
373 elif compile_prog "" "-lrt" "posixaio"; then
378 echo "POSIX AIO support $posix_aio"
379 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
381 ##########################################
382 # posix aio fsync probe
384 if test "$posix_aio" = "yes" ; then
391 return aio_fsync(O_SYNC, &cb);
395 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
399 echo "POSIX AIO fsync $posix_aio_fsync"
401 ##########################################
405 #include <sys/types.h>
406 #include <sys/asynch.h>
411 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
415 if compile_prog "" "-laio" "solarisaio" ; then
419 echo "Solaris AIO support $solaris_aio"
421 ##########################################
422 # __sync_fetch_and_and test
425 static int sfaa(int *ptr)
427 return __sync_fetch_and_and(ptr, 0);
430 int main(int argc, char **argv)
437 if compile_prog "" "" "__sync_fetch_and_add()" ; then
440 echo "__sync_fetch_and add $sfaa"
442 ##########################################
447 #include <infiniband/arch.h>
448 int main(int argc, char **argv)
450 struct ibv_pd *pd = ibv_alloc_pd(NULL);
454 if compile_prog "" "-libverbs" "libverbs" ; then
456 LIBS="-libverbs $LIBS"
458 echo "libverbs $libverbs"
460 ##########################################
465 #include <rdma/rdma_cma.h>
466 int main(int argc, char **argv)
468 rdma_destroy_qp(NULL);
472 if compile_prog "" "-lrdmacm" "rdma"; then
474 LIBS="-lrdmacm $LIBS"
476 echo "rdmacm $rdmacm"
478 ##########################################
479 # Linux fallocate probe
483 #include <linux/falloc.h>
484 int main(int argc, char **argv)
486 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
490 if compile_prog "" "" "linux_fallocate"; then
491 linux_fallocate="yes"
493 echo "Linux fallocate $linux_fallocate"
495 ##########################################
496 # POSIX fadvise probe
501 int main(int argc, char **argv)
503 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
507 if compile_prog "" "" "posix_fadvise"; then
510 echo "POSIX fadvise $posix_fadvise"
512 ##########################################
513 # POSIX fallocate probe
518 int main(int argc, char **argv)
520 int r = posix_fallocate(0, 0, 1024);
524 if compile_prog "" "" "posix_fallocate"; then
525 posix_fallocate="yes"
527 echo "POSIX fallocate $posix_fallocate"
529 ##########################################
530 # sched_set/getaffinity 2 or 3 argument test
531 linux_2arg_affinity="no"
532 linux_3arg_affinity="no"
535 int main(int argc, char **argv)
538 return sched_setaffinity(0, sizeof(mask), &mask);
541 if compile_prog "" "" "sched_setaffinity(,,)"; then
542 linux_3arg_affinity="yes"
546 int main(int argc, char **argv)
549 return sched_setaffinity(0, &mask);
552 if compile_prog "" "" "sched_setaffinity(,)"; then
553 linux_2arg_affinity="yes"
556 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
557 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
559 ##########################################
560 # clock_gettime probe
565 int main(int argc, char **argv)
567 return clock_gettime(0, NULL);
570 if compile_prog "" "" "clock_gettime"; then
572 elif compile_prog "" "-lrt" "clock_gettime"; then
576 echo "clock_gettime $clock_gettime"
578 ##########################################
579 # CLOCK_MONOTONIC probe
581 if test "$clock_gettime" = "yes" ; then
585 int main(int argc, char **argv)
587 return clock_gettime(CLOCK_MONOTONIC, NULL);
590 if compile_prog "" "$LIBS" "clock monotonic"; then
591 clock_monotonic="yes"
594 echo "CLOCK_MONOTONIC $clock_monotonic"
596 ##########################################
597 # CLOCK_MONOTONIC_PRECISE probe
598 clock_monotonic_precise="no"
599 if test "$clock_gettime" = "yes" ; then
603 int main(int argc, char **argv)
605 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
608 if compile_prog "" "$LIBS" "clock monotonic precise"; then
609 clock_monotonic_precise="yes"
612 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
614 ##########################################
615 # gettimeofday() probe
618 #include <sys/time.h>
620 int main(int argc, char **argv)
623 return gettimeofday(&tv, NULL);
626 if compile_prog "" "" "gettimeofday"; then
629 echo "gettimeofday $gettimeofday"
631 ##########################################
637 int main(int argc, char **argv)
642 if compile_prog "" "" "fdatasync"; then
645 echo "fdatasync $fdatasync"
647 ##########################################
648 # sync_file_range() probe
654 #include <linux/fs.h>
655 int main(int argc, char **argv)
657 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
658 SYNC_FILE_RANGE_WAIT_AFTER;
659 return sync_file_range(0, 0, 0, flags);
662 if compile_prog "" "" "sync_file_range"; then
663 sync_file_range="yes"
665 echo "sync_file_range $sync_file_range"
667 ##########################################
668 # ext4 move extent probe
672 #include <sys/ioctl.h>
673 int main(int argc, char **argv)
675 struct move_extent me;
676 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
679 if compile_prog "" "" "ext4 move extent" ; then
681 elif test $targetos = "Linux" ; then
682 # On Linux, just default to it on and let it error at runtime if we really
683 # don't have it. None of my updated systems have it defined, but it does
684 # work. Takes a while to bubble back.
687 echo "EXT4 move extent $ext4_me"
689 ##########################################
695 int main(int argc, char **argv)
697 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
700 if compile_prog "" "" "linux splice"; then
703 echo "Linux splice(2) $linux_splice"
705 ##########################################
710 #include <guasi_syscalls.h>
711 int main(int argc, char **argv)
713 guasi_t ctx = guasi_create(0, 0, 0);
717 if compile_prog "" "" "guasi"; then
722 ##########################################
726 #include <nvm/vectored_write.h>
727 int main(int argc, char **argv)
729 struct vsl_iovec iov;
730 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
733 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
734 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
737 echo "Fusion-io atomic engine $fusion_aw"
739 ##########################################
744 int main(int argc, char **argv)
746 return numa_available();
749 if compile_prog "" "-lnuma" "libnuma"; then
753 echo "libnuma $libnuma"
755 ##########################################
760 int main(int argc, char **argv)
766 if compile_prog "" "" "strsep"; then
769 echo "strsep $strsep"
771 ##########################################
772 # getopt_long_only() probe
773 getopt_long_only="no"
777 int main(int argc, char **argv)
779 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
783 if compile_prog "" "" "getopt_long_only"; then
784 getopt_long_only="yes"
786 echo "getopt_long_only() $getopt_long_only"
788 ##########################################
792 #include <sys/socket.h>
793 #include <arpa/inet.h>
795 int main(int argc, char **argv)
798 return inet_aton(NULL, &in);
801 if compile_prog "" "" "inet_aton"; then
804 echo "inet_aton $inet_aton"
806 ##########################################
811 #include <netinet/in.h>
812 int main(int argc, char **argv)
818 if compile_prog "" "" "socklen_t"; then
821 echo "socklen_t $socklen_t"
823 ##########################################
824 # Whether or not __thread is supported for TLS
828 static int __thread ret;
829 int main(int argc, char **argv)
834 if compile_prog "" "" "__thread"; then
837 echo "__thread $tls_thread"
839 ##########################################
840 # Whether or not __thread is supported for TLS
841 if test "$gfio" = "yes" ; then
854 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
855 if test "$?" != "0" ; then
856 echo "configure: gtk and gthread not found"
859 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
860 if test "$?" != "0" ; then
861 echo "configure: gtk and gthread not found"
864 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio"; then
866 LIBS="$LIBS $GTK_LIBS"
867 CFLAGS="$CFLAGS $GTK_CFLAGS"
869 echo "Please install gtk and gdk libraries"
876 # Check whether we have getrusage(RUSAGE_THREAD)
879 #include <sys/time.h>
880 #include <sys/resource.h>
881 int main(int argc, char **argv)
884 getrusage(RUSAGE_THREAD, &ru);
888 if compile_prog "" "" "RUSAGE_THREAD"; then
891 echo "RUSAGE_THREAD $rusage_thread"
893 ##########################################
894 # Check whether we have SCHED_IDLE
898 int main(int argc, char **argv)
900 struct sched_param p;
901 return sched_setscheduler(0, SCHED_IDLE, &p);
904 if compile_prog "" "" "SCHED_IDLE"; then
907 echo "SCHED_IDLE $sched_idle"
909 ##########################################
910 # Check whether we have TCP_NODELAY
914 #include <sys/types.h>
915 #include <sys/socket.h>
916 #include <netinet/tcp.h>
917 int main(int argc, char **argv)
919 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
922 if compile_prog "" "" "TCP_NODELAY"; then
925 echo "TCP_NODELAY $tcp_nodelay"
927 #############################################################################
929 echo "# Automatically generated by configure - do not modify" > $config_host_mak
930 printf "# Configured with:" >> $config_host_mak
931 printf " '%s'" "$0" "$@" >> $config_host_mak
932 echo >> $config_host_mak
934 if test "$wordsize" = "64" ; then
935 output_sym "CONFIG_64BIT"
936 elif test "$wordsize" = "32" ; then
937 output_sym "CONFIG_32BIT"
939 echo "Unknown wordsize!"
942 if test "$bigendian" = "yes" ; then
943 output_sym "CONFIG_BIG_ENDIAN"
945 output_sym "CONFIG_LITTLE_ENDIAN"
947 if test "$libaio" = "yes" ; then
948 output_sym "CONFIG_LIBAIO"
950 if test "$posix_aio" = "yes" ; then
951 output_sym "CONFIG_POSIXAIO"
953 if test "$posix_aio_fsync" = "yes" ; then
954 output_sym "CONFIG_POSIXAIO_FSYNC"
956 if test "$linux_fallocate" = "yes" ; then
957 output_sym "CONFIG_LINUX_FALLOCATE"
959 if test "$posix_fallocate" = "yes" ; then
960 output_sym "CONFIG_POSIX_FALLOCATE"
962 if test "$fdatasync" = "yes" ; then
963 output_sym "CONFIG_FDATASYNC"
965 if test "$sync_file_range" = "yes" ; then
966 output_sym "CONFIG_SYNC_FILE_RANGE"
968 if test "$sfaa" = "yes" ; then
969 output_sym "CONFIG_SFAA"
971 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
972 output_sym "CONFIG_RDMA"
974 if test "$clock_gettime" = "yes" ; then
975 output_sym "CONFIG_CLOCK_GETTIME"
977 if test "$clock_monotonic" = "yes" ; then
978 output_sym "CONFIG_CLOCK_MONOTONIC"
980 if test "$clock_monotonic_precise" = "yes" ; then
981 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
983 if test "$gettimeofday" = "yes" ; then
984 output_sym "CONFIG_GETTIMEOFDAY"
986 if test "$posix_fadvise" = "yes" ; then
987 output_sym "CONFIG_POSIX_FADVISE"
989 if test "$linux_3arg_affinity" = "yes" ; then
990 output_sym "CONFIG_3ARG_AFFINITY"
991 elif test "$linux_2arg_affinity" = "yes" ; then
992 output_sym "CONFIG_2ARG_AFFINITY"
994 if test "$strsep" = "yes" ; then
995 output_sym "CONFIG_STRSEP"
997 if test "$getopt_long_only" = "yes" ; then
998 output_sym "CONFIG_GETOPT_LONG_ONLY"
1000 if test "$inet_aton" = "yes" ; then
1001 output_sym "CONFIG_INET_ATON"
1003 if test "$socklen_t" = "yes" ; then
1004 output_sym "CONFIG_SOCKLEN_T"
1006 if test "$ext4_me" = "yes" ; then
1007 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1009 if test "$linux_splice" = "yes" ; then
1010 output_sym "CONFIG_LINUX_SPLICE"
1012 if test "$guasi" = "yes" ; then
1013 output_sym "CONFIG_GUASI"
1015 if test "$fusion_aw" = "yes" ; then
1016 output_sym "CONFIG_FUSION_AW"
1018 if test "$libnuma" = "yes" ; then
1019 output_sym "CONFIG_LIBNUMA"
1021 if test "$solaris_aio" = "yes" ; then
1022 output_sym "CONFIG_SOLARISAIO"
1024 if test "$tls_thread" = "yes" ; then
1025 output_sym "CONFIG_TLS_THREAD"
1027 if test "$rusage_thread" = "yes" ; then
1028 output_sym "CONFIG_RUSAGE_THREAD"
1030 if test "$gfio" = "yes" ; then
1031 echo "CONFIG_GFIO=y" >> $config_host_mak
1033 if test "$sched_idle" = "yes" ; then
1034 output_sym "CONFIG_SCHED_IDLE"
1036 if test "$tcp_nodelay" = "yes" ; then
1037 output_sym "CONFIG_TCP_NODELAY"
1040 echo "LIBS+=$LIBS" >> $config_host_mak
1041 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
1042 echo "CC=$cc" >> $config_host_mak
1043 echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak