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