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