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