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