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