zbd random read conventional zones
[fio.git] / configure
1 #!/bin/sh
2 #
3 # Fio configure script. Heavily influenced by the manual qemu configure
4 # script. Sad this is easier than autoconf and enemies.
5 #
6
7 # set temporary file name
8 if test ! -z "$TMPDIR" ; then
9     TMPDIR1="${TMPDIR}"
10 elif test ! -z "$TEMPDIR" ; then
11     TMPDIR1="${TEMPDIR}"
12 else
13     TMPDIR1="/tmp"
14 fi
15
16 TMPC="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.c"
17 TMPC2="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}-2.c"
18 TMPO="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.o"
19 TMPE="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.exe"
20
21 # NB: do not call "exit" in the trap handler; this is buggy with some shells;
22 # see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
23 trap "rm -f $TMPC $TMPC2 $TMPO $TMPE" EXIT INT QUIT TERM
24
25 rm -rf config.log
26
27 config_host_mak="config-host.mak"
28 config_host_h="config-host.h"
29
30 rm -rf $config_host_mak
31 rm -rf $config_host_h
32
33 fatal() {
34   echo $@
35   echo "Configure failed, check config.log and/or the above output"
36   rm -rf $config_host_mak
37   rm -rf $config_host_h
38   exit 1
39 }
40
41 # Print result for each configuration test
42 print_config() {
43   printf "%-30s%s\n" "$1" "$2"
44 }
45
46 # Default CFLAGS
47 CFLAGS="-D_GNU_SOURCE -include config-host.h"
48 BUILD_CFLAGS=""
49
50 # Print a helpful header at the top of config.log
51 echo "# FIO configure log $(date)" >> config.log
52 printf "# Configured with:" >> config.log
53 printf " '%s'" "$0" "$@" >> config.log
54 echo >> config.log
55 echo "#" >> config.log
56
57 # Print configure header at the top of $config_host_h
58 echo "/*" > $config_host_h
59 echo " * Automatically generated by configure - do not modify" >> $config_host_h
60 printf " * Configured with:" >> $config_host_h
61 printf " * '%s'" "$0" "$@" >> $config_host_h
62 echo "" >> $config_host_h
63 echo " */" >> $config_host_h
64
65 do_cc() {
66     # Run the compiler, capturing its output to the log.
67     echo $cc "$@" >> config.log
68     $cc "$@" >> config.log 2>&1 || return $?
69     # Test passed. If this is an --enable-werror build, rerun
70     # the test with -Werror and bail out if it fails. This
71     # makes warning-generating-errors in configure test code
72     # obvious to developers.
73     if test "$werror" != "yes"; then
74         return 0
75     fi
76     # Don't bother rerunning the compile if we were already using -Werror
77     case "$*" in
78         *-Werror*)
79            return 0
80         ;;
81     esac
82     echo $cc -Werror "$@" >> config.log
83     $cc -Werror "$@" >> config.log 2>&1 && return $?
84     echo "ERROR: configure test passed without -Werror but failed with -Werror."
85     echo "This is probably a bug in the configure script. The failing command"
86     echo "will be at the bottom of config.log."
87     fatal "You can run configure with --disable-werror to bypass this check."
88 }
89
90 compile_object() {
91   do_cc $CFLAGS -c -o $TMPO $TMPC
92 }
93
94 compile_prog() {
95   local_cflags="$1"
96   local_ldflags="$2 $LIBS"
97   echo "Compiling test case $3" >> config.log
98   do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
99 }
100
101 feature_not_found() {
102   feature=$1
103   packages=$2
104
105   echo "ERROR"
106   echo "ERROR: User requested feature $feature"
107   if test ! -z "$packages" ; then
108     echo "ERROR: That feature needs $packages installed"
109   fi
110   echo "ERROR: configure was not able to find it"
111   fatal "ERROR"
112 }
113
114 has() {
115   type "$1" >/dev/null 2>&1
116 }
117
118 check_define() {
119   cat > $TMPC <<EOF
120 #if !defined($1)
121 #error $1 not defined
122 #endif
123 int main(void)
124 {
125   return 0;
126 }
127 EOF
128   compile_object
129 }
130
131 output_sym() {
132   echo "$1=y" >> $config_host_mak
133   echo "#define $1" >> $config_host_h
134 }
135
136 targetos=""
137 cpu=""
138
139 # default options
140 show_help="no"
141 exit_val=0
142 gfio_check="no"
143 libhdfs="no"
144 pmemblk="no"
145 devdax="no"
146 pmem="no"
147 disable_lex=""
148 disable_pmem="no"
149 disable_native="no"
150 march_set="no"
151 libiscsi="no"
152 prefix=/usr/local
153
154 # parse options
155 for opt do
156   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
157   case "$opt" in
158   --prefix=*) prefix="$optarg"
159   ;;
160   --cpu=*) cpu="$optarg"
161   ;;
162   #  esx is cross compiled and cannot be detect through simple uname calls
163   --esx)
164   esx="yes"
165   ;;
166   --cc=*) CC="$optarg"
167   ;;
168   --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
169   ;;
170   --build-32bit-win) build_32bit_win="yes"
171   ;;
172   --target-win-ver=*) target_win_ver="$optarg"
173   ;;
174   --build-static) build_static="yes"
175   ;;
176   --enable-gfio) gfio_check="yes"
177   ;;
178   --disable-numa) disable_numa="yes"
179   ;;
180   --disable-rdma) disable_rdma="yes"
181   ;;
182   --disable-rados) disable_rados="yes"
183   ;;
184   --disable-rbd) disable_rbd="yes"
185   ;;
186   --disable-http) disable_http="yes"
187   ;;
188   --disable-gfapi) disable_gfapi="yes"
189   ;;
190   --enable-libhdfs) libhdfs="yes"
191   ;;
192   --disable-lex) disable_lex="yes"
193   ;;
194   --enable-lex) disable_lex="no"
195   ;;
196   --disable-shm) no_shm="yes"
197   ;;
198   --disable-optimizations) disable_opt="yes"
199   ;;
200   --disable-pmem) disable_pmem="yes"
201   ;;
202   --enable-cuda) enable_cuda="yes"
203   ;;
204   --disable-native) disable_native="yes"
205   ;;
206   --with-ime=*) ime_path="$optarg"
207   ;;
208   --enable-libiscsi) libiscsi="yes"
209   ;;
210   --help)
211     show_help="yes"
212     ;;
213   *)
214   echo "Bad option $opt"
215   show_help="yes"
216   exit_val=1
217   esac
218 done
219
220 if test "$show_help" = "yes" ; then
221   echo "--prefix=               Use this directory as installation prefix"
222   echo "--cpu=                  Specify target CPU if auto-detect fails"
223   echo "--cc=                   Specify compiler to use"
224   echo "--extra-cflags=         Specify extra CFLAGS to pass to compiler"
225   echo "--build-32bit-win       Enable 32-bit build on Windows"
226   echo "--target-win-ver=       Minimum version of Windows to target (XP or 7)"
227   echo "--build-static          Build a static fio"
228   echo "--esx                   Configure build options for esx"
229   echo "--enable-gfio           Enable building of gtk gfio"
230   echo "--disable-numa          Disable libnuma even if found"
231   echo "--disable-rdma          Disable RDMA support even if found"
232   echo "--disable-rados         Disable Rados support even if found"
233   echo "--disable-rbd           Disable Rados Block Device even if found"
234   echo "--disable-http          Disable HTTP support even if found"
235   echo "--disable-gfapi         Disable gfapi"
236   echo "--enable-libhdfs        Enable hdfs support"
237   echo "--disable-lex           Disable use of lex/yacc for math"
238   echo "--disable-pmem          Disable pmem based engines even if found"
239   echo "--enable-lex            Enable use of lex/yacc for math"
240   echo "--disable-shm           Disable SHM support"
241   echo "--disable-optimizations Don't enable compiler optimizations"
242   echo "--enable-cuda           Enable GPUDirect RDMA support"
243   echo "--disable-native        Don't build for native host"
244   echo "--with-ime=             Install path for DDN's Infinite Memory Engine"
245   echo "--enable-libiscsi       Enable iscsi support"
246   exit $exit_val
247 fi
248
249 cross_prefix=${cross_prefix-${CROSS_COMPILE}}
250 # Preferred compiler (can be overriden later after we know the platform):
251 #  ${CC} (if set)
252 #  ${cross_prefix}gcc (if cross-prefix specified)
253 #  gcc if available
254 #  clang if available
255 if test -z "${CC}${cross_prefix}"; then
256   if has gcc; then
257     cc=gcc
258   elif has clang; then
259     cc=clang
260   fi
261 else
262   cc="${CC-${cross_prefix}gcc}"
263 fi
264
265 if check_define __ANDROID__ ; then
266   targetos="Android"
267 elif check_define __linux__ ; then
268   targetos="Linux"
269 elif check_define __OpenBSD__ ; then
270   targetos='OpenBSD'
271 elif check_define __NetBSD__ ; then
272   targetos='NetBSD'
273 elif check_define __sun__ ; then
274   targetos='SunOS'
275   CFLAGS="$CFLAGS -D_REENTRANT"
276 elif check_define _WIN32 ; then
277   targetos='CYGWIN'
278 else
279   targetos=`uname -s`
280 fi
281
282 echo "# Automatically generated by configure - do not modify" > $config_host_mak
283 printf "# Configured with:" >> $config_host_mak
284 printf " '%s'" "$0" "$@" >> $config_host_mak
285 echo >> $config_host_mak
286 echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
287
288 if test "$no_shm" = "yes" ; then
289   output_sym "CONFIG_NO_SHM"
290 fi
291
292 if test "$disable_opt" = "yes" ; then
293   output_sym "CONFIG_FIO_NO_OPT"
294 fi
295
296 # Some host OSes need non-standard checks for which CPU to use.
297 # Note that these checks are broken for cross-compilation: if you're
298 # cross-compiling to one of these OSes then you'll need to specify
299 # the correct CPU with the --cpu option.
300 case $targetos in
301 AIX|OpenBSD|NetBSD)
302   # Unless explicitly enabled, turn off lex.
303   # OpenBSD will hit syntax error when enabled.
304   if test -z "$disable_lex" ; then
305     disable_lex="yes"
306   else
307     force_no_lex_o="yes"
308   fi
309   ;;
310 Darwin)
311   # on Leopard most of the system is 32-bit, so we have to ask the kernel if
312   # we can run 64-bit userspace code.
313   # If the user didn't specify a CPU explicitly and the kernel says this is
314   # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
315   # detection code.
316   if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
317     cpu="x86_64"
318   fi
319   # Error at compile time linking of weak/partial symbols if possible...
320 cat > $TMPC <<EOF
321 int main(void)
322 {
323   return 0;
324 }
325 EOF
326   if compile_prog "" "-Wl,-no_weak_imports" "disable weak symbols"; then
327     echo "Disabling weak symbols"
328     LDFLAGS="$LDFLAGS -Wl,-no_weak_imports"
329   fi
330   ;;
331 SunOS)
332   # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
333   if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
334     cpu="x86_64"
335   fi
336   LIBS="-lnsl -lsocket"
337   ;;
338 CYGWIN*)
339   # We still force some options, so keep this message here.
340   echo "Forcing some known good options on Windows"
341   if test -z "${CC}${cross_prefix}"; then
342     if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
343       cc="i686-w64-mingw32-gcc"
344     else
345       cc="x86_64-w64-mingw32-gcc"
346     fi
347   fi
348
349   target_win_ver=$(echo "$target_win_ver" | tr '[:lower:]' '[:upper:]')
350   if test -z "$target_win_ver"; then
351     # Default Windows API target
352     target_win_ver="7"
353   fi
354   if test "$target_win_ver" = "XP"; then
355     output_sym "CONFIG_WINDOWS_XP"
356   elif test "$target_win_ver" = "7"; then
357     output_sym "CONFIG_WINDOWS_7"
358     CFLAGS="$CFLAGS -D_WIN32_WINNT=0x0601"
359   else
360     fatal "Unknown target Windows version"
361   fi
362
363   # We need this to be output_sym'd here because this is Windows specific.
364   # The regular configure path never sets this config.
365   output_sym "CONFIG_WINDOWSAIO"
366   # We now take the regular configuration path without having exit 0 here.
367   # Flags below are still necessary mostly for MinGW.
368   build_static="yes"
369   socklen_t="yes"
370   rusage_thread="yes"
371   fdatasync="yes"
372   clock_gettime="yes" # clock_monotonic probe has dependency on this
373   clock_monotonic="yes"
374   gettimeofday="yes"
375   sched_idle="yes"
376   tcp_nodelay="yes"
377   ipv6="yes"
378   ;;
379 esac
380
381 # Now we know the target platform we can have another guess at the preferred
382 # compiler when it wasn't explictly set
383 if test -z "${CC}${cross_prefix}"; then
384   if test "$targetos" = "FreeBSD" || test "$targetos" = "Darwin"; then
385     if has clang; then
386       cc=clang
387     fi
388   fi
389 fi
390 if test -z "$cc"; then
391     echo "configure: failed to find compiler"
392     exit 1
393 fi
394
395 if test ! -z "$cpu" ; then
396   # command line argument
397   :
398 elif check_define __i386__ ; then
399   cpu="i386"
400 elif check_define __x86_64__ ; then
401   cpu="x86_64"
402 elif check_define __sparc__ ; then
403   if check_define __arch64__ ; then
404     cpu="sparc64"
405   else
406     cpu="sparc"
407   fi
408 elif check_define _ARCH_PPC ; then
409   if check_define _ARCH_PPC64 ; then
410     cpu="ppc64"
411   else
412     cpu="ppc"
413   fi
414 elif check_define __mips__ ; then
415   cpu="mips"
416 elif check_define __ia64__ ; then
417   cpu="ia64"
418 elif check_define __s390__ ; then
419   if check_define __s390x__ ; then
420     cpu="s390x"
421   else
422     cpu="s390"
423   fi
424 elif check_define __arm__ ; then
425   cpu="arm"
426 elif check_define __aarch64__ ; then
427   cpu="aarch64"
428 elif check_define __hppa__ ; then
429   cpu="hppa"
430 else
431   cpu=`uname -m`
432 fi
433
434 # Normalise host CPU name and set ARCH.
435 case "$cpu" in
436   ia64|ppc|ppc64|s390|s390x|sparc64)
437     cpu="$cpu"
438   ;;
439   i386|i486|i586|i686|i86pc|BePC)
440     cpu="x86"
441   ;;
442   x86_64|amd64)
443     cpu="x86_64"
444   ;;
445   armv*b|armv*l|arm)
446     cpu="arm"
447   ;;
448   aarch64)
449     cpu="arm64"
450   ;;
451   hppa|parisc|parisc64)
452     cpu="hppa"
453   ;;
454   mips*)
455     cpu="mips"
456   ;;
457   sparc|sun4[cdmuv])
458     cpu="sparc"
459   ;;
460   *)
461   echo "Unknown CPU"
462   ;;
463 esac
464
465 ##########################################
466 # check cross compile
467
468 if test "$cross_compile" != "yes" ; then
469   cross_compile="no"
470 fi
471 cat > $TMPC <<EOF
472 int main(void)
473 {
474   return 0;
475 }
476 EOF
477 if compile_prog "" "" "cross"; then
478   $TMPE 2>/dev/null || cross_compile="yes"
479 else
480   fatal "compile test failed"
481 fi
482
483 ##########################################
484 # check endianness
485 if test "$bigendian" != "yes" ; then
486   bigendian="no"
487 fi
488 if test "$cross_compile" = "no" ; then
489   cat > $TMPC <<EOF
490 #include <inttypes.h>
491 int main(void)
492 {
493   volatile uint32_t i=0x01234567;
494   return (*((uint8_t*)(&i))) == 0x67;
495 }
496 EOF
497   if compile_prog "" "" "endian"; then
498     $TMPE && bigendian="yes"
499   fi
500 else
501   # If we're cross compiling, try our best to work it out and rely on the
502   # run-time check to fail if we get it wrong.
503   cat > $TMPC <<EOF
504 #include <endian.h>
505 int main(void)
506 {
507 #if __BYTE_ORDER != __BIG_ENDIAN
508 # error "Unknown endianness"
509 #endif
510 }
511 EOF
512   compile_prog "" "" "endian" && bigendian="yes"
513   check_define "__ARMEB__" && bigendian="yes"
514   check_define "__MIPSEB__" && bigendian="yes"
515 fi
516
517
518 print_config "Operating system" "$targetos"
519 print_config "CPU" "$cpu"
520 print_config "Big endian" "$bigendian"
521 if test ! -z "$target_win_ver"; then
522   print_config "Target Windows version" "$target_win_ver"
523 fi
524 print_config "Compiler" "$cc"
525 print_config "Cross compile" "$cross_compile"
526 echo
527
528 ##########################################
529 # See if we need to build a static build
530 if test "$build_static" = "yes" ; then
531   CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
532   LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
533 else
534   build_static="no"
535 fi
536 print_config "Static build" "$build_static"
537
538 ##########################################
539 # check for wordsize
540 wordsize="0"
541 cat > $TMPC <<EOF
542 #include <limits.h>
543 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
544 int main(void)
545 {
546   BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
547   return 0;
548 }
549 EOF
550 if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
551   wordsize="32"
552 elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
553   wordsize="64"
554 else
555   fatal "Unknown wordsize"
556 fi
557 print_config "Wordsize" "$wordsize"
558
559 ##########################################
560 # zlib probe
561 if test "$zlib" != "yes" ; then
562   zlib="no"
563 fi
564 cat > $TMPC <<EOF
565 #include <zlib.h>
566 int main(void)
567 {
568   z_stream stream;
569   if (inflateInit(&stream) != Z_OK)
570     return 1;
571   return 0;
572 }
573 EOF
574 if compile_prog "" "-lz" "zlib" ; then
575   zlib=yes
576   LIBS="-lz $LIBS"
577 fi
578 print_config "zlib" "$zlib"
579
580 ##########################################
581 # linux-aio probe
582 if test "$libaio" != "yes" ; then
583   libaio="no"
584 fi
585 if test "$esx" != "yes" ; then
586   cat > $TMPC <<EOF
587 #include <libaio.h>
588 #include <stddef.h>
589 int main(void)
590 {
591   io_setup(0, NULL);
592   return 0;
593 }
594 EOF
595   if compile_prog "" "-laio" "libaio" ; then
596     libaio=yes
597     LIBS="-laio $LIBS"
598   else
599     if test "$libaio" = "yes" ; then
600       feature_not_found "linux AIO" "libaio-dev or libaio-devel"
601     fi
602     libaio=no
603   fi
604 fi
605 print_config "Linux AIO support" "$libaio"
606
607 ##########################################
608 # posix aio probe
609 if test "$posix_aio" != "yes" ; then
610   posix_aio="no"
611 fi
612 if test "$posix_aio_lrt" != "yes" ; then
613   posix_aio_lrt="no"
614 fi
615 cat > $TMPC <<EOF
616 #include <aio.h>
617 int main(void)
618 {
619   struct aiocb cb;
620   aio_read(&cb);
621   return 0;
622 }
623 EOF
624 if compile_prog "" "" "posixaio" ; then
625   posix_aio="yes"
626 elif compile_prog "" "-lrt" "posixaio -lrt"; then
627   posix_aio="yes"
628   posix_aio_lrt="yes"
629   LIBS="-lrt $LIBS"
630 fi
631 print_config "POSIX AIO support" "$posix_aio"
632 print_config "POSIX AIO support needs -lrt" "$posix_aio_lrt"
633
634 ##########################################
635 # posix aio fsync probe
636 if test "$posix_aio_fsync" != "yes" ; then
637   posix_aio_fsync="no"
638 fi
639 if test "$posix_aio" = "yes" ; then
640   cat > $TMPC <<EOF
641 #include <fcntl.h>
642 #include <aio.h>
643 int main(void)
644 {
645   struct aiocb cb;
646   return aio_fsync(O_SYNC, &cb);
647   return 0;
648 }
649 EOF
650   if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
651     posix_aio_fsync=yes
652   fi
653 fi
654 print_config "POSIX AIO fsync" "$posix_aio_fsync"
655
656 ##########################################
657 # POSIX pshared attribute probe
658 if test "$posix_pshared" != "yes" ; then
659   posix_pshared="no"
660 fi
661 cat > $TMPC <<EOF
662 #include <unistd.h>
663 int main(void)
664 {
665 #if defined(_POSIX_THREAD_PROCESS_SHARED) && ((_POSIX_THREAD_PROCESS_SHARED + 0) > 0)
666 # if defined(__CYGWIN__)
667 #  error "_POSIX_THREAD_PROCESS_SHARED is buggy on Cygwin"
668 # elif defined(__APPLE__)
669 #  include <AvailabilityMacros.h>
670 #  include <TargetConditionals.h>
671 #  if TARGET_OS_MAC && MAC_OS_X_VERSION_MIN_REQUIRED < 1070
672 #   error "_POSIX_THREAD_PROCESS_SHARED is buggy/unsupported prior to OSX 10.7"
673 #  endif
674 # endif
675 #else
676 # error "_POSIX_THREAD_PROCESS_SHARED is unsupported"
677 #endif
678   return 0;
679 }
680 EOF
681 if compile_prog "" "$LIBS" "posix_pshared" ; then
682   posix_pshared=yes
683 fi
684 print_config "POSIX pshared support" "$posix_pshared"
685
686 ##########################################
687 # solaris aio probe
688 if test "$solaris_aio" != "yes" ; then
689   solaris_aio="no"
690 fi
691 cat > $TMPC <<EOF
692 #include <sys/types.h>
693 #include <sys/asynch.h>
694 #include <unistd.h>
695 int main(void)
696 {
697   aio_result_t res;
698   return aioread(0, NULL, 0, 0, SEEK_SET, &res);
699   return 0;
700 }
701 EOF
702 if compile_prog "" "-laio" "solarisaio" ; then
703   solaris_aio=yes
704   LIBS="-laio $LIBS"
705 fi
706 print_config "Solaris AIO support" "$solaris_aio"
707
708 ##########################################
709 # __sync_fetch_and_add test
710 if test "$sfaa" != "yes" ; then
711   sfaa="no"
712 fi
713 cat > $TMPC << EOF
714 #include <inttypes.h>
715 static int sfaa(uint64_t *ptr)
716 {
717   return __sync_fetch_and_add(ptr, 0);
718 }
719
720 int main(int argc, char **argv)
721 {
722   uint64_t val = 42;
723   sfaa(&val);
724   return val;
725 }
726 EOF
727 if compile_prog "" "" "__sync_fetch_and_add()" ; then
728     sfaa="yes"
729 fi
730 print_config "__sync_fetch_and_add" "$sfaa"
731
732 ##########################################
733 # __sync_synchronize() test
734 if test "$sync_sync" != "yes" ; then
735   sync_sync="no"
736 fi
737 cat > $TMPC << EOF
738 #include <inttypes.h>
739
740 int main(int argc, char **argv)
741 {
742   __sync_synchronize();
743   return 0;
744 }
745 EOF
746 if compile_prog "" "" "__sync_synchronize()" ; then
747     sync_sync="yes"
748 fi
749 print_config "__sync_synchronize" "$sync_sync"
750
751 ##########################################
752 # __sync_val_compare_and_swap() test
753 if test "$cmp_swap" != "yes" ; then
754   cmp_swap="no"
755 fi
756 cat > $TMPC << EOF
757 #include <inttypes.h>
758
759 int main(int argc, char **argv)
760 {
761   int x = 0;
762   return __sync_val_compare_and_swap(&x, 1, 2);
763 }
764 EOF
765 if compile_prog "" "" "__sync_val_compare_and_swap()" ; then
766     cmp_swap="yes"
767 fi
768 print_config "__sync_val_compare_and_swap" "$cmp_swap"
769
770 ##########################################
771 # libverbs probe
772 if test "$libverbs" != "yes" ; then
773   libverbs="no"
774 fi
775 cat > $TMPC << EOF
776 #include <infiniband/verbs.h>
777 int main(int argc, char **argv)
778 {
779   struct ibv_pd *pd = ibv_alloc_pd(NULL);
780   return 0;
781 }
782 EOF
783 if test "$disable_rdma" != "yes" && compile_prog "" "-libverbs" "libverbs" ; then
784     libverbs="yes"
785     LIBS="-libverbs $LIBS"
786 fi
787 print_config "libverbs" "$libverbs"
788
789 ##########################################
790 # rdmacm probe
791 if test "$rdmacm" != "yes" ; then
792   rdmacm="no"
793 fi
794 cat > $TMPC << EOF
795 #include <stdio.h>
796 #include <rdma/rdma_cma.h>
797 int main(int argc, char **argv)
798 {
799   rdma_destroy_qp(NULL);
800   return 0;
801 }
802 EOF
803 if test "$disable_rdma" != "yes" && compile_prog "" "-lrdmacm" "rdma"; then
804     rdmacm="yes"
805     LIBS="-lrdmacm $LIBS"
806 fi
807 print_config "rdmacm" "$rdmacm"
808
809 ##########################################
810 # asprintf() and vasprintf() probes
811 if test "$have_asprintf" != "yes" ; then
812   have_asprintf="no"
813 fi
814 cat > $TMPC << EOF
815 #include <stdio.h>
816
817 int main(int argc, char **argv)
818 {
819   return asprintf(NULL, "%s", "str") == 0;
820 }
821 EOF
822 if compile_prog "" "" "have_asprintf"; then
823     have_asprintf="yes"
824 fi
825 print_config "asprintf()" "$have_asprintf"
826
827 if test "$have_vasprintf" != "yes" ; then
828   have_vasprintf="no"
829 fi
830 cat > $TMPC << EOF
831 #include <stdio.h>
832
833 int main(int argc, char **argv)
834 {
835   return vasprintf(NULL, "%s", NULL) == 0;
836 }
837 EOF
838 if compile_prog "" "" "have_vasprintf"; then
839     have_vasprintf="yes"
840 fi
841 print_config "vasprintf()" "$have_vasprintf"
842
843 ##########################################
844 # Linux fallocate probe
845 if test "$linux_fallocate" != "yes" ; then
846   linux_fallocate="no"
847 fi
848 cat > $TMPC << EOF
849 #include <stdio.h>
850 #include <fcntl.h>
851 #include <linux/falloc.h>
852 int main(int argc, char **argv)
853 {
854   int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
855   return r;
856 }
857 EOF
858 if compile_prog "" "" "linux_fallocate"; then
859     linux_fallocate="yes"
860 fi
861 print_config "Linux fallocate" "$linux_fallocate"
862
863 ##########################################
864 # POSIX fadvise probe
865 if test "$posix_fadvise" != "yes" ; then
866   posix_fadvise="no"
867 fi
868 cat > $TMPC << EOF
869 #include <stdio.h>
870 #include <fcntl.h>
871 int main(int argc, char **argv)
872 {
873   int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
874   return r;
875 }
876 EOF
877 if compile_prog "" "" "posix_fadvise"; then
878     posix_fadvise="yes"
879 fi
880 print_config "POSIX fadvise" "$posix_fadvise"
881
882 ##########################################
883 # POSIX fallocate probe
884 if test "$posix_fallocate" != "yes" ; then
885   posix_fallocate="no"
886 fi
887 cat > $TMPC << EOF
888 #include <stdio.h>
889 #include <fcntl.h>
890 int main(int argc, char **argv)
891 {
892   int r = posix_fallocate(0, 0, 1024);
893   return r;
894 }
895 EOF
896 if compile_prog "" "" "posix_fallocate"; then
897     posix_fallocate="yes"
898 fi
899 print_config "POSIX fallocate" "$posix_fallocate"
900
901 ##########################################
902 # sched_set/getaffinity 2 or 3 argument test
903 if test "$linux_2arg_affinity" != "yes" ; then
904   linux_2arg_affinity="no"
905 fi
906 if test "$linux_3arg_affinity" != "yes" ; then
907   linux_3arg_affinity="no"
908 fi
909 cat > $TMPC << EOF
910 #include <sched.h>
911 int main(int argc, char **argv)
912 {
913   cpu_set_t mask;
914   return sched_setaffinity(0, sizeof(mask), &mask);
915 }
916 EOF
917 if compile_prog "" "" "sched_setaffinity(,,)"; then
918   linux_3arg_affinity="yes"
919 else
920   cat > $TMPC << EOF
921 #include <sched.h>
922 int main(int argc, char **argv)
923 {
924   cpu_set_t mask;
925   return sched_setaffinity(0, &mask);
926 }
927 EOF
928   if compile_prog "" "" "sched_setaffinity(,)"; then
929     linux_2arg_affinity="yes"
930   fi
931 fi
932 print_config "sched_setaffinity(3 arg)" "$linux_3arg_affinity"
933 print_config "sched_setaffinity(2 arg)" "$linux_2arg_affinity"
934
935 ##########################################
936 # clock_gettime probe
937 if test "$clock_gettime" != "yes" ; then
938   clock_gettime="no"
939 fi
940 cat > $TMPC << EOF
941 #include <stdio.h>
942 #include <time.h>
943 int main(int argc, char **argv)
944 {
945   return clock_gettime(0, NULL);
946 }
947 EOF
948 if compile_prog "" "" "clock_gettime"; then
949     clock_gettime="yes"
950 elif compile_prog "" "-lrt" "clock_gettime"; then
951     clock_gettime="yes"
952     LIBS="-lrt $LIBS"
953 fi
954 print_config "clock_gettime" "$clock_gettime"
955
956 ##########################################
957 # CLOCK_MONOTONIC probe
958 if test "$clock_monotonic" != "yes" ; then
959   clock_monotonic="no"
960 fi
961 if test "$clock_gettime" = "yes" ; then
962   cat > $TMPC << EOF
963 #include <stdio.h>
964 #include <time.h>
965 int main(int argc, char **argv)
966 {
967   return clock_gettime(CLOCK_MONOTONIC, NULL);
968 }
969 EOF
970   if compile_prog "" "$LIBS" "clock monotonic"; then
971       clock_monotonic="yes"
972   fi
973 fi
974 print_config "CLOCK_MONOTONIC" "$clock_monotonic"
975
976 ##########################################
977 # CLOCK_MONOTONIC_RAW probe
978 if test "$clock_monotonic_raw" != "yes" ; then
979   clock_monotonic_raw="no"
980 fi
981 if test "$clock_gettime" = "yes" ; then
982   cat > $TMPC << EOF
983 #include <stdio.h>
984 #include <time.h>
985 int main(int argc, char **argv)
986 {
987   return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
988 }
989 EOF
990   if compile_prog "" "$LIBS" "clock monotonic"; then
991       clock_monotonic_raw="yes"
992   fi
993 fi
994 print_config "CLOCK_MONOTONIC_RAW" "$clock_monotonic_raw"
995
996 ##########################################
997 # CLOCK_MONOTONIC_PRECISE probe
998 if test "$clock_monotonic_precise" != "yes" ; then
999   clock_monotonic_precise="no"
1000 fi
1001 if test "$clock_gettime" = "yes" ; then
1002   cat > $TMPC << EOF
1003 #include <stdio.h>
1004 #include <time.h>
1005 int main(int argc, char **argv)
1006 {
1007   return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
1008 }
1009 EOF
1010   if compile_prog "" "$LIBS" "clock monotonic precise"; then
1011       clock_monotonic_precise="yes"
1012   fi
1013 fi
1014 print_config "CLOCK_MONOTONIC_PRECISE" "$clock_monotonic_precise"
1015
1016 ##########################################
1017 # clockid_t probe
1018 if test "$clockid_t" != "yes" ; then
1019   clockid_t="no"
1020 fi
1021 cat > $TMPC << EOF
1022 #include <time.h>
1023 #include <string.h>
1024 int main(int argc, char **argv)
1025 {
1026   volatile clockid_t cid;
1027   memset((void*)&cid, 0, sizeof(cid));
1028   return 0;
1029 }
1030 EOF
1031 if compile_prog "" "$LIBS" "clockid_t"; then
1032   clockid_t="yes"
1033 fi
1034 print_config "clockid_t" "$clockid_t"
1035
1036 ##########################################
1037 # gettimeofday() probe
1038 if test "$gettimeofday" != "yes" ; then
1039   gettimeofday="no"
1040 fi
1041 cat > $TMPC << EOF
1042 #include <sys/time.h>
1043 #include <stdio.h>
1044 int main(int argc, char **argv)
1045 {
1046   struct timeval tv;
1047   return gettimeofday(&tv, NULL);
1048 }
1049 EOF
1050 if compile_prog "" "" "gettimeofday"; then
1051     gettimeofday="yes"
1052 fi
1053 print_config "gettimeofday" "$gettimeofday"
1054
1055 ##########################################
1056 # fdatasync() probe
1057 if test "$fdatasync" != "yes" ; then
1058   fdatasync="no"
1059 fi
1060 cat > $TMPC << EOF
1061 #include <stdio.h>
1062 #include <unistd.h>
1063 int main(int argc, char **argv)
1064 {
1065   return fdatasync(0);
1066 }
1067 EOF
1068 if compile_prog "" "" "fdatasync"; then
1069   fdatasync="yes"
1070 fi
1071 print_config "fdatasync" "$fdatasync"
1072
1073 ##########################################
1074 # sync_file_range() probe
1075 if test "$sync_file_range" != "yes" ; then
1076   sync_file_range="no"
1077 fi
1078 cat > $TMPC << EOF
1079 #include <stdio.h>
1080 #include <unistd.h>
1081 #include <fcntl.h>
1082 #include <linux/fs.h>
1083 int main(int argc, char **argv)
1084 {
1085   unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
1086                         SYNC_FILE_RANGE_WAIT_AFTER;
1087   return sync_file_range(0, 0, 0, flags);
1088 }
1089 EOF
1090 if compile_prog "" "" "sync_file_range"; then
1091   sync_file_range="yes"
1092 fi
1093 print_config "sync_file_range" "$sync_file_range"
1094
1095 ##########################################
1096 # ext4 move extent probe
1097 if test "$ext4_me" != "yes" ; then
1098   ext4_me="no"
1099 fi
1100 cat > $TMPC << EOF
1101 #include <fcntl.h>
1102 #include <sys/ioctl.h>
1103 int main(int argc, char **argv)
1104 {
1105   struct move_extent me;
1106   return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
1107 }
1108 EOF
1109 if compile_prog "" "" "ext4 move extent" ; then
1110   ext4_me="yes"
1111 elif test $targetos = "Linux" ; then
1112   # On Linux, just default to it on and let it error at runtime if we really
1113   # don't have it. None of my updated systems have it defined, but it does
1114   # work. Takes a while to bubble back.
1115   ext4_me="yes"
1116 fi
1117 print_config "EXT4 move extent" "$ext4_me"
1118
1119 ##########################################
1120 # splice probe
1121 if test "$linux_splice" != "yes" ; then
1122   linux_splice="no"
1123 fi
1124 cat > $TMPC << EOF
1125 #include <stdio.h>
1126 #include <fcntl.h>
1127 int main(int argc, char **argv)
1128 {
1129   return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
1130 }
1131 EOF
1132 if compile_prog "" "" "linux splice"; then
1133   linux_splice="yes"
1134 fi
1135 print_config "Linux splice(2)" "$linux_splice"
1136
1137 ##########################################
1138 # GUASI probe
1139 if test "$guasi" != "yes" ; then
1140   guasi="no"
1141 fi
1142 cat > $TMPC << EOF
1143 #include <guasi.h>
1144 #include <guasi_syscalls.h>
1145 int main(int argc, char **argv)
1146 {
1147   guasi_t ctx = guasi_create(0, 0, 0);
1148   return 0;
1149 }
1150 EOF
1151 if compile_prog "" "" "guasi"; then
1152   guasi="yes"
1153 fi
1154 print_config "GUASI" "$guasi"
1155
1156 ##########################################
1157 # libnuma probe
1158 if test "$libnuma" != "yes" ; then
1159   libnuma="no"
1160 fi
1161 cat > $TMPC << EOF
1162 #include <numa.h>
1163 int main(int argc, char **argv)
1164 {
1165   return numa_available();
1166 }
1167 EOF
1168 if test "$disable_numa" != "yes"  && compile_prog "" "-lnuma" "libnuma"; then
1169   libnuma="yes"
1170   LIBS="-lnuma $LIBS"
1171 fi
1172 print_config "libnuma" "$libnuma"
1173
1174 ##########################################
1175 # libnuma 2.x version API, initialize with "no" only if $libnuma is set to "yes"
1176 if test "$libnuma" = "yes" ; then
1177 libnuma_v2="no"
1178 cat > $TMPC << EOF
1179 #include <numa.h>
1180 int main(int argc, char **argv)
1181 {
1182   struct bitmask *mask = numa_parse_nodestring(NULL);
1183   return mask->size == 0;
1184 }
1185 EOF
1186 if compile_prog "" "" "libnuma api"; then
1187   libnuma_v2="yes"
1188 fi
1189 print_config "libnuma v2" "$libnuma_v2"
1190 fi
1191
1192 ##########################################
1193 # strsep() probe
1194 if test "$strsep" != "yes" ; then
1195   strsep="no"
1196 fi
1197 cat > $TMPC << EOF
1198 #include <string.h>
1199 int main(int argc, char **argv)
1200 {
1201   static char *string = "This is a string";
1202   strsep(&string, "needle");
1203   return 0;
1204 }
1205 EOF
1206 if compile_prog "" "" "strsep"; then
1207   strsep="yes"
1208 fi
1209 print_config "strsep" "$strsep"
1210
1211 ##########################################
1212 # strcasestr() probe
1213 if test "$strcasestr" != "yes" ; then
1214   strcasestr="no"
1215 fi
1216 cat > $TMPC << EOF
1217 #include <string.h>
1218 int main(int argc, char **argv)
1219 {
1220   return strcasestr(argv[0], argv[1]) != NULL;
1221 }
1222 EOF
1223 if compile_prog "" "" "strcasestr"; then
1224   strcasestr="yes"
1225 fi
1226 print_config "strcasestr" "$strcasestr"
1227
1228 ##########################################
1229 # strlcat() probe
1230 if test "$strlcat" != "yes" ; then
1231   strlcat="no"
1232 fi
1233 cat > $TMPC << EOF
1234 #include <string.h>
1235 int main(int argc, char **argv)
1236 {
1237   static char dst[64];
1238   static char *string = "This is a string";
1239   memset(dst, 0, sizeof(dst));
1240   strlcat(dst, string, sizeof(dst));
1241   return 0;
1242 }
1243 EOF
1244 if compile_prog "" "" "strlcat"; then
1245   strlcat="yes"
1246 fi
1247 print_config "strlcat" "$strlcat"
1248
1249 ##########################################
1250 # getopt_long_only() probe
1251 if test "$getopt_long_only" != "yes" ; then
1252   getopt_long_only="no"
1253 fi
1254 cat > $TMPC << EOF
1255 #include <unistd.h>
1256 #include <stdio.h>
1257 #include <getopt.h>
1258 int main(int argc, char **argv)
1259 {
1260   int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1261   return c;
1262 }
1263 EOF
1264 if compile_prog "" "" "getopt_long_only"; then
1265   getopt_long_only="yes"
1266 fi
1267 print_config "getopt_long_only()" "$getopt_long_only"
1268
1269 ##########################################
1270 # inet_aton() probe
1271 if test "$inet_aton" != "yes" ; then
1272   inet_aton="no"
1273 fi
1274 cat > $TMPC << EOF
1275 #include <sys/socket.h>
1276 #include <arpa/inet.h>
1277 #include <stdio.h>
1278 int main(int argc, char **argv)
1279 {
1280   struct in_addr in;
1281   return inet_aton(NULL, &in);
1282 }
1283 EOF
1284 if compile_prog "" "" "inet_aton"; then
1285   inet_aton="yes"
1286 fi
1287 print_config "inet_aton" "$inet_aton"
1288
1289 ##########################################
1290 # socklen_t probe
1291 if test "$socklen_t" != "yes" ; then
1292   socklen_t="no"
1293 fi
1294 cat > $TMPC << EOF
1295 #include <sys/socket.h>
1296 int main(int argc, char **argv)
1297 {
1298   socklen_t len = 0;
1299   return len;
1300 }
1301 EOF
1302 if compile_prog "" "" "socklen_t"; then
1303   socklen_t="yes"
1304 fi
1305 print_config "socklen_t" "$socklen_t"
1306
1307 ##########################################
1308 # Whether or not __thread is supported for TLS
1309 if test "$tls_thread" != "yes" ; then
1310   tls_thread="no"
1311 fi
1312 cat > $TMPC << EOF
1313 #include <stdio.h>
1314 static __thread int ret;
1315 int main(int argc, char **argv)
1316 {
1317   return ret;
1318 }
1319 EOF
1320 if compile_prog "" "" "__thread"; then
1321   tls_thread="yes"
1322 fi
1323 print_config "__thread" "$tls_thread"
1324
1325 ##########################################
1326 # Check if we have required gtk/glib support for gfio
1327 if test "$gfio" != "yes" ; then
1328   gfio="no"
1329 fi
1330 if test "$gfio_check" = "yes" ; then
1331   cat > $TMPC << EOF
1332 #include <glib.h>
1333 #include <cairo.h>
1334 #include <gtk/gtk.h>
1335 int main(void)
1336 {
1337   gdk_threads_enter();
1338   gdk_threads_leave();
1339
1340   return GTK_CHECK_VERSION(2, 18, 0) ? 0 : 1; /* 0 on success */
1341 }
1342 EOF
1343 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1344 ORG_LDFLAGS=$LDFLAGS
1345 LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1346 if test "$?" != "0" ; then
1347   echo "configure: gtk and gthread not found"
1348   exit 1
1349 fi
1350 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1351 if test "$?" != "0" ; then
1352   echo "configure: gtk and gthread not found"
1353   exit 1
1354 fi
1355 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1356   $TMPE
1357   if test "$?" = "0" ; then
1358     gfio="yes"
1359     GFIO_LIBS="$LIBS $GTK_LIBS"
1360     CFLAGS="$CFLAGS $GTK_CFLAGS"
1361   else
1362     echo "GTK found, but need version 2.18 or higher"
1363     gfio="no"
1364   fi
1365 else
1366   echo "Please install gtk and gdk libraries"
1367   gfio="no"
1368 fi
1369 LDFLAGS=$ORG_LDFLAGS
1370 fi
1371
1372 if test "$gfio_check" = "yes" ; then
1373   print_config "gtk 2.18 or higher" "$gfio"
1374 fi
1375
1376 ##########################################
1377 # Check whether we have getrusage(RUSAGE_THREAD)
1378 if test "$rusage_thread" != "yes" ; then
1379   rusage_thread="no"
1380 fi
1381 cat > $TMPC << EOF
1382 #include <sys/time.h>
1383 #include <sys/resource.h>
1384 int main(int argc, char **argv)
1385 {
1386   struct rusage ru;
1387   getrusage(RUSAGE_THREAD, &ru);
1388   return 0;
1389 }
1390 EOF
1391 if compile_prog "" "" "RUSAGE_THREAD"; then
1392   rusage_thread="yes"
1393 fi
1394 print_config "RUSAGE_THREAD" "$rusage_thread"
1395
1396 ##########################################
1397 # Check whether we have SCHED_IDLE
1398 if test "$sched_idle" != "yes" ; then
1399   sched_idle="no"
1400 fi
1401 cat > $TMPC << EOF
1402 #include <sched.h>
1403 int main(int argc, char **argv)
1404 {
1405   struct sched_param p;
1406   return sched_setscheduler(0, SCHED_IDLE, &p);
1407 }
1408 EOF
1409 if compile_prog "" "" "SCHED_IDLE"; then
1410   sched_idle="yes"
1411 fi
1412 print_config "SCHED_IDLE" "$sched_idle"
1413
1414 ##########################################
1415 # Check whether we have TCP_NODELAY
1416 if test "$tcp_nodelay" != "yes" ; then
1417   tcp_nodelay="no"
1418 fi
1419 cat > $TMPC << EOF
1420 #include <stdio.h>
1421 #include <sys/types.h>
1422 #include <sys/socket.h>
1423 #include <netinet/tcp.h>
1424 int main(int argc, char **argv)
1425 {
1426   return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1427 }
1428 EOF
1429 if compile_prog "" "" "TCP_NODELAY"; then
1430   tcp_nodelay="yes"
1431 fi
1432 print_config "TCP_NODELAY" "$tcp_nodelay"
1433
1434 ##########################################
1435 # Check whether we have SO_SNDBUF
1436 if test "$window_size" != "yes" ; then
1437   window_size="no"
1438 fi
1439 cat > $TMPC << EOF
1440 #include <stdio.h>
1441 #include <sys/types.h>
1442 #include <sys/socket.h>
1443 #include <netinet/tcp.h>
1444 int main(int argc, char **argv)
1445 {
1446   setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1447   setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1448 }
1449 EOF
1450 if compile_prog "" "" "SO_SNDBUF"; then
1451   window_size="yes"
1452 fi
1453 print_config "Net engine window_size" "$window_size"
1454
1455 ##########################################
1456 # Check whether we have TCP_MAXSEG
1457 if test "$mss" != "yes" ; then
1458   mss="no"
1459 fi
1460 cat > $TMPC << EOF
1461 #include <stdio.h>
1462 #include <sys/types.h>
1463 #include <sys/socket.h>
1464 #include <netinet/tcp.h>
1465 #include <arpa/inet.h>
1466 #include <netinet/in.h>
1467 int main(int argc, char **argv)
1468 {
1469   return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1470 }
1471 EOF
1472 if compile_prog "" "" "TCP_MAXSEG"; then
1473   mss="yes"
1474 fi
1475 print_config "TCP_MAXSEG" "$mss"
1476
1477 ##########################################
1478 # Check whether we have RLIMIT_MEMLOCK
1479 if test "$rlimit_memlock" != "yes" ; then
1480   rlimit_memlock="no"
1481 fi
1482 cat > $TMPC << EOF
1483 #include <sys/time.h>
1484 #include <sys/resource.h>
1485 int main(int argc, char **argv)
1486 {
1487   struct rlimit rl;
1488   return getrlimit(RLIMIT_MEMLOCK, &rl);
1489 }
1490 EOF
1491 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1492   rlimit_memlock="yes"
1493 fi
1494 print_config "RLIMIT_MEMLOCK" "$rlimit_memlock"
1495
1496 ##########################################
1497 # Check whether we have pwritev/preadv
1498 if test "$pwritev" != "yes" ; then
1499   pwritev="no"
1500 fi
1501 cat > $TMPC << EOF
1502 #include <stdio.h>
1503 #include <sys/uio.h>
1504 int main(int argc, char **argv)
1505 {
1506   return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1507 }
1508 EOF
1509 if compile_prog "" "" "pwritev"; then
1510   pwritev="yes"
1511 fi
1512 print_config "pwritev/preadv" "$pwritev"
1513
1514 ##########################################
1515 # Check whether we have pwritev2/preadv2
1516 if test "$pwritev2" != "yes" ; then
1517   pwritev2="no"
1518 fi
1519 cat > $TMPC << EOF
1520 #include <stdio.h>
1521 #include <sys/uio.h>
1522 int main(int argc, char **argv)
1523 {
1524   return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1525 }
1526 EOF
1527 if compile_prog "" "" "pwritev2"; then
1528   pwritev2="yes"
1529 fi
1530 print_config "pwritev2/preadv2" "$pwritev2"
1531
1532 ##########################################
1533 # Check whether we have the required functions for ipv6
1534 if test "$ipv6" != "yes" ; then
1535   ipv6="no"
1536 fi
1537 cat > $TMPC << EOF
1538 #include <sys/types.h>
1539 #include <sys/socket.h>
1540 #include <netinet/in.h>
1541 #include <netdb.h>
1542 #include <stdio.h>
1543 int main(int argc, char **argv)
1544 {
1545   struct addrinfo hints;
1546   struct in6_addr addr;
1547   int ret;
1548
1549   ret = getaddrinfo(NULL, NULL, &hints, NULL);
1550   freeaddrinfo(NULL);
1551   printf("%s\n", gai_strerror(ret));
1552   addr = in6addr_any;
1553   return 0;
1554 }
1555 EOF
1556 if compile_prog "" "" "ipv6"; then
1557   ipv6="yes"
1558 fi
1559 print_config "IPv6 helpers" "$ipv6"
1560
1561 ##########################################
1562 # check for http
1563 if test "$http" != "yes" ; then
1564   http="no"
1565 fi
1566 # check for openssl >= 1.1.0, which uses an opaque HMAC_CTX pointer
1567 cat > $TMPC << EOF
1568 #include <curl/curl.h>
1569 #include <openssl/hmac.h>
1570
1571 int main(int argc, char **argv)
1572 {
1573   CURL *curl;
1574   HMAC_CTX *ctx;
1575
1576   curl = curl_easy_init();
1577   curl_easy_cleanup(curl);
1578
1579   ctx = HMAC_CTX_new();
1580   HMAC_CTX_reset(ctx);
1581   HMAC_CTX_free(ctx);
1582   return 0;
1583 }
1584 EOF
1585 # openssl < 1.1.0 uses the HMAC_CTX type directly
1586 cat > $TMPC2 << EOF
1587 #include <curl/curl.h>
1588 #include <openssl/hmac.h>
1589
1590 int main(int argc, char **argv)
1591 {
1592   CURL *curl;
1593   HMAC_CTX ctx;
1594
1595   curl = curl_easy_init();
1596   curl_easy_cleanup(curl);
1597
1598   HMAC_CTX_init(&ctx);
1599   HMAC_CTX_cleanup(&ctx);
1600   return 0;
1601 }
1602 EOF
1603 if test "$disable_http" != "yes"; then
1604   HTTP_LIBS="-lcurl -lssl -lcrypto"
1605   if compile_prog "" "$HTTP_LIBS" "curl-new-ssl"; then
1606     output_sym "CONFIG_HAVE_OPAQUE_HMAC_CTX"
1607     http="yes"
1608     LIBS="$HTTP_LIBS $LIBS"
1609   elif mv $TMPC2 $TMPC && compile_prog "" "$HTTP_LIBS" "curl-old-ssl"; then
1610     http="yes"
1611     LIBS="$HTTP_LIBS $LIBS"
1612   fi
1613 fi
1614 print_config "http engine" "$http"
1615
1616 ##########################################
1617 # check for rados
1618 if test "$rados" != "yes" ; then
1619   rados="no"
1620 fi
1621 cat > $TMPC << EOF
1622 #include <rados/librados.h>
1623
1624 int main(int argc, char **argv)
1625 {
1626   rados_t cluster;
1627   rados_ioctx_t io_ctx;
1628   const char cluster_name[] = "ceph";
1629   const char user_name[] = "client.admin";
1630   const char pool[] = "rados";
1631
1632   /* The rados_create2 signature required was only introduced in ceph 0.65 */
1633   rados_create2(&cluster, cluster_name, user_name, 0);
1634   rados_ioctx_create(cluster, pool, &io_ctx);
1635
1636   return 0;
1637 }
1638 EOF
1639 if test "$disable_rados" != "yes"  && compile_prog "" "-lrados" "rados"; then
1640   LIBS="-lrados $LIBS"
1641   rados="yes"
1642 fi
1643 print_config "Rados engine" "$rados"
1644
1645 ##########################################
1646 # check for rbd
1647 if test "$rbd" != "yes" ; then
1648   rbd="no"
1649 fi
1650 cat > $TMPC << EOF
1651 #include <rbd/librbd.h>
1652
1653 int main(int argc, char **argv)
1654 {
1655   rados_t cluster;
1656   rados_ioctx_t io_ctx;
1657   const char cluster_name[] = "ceph";
1658   const char user_name[] = "client.admin";
1659   const char pool[] = "rbd";
1660   int major, minor, extra;
1661
1662   rbd_version(&major, &minor, &extra);
1663   /* The rados_create2 signature required was only introduced in ceph 0.65 */
1664   rados_create2(&cluster, cluster_name, user_name, 0);
1665   rados_ioctx_create(cluster, pool, &io_ctx);
1666
1667   return 0;
1668 }
1669 EOF
1670 if test "$disable_rbd" != "yes"  && compile_prog "" "-lrbd -lrados" "rbd"; then
1671   LIBS="-lrbd -lrados $LIBS"
1672   rbd="yes"
1673 fi
1674 print_config "Rados Block Device engine" "$rbd"
1675
1676 ##########################################
1677 # check for rbd_poll
1678 if test "$rbd_poll" != "yes" ; then
1679   rbd_poll="no"
1680 fi
1681 if test "$rbd" = "yes"; then
1682 cat > $TMPC << EOF
1683 #include <rbd/librbd.h>
1684 #include <sys/eventfd.h>
1685
1686 int main(int argc, char **argv)
1687 {
1688   rbd_image_t image;
1689   rbd_completion_t comp;
1690
1691   int fd = eventfd(0, EFD_NONBLOCK);
1692   rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1693   rbd_poll_io_events(image, comp, 1);
1694
1695   return 0;
1696 }
1697 EOF
1698 if compile_prog "" "-lrbd -lrados" "rbd"; then
1699   rbd_poll="yes"
1700 fi
1701 print_config "rbd_poll" "$rbd_poll"
1702 fi
1703
1704 ##########################################
1705 # check for rbd_invalidate_cache()
1706 if test "$rbd_inval" != "yes" ; then
1707   rbd_inval="no"
1708 fi
1709 if test "$rbd" = "yes"; then
1710 cat > $TMPC << EOF
1711 #include <rbd/librbd.h>
1712
1713 int main(int argc, char **argv)
1714 {
1715   rbd_image_t image;
1716
1717   return rbd_invalidate_cache(image);
1718 }
1719 EOF
1720 if compile_prog "" "-lrbd -lrados" "rbd"; then
1721   rbd_inval="yes"
1722 fi
1723 print_config "rbd_invalidate_cache" "$rbd_inval"
1724 fi
1725
1726 ##########################################
1727 # Check whether we have setvbuf
1728 if test "$setvbuf" != "yes" ; then
1729   setvbuf="no"
1730 fi
1731 cat > $TMPC << EOF
1732 #include <stdio.h>
1733 int main(int argc, char **argv)
1734 {
1735   FILE *f = NULL;
1736   char buf[80];
1737   setvbuf(f, buf, _IOFBF, sizeof(buf));
1738   return 0;
1739 }
1740 EOF
1741 if compile_prog "" "" "setvbuf"; then
1742   setvbuf="yes"
1743 fi
1744 print_config "setvbuf" "$setvbuf"
1745
1746 ##########################################
1747 # check for gfapi
1748 if test "$gfapi" != "yes" ; then
1749   gfapi="no"
1750 fi
1751 cat > $TMPC << EOF
1752 #include <glusterfs/api/glfs.h>
1753
1754 int main(int argc, char **argv)
1755 {
1756   glfs_t *g = glfs_new("foo");
1757
1758   return 0;
1759 }
1760 EOF
1761 if test "$disable_gfapi" != "yes"  && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1762   LIBS="-lgfapi -lglusterfs $LIBS"
1763   gfapi="yes"
1764 fi
1765 print_config "Gluster API engine" "$gfapi"
1766
1767 ##########################################
1768 # check for gfapi fadvise support, initialize with "no" only if $gfapi is set to "yes"
1769 if test "$gfapi" = "yes" ; then
1770 gf_fadvise="no"
1771 cat > $TMPC << EOF
1772 #include <glusterfs/api/glfs.h>
1773
1774 int main(int argc, char **argv)
1775 {
1776   struct glfs_fd *fd;
1777   int ret = glfs_fadvise(fd, 0, 0, 1);
1778
1779   return 0;
1780 }
1781 EOF
1782 if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1783   gf_fadvise="yes"
1784 fi
1785 print_config "Gluster API use fadvise" "$gf_fadvise"
1786 fi
1787
1788 ##########################################
1789 # check for gfapi trim support
1790 if test "$gf_trim" != "yes" ; then
1791   gf_trim="no"
1792 fi
1793 if test "$gfapi" = "yes" ; then
1794 cat > $TMPC << EOF
1795 #include <glusterfs/api/glfs.h>
1796
1797 int main(int argc, char **argv)
1798 {
1799   return glfs_discard_async(NULL, 0, 0);
1800 }
1801 EOF
1802 if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1803   gf_trim="yes"
1804 fi
1805 print_config "Gluster API trim support" "$gf_trim"
1806 fi
1807
1808 ##########################################
1809 # Check if we support stckf on s390
1810 if test "$s390_z196_facilities" != "yes" ; then
1811   s390_z196_facilities="no"
1812 fi
1813 cat > $TMPC << EOF
1814 #define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1815 int main(int argc, char **argv)
1816 {
1817     /* We want just 1 double word to be returned.  */
1818     register unsigned long reg0 asm("0") = 0;
1819     unsigned long stfle_bits;
1820     asm volatile(".machine push"        "\n\t"
1821                  ".machine \"z9-109\""  "\n\t"
1822                  "stfle %0"             "\n\t"
1823                  ".machine pop"         "\n"
1824                  : "=QS" (stfle_bits), "+d" (reg0)
1825                  : : "cc");
1826
1827     if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1828       return 0;
1829     else
1830       return -1;
1831 }
1832 EOF
1833 if compile_prog "" "" "s390_z196_facilities"; then
1834   $TMPE
1835   if [ $? -eq 0 ]; then
1836         s390_z196_facilities="yes"
1837   fi
1838 fi
1839 print_config "s390_z196_facilities" "$s390_z196_facilities"
1840
1841 ##########################################
1842 # Check if we have required environment variables configured for libhdfs
1843 if test "$libhdfs" = "yes" ; then
1844   hdfs_conf_error=0
1845   if test "$JAVA_HOME" = "" ; then
1846     echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1847     hdfs_conf_error=1
1848   fi
1849   if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1850     echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1851     hdfs_conf_error=1
1852   fi
1853   if test "$FIO_LIBHDFS_LIB" = "" ; then
1854     echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1855     hdfs_conf_error=1
1856   fi
1857   if test "$hdfs_conf_error" = "1" ; then
1858     exit 1
1859   fi
1860   FIO_HDFS_CPU=$cpu
1861   if test "$FIO_HDFS_CPU" = "x86_64" ; then
1862     FIO_HDFS_CPU="amd64"
1863   fi
1864 fi
1865 print_config "HDFS engine" "$libhdfs"
1866
1867 ##########################################
1868 # Check whether we have MTD
1869 if test "$mtd" != "yes" ; then
1870   mtd="no"
1871 fi
1872 cat > $TMPC << EOF
1873 #include <string.h>
1874 #include <mtd/mtd-user.h>
1875 #include <sys/ioctl.h>
1876 int main(int argc, char **argv)
1877 {
1878   struct mtd_write_req ops;
1879   struct mtd_info_user info;
1880   memset(&ops, 0, sizeof(ops));
1881   info.type = MTD_MLCNANDFLASH;
1882   return ioctl(0, MEMGETINFO, &info);
1883 }
1884 EOF
1885 if compile_prog "" "" "mtd"; then
1886   mtd="yes"
1887 fi
1888 print_config "MTD" "$mtd"
1889
1890 ##########################################
1891 # Check whether we have libpmem
1892 if test "$libpmem" != "yes" ; then
1893   libpmem="no"
1894 fi
1895 cat > $TMPC << EOF
1896 #include <libpmem.h>
1897 int main(int argc, char **argv)
1898 {
1899   int rc;
1900   rc = pmem_is_pmem(0, 0);
1901   return 0;
1902 }
1903 EOF
1904 if compile_prog "" "-lpmem" "libpmem"; then
1905   libpmem="yes"
1906   LIBS="-lpmem $LIBS"
1907 fi
1908 print_config "libpmem" "$libpmem"
1909
1910 ##########################################
1911 # Check whether we have libpmemblk
1912 # libpmem is a prerequisite
1913 if test "$libpmemblk" != "yes" ; then
1914   libpmemblk="no"
1915 fi
1916 if test "$libpmem" = "yes"; then
1917   cat > $TMPC << EOF
1918 #include <libpmemblk.h>
1919 int main(int argc, char **argv)
1920 {
1921   PMEMblkpool *pbp;
1922   pbp = pmemblk_open("", 0);
1923   return 0;
1924 }
1925 EOF
1926   if compile_prog "" "-lpmemblk" "libpmemblk"; then
1927     libpmemblk="yes"
1928     LIBS="-lpmemblk $LIBS"
1929   fi
1930 fi
1931 print_config "libpmemblk" "$libpmemblk"
1932
1933 # Choose the ioengines
1934 if test "$libpmem" = "yes" && test "$disable_pmem" = "no"; then
1935   pmem="yes"
1936   devdax="yes"
1937   if test "$libpmemblk" = "yes"; then
1938     pmemblk="yes"
1939   fi
1940 fi
1941
1942 ##########################################
1943 # Report whether pmemblk engine is enabled
1944 print_config "PMDK pmemblk engine" "$pmemblk"
1945
1946 ##########################################
1947 # Report whether dev-dax engine is enabled
1948 print_config "PMDK dev-dax engine" "$devdax"
1949
1950 ##########################################
1951 # Report whether libpmem engine is enabled
1952 print_config "PMDK libpmem engine" "$pmem"
1953
1954 ##########################################
1955 # Check whether we support DDN's IME
1956 if test "$libime" != "yes" ; then
1957   libime="no"
1958 fi
1959 cat > $TMPC << EOF
1960 #include <ime_native.h>
1961 int main(int argc, char **argv)
1962 {
1963   int rc;
1964   ime_native_init();
1965   rc = ime_native_finalize();
1966   return 0;
1967 }
1968 EOF
1969 if compile_prog "-I${ime_path}/include" "-L${ime_path}/lib -lim_client" "libime"; then
1970   libime="yes"
1971   CFLAGS="-I${ime_path}/include $CFLAGS"
1972   LDFLAGS="-Wl,-rpath ${ime_path}/lib -L${ime_path}/lib $LDFLAGS"
1973   LIBS="-lim_client $LIBS"
1974 fi
1975 print_config "DDN's Infinite Memory Engine" "$libime"
1976
1977 ##########################################
1978 # Check if we have required environment variables configured for libiscsi
1979 if test "$libiscsi" = "yes" ; then
1980   if $(pkg-config --atleast-version=1.9.0 libiscsi); then
1981     libiscsi="yes"
1982     libiscsi_cflags=$(pkg-config --cflags libiscsi)
1983     libiscsi_libs=$(pkg-config --libs libiscsi)
1984   else
1985     if test "$libiscsi" = "yes" ; then
1986       echo "libiscsi" "Install libiscsi >= 1.9.0"
1987     fi
1988     libiscsi="no"
1989   fi
1990 fi
1991 print_config "iscsi engine" "$libiscsi"
1992
1993 ##########################################
1994 # Check if we have lex/yacc available
1995 yacc="no"
1996 yacc_is_bison="no"
1997 lex="no"
1998 arith="no"
1999 if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
2000 if test "$targetos" != "SunOS" ; then
2001 LEX=$(which lex 2> /dev/null)
2002 if test -x "$LEX" ; then
2003   lex="yes"
2004 fi
2005 YACC=$(which bison 2> /dev/null)
2006 if test -x "$YACC" ; then
2007   yacc="yes"
2008   yacc_is_bison="yes"
2009 else
2010   YACC=$(which yacc 2> /dev/null)
2011   if test -x "$YACC" ; then
2012     yacc="yes"
2013   fi
2014 fi
2015 if test "$yacc" = "yes" && test "$lex" = "yes" ; then
2016   arith="yes"
2017 fi
2018
2019 if test "$arith" = "yes" ; then
2020 cat > $TMPC << EOF
2021 extern int yywrap(void);
2022
2023 int main(int argc, char **argv)
2024 {
2025   yywrap();
2026   return 0;
2027 }
2028 EOF
2029 if compile_prog "" "-ll" "lex"; then
2030   LIBS="-ll $LIBS"
2031 else
2032   arith="no"
2033 fi
2034 fi
2035 fi
2036 fi
2037
2038 # Check if lex fails using -o
2039 if test "$arith" = "yes" ; then
2040 if test "$force_no_lex_o" = "yes" ; then
2041   lex_use_o="no"
2042 else
2043 $LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
2044 if test "$?" = "0" ; then
2045   lex_use_o="yes"
2046 else
2047   lex_use_o="no"
2048 fi
2049 fi
2050 fi
2051
2052 print_config "lex/yacc for arithmetic" "$arith"
2053
2054 ##########################################
2055 # Check whether we have setmntent/getmntent
2056 if test "$getmntent" != "yes" ; then
2057   getmntent="no"
2058 fi
2059 cat > $TMPC << EOF
2060 #include <stdio.h>
2061 #include <mntent.h>
2062 int main(int argc, char **argv)
2063 {
2064   FILE *mtab = setmntent(NULL, "r");
2065   struct mntent *mnt = getmntent(mtab);
2066   endmntent(mtab);
2067   return 0;
2068 }
2069 EOF
2070 if compile_prog "" "" "getmntent"; then
2071   getmntent="yes"
2072 fi
2073 print_config "getmntent" "$getmntent"
2074
2075 ##########################################
2076 # Check whether we have getmntinfo
2077 # These are originally added for BSDs, but may also work
2078 # on other operating systems with getmntinfo(3).
2079
2080 # getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
2081 # Note that NetBSD needs -Werror to catch warning as error.
2082 if test "$getmntinfo" != "yes" ; then
2083   getmntinfo="no"
2084 fi
2085 cat > $TMPC << EOF
2086 #include <stdio.h>
2087 #include <sys/param.h>
2088 #include <sys/mount.h>
2089 int main(int argc, char **argv)
2090 {
2091   struct statfs *st;
2092   return getmntinfo(&st, MNT_NOWAIT);
2093 }
2094 EOF
2095 if compile_prog "-Werror" "" "getmntinfo"; then
2096   getmntinfo="yes"
2097 fi
2098 print_config "getmntinfo" "$getmntinfo"
2099
2100 # getmntinfo(3) for NetBSD.
2101 if test "$getmntinfo_statvfs" != "yes" ; then
2102   getmntinfo_statvfs="no"
2103 fi
2104 cat > $TMPC << EOF
2105 #include <stdio.h>
2106 #include <sys/statvfs.h>
2107 int main(int argc, char **argv)
2108 {
2109   struct statvfs *st;
2110   return getmntinfo(&st, MNT_NOWAIT);
2111 }
2112 EOF
2113 # Skip the test if the one with statfs arg is detected.
2114 if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
2115   getmntinfo_statvfs="yes"
2116   print_config "getmntinfo_statvfs" "$getmntinfo_statvfs"
2117 fi
2118
2119 ##########################################
2120 # Check whether we have _Static_assert
2121 if test "$static_assert" != "yes" ; then
2122   static_assert="no"
2123 fi
2124 cat > $TMPC << EOF
2125 #include <assert.h>
2126 #include <stdlib.h>
2127 #include <stddef.h>
2128
2129 struct foo {
2130   int a, b;
2131 };
2132
2133 int main(int argc, char **argv)
2134 {
2135   _Static_assert(offsetof(struct foo, a) == 0 , "Check");
2136   return 0 ;
2137 }
2138 EOF
2139 if compile_prog "" "" "static_assert"; then
2140     static_assert="yes"
2141 fi
2142 print_config "Static Assert" "$static_assert"
2143
2144 ##########################################
2145 # Check whether we have bool / stdbool.h
2146 if test "$have_bool" != "yes" ; then
2147   have_bool="no"
2148 fi
2149 cat > $TMPC << EOF
2150 #include <stdbool.h>
2151 int main(int argc, char **argv)
2152 {
2153   bool var = true;
2154   return var != false;
2155 }
2156 EOF
2157 if compile_prog "" "" "bool"; then
2158   have_bool="yes"
2159 fi
2160 print_config "bool" "$have_bool"
2161
2162 ##########################################
2163 # Check whether we have strndup()
2164 strndup="no"
2165 cat > $TMPC << EOF
2166 #include <string.h>
2167 #include <stdlib.h>
2168 int main(int argc, char **argv)
2169 {
2170   char *res = strndup("test string", 8);
2171
2172   free(res);
2173   return 0;
2174 }
2175 EOF
2176 if compile_prog "" "" "strndup"; then
2177   strndup="yes"
2178 fi
2179 print_config "strndup" "$strndup"
2180
2181 ##########################################
2182 # <valgrind/drd.h> probe
2183 # Note: presence of <valgrind/drd.h> implies that <valgrind/valgrind.h> is
2184 # also available but not the other way around.
2185 if test "$valgrind_dev" != "yes" ; then
2186   valgrind_dev="no"
2187 fi
2188 cat > $TMPC << EOF
2189 #include <valgrind/drd.h>
2190 int main(int argc, char **argv)
2191 {
2192   return 0;
2193 }
2194 EOF
2195 if compile_prog "" "" "valgrind_dev"; then
2196   valgrind_dev="yes"
2197 fi
2198 print_config "Valgrind headers" "$valgrind_dev"
2199
2200 ##########################################
2201 # <linux/blkzoned.h> probe
2202 if test "$linux_blkzoned" != "yes" ; then
2203   linux_blkzoned="no"
2204 fi
2205 cat > $TMPC << EOF
2206 #include <linux/blkzoned.h>
2207 int main(int argc, char **argv)
2208 {
2209   return 0;
2210 }
2211 EOF
2212 if compile_prog "" "" "linux_blkzoned"; then
2213   linux_blkzoned="yes"
2214 fi
2215 print_config "Zoned block device support" "$linux_blkzoned"
2216
2217 ##########################################
2218 # check march=armv8-a+crc+crypto
2219 if test "$march_armv8_a_crc_crypto" != "yes" ; then
2220   march_armv8_a_crc_crypto="no"
2221 fi
2222 if test "$cpu" = "arm64" ; then
2223   cat > $TMPC <<EOF
2224 #include <arm_acle.h>
2225 #include <arm_neon.h>
2226 #include <sys/auxv.h>
2227
2228 int main(void)
2229 {
2230   /* Can we also do a runtime probe? */
2231 #if __linux__
2232   return getauxval(AT_HWCAP);
2233 #else
2234 # error "Don't know how to do runtime probe for ARM CRC32c"
2235 #endif
2236 }
2237 EOF
2238   if compile_prog "-march=armv8-a+crc+crypto" "" "ARM CRC32c"; then
2239     march_armv8_a_crc_crypto="yes"
2240     CFLAGS="$CFLAGS -march=armv8-a+crc+crypto"
2241     march_set="yes"
2242   fi
2243 fi
2244 print_config "march_armv8_a_crc_crypto" "$march_armv8_a_crc_crypto"
2245
2246 ##########################################
2247 # cuda probe
2248 if test "$cuda" != "yes" ; then
2249   cuda="no"
2250 fi
2251 cat > $TMPC << EOF
2252 #include <cuda.h>
2253 int main(int argc, char **argv)
2254 {
2255   return cuInit(0);
2256 }
2257 EOF
2258 if test "$enable_cuda" = "yes" && compile_prog "" "-lcuda" "cuda"; then
2259   cuda="yes"
2260   LIBS="-lcuda $LIBS"
2261 fi
2262 print_config "cuda" "$cuda"
2263
2264 ##########################################
2265 # mkdir() probe. mingw apparently has a one-argument mkdir :/
2266 mkdir_two="no"
2267 cat > $TMPC << EOF
2268 #include <sys/stat.h>
2269 #include <sys/types.h>
2270 int main(int argc, char **argv)
2271 {
2272   return mkdir("/tmp/bla", 0600);
2273 }
2274 EOF
2275 if compile_prog "" "" "mkdir(a, b)"; then
2276   mkdir_two="yes"
2277 fi
2278 print_config "mkdir(a, b)" "$mkdir_two"
2279
2280 ##########################################
2281 # check for cc -march=native
2282 build_native="no"
2283 cat > $TMPC << EOF
2284 int main(int argc, char **argv)
2285 {
2286   return 0;
2287 }
2288 EOF
2289 if test "$disable_native" = "no" && test "$disable_opt" != "yes" && \
2290    compile_prog "-march=native" "" "march=native"; then
2291   build_native="yes"
2292 fi
2293 print_config "Build march=native" "$build_native"
2294
2295 ##########################################
2296 # check for -lcunit
2297 if test "$cunit" != "yes" ; then
2298   cunit="no"
2299 fi
2300 cat > $TMPC << EOF
2301 #include <CUnit/CUnit.h>
2302 #include <CUnit/Basic.h>
2303 int main(void)
2304 {
2305   if (CU_initialize_registry() != CUE_SUCCESS)
2306     return CU_get_error();
2307   CU_basic_set_mode(CU_BRM_VERBOSE);
2308   CU_basic_run_tests();
2309   CU_cleanup_registry();
2310   return CU_get_error();
2311 }
2312 EOF
2313 if compile_prog "" "-lcunit" "CUnit"; then
2314   cunit="yes"
2315 fi
2316 print_config "CUnit" "$cunit"
2317
2318 ##########################################
2319 # check for __kernel_rwf_t
2320 __kernel_rwf_t="no"
2321 cat > $TMPC << EOF
2322 #include <linux/fs.h>
2323 int main(int argc, char **argv)
2324 {
2325   __kernel_rwf_t x;
2326   x = 0;
2327   return x;
2328 }
2329 EOF
2330 if compile_prog "" "" "__kernel_rwf_t"; then
2331   __kernel_rwf_t="yes"
2332 fi
2333 print_config "__kernel_rwf_t" "$__kernel_rwf_t"
2334
2335 ##########################################
2336 # check if gcc has -Wimplicit-fallthrough
2337 fallthrough="no"
2338 cat > $TMPC << EOF
2339 int main(int argc, char **argv)
2340 {
2341   return 0;
2342 }
2343 EOF
2344 if compile_prog "-Wimplicit-fallthrough" "" "-Wimplicit-fallthrough"; then
2345   fallthrough="yes"
2346 fi
2347 print_config "-Wimplicit-fallthrough" "$fallthrough"
2348
2349 ##########################################
2350 # check for MADV_HUGEPAGE support
2351 if test "$thp" != "yes" ; then
2352   thp="no"
2353 fi
2354 if test "$esx" != "yes" ; then
2355   cat > $TMPC <<EOF
2356 #include <sys/mman.h>
2357 int main(void)
2358 {
2359   return madvise(0, 0x1000, MADV_HUGEPAGE);
2360 }
2361 EOF
2362   if compile_prog "" "" "thp" ; then
2363     thp=yes
2364   else
2365     if test "$thp" = "yes" ; then
2366       feature_not_found "Transparent Huge Page" ""
2367     fi
2368     thp=no
2369   fi
2370 fi
2371 print_config "MADV_HUGEPAGE" "$thp"
2372
2373 #############################################################################
2374
2375 if test "$wordsize" = "64" ; then
2376   output_sym "CONFIG_64BIT"
2377 elif test "$wordsize" = "32" ; then
2378   output_sym "CONFIG_32BIT"
2379 else
2380   fatal "Unknown wordsize!"
2381 fi
2382 if test "$bigendian" = "yes" ; then
2383   output_sym "CONFIG_BIG_ENDIAN"
2384 else
2385   output_sym "CONFIG_LITTLE_ENDIAN"
2386 fi
2387 if test "$zlib" = "yes" ; then
2388   output_sym "CONFIG_ZLIB"
2389 fi
2390 if test "$libaio" = "yes" ; then
2391   output_sym "CONFIG_LIBAIO"
2392 fi
2393 if test "$posix_aio" = "yes" ; then
2394   output_sym "CONFIG_POSIXAIO"
2395 fi
2396 if test "$posix_aio_fsync" = "yes" ; then
2397   output_sym "CONFIG_POSIXAIO_FSYNC"
2398 fi
2399 if test "$posix_pshared" = "yes" ; then
2400   output_sym "CONFIG_PSHARED"
2401 fi
2402 if test "$have_asprintf" = "yes" ; then
2403     output_sym "CONFIG_HAVE_ASPRINTF"
2404 fi
2405 if test "$have_vasprintf" = "yes" ; then
2406     output_sym "CONFIG_HAVE_VASPRINTF"
2407 fi
2408 if test "$linux_fallocate" = "yes" ; then
2409   output_sym "CONFIG_LINUX_FALLOCATE"
2410 fi
2411 if test "$posix_fallocate" = "yes" ; then
2412   output_sym "CONFIG_POSIX_FALLOCATE"
2413 fi
2414 if test "$fdatasync" = "yes" ; then
2415   output_sym "CONFIG_FDATASYNC"
2416 fi
2417 if test "$sync_file_range" = "yes" ; then
2418   output_sym "CONFIG_SYNC_FILE_RANGE"
2419 fi
2420 if test "$sfaa" = "yes" ; then
2421   output_sym "CONFIG_SFAA"
2422 fi
2423 if test "$sync_sync" = "yes" ; then
2424   output_sym "CONFIG_SYNC_SYNC"
2425 fi
2426 if test "$cmp_swap" = "yes" ; then
2427   output_sym "CONFIG_CMP_SWAP"
2428 fi
2429 if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
2430   output_sym "CONFIG_RDMA"
2431 fi
2432 if test "$clock_gettime" = "yes" ; then
2433   output_sym "CONFIG_CLOCK_GETTIME"
2434 fi
2435 if test "$clock_monotonic" = "yes" ; then
2436   output_sym "CONFIG_CLOCK_MONOTONIC"
2437 fi
2438 if test "$clock_monotonic_raw" = "yes" ; then
2439   output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
2440 fi
2441 if test "$clock_monotonic_precise" = "yes" ; then
2442   output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
2443 fi
2444 if test "$clockid_t" = "yes"; then
2445   output_sym "CONFIG_CLOCKID_T"
2446 fi
2447 if test "$gettimeofday" = "yes" ; then
2448   output_sym "CONFIG_GETTIMEOFDAY"
2449 fi
2450 if test "$posix_fadvise" = "yes" ; then
2451   output_sym "CONFIG_POSIX_FADVISE"
2452 fi
2453 if test "$linux_3arg_affinity" = "yes" ; then
2454   output_sym "CONFIG_3ARG_AFFINITY"
2455 elif test "$linux_2arg_affinity" = "yes" ; then
2456   output_sym "CONFIG_2ARG_AFFINITY"
2457 fi
2458 if test "$strsep" = "yes" ; then
2459   output_sym "CONFIG_STRSEP"
2460 fi
2461 if test "$strcasestr" = "yes" ; then
2462   output_sym "CONFIG_STRCASESTR"
2463 fi
2464 if test "$strlcat" = "yes" ; then
2465   output_sym "CONFIG_STRLCAT"
2466 fi
2467 if test "$getopt_long_only" = "yes" ; then
2468   output_sym "CONFIG_GETOPT_LONG_ONLY"
2469 fi
2470 if test "$inet_aton" = "yes" ; then
2471   output_sym "CONFIG_INET_ATON"
2472 fi
2473 if test "$socklen_t" = "yes" ; then
2474   output_sym "CONFIG_SOCKLEN_T"
2475 fi
2476 if test "$ext4_me" = "yes" ; then
2477   output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
2478 fi
2479 if test "$linux_splice" = "yes" ; then
2480   output_sym "CONFIG_LINUX_SPLICE"
2481 fi
2482 if test "$guasi" = "yes" ; then
2483   output_sym "CONFIG_GUASI"
2484 fi
2485 if test "$libnuma_v2" = "yes" ; then
2486   output_sym "CONFIG_LIBNUMA"
2487 fi
2488 if test "$solaris_aio" = "yes" ; then
2489   output_sym "CONFIG_SOLARISAIO"
2490 fi
2491 if test "$tls_thread" = "yes" ; then
2492   output_sym "CONFIG_TLS_THREAD"
2493 fi
2494 if test "$rusage_thread" = "yes" ; then
2495   output_sym "CONFIG_RUSAGE_THREAD"
2496 fi
2497 if test "$gfio" = "yes" ; then
2498   output_sym "CONFIG_GFIO"
2499 fi
2500 if test "$esx" = "yes" ; then
2501   output_sym "CONFIG_ESX"
2502   output_sym "CONFIG_NO_SHM"
2503 fi
2504 if test "$sched_idle" = "yes" ; then
2505   output_sym "CONFIG_SCHED_IDLE"
2506 fi
2507 if test "$tcp_nodelay" = "yes" ; then
2508   output_sym "CONFIG_TCP_NODELAY"
2509 fi
2510 if test "$window_size" = "yes" ; then
2511   output_sym "CONFIG_NET_WINDOWSIZE"
2512 fi
2513 if test "$mss" = "yes" ; then
2514   output_sym "CONFIG_NET_MSS"
2515 fi
2516 if test "$rlimit_memlock" = "yes" ; then
2517   output_sym "CONFIG_RLIMIT_MEMLOCK"
2518 fi
2519 if test "$pwritev" = "yes" ; then
2520   output_sym "CONFIG_PWRITEV"
2521 fi
2522 if test "$pwritev2" = "yes" ; then
2523   output_sym "CONFIG_PWRITEV2"
2524 fi
2525 if test "$ipv6" = "yes" ; then
2526   output_sym "CONFIG_IPV6"
2527 fi
2528 if test "$http" = "yes" ; then
2529   output_sym "CONFIG_HTTP"
2530 fi
2531 if test "$rados" = "yes" ; then
2532   output_sym "CONFIG_RADOS"
2533 fi
2534 if test "$rbd" = "yes" ; then
2535   output_sym "CONFIG_RBD"
2536 fi
2537 if test "$rbd_poll" = "yes" ; then
2538   output_sym "CONFIG_RBD_POLL"
2539 fi
2540 if test "$rbd_inval" = "yes" ; then
2541   output_sym "CONFIG_RBD_INVAL"
2542 fi
2543 if test "$setvbuf" = "yes" ; then
2544   output_sym "CONFIG_SETVBUF"
2545 fi
2546 if test "$s390_z196_facilities" = "yes" ; then
2547   output_sym "CONFIG_S390_Z196_FACILITIES"
2548   CFLAGS="$CFLAGS -march=z9-109"
2549   march_set="yes"
2550 fi
2551 if test "$gfapi" = "yes" ; then
2552   output_sym "CONFIG_GFAPI"
2553 fi
2554 if test "$gf_fadvise" = "yes" ; then
2555   output_sym "CONFIG_GF_FADVISE"
2556 fi
2557 if test "$gf_trim" = "yes" ; then
2558   output_sym "CONFIG_GF_TRIM"
2559 fi
2560 if test "$libhdfs" = "yes" ; then
2561   output_sym "CONFIG_LIBHDFS"
2562   echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
2563   echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
2564   echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
2565   echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
2566 fi
2567 if test "$mtd" = "yes" ; then
2568   output_sym "CONFIG_MTD"
2569 fi
2570 if test "$pmemblk" = "yes" ; then
2571   output_sym "CONFIG_PMEMBLK"
2572 fi
2573 if test "$devdax" = "yes" ; then
2574   output_sym "CONFIG_LINUX_DEVDAX"
2575 fi
2576 if test "$pmem" = "yes" ; then
2577   output_sym "CONFIG_LIBPMEM"
2578 fi
2579 if test "$libime" = "yes" ; then
2580   output_sym "CONFIG_IME"
2581 fi
2582 if test "$arith" = "yes" ; then
2583   output_sym "CONFIG_ARITHMETIC"
2584   if test "$yacc_is_bison" = "yes" ; then
2585     echo "YACC=$YACC -y" >> $config_host_mak
2586   else
2587     echo "YACC=$YACC" >> $config_host_mak
2588   fi
2589   if test "$lex_use_o" = "yes" ; then
2590     echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
2591   fi
2592 fi
2593 if test "$getmntent" = "yes" ; then
2594   output_sym "CONFIG_GETMNTENT"
2595 fi
2596 if test "$getmntinfo" = "yes" ; then
2597   output_sym "CONFIG_GETMNTINFO"
2598 fi
2599 if test "$getmntinfo_statvfs" = "yes" ; then
2600   output_sym "CONFIG_GETMNTINFO_STATVFS"
2601 fi
2602 if test "$static_assert" = "yes" ; then
2603   output_sym "CONFIG_STATIC_ASSERT"
2604 fi
2605 if test "$have_bool" = "yes" ; then
2606   output_sym "CONFIG_HAVE_BOOL"
2607 fi
2608 if test "$strndup" = "yes" ; then
2609   output_sym "CONFIG_HAVE_STRNDUP"
2610 fi
2611 if test "$disable_opt" = "yes" ; then
2612   output_sym "CONFIG_DISABLE_OPTIMIZATIONS"
2613 fi
2614 if test "$valgrind_dev" = "yes"; then
2615   output_sym "CONFIG_VALGRIND_DEV"
2616 fi
2617 if test "$linux_blkzoned" = "yes" ; then
2618   output_sym "CONFIG_LINUX_BLKZONED"
2619 fi
2620 if test "$zlib" = "no" ; then
2621   echo "Consider installing zlib-dev (zlib-devel, some fio features depend on it."
2622   if test "$build_static" = "yes"; then
2623     echo "Note that some distros have separate packages for static libraries."
2624   fi
2625 fi
2626 if test "$march_armv8_a_crc_crypto" = "yes" ; then
2627   output_sym "ARCH_HAVE_CRC_CRYPTO"
2628 fi
2629 if test "$cuda" = "yes" ; then
2630   output_sym "CONFIG_CUDA"
2631 fi
2632 if test "$mkdir_two" = "yes" ; then
2633   output_sym "CONFIG_HAVE_MKDIR_TWO"
2634 fi
2635 if test "$march_set" = "no" && test "$build_native" = "yes" ; then
2636   output_sym "CONFIG_BUILD_NATIVE"
2637 fi
2638 if test "$cunit" = "yes" ; then
2639   output_sym "CONFIG_HAVE_CUNIT"
2640 fi
2641 if test "$__kernel_rwf_t" = "yes"; then
2642   output_sym "CONFIG_HAVE_KERNEL_RWF_T"
2643 fi
2644 if test "$fallthrough" = "yes"; then
2645   CFLAGS="$CFLAGS -Wimplicit-fallthrough"
2646 fi
2647 if test "$thp" = "yes" ; then
2648   output_sym "CONFIG_HAVE_THP"
2649 fi
2650 if test "$libiscsi" = "yes" ; then
2651   output_sym "CONFIG_LIBISCSI"
2652   echo "CONFIG_LIBISCSI=m" >> $config_host_mak
2653   echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
2654   echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
2655 fi
2656
2657 echo "LIBS+=$LIBS" >> $config_host_mak
2658 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
2659 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
2660 echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
2661 echo "CC=$cc" >> $config_host_mak
2662 echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
2663 echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
2664
2665 if [ `dirname $0` != "." -a ! -e Makefile ]; then
2666     cat > Makefile <<EOF
2667 SRCDIR:=`dirname $0`
2668 include \$(SRCDIR)/Makefile
2669 EOF
2670 fi