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