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