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_ld="config-host.ld"
29 # Print a helpful header at the top of config.log
30 echo "# FIO configure log $(date)" >> config.log
31 printf "# Configured with:" >> config.log
32 printf " '%s'" "$0" "$@" >> config.log
34 echo "#" >> config.log
37 # Run the compiler, capturing its output to the log.
38 echo $cc "$@" >> config.log
39 $cc "$@" >> config.log 2>&1 || return $?
40 # Test passed. If this is an --enable-werror build, rerun
41 # the test with -Werror and bail out if it fails. This
42 # makes warning-generating-errors in configure test code
43 # obvious to developers.
44 if test "$werror" != "yes"; then
47 # Don't bother rerunning the compile if we were already using -Werror
53 echo $cc -Werror "$@" >> config.log
54 $cc -Werror "$@" >> config.log 2>&1 && return $?
55 echo "ERROR: configure test passed without -Werror but failed with -Werror."
56 echo "This is probably a bug in the configure script. The failing command"
57 echo "will be at the bottom of config.log."
58 echo "You can run configure with --disable-werror to bypass this check."
63 do_cc $CFLAGS -c -o $TMPO $TMPC
69 echo "Compiling test case $3" >> config.log
70 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
77 echo "ERROR: User requested feature $feature"
78 echo "ERROR: configure was not able to find it"
84 type "$1" >/dev/null 2>&1
103 cc="${CC-${cross_prefix}gcc}"
110 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
119 echo "--cc= Specify compiler to use"
120 echo "--enable-gfio Enable building of gtk gfio"
124 echo "Bad option $opt"
129 if check_define __linux__ ; then
131 elif check_define __OpenBSD__ ; then
133 elif check_define __sun__ ; then
139 # Some host OSes need non-standard checks for which CPU to use.
140 # Note that these checks are broken for cross-compilation: if you're
141 # cross-compiling to one of these OSes then you'll need to specify
142 # the correct CPU with the --cpu option.
145 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
146 # we can run 64-bit userspace code.
147 # If the user didn't specify a CPU explicitly and the kernel says this is
148 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
150 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
155 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
156 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
161 echo "Forcing known good options on Windows"
162 if test -z "$CC" ; then
163 CC="x86_64-w64-mingw32-gcc"
165 echo "CC=$CC" > $config_host_mak
166 echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
167 echo "CONFIG_64BIT_LLP64=y" >> $config_host_mak
168 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
169 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
170 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
171 echo "CONFIG_FADVISE=y" >> $config_host_mak
172 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
173 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
174 echo "CONFIG_FADVISE=y" >> $config_host_mak
175 echo "CONFIG_SFAA=y" >> $config_host_mak
179 if test ! -z "$cpu" ; then
180 # command line argument
182 elif check_define __i386__ ; then
184 elif check_define __x86_64__ ; then
186 elif check_define __sparc__ ; then
187 if check_define __arch64__ ; then
192 elif check_define _ARCH_PPC ; then
193 if check_define _ARCH_PPC64 ; then
198 elif check_define __mips__ ; then
200 elif check_define __ia64__ ; then
202 elif check_define __s390__ ; then
203 if check_define __s390x__ ; then
208 elif check_define __arm__ ; then
210 elif check_define __hppa__ ; then
216 # Normalise host CPU name and set ARCH.
218 ia64|ppc|ppc64|s390|s390x|sparc64)
221 i386|i486|i586|i686|i86pc|BePC)
230 hppa|parisc|parisc64)
246 if test "$targetos" = "FreeBSD"; then
255 cc="${CC-${cross_prefix}gcc}"
257 ##########################################
261 #include <inttypes.h>
264 volatile uint32_t i=0x01234567;
265 return (*((uint8_t*)(&i))) == 0x67;
268 if compile_prog "" "" "endian"; then
269 $TMPE && bigendian="yes"
273 echo "Operating system $targetos"
275 echo "Big endian $bigendian"
279 ##########################################
286 unsigned int wsize = sizeof(long) * 8;
287 printf("%d\n", wsize);
291 if compile_prog "" "" "wordsize"; then
294 echo "Wordsize $wordsize"
296 ##########################################
308 if compile_prog "" "-laio" "libaio" ; then
312 if test "$libaio" = "yes" ; then
313 feature_not_found "linux AIO"
317 echo "Linux AIO support $libaio"
319 ##########################################
332 if compile_prog "" "" "posixaio" ; then
334 elif compile_prog "" "-lrt" "posixaio"; then
339 echo "POSIX AIO support $posix_aio"
340 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
342 ##########################################
343 # posix aio fsync probe
345 if test "$posix_aio" = "yes" ; then
352 return aio_fsync(O_SYNC, &cb);
356 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
360 echo "POSIX AIO fsync $posix_aio_fsync"
362 ##########################################
366 #include <sys/types.h>
367 #include <sys/asynch.h>
372 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
376 if compile_prog "" "-laio" "solarisaio" ; then
380 echo "Solaris AIO support $solaris_aio"
382 ##########################################
383 # __sync_fetch_and_and test
386 static int sfaa(int *ptr)
388 return __sync_fetch_and_and(ptr, 0);
391 int main(int argc, char **argv)
398 if compile_prog "" "" "__sync_fetch_and_add()" ; then
401 echo "__sync_fetch_and add $sfaa"
403 ##########################################
408 #include <infiniband/arch.h>
409 int main(int argc, char **argv)
411 struct ibv_pd *pd = ibv_alloc_pd(NULL);
415 if compile_prog "" "-libverbs" "libverbs" ; then
417 LIBS="-libverbs $LIBS"
419 echo "libverbs $libverbs"
421 ##########################################
426 #include <rdma/rdma_cma.h>
427 int main(int argc, char **argv)
429 rdma_destroy_qp(NULL);
433 if compile_prog "" "-lrdmacm" "rdma"; then
435 LIBS="-lrdmacm $LIBS"
437 echo "rdmacm $rdmacm"
439 ##########################################
440 # Linux fallocate probe
444 #include <linux/falloc.h>
445 int main(int argc, char **argv)
447 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
451 if compile_prog "" "" "linux_fallocate"; then
452 linux_fallocate="yes"
454 echo "Linux fallocate $linux_fallocate"
456 ##########################################
457 # POSIX fadvise probe
462 int main(int argc, char **argv)
464 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
468 if compile_prog "" "" "posix_fadvise"; then
471 echo "POSIX fadvise $posix_fadvise"
473 ##########################################
474 # POSIX fallocate probe
479 int main(int argc, char **argv)
481 int r = posix_fallocate(0, 0, 1024);
485 if compile_prog "" "" "posix_fallocate"; then
486 posix_fallocate="yes"
488 echo "POSIX fallocate $posix_fallocate"
490 ##########################################
491 # sched_set/getaffinity 2 or 3 argument test
492 linux_2arg_affinity="no"
493 linux_3arg_affinity="no"
497 int main(int argc, char **argv)
500 return sched_setaffinity(0, sizeof(mask), &mask);
503 if compile_prog "" "" "sched_setaffinity(,,)"; then
504 linux_3arg_affinity="yes"
509 int main(int argc, char **argv)
512 return sched_setaffinity(0, &mask);
515 if compile_prog "" "" "sched_setaffinity(,)"; then
516 linux_2arg_affinity="yes"
519 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
520 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
522 ##########################################
523 # clock_gettime probe
528 int main(int argc, char **argv)
530 return clock_gettime(0, NULL);
533 if compile_prog "" "" "clock_gettime"; then
535 elif compile_prog "" "-lrt" "clock_gettime"; then
539 echo "clock_gettime $clock_gettime"
541 ##########################################
542 # CLOCK_MONOTONIC probe
544 if test "$clock_gettime" = "yes" ; then
548 int main(int argc, char **argv)
550 return clock_gettime(CLOCK_MONOTONIC, NULL);
553 if compile_prog "" "$LIBS" "clock monotonic"; then
554 clock_monotonic="yes"
557 echo "CLOCK_MONOTONIC $clock_monotonic"
559 ##########################################
560 # CLOCK_MONOTONIC_PRECISE probe
561 clock_monotonic_precise="no"
562 if test "$clock_gettime" = "yes" ; then
566 int main(int argc, char **argv)
568 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
571 if compile_prog "" "$LIBS" "clock monotonic precise"; then
572 clock_monotonic_precise="yes"
575 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
577 ##########################################
578 # gettimeofday() probe
581 #include <sys/time.h>
583 int main(int argc, char **argv)
586 return gettimeofday(&tv, NULL);
589 if compile_prog "" "" "gettimeofday"; then
592 echo "gettimeofday $gettimeofday"
594 ##########################################
600 int main(int argc, char **argv)
605 if compile_prog "" "" "fdatasync"; then
608 echo "fdatasync $fdatasync"
610 ##########################################
611 # sync_file_range() probe
618 #include <linux/fs.h>
619 int main(int argc, char **argv)
621 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
622 SYNC_FILE_RANGE_WAIT_AFTER;
623 return sync_file_range(0, 0, 0, flags);
626 if compile_prog "" "" "sync_file_range"; then
627 sync_file_range="yes"
629 echo "sync_file_range $sync_file_range"
631 ##########################################
632 # ext4 move extent probe
636 #include <sys/ioctl.h>
637 int main(int argc, char **argv)
639 struct move_extent me;
640 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
643 if compile_prog "" "" "ext4 move extent" ; then
645 elif test $targetos = "Linux" ; then
646 # On Linux, just default to it on and let it error at runtime if we really
647 # don't have it. None of my updated systems have it defined, but it does
648 # work. Takes a while to bubble back.
651 echo "EXT4 move extent $ext4_me"
653 ##########################################
660 int main(int argc, char **argv)
662 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
665 if compile_prog "" "" "linux splice"; then
668 echo "Linux splice(2) $linux_splice"
670 ##########################################
675 #include <guasi_syscalls.h>
676 int main(int argc, char **argv)
678 guasi_t ctx = guasi_create(0, 0, 0);
682 if compile_prog "" "" "guasi"; then
687 ##########################################
691 #include <nvm/vectored_write.h>
692 int main(int argc, char **argv)
694 struct vsl_iovec iov;
695 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
698 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
699 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
702 echo "Fusion-io atomic engine $fusion_aw"
704 ##########################################
709 int main(int argc, char **argv)
711 return numa_available();
714 if compile_prog "" "-lnuma" "libnuma"; then
718 echo "libnuma $libnuma"
720 ##########################################
725 int main(int argc, char **argv)
731 if compile_prog "" "" "strsep"; then
734 echo "strsep $strsep"
736 ##########################################
737 # getopt_long_only() probe
738 getopt_long_only="no"
742 int main(int argc, char **argv)
744 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
748 if compile_prog "" "" "getopt_long_only"; then
749 getopt_long_only="yes"
751 echo "getopt_long_only() $getopt_long_only"
753 ##########################################
757 #include <sys/socket.h>
758 #include <arpa/inet.h>
760 int main(int argc, char **argv)
763 return inet_aton(NULL, &in);
766 if compile_prog "" "" "inet_aton"; then
769 echo "inet_aton $inet_aton"
771 ##########################################
776 #include <netinet/in.h>
777 int main(int argc, char **argv)
783 if compile_prog "" "" "socklen_t"; then
786 echo "socklen_t $socklen_t"
788 ##########################################
789 # Whether or not __thread is supported for TLS
793 static int __thread ret;
794 int main(int argc, char **argv)
799 if compile_prog "" "" "__thread"; then
802 echo "__thread $tls_thread"
804 ##########################################
805 # Whether or not __thread is supported for TLS
806 if test "$gfio" = "yes" ; then
819 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
820 if test "$?" != "0" ; then
821 echo "configure: gtk and gthread not found"
824 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
825 if test "$?" != "0" ; then
826 echo "configure: gtk and gthread not found"
829 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio"; then
831 LIBS="$LIBS $GTK_LIBS"
832 CFLAGS="$CFLAGS $GTK_CFLAGS"
834 echo "Please install gtk and gdk libraries"
841 #############################################################################
843 echo "# Automatically generated by configure - do not modify" > $config_host_mak
844 printf "# Configured with:" >> $config_host_mak
845 printf " '%s'" "$0" "$@" >> $config_host_mak
846 echo >> $config_host_mak
848 if test "$wordsize" = "64" ; then
849 echo "CONFIG_64BIT=y" >> $config_host_mak
850 elif test "$wordsize" = "32" ; then
851 echo "CONFIG_32BIT=y" >> $config_host_mak
853 echo "Unknown wordsize!"
856 if test "$bigendian" = "yes" ; then
857 echo "CONFIG_BIG_ENDIAN=y" >> $config_host_mak
859 echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
861 if test "$libaio" = "yes" ; then
862 echo "CONFIG_LIBAIO=y" >> $config_host_mak
864 if test "$posix_aio" = "yes" ; then
865 echo "CONFIG_POSIXAIO=y" >> $config_host_mak
867 if test "$posix_aio_fsync" = "yes" ; then
868 echo "CONFIG_POSIXAIO_FSYNC=y" >> $config_host_mak
870 if test "$linux_fallocate" = "yes" ; then
871 echo "CONFIG_LINUX_FALLOCATE=y" >> $config_host_mak
873 if test "$posix_fallocate" = "yes" ; then
874 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
876 if test "$fdatasync" = "yes" ; then
877 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
879 if test "$sync_file_range" = "yes" ; then
880 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
882 if test "$sfaa" = "yes" ; then
883 echo "CONFIG_SFAA=y" >> $config_host_mak
885 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
886 echo "CONFIG_RDMA=y" >> $config_host_mak
888 if test "$clock_gettime" = "yes" ; then
889 echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
891 if test "$clock_monotonic" = "yes" ; then
892 echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
894 if test "$clock_monotonic_precise" = "yes" ; then
895 echo "CONFIG_CLOCK_MONOTONIC_PRECISE=y" >> $config_host_mak
897 if test "$gettimeofday" = "yes" ; then
898 echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
900 if test "$posix_fadvise" = "yes" ; then
901 echo "CONFIG_POSIX_FADVISE=y" >> $config_host_mak
903 if test "$linux_3arg_affinity" = "yes" ; then
904 echo "CONFIG_3ARG_AFFINITY=y" >> $config_host_mak
905 elif test "$linux_2arg_affinity" = "yes" ; then
906 echo "CONFIG_2ARG_AFFINITY=y" >> $config_host_mak
908 if test "$strsep" = "yes" ; then
909 echo "CONFIG_STRSEP=y" >> $config_host_mak
911 if test "$getopt_long_only" = "yes" ; then
912 echo "CONFIG_GETOPT_LONG_ONLY=y" >> $config_host_mak
914 if test "$inet_aton" = "yes" ; then
915 echo "CONFIG_INET_ATON=y" >> $config_host_mak
917 if test "$socklen_t" = "yes" ; then
918 echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
920 if test "$ext4_me" = "yes" ; then
921 echo "CONFIG_LINUX_EXT4_MOVE_EXTENT=y" >> $config_host_mak
923 if test "$linux_splice" = "yes" ; then
924 echo "CONFIG_LINUX_SPLICE=y" >> $config_host_mak
926 if test "$guasi" = "yes" ; then
927 echo "CONFIG_GUASI=y" >> $config_host_mak
929 if test "$fusion_aw" = "yes" ; then
930 echo "CONFIG_FUSION_AW=y" >> $config_host_mak
932 if test "$libnuma" = "yes" ; then
933 echo "CONFIG_LIBNUMA=y" >> $config_host_mak
935 if test "$solaris_aio" = "yes" ; then
936 echo "CONFIG_SOLARISAIO=y" >> $config_host_mak
938 if test "$tls_thread" = "yes" ; then
939 echo "CONFIG_TLS_THREAD=y" >> $config_host_mak
941 if test "$gfio" = "yes" ; then
942 echo "CONFIG_GFIO=y" >> $config_host_mak
945 echo "LIBS+=$LIBS" >> $config_host_mak
946 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
947 echo "CC=$cc" >> $config_host_mak