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