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