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