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