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}"
138 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
140 --cpu=*) cpu="$optarg"
144 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
146 --build-32bit-win=*) build_32bit_win="$optarg"
155 echo "Bad option $opt"
161 if test "$show_help" = "yes" ; then
162 echo "--cpu= Specify target CPU if auto-detect fails"
163 echo "--cc= Specify compiler to use"
164 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
165 echo "--build-32bit-win= Specify yes for a 32-bit build on Windows"
166 echo "--enable-gfio Enable building of gtk gfio"
170 if check_define __ANDROID__ ; then
172 elif check_define __linux__ ; then
174 elif check_define __OpenBSD__ ; then
176 elif check_define __sun__ ; then
182 # Some host OSes need non-standard checks for which CPU to use.
183 # Note that these checks are broken for cross-compilation: if you're
184 # cross-compiling to one of these OSes then you'll need to specify
185 # the correct CPU with the --cpu option.
188 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
189 # we can run 64-bit userspace code.
190 # If the user didn't specify a CPU explicitly and the kernel says this is
191 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
193 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
198 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
199 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
202 LIBS="-lnsl -lsocket"
205 echo "Forcing known good options on Windows"
206 if test -z "$CC" ; then
207 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
208 CC="i686-w64-mingw32-gcc"
210 CC="x86_64-w64-mingw32-gcc"
213 output_sym "CONFIG_LITTLE_ENDIAN"
214 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
215 output_sym "CONFIG_32BIT"
217 output_sym "CONFIG_64BIT_LLP64"
219 output_sym "CONFIG_FADVISE"
220 output_sym "CONFIG_SOCKLEN_T"
221 output_sym "CONFIG_FADVISE"
222 output_sym "CONFIG_SFAA"
223 output_sym "CONFIG_RUSAGE_THREAD"
224 output_sym "CONFIG_WINDOWSAIO"
225 output_sym "CONFIG_FDATASYNC"
226 output_sym "CONFIG_CLOCK_MONOTONIC"
227 output_sym "CONFIG_GETTIMEOFDAY"
228 output_sym "CONFIG_CLOCK_GETTIME"
229 output_sym "CONFIG_SCHED_IDLE"
230 output_sym "CONFIG_TCP_NODELAY"
231 echo "CC=$CC" >> $config_host_mak
232 echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
236 output_sym "CONFIG_32BIT"
237 output_sym "CONFIG_LITTLE_ENDIAN"
238 output_sym "CONFIG_SOCKLEN_T"
239 output_sym "CONFIG_GETTIMEOFDAY"
240 output_sym "CONFIG_CLOCK_GETTIME"
241 output_sym "CONFIG_CLOCK_MONOTONIC"
242 echo "CC=$cc" >> $config_host_mak
243 echo "EXTFLAGS=$CFLAGS -include config-host.h -DFIO_NO_HAVE_SHM_H -D_GNU_SOURCE" >> $config_host_mak
247 if test ! -z "$cpu" ; then
248 # command line argument
250 elif check_define __i386__ ; then
252 elif check_define __x86_64__ ; then
254 elif check_define __sparc__ ; then
255 if check_define __arch64__ ; then
260 elif check_define _ARCH_PPC ; then
261 if check_define _ARCH_PPC64 ; then
266 elif check_define __mips__ ; then
268 elif check_define __ia64__ ; then
270 elif check_define __s390__ ; then
271 if check_define __s390x__ ; then
276 elif check_define __arm__ ; then
278 elif check_define __hppa__ ; then
284 # Normalise host CPU name and set ARCH.
286 ia64|ppc|ppc64|s390|s390x|sparc64)
289 i386|i486|i586|i686|i86pc|BePC)
298 hppa|parisc|parisc64)
312 if test -z "$CC" ; then
313 if test "$targetos" = "FreeBSD"; then
322 cc="${CC-${cross_prefix}gcc}"
324 ##########################################
328 #include <inttypes.h>
331 volatile uint32_t i=0x01234567;
332 return (*((uint8_t*)(&i))) == 0x67;
335 if compile_prog "" "" "endian"; then
336 $TMPE && bigendian="yes"
340 echo "Operating system $targetos"
342 echo "Big endian $bigendian"
346 ##########################################
353 unsigned int wsize = sizeof(long) * 8;
354 printf("%d\n", wsize);
358 if compile_prog "" "" "wordsize"; then
361 echo "Wordsize $wordsize"
363 ##########################################
375 if compile_prog "" "-laio" "libaio" ; then
379 if test "$libaio" = "yes" ; then
380 feature_not_found "linux AIO"
384 echo "Linux AIO support $libaio"
386 ##########################################
399 if compile_prog "" "" "posixaio" ; then
401 elif compile_prog "" "-lrt" "posixaio"; then
406 echo "POSIX AIO support $posix_aio"
407 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
409 ##########################################
410 # posix aio fsync probe
412 if test "$posix_aio" = "yes" ; then
419 return aio_fsync(O_SYNC, &cb);
423 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
427 echo "POSIX AIO fsync $posix_aio_fsync"
429 ##########################################
433 #include <sys/types.h>
434 #include <sys/asynch.h>
439 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
443 if compile_prog "" "-laio" "solarisaio" ; then
447 echo "Solaris AIO support $solaris_aio"
449 ##########################################
450 # __sync_fetch_and_and test
453 static int sfaa(int *ptr)
455 return __sync_fetch_and_add(ptr, 0);
458 int main(int argc, char **argv)
465 if compile_prog "" "" "__sync_fetch_and_add()" ; then
468 echo "__sync_fetch_and_add $sfaa"
470 ##########################################
475 #include <infiniband/arch.h>
476 int main(int argc, char **argv)
478 struct ibv_pd *pd = ibv_alloc_pd(NULL);
482 if compile_prog "" "-libverbs" "libverbs" ; then
484 LIBS="-libverbs $LIBS"
486 echo "libverbs $libverbs"
488 ##########################################
493 #include <rdma/rdma_cma.h>
494 int main(int argc, char **argv)
496 rdma_destroy_qp(NULL);
500 if compile_prog "" "-lrdmacm" "rdma"; then
502 LIBS="-lrdmacm $LIBS"
504 echo "rdmacm $rdmacm"
506 ##########################################
507 # Linux fallocate probe
511 #include <linux/falloc.h>
512 int main(int argc, char **argv)
514 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
518 if compile_prog "" "" "linux_fallocate"; then
519 linux_fallocate="yes"
521 echo "Linux fallocate $linux_fallocate"
523 ##########################################
524 # POSIX fadvise probe
529 int main(int argc, char **argv)
531 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
535 if compile_prog "" "" "posix_fadvise"; then
538 echo "POSIX fadvise $posix_fadvise"
540 ##########################################
541 # POSIX fallocate probe
546 int main(int argc, char **argv)
548 int r = posix_fallocate(0, 0, 1024);
552 if compile_prog "" "" "posix_fallocate"; then
553 posix_fallocate="yes"
555 echo "POSIX fallocate $posix_fallocate"
557 ##########################################
558 # sched_set/getaffinity 2 or 3 argument test
559 linux_2arg_affinity="no"
560 linux_3arg_affinity="no"
563 int main(int argc, char **argv)
566 return sched_setaffinity(0, sizeof(mask), &mask);
569 if compile_prog "" "" "sched_setaffinity(,,)"; then
570 linux_3arg_affinity="yes"
574 int main(int argc, char **argv)
577 return sched_setaffinity(0, &mask);
580 if compile_prog "" "" "sched_setaffinity(,)"; then
581 linux_2arg_affinity="yes"
584 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
585 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
587 ##########################################
588 # clock_gettime probe
593 int main(int argc, char **argv)
595 return clock_gettime(0, NULL);
598 if compile_prog "" "" "clock_gettime"; then
600 elif compile_prog "" "-lrt" "clock_gettime"; then
604 echo "clock_gettime $clock_gettime"
606 ##########################################
607 # CLOCK_MONOTONIC probe
609 if test "$clock_gettime" = "yes" ; then
613 int main(int argc, char **argv)
615 return clock_gettime(CLOCK_MONOTONIC, NULL);
618 if compile_prog "" "$LIBS" "clock monotonic"; then
619 clock_monotonic="yes"
622 echo "CLOCK_MONOTONIC $clock_monotonic"
624 ##########################################
625 # CLOCK_MONOTONIC_PRECISE probe
626 clock_monotonic_precise="no"
627 if test "$clock_gettime" = "yes" ; then
631 int main(int argc, char **argv)
633 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
636 if compile_prog "" "$LIBS" "clock monotonic precise"; then
637 clock_monotonic_precise="yes"
640 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
642 ##########################################
643 # gettimeofday() probe
646 #include <sys/time.h>
648 int main(int argc, char **argv)
651 return gettimeofday(&tv, NULL);
654 if compile_prog "" "" "gettimeofday"; then
657 echo "gettimeofday $gettimeofday"
659 ##########################################
665 int main(int argc, char **argv)
670 if compile_prog "" "" "fdatasync"; then
673 echo "fdatasync $fdatasync"
675 ##########################################
676 # sync_file_range() probe
682 #include <linux/fs.h>
683 int main(int argc, char **argv)
685 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
686 SYNC_FILE_RANGE_WAIT_AFTER;
687 return sync_file_range(0, 0, 0, flags);
690 if compile_prog "" "" "sync_file_range"; then
691 sync_file_range="yes"
693 echo "sync_file_range $sync_file_range"
695 ##########################################
696 # ext4 move extent probe
700 #include <sys/ioctl.h>
701 int main(int argc, char **argv)
703 struct move_extent me;
704 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
707 if compile_prog "" "" "ext4 move extent" ; then
709 elif test $targetos = "Linux" ; then
710 # On Linux, just default to it on and let it error at runtime if we really
711 # don't have it. None of my updated systems have it defined, but it does
712 # work. Takes a while to bubble back.
715 echo "EXT4 move extent $ext4_me"
717 ##########################################
723 int main(int argc, char **argv)
725 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
728 if compile_prog "" "" "linux splice"; then
731 echo "Linux splice(2) $linux_splice"
733 ##########################################
738 #include <guasi_syscalls.h>
739 int main(int argc, char **argv)
741 guasi_t ctx = guasi_create(0, 0, 0);
745 if compile_prog "" "" "guasi"; then
750 ##########################################
754 #include <nvm/vectored_write.h>
755 int main(int argc, char **argv)
757 struct vsl_iovec iov;
758 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
761 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
762 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
765 echo "Fusion-io atomic engine $fusion_aw"
767 ##########################################
772 int main(int argc, char **argv)
774 return numa_available();
777 if compile_prog "" "-lnuma" "libnuma"; then
781 echo "libnuma $libnuma"
783 ##########################################
788 int main(int argc, char **argv)
794 if compile_prog "" "" "strsep"; then
797 echo "strsep $strsep"
799 ##########################################
800 # getopt_long_only() probe
801 getopt_long_only="no"
805 int main(int argc, char **argv)
807 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
811 if compile_prog "" "" "getopt_long_only"; then
812 getopt_long_only="yes"
814 echo "getopt_long_only() $getopt_long_only"
816 ##########################################
820 #include <sys/socket.h>
821 #include <arpa/inet.h>
823 int main(int argc, char **argv)
826 return inet_aton(NULL, &in);
829 if compile_prog "" "" "inet_aton"; then
832 echo "inet_aton $inet_aton"
834 ##########################################
839 #include <netinet/in.h>
840 int main(int argc, char **argv)
846 if compile_prog "" "" "socklen_t"; then
849 echo "socklen_t $socklen_t"
851 ##########################################
852 # Whether or not __thread is supported for TLS
856 static int __thread ret;
857 int main(int argc, char **argv)
862 if compile_prog "" "" "__thread"; then
865 echo "__thread $tls_thread"
867 ##########################################
868 # Whether or not __thread is supported for TLS
869 if test "$gfio" = "yes" ; then
879 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
882 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
883 if test "$?" != "0" ; then
884 echo "configure: gtk and gthread not found"
887 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
888 if test "$?" != "0" ; then
889 echo "configure: gtk and gthread not found"
892 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
894 if test "$r" != "0" ; then
896 LIBS="$LIBS $GTK_LIBS"
897 CFLAGS="$CFLAGS $GTK_CFLAGS"
899 echo "GTK found, but need version 2.18 or higher"
903 echo "Please install gtk and gdk libraries"
910 # Check whether we have getrusage(RUSAGE_THREAD)
913 #include <sys/time.h>
914 #include <sys/resource.h>
915 int main(int argc, char **argv)
918 getrusage(RUSAGE_THREAD, &ru);
922 if compile_prog "" "" "RUSAGE_THREAD"; then
925 echo "RUSAGE_THREAD $rusage_thread"
927 ##########################################
928 # Check whether we have SCHED_IDLE
932 int main(int argc, char **argv)
934 struct sched_param p;
935 return sched_setscheduler(0, SCHED_IDLE, &p);
938 if compile_prog "" "" "SCHED_IDLE"; then
941 echo "SCHED_IDLE $sched_idle"
943 ##########################################
944 # Check whether we have TCP_NODELAY
948 #include <sys/types.h>
949 #include <sys/socket.h>
950 #include <netinet/tcp.h>
951 int main(int argc, char **argv)
953 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
956 if compile_prog "" "" "TCP_NODELAY"; then
959 echo "TCP_NODELAY $tcp_nodelay"
961 ##########################################
962 # Check whether we have RLIMIT_MEMLOCK
965 #include <sys/time.h>
966 #include <sys/resource.h>
967 int main(int argc, char **argv)
970 return getrlimit(RLIMIT_MEMLOCK, &rl);
973 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
976 echo "RLIMIT_MEMLOCK $rlimit_memlock"
978 #############################################################################
980 echo "# Automatically generated by configure - do not modify" > $config_host_mak
981 printf "# Configured with:" >> $config_host_mak
982 printf " '%s'" "$0" "$@" >> $config_host_mak
983 echo >> $config_host_mak
985 if test "$wordsize" = "64" ; then
986 output_sym "CONFIG_64BIT"
987 elif test "$wordsize" = "32" ; then
988 output_sym "CONFIG_32BIT"
990 fatal "Unknown wordsize!"
992 if test "$bigendian" = "yes" ; then
993 output_sym "CONFIG_BIG_ENDIAN"
995 output_sym "CONFIG_LITTLE_ENDIAN"
997 if test "$libaio" = "yes" ; then
998 output_sym "CONFIG_LIBAIO"
1000 if test "$posix_aio" = "yes" ; then
1001 output_sym "CONFIG_POSIXAIO"
1003 if test "$posix_aio_fsync" = "yes" ; then
1004 output_sym "CONFIG_POSIXAIO_FSYNC"
1006 if test "$linux_fallocate" = "yes" ; then
1007 output_sym "CONFIG_LINUX_FALLOCATE"
1009 if test "$posix_fallocate" = "yes" ; then
1010 output_sym "CONFIG_POSIX_FALLOCATE"
1012 if test "$fdatasync" = "yes" ; then
1013 output_sym "CONFIG_FDATASYNC"
1015 if test "$sync_file_range" = "yes" ; then
1016 output_sym "CONFIG_SYNC_FILE_RANGE"
1018 if test "$sfaa" = "yes" ; then
1019 output_sym "CONFIG_SFAA"
1021 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
1022 output_sym "CONFIG_RDMA"
1024 if test "$clock_gettime" = "yes" ; then
1025 output_sym "CONFIG_CLOCK_GETTIME"
1027 if test "$clock_monotonic" = "yes" ; then
1028 output_sym "CONFIG_CLOCK_MONOTONIC"
1030 if test "$clock_monotonic_precise" = "yes" ; then
1031 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
1033 if test "$gettimeofday" = "yes" ; then
1034 output_sym "CONFIG_GETTIMEOFDAY"
1036 if test "$posix_fadvise" = "yes" ; then
1037 output_sym "CONFIG_POSIX_FADVISE"
1039 if test "$linux_3arg_affinity" = "yes" ; then
1040 output_sym "CONFIG_3ARG_AFFINITY"
1041 elif test "$linux_2arg_affinity" = "yes" ; then
1042 output_sym "CONFIG_2ARG_AFFINITY"
1044 if test "$strsep" = "yes" ; then
1045 output_sym "CONFIG_STRSEP"
1047 if test "$getopt_long_only" = "yes" ; then
1048 output_sym "CONFIG_GETOPT_LONG_ONLY"
1050 if test "$inet_aton" = "yes" ; then
1051 output_sym "CONFIG_INET_ATON"
1053 if test "$socklen_t" = "yes" ; then
1054 output_sym "CONFIG_SOCKLEN_T"
1056 if test "$ext4_me" = "yes" ; then
1057 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1059 if test "$linux_splice" = "yes" ; then
1060 output_sym "CONFIG_LINUX_SPLICE"
1062 if test "$guasi" = "yes" ; then
1063 output_sym "CONFIG_GUASI"
1065 if test "$fusion_aw" = "yes" ; then
1066 output_sym "CONFIG_FUSION_AW"
1068 if test "$libnuma" = "yes" ; then
1069 output_sym "CONFIG_LIBNUMA"
1071 if test "$solaris_aio" = "yes" ; then
1072 output_sym "CONFIG_SOLARISAIO"
1074 if test "$tls_thread" = "yes" ; then
1075 output_sym "CONFIG_TLS_THREAD"
1077 if test "$rusage_thread" = "yes" ; then
1078 output_sym "CONFIG_RUSAGE_THREAD"
1080 if test "$gfio" = "yes" ; then
1081 echo "CONFIG_GFIO=y" >> $config_host_mak
1083 if test "$sched_idle" = "yes" ; then
1084 output_sym "CONFIG_SCHED_IDLE"
1086 if test "$tcp_nodelay" = "yes" ; then
1087 output_sym "CONFIG_TCP_NODELAY"
1089 if test "$rlimit_memlock" = "yes" ; then
1090 output_sym "CONFIG_RLIMIT_MEMLOCK"
1093 echo "LIBS+=$LIBS" >> $config_host_mak
1094 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
1095 echo "CC=$cc" >> $config_host_mak
1096 echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak