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