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