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