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