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