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
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
204 echo "Forcing known good options on Windows"
205 if test -z "$CC" ; then
206 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
207 CC="i686-w64-mingw32-gcc"
209 CC="x86_64-w64-mingw32-gcc"
212 output_sym "CONFIG_LITTLE_ENDIAN"
213 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
214 output_sym "CONFIG_32BIT"
216 output_sym "CONFIG_64BIT_LLP64"
218 output_sym "CONFIG_FADVISE"
219 output_sym "CONFIG_SOCKLEN_T"
220 output_sym "CONFIG_FADVISE"
221 output_sym "CONFIG_SFAA"
222 output_sym "CONFIG_RUSAGE_THREAD"
223 output_sym "CONFIG_WINDOWSAIO"
224 output_sym "CONFIG_FDATASYNC"
225 output_sym "CONFIG_CLOCK_MONOTONIC"
226 output_sym "CONFIG_GETTIMEOFDAY"
227 output_sym "CONFIG_CLOCK_GETTIME"
228 output_sym "CONFIG_SCHED_IDLE"
229 output_sym "CONFIG_TCP_NODELAY"
230 echo "CC=$CC" >> $config_host_mak
231 echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
235 output_sym "CONFIG_32BIT"
236 output_sym "CONFIG_LITTLE_ENDIAN"
237 output_sym "CONFIG_SOCKLEN_T"
238 output_sym "CONFIG_GETTIMEOFDAY"
239 output_sym "CONFIG_CLOCK_GETTIME"
240 output_sym "CONFIG_CLOCK_MONOTONIC"
241 echo "CC=$cc" >> $config_host_mak
242 echo "EXTFLAGS=$CFLAGS -include config-host.h -DFIO_NO_HAVE_SHM_H -D_GNU_SOURCE" >> $config_host_mak
246 if test ! -z "$cpu" ; then
247 # command line argument
249 elif check_define __i386__ ; then
251 elif check_define __x86_64__ ; then
253 elif check_define __sparc__ ; then
254 if check_define __arch64__ ; then
259 elif check_define _ARCH_PPC ; then
260 if check_define _ARCH_PPC64 ; then
265 elif check_define __mips__ ; then
267 elif check_define __ia64__ ; then
269 elif check_define __s390__ ; then
270 if check_define __s390x__ ; then
275 elif check_define __arm__ ; then
277 elif check_define __hppa__ ; then
283 # Normalise host CPU name and set ARCH.
285 ia64|ppc|ppc64|s390|s390x|sparc64)
288 i386|i486|i586|i686|i86pc|BePC)
297 hppa|parisc|parisc64)
311 if test -z "$CC" ; then
312 if test "$targetos" = "FreeBSD"; then
321 cc="${CC-${cross_prefix}gcc}"
323 ##########################################
327 #include <inttypes.h>
330 volatile uint32_t i=0x01234567;
331 return (*((uint8_t*)(&i))) == 0x67;
334 if compile_prog "" "" "endian"; then
335 $TMPE && bigendian="yes"
339 echo "Operating system $targetos"
341 echo "Big endian $bigendian"
345 ##########################################
352 unsigned int wsize = sizeof(long) * 8;
353 printf("%d\n", wsize);
357 if compile_prog "" "" "wordsize"; then
360 echo "Wordsize $wordsize"
362 ##########################################
374 if compile_prog "" "-laio" "libaio" ; then
378 if test "$libaio" = "yes" ; then
379 feature_not_found "linux AIO"
383 echo "Linux AIO support $libaio"
385 ##########################################
398 if compile_prog "" "" "posixaio" ; then
400 elif compile_prog "" "-lrt" "posixaio"; then
405 echo "POSIX AIO support $posix_aio"
406 echo "POSIX AIO support needs -lrt $posix_aio_lrt"
408 ##########################################
409 # posix aio fsync probe
411 if test "$posix_aio" = "yes" ; then
418 return aio_fsync(O_SYNC, &cb);
422 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
426 echo "POSIX AIO fsync $posix_aio_fsync"
428 ##########################################
432 #include <sys/types.h>
433 #include <sys/asynch.h>
438 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
442 if compile_prog "" "-laio" "solarisaio" ; then
446 echo "Solaris AIO support $solaris_aio"
448 ##########################################
449 # __sync_fetch_and_and test
452 static int sfaa(int *ptr)
454 return __sync_fetch_and_and(ptr, 0);
457 int main(int argc, char **argv)
464 if compile_prog "" "" "__sync_fetch_and_add()" ; then
467 echo "__sync_fetch_and add $sfaa"
469 ##########################################
474 #include <infiniband/arch.h>
475 int main(int argc, char **argv)
477 struct ibv_pd *pd = ibv_alloc_pd(NULL);
481 if compile_prog "" "-libverbs" "libverbs" ; then
483 LIBS="-libverbs $LIBS"
485 echo "libverbs $libverbs"
487 ##########################################
492 #include <rdma/rdma_cma.h>
493 int main(int argc, char **argv)
495 rdma_destroy_qp(NULL);
499 if compile_prog "" "-lrdmacm" "rdma"; then
501 LIBS="-lrdmacm $LIBS"
503 echo "rdmacm $rdmacm"
505 ##########################################
506 # Linux fallocate probe
510 #include <linux/falloc.h>
511 int main(int argc, char **argv)
513 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
517 if compile_prog "" "" "linux_fallocate"; then
518 linux_fallocate="yes"
520 echo "Linux fallocate $linux_fallocate"
522 ##########################################
523 # POSIX fadvise probe
528 int main(int argc, char **argv)
530 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
534 if compile_prog "" "" "posix_fadvise"; then
537 echo "POSIX fadvise $posix_fadvise"
539 ##########################################
540 # POSIX fallocate probe
545 int main(int argc, char **argv)
547 int r = posix_fallocate(0, 0, 1024);
551 if compile_prog "" "" "posix_fallocate"; then
552 posix_fallocate="yes"
554 echo "POSIX fallocate $posix_fallocate"
556 ##########################################
557 # sched_set/getaffinity 2 or 3 argument test
558 linux_2arg_affinity="no"
559 linux_3arg_affinity="no"
562 int main(int argc, char **argv)
565 return sched_setaffinity(0, sizeof(mask), &mask);
568 if compile_prog "" "" "sched_setaffinity(,,)"; then
569 linux_3arg_affinity="yes"
573 int main(int argc, char **argv)
576 return sched_setaffinity(0, &mask);
579 if compile_prog "" "" "sched_setaffinity(,)"; then
580 linux_2arg_affinity="yes"
583 echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
584 echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
586 ##########################################
587 # clock_gettime probe
592 int main(int argc, char **argv)
594 return clock_gettime(0, NULL);
597 if compile_prog "" "" "clock_gettime"; then
599 elif compile_prog "" "-lrt" "clock_gettime"; then
603 echo "clock_gettime $clock_gettime"
605 ##########################################
606 # CLOCK_MONOTONIC probe
608 if test "$clock_gettime" = "yes" ; then
612 int main(int argc, char **argv)
614 return clock_gettime(CLOCK_MONOTONIC, NULL);
617 if compile_prog "" "$LIBS" "clock monotonic"; then
618 clock_monotonic="yes"
621 echo "CLOCK_MONOTONIC $clock_monotonic"
623 ##########################################
624 # CLOCK_MONOTONIC_PRECISE probe
625 clock_monotonic_precise="no"
626 if test "$clock_gettime" = "yes" ; then
630 int main(int argc, char **argv)
632 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
635 if compile_prog "" "$LIBS" "clock monotonic precise"; then
636 clock_monotonic_precise="yes"
639 echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
641 ##########################################
642 # gettimeofday() probe
645 #include <sys/time.h>
647 int main(int argc, char **argv)
650 return gettimeofday(&tv, NULL);
653 if compile_prog "" "" "gettimeofday"; then
656 echo "gettimeofday $gettimeofday"
658 ##########################################
664 int main(int argc, char **argv)
669 if compile_prog "" "" "fdatasync"; then
672 echo "fdatasync $fdatasync"
674 ##########################################
675 # sync_file_range() probe
681 #include <linux/fs.h>
682 int main(int argc, char **argv)
684 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
685 SYNC_FILE_RANGE_WAIT_AFTER;
686 return sync_file_range(0, 0, 0, flags);
689 if compile_prog "" "" "sync_file_range"; then
690 sync_file_range="yes"
692 echo "sync_file_range $sync_file_range"
694 ##########################################
695 # ext4 move extent probe
699 #include <sys/ioctl.h>
700 int main(int argc, char **argv)
702 struct move_extent me;
703 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
706 if compile_prog "" "" "ext4 move extent" ; then
708 elif test $targetos = "Linux" ; then
709 # On Linux, just default to it on and let it error at runtime if we really
710 # don't have it. None of my updated systems have it defined, but it does
711 # work. Takes a while to bubble back.
714 echo "EXT4 move extent $ext4_me"
716 ##########################################
722 int main(int argc, char **argv)
724 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
727 if compile_prog "" "" "linux splice"; then
730 echo "Linux splice(2) $linux_splice"
732 ##########################################
737 #include <guasi_syscalls.h>
738 int main(int argc, char **argv)
740 guasi_t ctx = guasi_create(0, 0, 0);
744 if compile_prog "" "" "guasi"; then
749 ##########################################
753 #include <nvm/vectored_write.h>
754 int main(int argc, char **argv)
756 struct vsl_iovec iov;
757 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
760 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
761 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
764 echo "Fusion-io atomic engine $fusion_aw"
766 ##########################################
771 int main(int argc, char **argv)
773 return numa_available();
776 if compile_prog "" "-lnuma" "libnuma"; then
780 echo "libnuma $libnuma"
782 ##########################################
787 int main(int argc, char **argv)
793 if compile_prog "" "" "strsep"; then
796 echo "strsep $strsep"
798 ##########################################
799 # getopt_long_only() probe
800 getopt_long_only="no"
804 int main(int argc, char **argv)
806 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
810 if compile_prog "" "" "getopt_long_only"; then
811 getopt_long_only="yes"
813 echo "getopt_long_only() $getopt_long_only"
815 ##########################################
819 #include <sys/socket.h>
820 #include <arpa/inet.h>
822 int main(int argc, char **argv)
825 return inet_aton(NULL, &in);
828 if compile_prog "" "" "inet_aton"; then
831 echo "inet_aton $inet_aton"
833 ##########################################
838 #include <netinet/in.h>
839 int main(int argc, char **argv)
845 if compile_prog "" "" "socklen_t"; then
848 echo "socklen_t $socklen_t"
850 ##########################################
851 # Whether or not __thread is supported for TLS
855 static int __thread ret;
856 int main(int argc, char **argv)
861 if compile_prog "" "" "__thread"; then
864 echo "__thread $tls_thread"
866 ##########################################
867 # Whether or not __thread is supported for TLS
868 if test "$gfio" = "yes" ; then
878 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
881 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
882 if test "$?" != "0" ; then
883 echo "configure: gtk and gthread not found"
886 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
887 if test "$?" != "0" ; then
888 echo "configure: gtk and gthread not found"
891 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
893 if test "$r" != "0" ; then
895 LIBS="$LIBS $GTK_LIBS"
896 CFLAGS="$CFLAGS $GTK_CFLAGS"
898 echo "GTK found, but need version 2.18 or higher"
902 echo "Please install gtk and gdk libraries"
909 # Check whether we have getrusage(RUSAGE_THREAD)
912 #include <sys/time.h>
913 #include <sys/resource.h>
914 int main(int argc, char **argv)
917 getrusage(RUSAGE_THREAD, &ru);
921 if compile_prog "" "" "RUSAGE_THREAD"; then
924 echo "RUSAGE_THREAD $rusage_thread"
926 ##########################################
927 # Check whether we have SCHED_IDLE
931 int main(int argc, char **argv)
933 struct sched_param p;
934 return sched_setscheduler(0, SCHED_IDLE, &p);
937 if compile_prog "" "" "SCHED_IDLE"; then
940 echo "SCHED_IDLE $sched_idle"
942 ##########################################
943 # Check whether we have TCP_NODELAY
947 #include <sys/types.h>
948 #include <sys/socket.h>
949 #include <netinet/tcp.h>
950 int main(int argc, char **argv)
952 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
955 if compile_prog "" "" "TCP_NODELAY"; then
958 echo "TCP_NODELAY $tcp_nodelay"
960 #############################################################################
962 echo "# Automatically generated by configure - do not modify" > $config_host_mak
963 printf "# Configured with:" >> $config_host_mak
964 printf " '%s'" "$0" "$@" >> $config_host_mak
965 echo >> $config_host_mak
967 if test "$wordsize" = "64" ; then
968 output_sym "CONFIG_64BIT"
969 elif test "$wordsize" = "32" ; then
970 output_sym "CONFIG_32BIT"
972 fatal "Unknown wordsize!"
974 if test "$bigendian" = "yes" ; then
975 output_sym "CONFIG_BIG_ENDIAN"
977 output_sym "CONFIG_LITTLE_ENDIAN"
979 if test "$libaio" = "yes" ; then
980 output_sym "CONFIG_LIBAIO"
982 if test "$posix_aio" = "yes" ; then
983 output_sym "CONFIG_POSIXAIO"
985 if test "$posix_aio_fsync" = "yes" ; then
986 output_sym "CONFIG_POSIXAIO_FSYNC"
988 if test "$linux_fallocate" = "yes" ; then
989 output_sym "CONFIG_LINUX_FALLOCATE"
991 if test "$posix_fallocate" = "yes" ; then
992 output_sym "CONFIG_POSIX_FALLOCATE"
994 if test "$fdatasync" = "yes" ; then
995 output_sym "CONFIG_FDATASYNC"
997 if test "$sync_file_range" = "yes" ; then
998 output_sym "CONFIG_SYNC_FILE_RANGE"
1000 if test "$sfaa" = "yes" ; then
1001 output_sym "CONFIG_SFAA"
1003 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
1004 output_sym "CONFIG_RDMA"
1006 if test "$clock_gettime" = "yes" ; then
1007 output_sym "CONFIG_CLOCK_GETTIME"
1009 if test "$clock_monotonic" = "yes" ; then
1010 output_sym "CONFIG_CLOCK_MONOTONIC"
1012 if test "$clock_monotonic_precise" = "yes" ; then
1013 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
1015 if test "$gettimeofday" = "yes" ; then
1016 output_sym "CONFIG_GETTIMEOFDAY"
1018 if test "$posix_fadvise" = "yes" ; then
1019 output_sym "CONFIG_POSIX_FADVISE"
1021 if test "$linux_3arg_affinity" = "yes" ; then
1022 output_sym "CONFIG_3ARG_AFFINITY"
1023 elif test "$linux_2arg_affinity" = "yes" ; then
1024 output_sym "CONFIG_2ARG_AFFINITY"
1026 if test "$strsep" = "yes" ; then
1027 output_sym "CONFIG_STRSEP"
1029 if test "$getopt_long_only" = "yes" ; then
1030 output_sym "CONFIG_GETOPT_LONG_ONLY"
1032 if test "$inet_aton" = "yes" ; then
1033 output_sym "CONFIG_INET_ATON"
1035 if test "$socklen_t" = "yes" ; then
1036 output_sym "CONFIG_SOCKLEN_T"
1038 if test "$ext4_me" = "yes" ; then
1039 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1041 if test "$linux_splice" = "yes" ; then
1042 output_sym "CONFIG_LINUX_SPLICE"
1044 if test "$guasi" = "yes" ; then
1045 output_sym "CONFIG_GUASI"
1047 if test "$fusion_aw" = "yes" ; then
1048 output_sym "CONFIG_FUSION_AW"
1050 if test "$libnuma" = "yes" ; then
1051 output_sym "CONFIG_LIBNUMA"
1053 if test "$solaris_aio" = "yes" ; then
1054 output_sym "CONFIG_SOLARISAIO"
1056 if test "$tls_thread" = "yes" ; then
1057 output_sym "CONFIG_TLS_THREAD"
1059 if test "$rusage_thread" = "yes" ; then
1060 output_sym "CONFIG_RUSAGE_THREAD"
1062 if test "$gfio" = "yes" ; then
1063 echo "CONFIG_GFIO=y" >> $config_host_mak
1065 if test "$sched_idle" = "yes" ; then
1066 output_sym "CONFIG_SCHED_IDLE"
1068 if test "$tcp_nodelay" = "yes" ; then
1069 output_sym "CONFIG_TCP_NODELAY"
1072 echo "LIBS+=$LIBS" >> $config_host_mak
1073 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
1074 echo "CC=$cc" >> $config_host_mak
1075 echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak