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