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