Make sure that assert() expressions do not have side effects
[fio.git] / configure
1 #!/bin/sh
2 #
3 # Fio configure script. Heavily influenced by the manual qemu configure
4 # script. Sad 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 # Print result for each configuration test
41 print_config() {
42   printf "%-30s%s\n" "$1" "$2"
43 }
44
45 # Default CFLAGS
46 CFLAGS="-D_GNU_SOURCE -include config-host.h"
47 BUILD_CFLAGS=""
48
49 # Print a helpful header at the top of config.log
50 echo "# FIO configure log $(date)" >> config.log
51 printf "# Configured with:" >> config.log
52 printf " '%s'" "$0" "$@" >> config.log
53 echo >> config.log
54 echo "#" >> config.log
55
56 # Print configure header at the top of $config_host_h
57 echo "/*" > $config_host_h
58 echo " * Automatically generated by configure - do not modify" >> $config_host_h
59 printf " * Configured with:" >> $config_host_h
60 printf " * '%s'" "$0" "$@" >> $config_host_h
61 echo "" >> $config_host_h
62 echo " */" >> $config_host_h
63
64 do_cc() {
65     # Run the compiler, capturing its output to the log.
66     echo $cc "$@" >> config.log
67     $cc "$@" >> config.log 2>&1 || return $?
68     # Test passed. If this is an --enable-werror build, rerun
69     # the test with -Werror and bail out if it fails. This
70     # makes warning-generating-errors in configure test code
71     # obvious to developers.
72     if test "$werror" != "yes"; then
73         return 0
74     fi
75     # Don't bother rerunning the compile if we were already using -Werror
76     case "$*" in
77         *-Werror*)
78            return 0
79         ;;
80     esac
81     echo $cc -Werror "$@" >> config.log
82     $cc -Werror "$@" >> config.log 2>&1 && return $?
83     echo "ERROR: configure test passed without -Werror but failed with -Werror."
84     echo "This is probably a bug in the configure script. The failing command"
85     echo "will be at the bottom of config.log."
86     fatal "You can run configure with --disable-werror to bypass this check."
87 }
88
89 compile_object() {
90   do_cc $CFLAGS -c -o $TMPO $TMPC
91 }
92
93 compile_prog() {
94   local_cflags="$1"
95   local_ldflags="$2 $LIBS"
96   echo "Compiling test case $3" >> config.log
97   do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
98 }
99
100 feature_not_found() {
101   feature=$1
102   packages=$2
103
104   echo "ERROR"
105   echo "ERROR: User requested feature $feature"
106   if test ! -z "$packages" ; then
107     echo "ERROR: That feature needs $packages installed"
108   fi
109   echo "ERROR: configure was not able to find it"
110   fatal "ERROR"
111 }
112
113 has() {
114   type "$1" >/dev/null 2>&1
115 }
116
117 check_define() {
118   cat > $TMPC <<EOF
119 #if !defined($1)
120 #error $1 not defined
121 #endif
122 int main(void)
123 {
124   return 0;
125 }
126 EOF
127   compile_object
128 }
129
130 output_sym() {
131   echo "$1=y" >> $config_host_mak
132   echo "#define $1" >> $config_host_h
133 }
134
135 targetos=""
136 cpu=""
137
138 # default options
139 show_help="no"
140 exit_val=0
141 gfio_check="no"
142 libhdfs="no"
143 pmemblk="no"
144 devdax="no"
145 pmem="no"
146 disable_lex=""
147 disable_pmem="no"
148 disable_native="no"
149 march_set="no"
150 prefix=/usr/local
151
152 # parse options
153 for opt do
154   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
155   case "$opt" in
156   --prefix=*) prefix="$optarg"
157   ;;
158   --cpu=*) cpu="$optarg"
159   ;;
160   #  esx is cross compiled and cannot be detect through simple uname calls
161   --esx)
162   esx="yes"
163   ;;
164   --cc=*) CC="$optarg"
165   ;;
166   --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
167   ;;
168   --build-32bit-win) build_32bit_win="yes"
169   ;;
170   --build-static) build_static="yes"
171   ;;
172   --enable-gfio) gfio_check="yes"
173   ;;
174   --disable-numa) disable_numa="yes"
175   ;;
176   --disable-rdma) disable_rdma="yes"
177   ;;
178   --disable-rados) disable_rados="yes"
179   ;;
180   --disable-rbd) disable_rbd="yes"
181   ;;
182   --disable-gfapi) disable_gfapi="yes"
183   ;;
184   --enable-libhdfs) libhdfs="yes"
185   ;;
186   --disable-lex) disable_lex="yes"
187   ;;
188   --enable-lex) disable_lex="no"
189   ;;
190   --disable-shm) no_shm="yes"
191   ;;
192   --disable-optimizations) disable_opt="yes"
193   ;;
194   --disable-pmem) disable_pmem="yes"
195   ;;
196   --enable-cuda) enable_cuda="yes"
197   ;;
198   --disable-native) disable_native="yes"
199   ;;
200   --help)
201     show_help="yes"
202     ;;
203   *)
204   echo "Bad option $opt"
205   show_help="yes"
206   exit_val=1
207   esac
208 done
209
210 if test "$show_help" = "yes" ; then
211   echo "--prefix=               Use this directory as installation prefix"
212   echo "--cpu=                  Specify target CPU if auto-detect fails"
213   echo "--cc=                   Specify compiler to use"
214   echo "--extra-cflags=         Specify extra CFLAGS to pass to compiler"
215   echo "--build-32bit-win       Enable 32-bit build on Windows"
216   echo "--build-static          Build a static fio"
217   echo "--esx                   Configure build options for esx"
218   echo "--enable-gfio           Enable building of gtk gfio"
219   echo "--disable-numa          Disable libnuma even if found"
220   echo "--disable-rdma          Disable RDMA support even if found"
221   echo "--disable-gfapi         Disable gfapi"
222   echo "--enable-libhdfs        Enable hdfs support"
223   echo "--disable-lex           Disable use of lex/yacc for math"
224   echo "--disable-pmem          Disable pmem based engines even if found"
225   echo "--enable-lex            Enable use of lex/yacc for math"
226   echo "--disable-shm           Disable SHM support"
227   echo "--disable-optimizations Don't enable compiler optimizations"
228   echo "--enable-cuda           Enable GPUDirect RDMA support"
229   echo "--disable-native        Don't build for native host"
230   exit $exit_val
231 fi
232
233 cross_prefix=${cross_prefix-${CROSS_COMPILE}}
234 # Preferred compiler (can be overriden later after we know the platform):
235 #  ${CC} (if set)
236 #  ${cross_prefix}gcc (if cross-prefix specified)
237 #  gcc if available
238 #  clang if available
239 if test -z "${CC}${cross_prefix}"; then
240   if has gcc; then
241     cc=gcc
242   elif has clang; then
243     cc=clang
244   fi
245 else
246   cc="${CC-${cross_prefix}gcc}"
247 fi
248
249 if check_define __ANDROID__ ; then
250   targetos="Android"
251 elif check_define __linux__ ; then
252   targetos="Linux"
253 elif check_define __OpenBSD__ ; then
254   targetos='OpenBSD'
255 elif check_define __NetBSD__ ; then
256   targetos='NetBSD'
257 elif check_define __sun__ ; then
258   targetos='SunOS'
259   CFLAGS="$CFLAGS -D_REENTRANT"
260 elif check_define _WIN32 ; then
261   targetos='CYGWIN'
262 else
263   targetos=`uname -s`
264 fi
265
266 echo "# Automatically generated by configure - do not modify" > $config_host_mak
267 printf "# Configured with:" >> $config_host_mak
268 printf " '%s'" "$0" "$@" >> $config_host_mak
269 echo >> $config_host_mak
270 echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
271
272 if test "$no_shm" = "yes" ; then
273   output_sym "CONFIG_NO_SHM"
274 fi
275
276 if test "$disable_opt" = "yes" ; then
277   output_sym "CONFIG_FIO_NO_OPT"
278 fi
279
280 # Some host OSes need non-standard checks for which CPU to use.
281 # Note that these checks are broken for cross-compilation: if you're
282 # cross-compiling to one of these OSes then you'll need to specify
283 # the correct CPU with the --cpu option.
284 case $targetos in
285 AIX|OpenBSD|NetBSD)
286   # Unless explicitly enabled, turn off lex.
287   # OpenBSD will hit syntax error when enabled.
288   if test -z "$disable_lex" ; then
289     disable_lex="yes"
290   else
291     force_no_lex_o="yes"
292   fi
293   ;;
294 Darwin)
295   # on Leopard most of the system is 32-bit, so we have to ask the kernel if
296   # we can run 64-bit userspace code.
297   # If the user didn't specify a CPU explicitly and the kernel says this is
298   # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
299   # detection code.
300   if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
301     cpu="x86_64"
302   fi
303   # Error at compile time linking of weak/partial symbols if possible...
304 cat > $TMPC <<EOF
305 int main(void)
306 {
307   return 0;
308 }
309 EOF
310   if compile_prog "" "-Wl,-no_weak_imports" "disable weak symbols"; then
311     echo "Disabling weak symbols"
312     LDFLAGS="$LDFLAGS -Wl,-no_weak_imports"
313   fi
314   ;;
315 SunOS)
316   # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
317   if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
318     cpu="x86_64"
319   fi
320   LIBS="-lnsl -lsocket"
321   ;;
322 CYGWIN*)
323   # We still force some options, so keep this message here.
324   echo "Forcing some known good options on Windows"
325   if test -z "${CC}${cross_prefix}"; then
326     if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
327       cc="i686-w64-mingw32-gcc"
328     else
329       cc="x86_64-w64-mingw32-gcc"
330     fi
331   fi
332   if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
333     output_sym "CONFIG_32BIT"
334   else
335     output_sym "CONFIG_64BIT_LLP64"
336   fi
337   # We need this to be output_sym'd here because this is Windows specific.
338   # The regular configure path never sets this config.
339   output_sym "CONFIG_WINDOWSAIO"
340   # We now take the regular configuration path without having exit 0 here.
341   # Flags below are still necessary mostly for MinGW.
342   socklen_t="yes"
343   sfaa="yes"
344   sync_sync="yes"
345   cmp_swap="yes"
346   rusage_thread="yes"
347   fdatasync="yes"
348   clock_gettime="yes" # clock_monotonic probe has dependency on this
349   clock_monotonic="yes"
350   gettimeofday="yes"
351   sched_idle="yes"
352   tcp_nodelay="yes"
353   tls_thread="yes"
354   static_assert="yes"
355   ipv6="yes"
356   mkdir_two="no"
357   echo "BUILD_CFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
358   ;;
359 esac
360
361 # Now we know the target platform we can have another guess at the preferred
362 # compiler when it wasn't explictly set
363 if test -z "${CC}${cross_prefix}"; then
364   if test "$targetos" = "FreeBSD" || test "$targetos" = "Darwin"; then
365     if has clang; then
366       cc=clang
367     fi
368   fi
369 fi
370 if test -z "$cc"; then
371     echo "configure: failed to find compiler"
372     exit 1
373 fi
374
375 if test ! -z "$cpu" ; then
376   # command line argument
377   :
378 elif check_define __i386__ ; then
379   cpu="i386"
380 elif check_define __x86_64__ ; then
381   cpu="x86_64"
382 elif check_define __sparc__ ; then
383   if check_define __arch64__ ; then
384     cpu="sparc64"
385   else
386     cpu="sparc"
387   fi
388 elif check_define _ARCH_PPC ; then
389   if check_define _ARCH_PPC64 ; then
390     cpu="ppc64"
391   else
392     cpu="ppc"
393   fi
394 elif check_define __mips__ ; then
395   cpu="mips"
396 elif check_define __ia64__ ; then
397   cpu="ia64"
398 elif check_define __s390__ ; then
399   if check_define __s390x__ ; then
400     cpu="s390x"
401   else
402     cpu="s390"
403   fi
404 elif check_define __arm__ ; then
405   cpu="arm"
406 elif check_define __aarch64__ ; then
407   cpu="aarch64"
408 elif check_define __hppa__ ; then
409   cpu="hppa"
410 else
411   cpu=`uname -m`
412 fi
413
414 # Normalise host CPU name and set ARCH.
415 case "$cpu" in
416   ia64|ppc|ppc64|s390|s390x|sparc64)
417     cpu="$cpu"
418   ;;
419   i386|i486|i586|i686|i86pc|BePC)
420     cpu="x86"
421   ;;
422   x86_64|amd64)
423     cpu="x86_64"
424   ;;
425   armv*b|armv*l|arm)
426     cpu="arm"
427   ;;
428   aarch64)
429     cpu="arm64"
430   ;;
431   hppa|parisc|parisc64)
432     cpu="hppa"
433   ;;
434   mips*)
435     cpu="mips"
436   ;;
437   sparc|sun4[cdmuv])
438     cpu="sparc"
439   ;;
440   *)
441   echo "Unknown CPU"
442   ;;
443 esac
444
445 ##########################################
446 # check cross compile
447
448 if test "$cross_compile" != "yes" ; then
449   cross_compile="no"
450 fi
451 cat > $TMPC <<EOF
452 int main(void)
453 {
454   return 0;
455 }
456 EOF
457 if compile_prog "" "" "cross"; then
458   $TMPE 2>/dev/null || cross_compile="yes"
459 else
460   fatal "compile test failed"
461 fi
462
463 ##########################################
464 # check endianness
465 if test "$bigendian" != "yes" ; then
466   bigendian="no"
467 fi
468 if test "$cross_compile" = "no" ; then
469   cat > $TMPC <<EOF
470 #include <inttypes.h>
471 int main(void)
472 {
473   volatile uint32_t i=0x01234567;
474   return (*((uint8_t*)(&i))) == 0x67;
475 }
476 EOF
477   if compile_prog "" "" "endian"; then
478     $TMPE && bigendian="yes"
479   fi
480 else
481   # If we're cross compiling, try our best to work it out and rely on the
482   # run-time check to fail if we get it wrong.
483   cat > $TMPC <<EOF
484 #include <endian.h>
485 int main(void)
486 {
487 #if __BYTE_ORDER != __BIG_ENDIAN
488 # error "Unknown endianness"
489 #endif
490 }
491 EOF
492   compile_prog "" "" "endian" && bigendian="yes"
493   check_define "__ARMEB__" && bigendian="yes"
494   check_define "__MIPSEB__" && bigendian="yes"
495 fi
496
497
498 print_config "Operating system" "$targetos"
499 print_config "CPU" "$cpu"
500 print_config "Big endian" "$bigendian"
501 print_config "Compiler" "$cc"
502 print_config "Cross compile" "$cross_compile"
503 echo
504
505 ##########################################
506 # See if we need to build a static build
507 if test "$build_static" = "yes" ; then
508   CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
509   LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
510 else
511   build_static="no"
512 fi
513 print_config "Static build" "$build_static"
514
515 ##########################################
516 # check for wordsize
517 wordsize="0"
518 cat > $TMPC <<EOF
519 #include <limits.h>
520 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
521 int main(void)
522 {
523   BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
524   return 0;
525 }
526 EOF
527 if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
528   wordsize="32"
529 elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
530   wordsize="64"
531 else
532   fatal "Unknown wordsize"
533 fi
534 print_config "Wordsize" "$wordsize"
535
536 ##########################################
537 # zlib probe
538 if test "$zlib" != "yes" ; then
539   zlib="no"
540 fi
541 cat > $TMPC <<EOF
542 #include <zlib.h>
543 int main(void)
544 {
545   z_stream stream;
546   if (inflateInit(&stream) != Z_OK)
547     return 1;
548   return 0;
549 }
550 EOF
551 if compile_prog "" "-lz" "zlib" ; then
552   zlib=yes
553   LIBS="-lz $LIBS"
554 fi
555 print_config "zlib" "$zlib"
556
557 ##########################################
558 # linux-aio probe
559 if test "$libaio" != "yes" ; then
560   libaio="no"
561 fi
562 if test "$esx" != "yes" ; then
563   cat > $TMPC <<EOF
564 #include <libaio.h>
565 #include <stddef.h>
566 int main(void)
567 {
568   io_setup(0, NULL);
569   return 0;
570 }
571 EOF
572   if compile_prog "" "-laio" "libaio" ; then
573     libaio=yes
574     LIBS="-laio $LIBS"
575   else
576     if test "$libaio" = "yes" ; then
577       feature_not_found "linux AIO" "libaio-dev or libaio-devel"
578     fi
579     libaio=no
580   fi
581 fi
582 print_config "Linux AIO support" "$libaio"
583
584 ##########################################
585 # posix aio probe
586 if test "$posix_aio" != "yes" ; then
587   posix_aio="no"
588 fi
589 if test "$posix_aio_lrt" != "yes" ; then
590   posix_aio_lrt="no"
591 fi
592 cat > $TMPC <<EOF
593 #include <aio.h>
594 int main(void)
595 {
596   struct aiocb cb;
597   aio_read(&cb);
598   return 0;
599 }
600 EOF
601 if compile_prog "" "" "posixaio" ; then
602   posix_aio="yes"
603 elif compile_prog "" "-lrt" "posixaio"; then
604   posix_aio="yes"
605   posix_aio_lrt="yes"
606   LIBS="-lrt $LIBS"
607 fi
608 print_config "POSIX AIO support" "$posix_aio"
609 print_config "POSIX AIO support needs -lrt" "$posix_aio_lrt"
610
611 ##########################################
612 # posix aio fsync probe
613 if test "$posix_aio_fsync" != "yes" ; then
614   posix_aio_fsync="no"
615 fi
616 if test "$posix_aio" = "yes" ; then
617   cat > $TMPC <<EOF
618 #include <fcntl.h>
619 #include <aio.h>
620 int main(void)
621 {
622   struct aiocb cb;
623   return aio_fsync(O_SYNC, &cb);
624   return 0;
625 }
626 EOF
627   if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
628     posix_aio_fsync=yes
629   fi
630 fi
631 print_config "POSIX AIO fsync" "$posix_aio_fsync"
632
633 ##########################################
634 # POSIX pshared attribute probe
635 if test "$posix_pshared" != "yes" ; then
636   posix_pshared="no"
637 fi
638 cat > $TMPC <<EOF
639 #include <unistd.h>
640 int main(void)
641 {
642 #if defined(_POSIX_THREAD_PROCESS_SHARED) && ((_POSIX_THREAD_PROCESS_SHARED + 0) > 0)
643 # if defined(__CYGWIN__)
644 #  error "_POSIX_THREAD_PROCESS_SHARED is buggy on Cygwin"
645 # elif defined(__APPLE__)
646 #  include <AvailabilityMacros.h>
647 #  include <TargetConditionals.h>
648 #  if TARGET_OS_MAC && MAC_OS_X_VERSION_MIN_REQUIRED < 1070
649 #   error "_POSIX_THREAD_PROCESS_SHARED is buggy/unsupported prior to OSX 10.7"
650 #  endif
651 # endif
652 #else
653 # error "_POSIX_THREAD_PROCESS_SHARED is unsupported"
654 #endif
655   return 0;
656 }
657 EOF
658 if compile_prog "" "$LIBS" "posix_pshared" ; then
659   posix_pshared=yes
660 fi
661 print_config "POSIX pshared support" "$posix_pshared"
662
663 ##########################################
664 # solaris aio probe
665 if test "$solaris_aio" != "yes" ; then
666   solaris_aio="no"
667 fi
668 cat > $TMPC <<EOF
669 #include <sys/types.h>
670 #include <sys/asynch.h>
671 #include <unistd.h>
672 int main(void)
673 {
674   aio_result_t res;
675   return aioread(0, NULL, 0, 0, SEEK_SET, &res);
676   return 0;
677 }
678 EOF
679 if compile_prog "" "-laio" "solarisaio" ; then
680   solaris_aio=yes
681   LIBS="-laio $LIBS"
682 fi
683 print_config "Solaris AIO support" "$solaris_aio"
684
685 ##########################################
686 # __sync_fetch_and_add test
687 if test "$sfaa" != "yes" ; then
688   sfaa="no"
689 fi
690 cat > $TMPC << EOF
691 #include <inttypes.h>
692 static int sfaa(uint64_t *ptr)
693 {
694   return __sync_fetch_and_add(ptr, 0);
695 }
696
697 int main(int argc, char **argv)
698 {
699   uint64_t val = 42;
700   sfaa(&val);
701   return val;
702 }
703 EOF
704 if compile_prog "" "" "__sync_fetch_and_add()" ; then
705     sfaa="yes"
706 fi
707 print_config "__sync_fetch_and_add" "$sfaa"
708
709 ##########################################
710 # __sync_synchronize() test
711 if test "$sync_sync" != "yes" ; then
712   sync_sync="no"
713 fi
714 cat > $TMPC << EOF
715 #include <inttypes.h>
716
717 int main(int argc, char **argv)
718 {
719   __sync_synchronize();
720   return 0;
721 }
722 EOF
723 if compile_prog "" "" "__sync_synchronize()" ; then
724     sync_sync="yes"
725 fi
726 print_config "__sync_synchronize" "$sync_sync"
727
728 ##########################################
729 # __sync_val_compare_and_swap() test
730 if test "$cmp_swap" != "yes" ; then
731   cmp_swap="no"
732 fi
733 cat > $TMPC << EOF
734 #include <inttypes.h>
735
736 int main(int argc, char **argv)
737 {
738   int x = 0;
739   return __sync_val_compare_and_swap(&x, 1, 2);
740 }
741 EOF
742 if compile_prog "" "" "__sync_val_compare_and_swap()" ; then
743     cmp_swap="yes"
744 fi
745 print_config "__sync_val_compare_and_swap" "$cmp_swap"
746
747 ##########################################
748 # libverbs probe
749 if test "$libverbs" != "yes" ; then
750   libverbs="no"
751 fi
752 cat > $TMPC << EOF
753 #include <infiniband/verbs.h>
754 int main(int argc, char **argv)
755 {
756   struct ibv_pd *pd = ibv_alloc_pd(NULL);
757   return 0;
758 }
759 EOF
760 if test "$disable_rdma" != "yes" && compile_prog "" "-libverbs" "libverbs" ; then
761     libverbs="yes"
762     LIBS="-libverbs $LIBS"
763 fi
764 print_config "libverbs" "$libverbs"
765
766 ##########################################
767 # rdmacm probe
768 if test "$rdmacm" != "yes" ; then
769   rdmacm="no"
770 fi
771 cat > $TMPC << EOF
772 #include <stdio.h>
773 #include <rdma/rdma_cma.h>
774 int main(int argc, char **argv)
775 {
776   rdma_destroy_qp(NULL);
777   return 0;
778 }
779 EOF
780 if test "$disable_rdma" != "yes" && compile_prog "" "-lrdmacm" "rdma"; then
781     rdmacm="yes"
782     LIBS="-lrdmacm $LIBS"
783 fi
784 print_config "rdmacm" "$rdmacm"
785
786 ##########################################
787 # Linux fallocate probe
788 if test "$linux_fallocate" != "yes" ; then
789   linux_fallocate="no"
790 fi
791 cat > $TMPC << EOF
792 #include <stdio.h>
793 #include <fcntl.h>
794 #include <linux/falloc.h>
795 int main(int argc, char **argv)
796 {
797   int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
798   return r;
799 }
800 EOF
801 if compile_prog "" "" "linux_fallocate"; then
802     linux_fallocate="yes"
803 fi
804 print_config "Linux fallocate" "$linux_fallocate"
805
806 ##########################################
807 # POSIX fadvise probe
808 if test "$posix_fadvise" != "yes" ; then
809   posix_fadvise="no"
810 fi
811 cat > $TMPC << EOF
812 #include <stdio.h>
813 #include <fcntl.h>
814 int main(int argc, char **argv)
815 {
816   int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
817   return r;
818 }
819 EOF
820 if compile_prog "" "" "posix_fadvise"; then
821     posix_fadvise="yes"
822 fi
823 print_config "POSIX fadvise" "$posix_fadvise"
824
825 ##########################################
826 # POSIX fallocate probe
827 if test "$posix_fallocate" != "yes" ; then
828   posix_fallocate="no"
829 fi
830 cat > $TMPC << EOF
831 #include <stdio.h>
832 #include <fcntl.h>
833 int main(int argc, char **argv)
834 {
835   int r = posix_fallocate(0, 0, 1024);
836   return r;
837 }
838 EOF
839 if compile_prog "" "" "posix_fallocate"; then
840     posix_fallocate="yes"
841 fi
842 print_config "POSIX fallocate" "$posix_fallocate"
843
844 ##########################################
845 # sched_set/getaffinity 2 or 3 argument test
846 if test "$linux_2arg_affinity" != "yes" ; then
847   linux_2arg_affinity="no"
848 fi
849 if test "$linux_3arg_affinity" != "yes" ; then
850   linux_3arg_affinity="no"
851 fi
852 cat > $TMPC << EOF
853 #include <sched.h>
854 int main(int argc, char **argv)
855 {
856   cpu_set_t mask;
857   return sched_setaffinity(0, sizeof(mask), &mask);
858 }
859 EOF
860 if compile_prog "" "" "sched_setaffinity(,,)"; then
861   linux_3arg_affinity="yes"
862 else
863   cat > $TMPC << EOF
864 #include <sched.h>
865 int main(int argc, char **argv)
866 {
867   cpu_set_t mask;
868   return sched_setaffinity(0, &mask);
869 }
870 EOF
871   if compile_prog "" "" "sched_setaffinity(,)"; then
872     linux_2arg_affinity="yes"
873   fi
874 fi
875 print_config "sched_setaffinity(3 arg)" "$linux_3arg_affinity"
876 print_config "sched_setaffinity(2 arg)" "$linux_2arg_affinity"
877
878 ##########################################
879 # clock_gettime probe
880 if test "$clock_gettime" != "yes" ; then
881   clock_gettime="no"
882 fi
883 cat > $TMPC << EOF
884 #include <stdio.h>
885 #include <time.h>
886 int main(int argc, char **argv)
887 {
888   return clock_gettime(0, NULL);
889 }
890 EOF
891 if compile_prog "" "" "clock_gettime"; then
892     clock_gettime="yes"
893 elif compile_prog "" "-lrt" "clock_gettime"; then
894     clock_gettime="yes"
895     LIBS="-lrt $LIBS"
896 fi
897 print_config "clock_gettime" "$clock_gettime"
898
899 ##########################################
900 # CLOCK_MONOTONIC probe
901 if test "$clock_monotonic" != "yes" ; then
902   clock_monotonic="no"
903 fi
904 if test "$clock_gettime" = "yes" ; then
905   cat > $TMPC << EOF
906 #include <stdio.h>
907 #include <time.h>
908 int main(int argc, char **argv)
909 {
910   return clock_gettime(CLOCK_MONOTONIC, NULL);
911 }
912 EOF
913   if compile_prog "" "$LIBS" "clock monotonic"; then
914       clock_monotonic="yes"
915   fi
916 fi
917 print_config "CLOCK_MONOTONIC" "$clock_monotonic"
918
919 ##########################################
920 # CLOCK_MONOTONIC_RAW probe
921 if test "$clock_monotonic_raw" != "yes" ; then
922   clock_monotonic_raw="no"
923 fi
924 if test "$clock_gettime" = "yes" ; then
925   cat > $TMPC << EOF
926 #include <stdio.h>
927 #include <time.h>
928 int main(int argc, char **argv)
929 {
930   return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
931 }
932 EOF
933   if compile_prog "" "$LIBS" "clock monotonic"; then
934       clock_monotonic_raw="yes"
935   fi
936 fi
937 print_config "CLOCK_MONOTONIC_RAW" "$clock_monotonic_raw"
938
939 ##########################################
940 # CLOCK_MONOTONIC_PRECISE probe
941 if test "$clock_monotonic_precise" != "yes" ; then
942   clock_monotonic_precise="no"
943 fi
944 if test "$clock_gettime" = "yes" ; then
945   cat > $TMPC << EOF
946 #include <stdio.h>
947 #include <time.h>
948 int main(int argc, char **argv)
949 {
950   return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
951 }
952 EOF
953   if compile_prog "" "$LIBS" "clock monotonic precise"; then
954       clock_monotonic_precise="yes"
955   fi
956 fi
957 print_config "CLOCK_MONOTONIC_PRECISE" "$clock_monotonic_precise"
958
959 ##########################################
960 # clockid_t probe
961 if test "$clockid_t" != "yes" ; then
962   clockid_t="no"
963 fi
964 cat > $TMPC << EOF
965 #include <time.h>
966 #include <string.h>
967 int main(int argc, char **argv)
968 {
969   volatile clockid_t cid;
970   memset((void*)&cid, 0, sizeof(cid));
971   return 0;
972 }
973 EOF
974 if compile_prog "" "$LIBS" "clockid_t"; then
975   clockid_t="yes"
976 fi
977 print_config "clockid_t" "$clockid_t"
978
979 ##########################################
980 # gettimeofday() probe
981 if test "$gettimeofday" != "yes" ; then
982   gettimeofday="no"
983 fi
984 cat > $TMPC << EOF
985 #include <sys/time.h>
986 #include <stdio.h>
987 int main(int argc, char **argv)
988 {
989   struct timeval tv;
990   return gettimeofday(&tv, NULL);
991 }
992 EOF
993 if compile_prog "" "" "gettimeofday"; then
994     gettimeofday="yes"
995 fi
996 print_config "gettimeofday" "$gettimeofday"
997
998 ##########################################
999 # fdatasync() probe
1000 if test "$fdatasync" != "yes" ; then
1001   fdatasync="no"
1002 fi
1003 cat > $TMPC << EOF
1004 #include <stdio.h>
1005 #include <unistd.h>
1006 int main(int argc, char **argv)
1007 {
1008   return fdatasync(0);
1009 }
1010 EOF
1011 if compile_prog "" "" "fdatasync"; then
1012   fdatasync="yes"
1013 fi
1014 print_config "fdatasync" "$fdatasync"
1015
1016 ##########################################
1017 # sync_file_range() probe
1018 if test "$sync_file_range" != "yes" ; then
1019   sync_file_range="no"
1020 fi
1021 cat > $TMPC << EOF
1022 #include <stdio.h>
1023 #include <unistd.h>
1024 #include <fcntl.h>
1025 #include <linux/fs.h>
1026 int main(int argc, char **argv)
1027 {
1028   unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
1029                         SYNC_FILE_RANGE_WAIT_AFTER;
1030   return sync_file_range(0, 0, 0, flags);
1031 }
1032 EOF
1033 if compile_prog "" "" "sync_file_range"; then
1034   sync_file_range="yes"
1035 fi
1036 print_config "sync_file_range" "$sync_file_range"
1037
1038 ##########################################
1039 # ext4 move extent probe
1040 if test "$ext4_me" != "yes" ; then
1041   ext4_me="no"
1042 fi
1043 cat > $TMPC << EOF
1044 #include <fcntl.h>
1045 #include <sys/ioctl.h>
1046 int main(int argc, char **argv)
1047 {
1048   struct move_extent me;
1049   return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
1050 }
1051 EOF
1052 if compile_prog "" "" "ext4 move extent" ; then
1053   ext4_me="yes"
1054 elif test $targetos = "Linux" ; then
1055   # On Linux, just default to it on and let it error at runtime if we really
1056   # don't have it. None of my updated systems have it defined, but it does
1057   # work. Takes a while to bubble back.
1058   ext4_me="yes"
1059 fi
1060 print_config "EXT4 move extent" "$ext4_me"
1061
1062 ##########################################
1063 # splice probe
1064 if test "$linux_splice" != "yes" ; then
1065   linux_splice="no"
1066 fi
1067 cat > $TMPC << EOF
1068 #include <stdio.h>
1069 #include <fcntl.h>
1070 int main(int argc, char **argv)
1071 {
1072   return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
1073 }
1074 EOF
1075 if compile_prog "" "" "linux splice"; then
1076   linux_splice="yes"
1077 fi
1078 print_config "Linux splice(2)" "$linux_splice"
1079
1080 ##########################################
1081 # GUASI probe
1082 if test "$guasi" != "yes" ; then
1083   guasi="no"
1084 fi
1085 cat > $TMPC << EOF
1086 #include <guasi.h>
1087 #include <guasi_syscalls.h>
1088 int main(int argc, char **argv)
1089 {
1090   guasi_t ctx = guasi_create(0, 0, 0);
1091   return 0;
1092 }
1093 EOF
1094 if compile_prog "" "" "guasi"; then
1095   guasi="yes"
1096 fi
1097 print_config "GUASI" "$guasi"
1098
1099 ##########################################
1100 # fusion-aw probe
1101 if test "$fusion_aw" != "yes" ; then
1102   fusion_aw="no"
1103 fi
1104 cat > $TMPC << EOF
1105 #include <nvm/nvm_primitives.h>
1106 int main(int argc, char **argv)
1107 {
1108   nvm_version_t ver_info;
1109   nvm_handle_t handle;
1110
1111   handle = nvm_get_handle(0, &ver_info);
1112   return nvm_atomic_write(handle, 0, 0, 0);
1113 }
1114 EOF
1115 if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
1116   LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
1117   fusion_aw="yes"
1118 fi
1119 print_config "Fusion-io atomic engine" "$fusion_aw"
1120
1121 ##########################################
1122 # libnuma probe
1123 if test "$libnuma" != "yes" ; then
1124   libnuma="no"
1125 fi
1126 cat > $TMPC << EOF
1127 #include <numa.h>
1128 int main(int argc, char **argv)
1129 {
1130   return numa_available();
1131 }
1132 EOF
1133 if test "$disable_numa" != "yes"  && compile_prog "" "-lnuma" "libnuma"; then
1134   libnuma="yes"
1135   LIBS="-lnuma $LIBS"
1136 fi
1137 print_config "libnuma" "$libnuma"
1138
1139 ##########################################
1140 # libnuma 2.x version API, initialize with "no" only if $libnuma is set to "yes"
1141 if test "$libnuma" = "yes" ; then
1142 libnuma_v2="no"
1143 cat > $TMPC << EOF
1144 #include <numa.h>
1145 int main(int argc, char **argv)
1146 {
1147   struct bitmask *mask = numa_parse_nodestring(NULL);
1148   return mask->size == 0;
1149 }
1150 EOF
1151 if compile_prog "" "" "libnuma api"; then
1152   libnuma_v2="yes"
1153 fi
1154 print_config "libnuma v2" "$libnuma_v2"
1155 fi
1156
1157 ##########################################
1158 # strsep() probe
1159 if test "$strsep" != "yes" ; then
1160   strsep="no"
1161 fi
1162 cat > $TMPC << EOF
1163 #include <string.h>
1164 int main(int argc, char **argv)
1165 {
1166   static char *string = "This is a string";
1167   strsep(&string, "needle");
1168   return 0;
1169 }
1170 EOF
1171 if compile_prog "" "" "strsep"; then
1172   strsep="yes"
1173 fi
1174 print_config "strsep" "$strsep"
1175
1176 ##########################################
1177 # strcasestr() probe
1178 if test "$strcasestr" != "yes" ; then
1179   strcasestr="no"
1180 fi
1181 cat > $TMPC << EOF
1182 #include <string.h>
1183 int main(int argc, char **argv)
1184 {
1185   return strcasestr(argv[0], argv[1]) != NULL;
1186 }
1187 EOF
1188 if compile_prog "" "" "strcasestr"; then
1189   strcasestr="yes"
1190 fi
1191 print_config "strcasestr" "$strcasestr"
1192
1193 ##########################################
1194 # strlcat() probe
1195 if test "$strlcat" != "yes" ; then
1196   strlcat="no"
1197 fi
1198 cat > $TMPC << EOF
1199 #include <string.h>
1200 int main(int argc, char **argv)
1201 {
1202   static char dst[64];
1203   static char *string = "This is a string";
1204   memset(dst, 0, sizeof(dst));
1205   strlcat(dst, string, sizeof(dst));
1206   return 0;
1207 }
1208 EOF
1209 if compile_prog "" "" "strlcat"; then
1210   strlcat="yes"
1211 fi
1212 print_config "strlcat" "$strlcat"
1213
1214 ##########################################
1215 # getopt_long_only() probe
1216 if test "$getopt_long_only" != "yes" ; then
1217   getopt_long_only="no"
1218 fi
1219 cat > $TMPC << EOF
1220 #include <unistd.h>
1221 #include <stdio.h>
1222 #include <getopt.h>
1223 int main(int argc, char **argv)
1224 {
1225   int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1226   return c;
1227 }
1228 EOF
1229 if compile_prog "" "" "getopt_long_only"; then
1230   getopt_long_only="yes"
1231 fi
1232 print_config "getopt_long_only()" "$getopt_long_only"
1233
1234 ##########################################
1235 # inet_aton() probe
1236 if test "$inet_aton" != "yes" ; then
1237   inet_aton="no"
1238 fi
1239 cat > $TMPC << EOF
1240 #include <sys/socket.h>
1241 #include <arpa/inet.h>
1242 #include <stdio.h>
1243 int main(int argc, char **argv)
1244 {
1245   struct in_addr in;
1246   return inet_aton(NULL, &in);
1247 }
1248 EOF
1249 if compile_prog "" "" "inet_aton"; then
1250   inet_aton="yes"
1251 fi
1252 print_config "inet_aton" "$inet_aton"
1253
1254 ##########################################
1255 # socklen_t probe
1256 if test "$socklen_t" != "yes" ; then
1257   socklen_t="no"
1258 fi
1259 cat > $TMPC << EOF
1260 #include <sys/socket.h>
1261 int main(int argc, char **argv)
1262 {
1263   socklen_t len = 0;
1264   return len;
1265 }
1266 EOF
1267 if compile_prog "" "" "socklen_t"; then
1268   socklen_t="yes"
1269 fi
1270 print_config "socklen_t" "$socklen_t"
1271
1272 ##########################################
1273 # Whether or not __thread is supported for TLS
1274 if test "$tls_thread" != "yes" ; then
1275   tls_thread="no"
1276 fi
1277 cat > $TMPC << EOF
1278 #include <stdio.h>
1279 static __thread int ret;
1280 int main(int argc, char **argv)
1281 {
1282   return ret;
1283 }
1284 EOF
1285 if compile_prog "" "" "__thread"; then
1286   tls_thread="yes"
1287 fi
1288 print_config "__thread" "$tls_thread"
1289
1290 ##########################################
1291 # Check if we have required gtk/glib support for gfio
1292 if test "$gfio" != "yes" ; then
1293   gfio="no"
1294 fi
1295 if test "$gfio_check" = "yes" ; then
1296   cat > $TMPC << EOF
1297 #include <glib.h>
1298 #include <cairo.h>
1299 #include <gtk/gtk.h>
1300 int main(void)
1301 {
1302   gdk_threads_enter();
1303   gdk_threads_leave();
1304
1305   return GTK_CHECK_VERSION(2, 18, 0) ? 0 : 1; /* 0 on success */
1306 }
1307 EOF
1308 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1309 ORG_LDFLAGS=$LDFLAGS
1310 LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1311 if test "$?" != "0" ; then
1312   echo "configure: gtk and gthread not found"
1313   exit 1
1314 fi
1315 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1316 if test "$?" != "0" ; then
1317   echo "configure: gtk and gthread not found"
1318   exit 1
1319 fi
1320 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1321   $TMPE
1322   if test "$?" = "0" ; then
1323     gfio="yes"
1324     GFIO_LIBS="$LIBS $GTK_LIBS"
1325     CFLAGS="$CFLAGS $GTK_CFLAGS"
1326   else
1327     echo "GTK found, but need version 2.18 or higher"
1328     gfio="no"
1329   fi
1330 else
1331   echo "Please install gtk and gdk libraries"
1332   gfio="no"
1333 fi
1334 LDFLAGS=$ORG_LDFLAGS
1335 fi
1336
1337 if test "$gfio_check" = "yes" ; then
1338   print_config "gtk 2.18 or higher" "$gfio"
1339 fi
1340
1341 ##########################################
1342 # Check whether we have getrusage(RUSAGE_THREAD)
1343 if test "$rusage_thread" != "yes" ; then
1344   rusage_thread="no"
1345 fi
1346 cat > $TMPC << EOF
1347 #include <sys/time.h>
1348 #include <sys/resource.h>
1349 int main(int argc, char **argv)
1350 {
1351   struct rusage ru;
1352   getrusage(RUSAGE_THREAD, &ru);
1353   return 0;
1354 }
1355 EOF
1356 if compile_prog "" "" "RUSAGE_THREAD"; then
1357   rusage_thread="yes"
1358 fi
1359 print_config "RUSAGE_THREAD" "$rusage_thread"
1360
1361 ##########################################
1362 # Check whether we have SCHED_IDLE
1363 if test "$sched_idle" != "yes" ; then
1364   sched_idle="no"
1365 fi
1366 cat > $TMPC << EOF
1367 #include <sched.h>
1368 int main(int argc, char **argv)
1369 {
1370   struct sched_param p;
1371   return sched_setscheduler(0, SCHED_IDLE, &p);
1372 }
1373 EOF
1374 if compile_prog "" "" "SCHED_IDLE"; then
1375   sched_idle="yes"
1376 fi
1377 print_config "SCHED_IDLE" "$sched_idle"
1378
1379 ##########################################
1380 # Check whether we have TCP_NODELAY
1381 if test "$tcp_nodelay" != "yes" ; then
1382   tcp_nodelay="no"
1383 fi
1384 cat > $TMPC << EOF
1385 #include <stdio.h>
1386 #include <sys/types.h>
1387 #include <sys/socket.h>
1388 #include <netinet/tcp.h>
1389 int main(int argc, char **argv)
1390 {
1391   return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1392 }
1393 EOF
1394 if compile_prog "" "" "TCP_NODELAY"; then
1395   tcp_nodelay="yes"
1396 fi
1397 print_config "TCP_NODELAY" "$tcp_nodelay"
1398
1399 ##########################################
1400 # Check whether we have SO_SNDBUF
1401 if test "$window_size" != "yes" ; then
1402   window_size="no"
1403 fi
1404 cat > $TMPC << EOF
1405 #include <stdio.h>
1406 #include <sys/types.h>
1407 #include <sys/socket.h>
1408 #include <netinet/tcp.h>
1409 int main(int argc, char **argv)
1410 {
1411   setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1412   setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1413 }
1414 EOF
1415 if compile_prog "" "" "SO_SNDBUF"; then
1416   window_size="yes"
1417 fi
1418 print_config "Net engine window_size" "$window_size"
1419
1420 ##########################################
1421 # Check whether we have TCP_MAXSEG
1422 if test "$mss" != "yes" ; then
1423   mss="no"
1424 fi
1425 cat > $TMPC << EOF
1426 #include <stdio.h>
1427 #include <sys/types.h>
1428 #include <sys/socket.h>
1429 #include <netinet/tcp.h>
1430 #include <arpa/inet.h>
1431 #include <netinet/in.h>
1432 int main(int argc, char **argv)
1433 {
1434   return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1435 }
1436 EOF
1437 if compile_prog "" "" "TCP_MAXSEG"; then
1438   mss="yes"
1439 fi
1440 print_config "TCP_MAXSEG" "$mss"
1441
1442 ##########################################
1443 # Check whether we have RLIMIT_MEMLOCK
1444 if test "$rlimit_memlock" != "yes" ; then
1445   rlimit_memlock="no"
1446 fi
1447 cat > $TMPC << EOF
1448 #include <sys/time.h>
1449 #include <sys/resource.h>
1450 int main(int argc, char **argv)
1451 {
1452   struct rlimit rl;
1453   return getrlimit(RLIMIT_MEMLOCK, &rl);
1454 }
1455 EOF
1456 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1457   rlimit_memlock="yes"
1458 fi
1459 print_config "RLIMIT_MEMLOCK" "$rlimit_memlock"
1460
1461 ##########################################
1462 # Check whether we have pwritev/preadv
1463 if test "$pwritev" != "yes" ; then
1464   pwritev="no"
1465 fi
1466 cat > $TMPC << EOF
1467 #include <stdio.h>
1468 #include <sys/uio.h>
1469 int main(int argc, char **argv)
1470 {
1471   return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1472 }
1473 EOF
1474 if compile_prog "" "" "pwritev"; then
1475   pwritev="yes"
1476 fi
1477 print_config "pwritev/preadv" "$pwritev"
1478
1479 ##########################################
1480 # Check whether we have pwritev2/preadv2
1481 if test "$pwritev2" != "yes" ; then
1482   pwritev2="no"
1483 fi
1484 cat > $TMPC << EOF
1485 #include <stdio.h>
1486 #include <sys/uio.h>
1487 int main(int argc, char **argv)
1488 {
1489   return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1490 }
1491 EOF
1492 if compile_prog "" "" "pwritev2"; then
1493   pwritev2="yes"
1494 fi
1495 print_config "pwritev2/preadv2" "$pwritev2"
1496
1497 ##########################################
1498 # Check whether we have the required functions for ipv6
1499 if test "$ipv6" != "yes" ; then
1500   ipv6="no"
1501 fi
1502 cat > $TMPC << EOF
1503 #include <sys/types.h>
1504 #include <sys/socket.h>
1505 #include <netinet/in.h>
1506 #include <netdb.h>
1507 #include <stdio.h>
1508 int main(int argc, char **argv)
1509 {
1510   struct addrinfo hints;
1511   struct in6_addr addr;
1512   int ret;
1513
1514   ret = getaddrinfo(NULL, NULL, &hints, NULL);
1515   freeaddrinfo(NULL);
1516   printf("%s\n", gai_strerror(ret));
1517   addr = in6addr_any;
1518   return 0;
1519 }
1520 EOF
1521 if compile_prog "" "" "ipv6"; then
1522   ipv6="yes"
1523 fi
1524 print_config "IPv6 helpers" "$ipv6"
1525
1526 ##########################################
1527 # check for rados
1528 if test "$rados" != "yes" ; then
1529   rados="no"
1530 fi
1531 cat > $TMPC << EOF
1532 #include <rados/librados.h>
1533
1534 int main(int argc, char **argv)
1535 {
1536   rados_t cluster;
1537   rados_ioctx_t io_ctx;
1538   const char cluster_name[] = "ceph";
1539   const char user_name[] = "client.admin";
1540   const char pool[] = "rados";
1541
1542   /* The rados_create2 signature required was only introduced in ceph 0.65 */
1543   rados_create2(&cluster, cluster_name, user_name, 0);
1544   rados_ioctx_create(cluster, pool, &io_ctx);
1545
1546   return 0;
1547 }
1548 EOF
1549 if test "$disable_rados" != "yes"  && compile_prog "" "-lrados" "rados"; then
1550   LIBS="-lrados $LIBS"
1551   rados="yes"
1552 fi
1553 print_config "Rados engine" "$rados"
1554
1555 ##########################################
1556 # check for rbd
1557 if test "$rbd" != "yes" ; then
1558   rbd="no"
1559 fi
1560 cat > $TMPC << EOF
1561 #include <rbd/librbd.h>
1562
1563 int main(int argc, char **argv)
1564 {
1565   rados_t cluster;
1566   rados_ioctx_t io_ctx;
1567   const char cluster_name[] = "ceph";
1568   const char user_name[] = "client.admin";
1569   const char pool[] = "rbd";
1570   int major, minor, extra;
1571
1572   rbd_version(&major, &minor, &extra);
1573   /* The rados_create2 signature required was only introduced in ceph 0.65 */
1574   rados_create2(&cluster, cluster_name, user_name, 0);
1575   rados_ioctx_create(cluster, pool, &io_ctx);
1576
1577   return 0;
1578 }
1579 EOF
1580 if test "$disable_rbd" != "yes"  && compile_prog "" "-lrbd -lrados" "rbd"; then
1581   LIBS="-lrbd -lrados $LIBS"
1582   rbd="yes"
1583 fi
1584 print_config "Rados Block Device engine" "$rbd"
1585
1586 ##########################################
1587 # check for rbd_poll
1588 if test "$rbd_poll" != "yes" ; then
1589   rbd_poll="no"
1590 fi
1591 if test "$rbd" = "yes"; then
1592 cat > $TMPC << EOF
1593 #include <rbd/librbd.h>
1594 #include <sys/eventfd.h>
1595
1596 int main(int argc, char **argv)
1597 {
1598   rbd_image_t image;
1599   rbd_completion_t comp;
1600
1601   int fd = eventfd(0, EFD_NONBLOCK);
1602   rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1603   rbd_poll_io_events(image, comp, 1);
1604
1605   return 0;
1606 }
1607 EOF
1608 if compile_prog "" "-lrbd -lrados" "rbd"; then
1609   rbd_poll="yes"
1610 fi
1611 print_config "rbd_poll" "$rbd_poll"
1612 fi
1613
1614 ##########################################
1615 # check for rbd_invalidate_cache()
1616 if test "$rbd_inval" != "yes" ; then
1617   rbd_inval="no"
1618 fi
1619 if test "$rbd" = "yes"; then
1620 cat > $TMPC << EOF
1621 #include <rbd/librbd.h>
1622
1623 int main(int argc, char **argv)
1624 {
1625   rbd_image_t image;
1626
1627   return rbd_invalidate_cache(image);
1628 }
1629 EOF
1630 if compile_prog "" "-lrbd -lrados" "rbd"; then
1631   rbd_inval="yes"
1632 fi
1633 print_config "rbd_invalidate_cache" "$rbd_inval"
1634 fi
1635
1636 ##########################################
1637 # Check whether we have setvbuf
1638 if test "$setvbuf" != "yes" ; then
1639   setvbuf="no"
1640 fi
1641 cat > $TMPC << EOF
1642 #include <stdio.h>
1643 int main(int argc, char **argv)
1644 {
1645   FILE *f = NULL;
1646   char buf[80];
1647   setvbuf(f, buf, _IOFBF, sizeof(buf));
1648   return 0;
1649 }
1650 EOF
1651 if compile_prog "" "" "setvbuf"; then
1652   setvbuf="yes"
1653 fi
1654 print_config "setvbuf" "$setvbuf"
1655
1656 ##########################################
1657 # check for gfapi
1658 if test "$gfapi" != "yes" ; then
1659   gfapi="no"
1660 fi
1661 cat > $TMPC << EOF
1662 #include <glusterfs/api/glfs.h>
1663
1664 int main(int argc, char **argv)
1665 {
1666   glfs_t *g = glfs_new("foo");
1667
1668   return 0;
1669 }
1670 EOF
1671 if test "$disable_gfapi" != "yes"  && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1672   LIBS="-lgfapi -lglusterfs $LIBS"
1673   gfapi="yes"
1674 fi
1675 print_config "Gluster API engine" "$gfapi"
1676
1677 ##########################################
1678 # check for gfapi fadvise support, initialize with "no" only if $gfapi is set to "yes"
1679 if test "$gfapi" = "yes" ; then
1680 gf_fadvise="no"
1681 cat > $TMPC << EOF
1682 #include <glusterfs/api/glfs.h>
1683
1684 int main(int argc, char **argv)
1685 {
1686   struct glfs_fd *fd;
1687   int ret = glfs_fadvise(fd, 0, 0, 1);
1688
1689   return 0;
1690 }
1691 EOF
1692 if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1693   gf_fadvise="yes"
1694 fi
1695 print_config "Gluster API use fadvise" "$gf_fadvise"
1696 fi
1697
1698 ##########################################
1699 # check for gfapi trim support
1700 if test "$gf_trim" != "yes" ; then
1701   gf_trim="no"
1702 fi
1703 if test "$gfapi" = "yes" ; then
1704 cat > $TMPC << EOF
1705 #include <glusterfs/api/glfs.h>
1706
1707 int main(int argc, char **argv)
1708 {
1709   return glfs_discard_async(NULL, 0, 0);
1710 }
1711 EOF
1712 if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1713   gf_trim="yes"
1714 fi
1715 print_config "Gluster API trim support" "$gf_trim"
1716 fi
1717
1718 ##########################################
1719 # Check if we support stckf on s390
1720 if test "$s390_z196_facilities" != "yes" ; then
1721   s390_z196_facilities="no"
1722 fi
1723 cat > $TMPC << EOF
1724 #define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1725 int main(int argc, char **argv)
1726 {
1727     /* We want just 1 double word to be returned.  */
1728     register unsigned long reg0 asm("0") = 0;
1729     unsigned long stfle_bits;
1730     asm volatile(".machine push"        "\n\t"
1731                  ".machine \"z9-109\""  "\n\t"
1732                  "stfle %0"             "\n\t"
1733                  ".machine pop"         "\n"
1734                  : "=QS" (stfle_bits), "+d" (reg0)
1735                  : : "cc");
1736
1737     if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1738       return 0;
1739     else
1740       return -1;
1741 }
1742 EOF
1743 if compile_prog "" "" "s390_z196_facilities"; then
1744   $TMPE
1745   if [ $? -eq 0 ]; then
1746         s390_z196_facilities="yes"
1747   fi
1748 fi
1749 print_config "s390_z196_facilities" "$s390_z196_facilities"
1750
1751 ##########################################
1752 # Check if we have required environment variables configured for libhdfs
1753 if test "$libhdfs" = "yes" ; then
1754   hdfs_conf_error=0
1755   if test "$JAVA_HOME" = "" ; then
1756     echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1757     hdfs_conf_error=1
1758   fi
1759   if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1760     echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1761     hdfs_conf_error=1
1762   fi
1763   if test "$FIO_LIBHDFS_LIB" = "" ; then
1764     echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1765     hdfs_conf_error=1
1766   fi
1767   if test "$hdfs_conf_error" = "1" ; then
1768     exit 1
1769   fi
1770   FIO_HDFS_CPU=$cpu
1771   if test "$FIO_HDFS_CPU" = "x86_64" ; then
1772     FIO_HDFS_CPU="amd64"
1773   fi
1774 fi
1775 print_config "HDFS engine" "$libhdfs"
1776
1777 ##########################################
1778 # Check whether we have MTD
1779 if test "$mtd" != "yes" ; then
1780   mtd="no"
1781 fi
1782 cat > $TMPC << EOF
1783 #include <string.h>
1784 #include <mtd/mtd-user.h>
1785 #include <sys/ioctl.h>
1786 int main(int argc, char **argv)
1787 {
1788   struct mtd_write_req ops;
1789   struct mtd_info_user info;
1790   memset(&ops, 0, sizeof(ops));
1791   info.type = MTD_MLCNANDFLASH;
1792   return ioctl(0, MEMGETINFO, &info);
1793 }
1794 EOF
1795 if compile_prog "" "" "mtd"; then
1796   mtd="yes"
1797 fi
1798 print_config "MTD" "$mtd"
1799
1800 ##########################################
1801 # Check whether we have libpmem
1802 if test "$libpmem" != "yes" ; then
1803   libpmem="no"
1804 fi
1805 cat > $TMPC << EOF
1806 #include <libpmem.h>
1807 int main(int argc, char **argv)
1808 {
1809   int rc;
1810   rc = pmem_is_pmem(0, 0);
1811   return 0;
1812 }
1813 EOF
1814 if compile_prog "" "-lpmem" "libpmem"; then
1815   libpmem="yes"
1816   LIBS="-lpmem $LIBS"
1817 fi
1818 print_config "libpmem" "$libpmem"
1819
1820 ##########################################
1821 # Check whether we have libpmemblk
1822 # libpmem is a prerequisite
1823 if test "$libpmemblk" != "yes" ; then
1824   libpmemblk="no"
1825 fi
1826 if test "$libpmem" = "yes"; then
1827   cat > $TMPC << EOF
1828 #include <libpmemblk.h>
1829 int main(int argc, char **argv)
1830 {
1831   PMEMblkpool *pbp;
1832   pbp = pmemblk_open("", 0);
1833   return 0;
1834 }
1835 EOF
1836   if compile_prog "" "-lpmemblk" "libpmemblk"; then
1837     libpmemblk="yes"
1838     LIBS="-lpmemblk $LIBS"
1839   fi
1840 fi
1841 print_config "libpmemblk" "$libpmemblk"
1842
1843 # Choose the ioengines
1844 if test "$libpmem" = "yes" && test "$disable_pmem" = "no"; then
1845   pmem="yes"
1846   devdax="yes"
1847   if test "$libpmemblk" = "yes"; then
1848     pmemblk="yes"
1849   fi
1850 fi
1851
1852 ##########################################
1853 # Report whether pmemblk engine is enabled
1854 print_config "NVML pmemblk engine" "$pmemblk"
1855
1856 ##########################################
1857 # Report whether dev-dax engine is enabled
1858 print_config "NVML dev-dax engine" "$devdax"
1859
1860 ##########################################
1861 # Report whether libpmem engine is enabled
1862 print_config "NVML libpmem engine" "$pmem"
1863
1864 ##########################################
1865 # Check if we have lex/yacc available
1866 yacc="no"
1867 yacc_is_bison="no"
1868 lex="no"
1869 arith="no"
1870 if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
1871 if test "$targetos" != "SunOS" ; then
1872 LEX=$(which lex 2> /dev/null)
1873 if test -x "$LEX" ; then
1874   lex="yes"
1875 fi
1876 YACC=$(which bison 2> /dev/null)
1877 if test -x "$YACC" ; then
1878   yacc="yes"
1879   yacc_is_bison="yes"
1880 else
1881   YACC=$(which yacc 2> /dev/null)
1882   if test -x "$YACC" ; then
1883     yacc="yes"
1884   fi
1885 fi
1886 if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1887   arith="yes"
1888 fi
1889
1890 if test "$arith" = "yes" ; then
1891 cat > $TMPC << EOF
1892 extern int yywrap(void);
1893
1894 int main(int argc, char **argv)
1895 {
1896   yywrap();
1897   return 0;
1898 }
1899 EOF
1900 if compile_prog "" "-ll" "lex"; then
1901   LIBS="-ll $LIBS"
1902 else
1903   arith="no"
1904 fi
1905 fi
1906 fi
1907 fi
1908
1909 # Check if lex fails using -o
1910 if test "$arith" = "yes" ; then
1911 if test "$force_no_lex_o" = "yes" ; then
1912   lex_use_o="no"
1913 else
1914 $LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1915 if test "$?" = "0" ; then
1916   lex_use_o="yes"
1917 else
1918   lex_use_o="no"
1919 fi
1920 fi
1921 fi
1922
1923 print_config "lex/yacc for arithmetic" "$arith"
1924
1925 ##########################################
1926 # Check whether we have setmntent/getmntent
1927 if test "$getmntent" != "yes" ; then
1928   getmntent="no"
1929 fi
1930 cat > $TMPC << EOF
1931 #include <stdio.h>
1932 #include <mntent.h>
1933 int main(int argc, char **argv)
1934 {
1935   FILE *mtab = setmntent(NULL, "r");
1936   struct mntent *mnt = getmntent(mtab);
1937   endmntent(mtab);
1938   return 0;
1939 }
1940 EOF
1941 if compile_prog "" "" "getmntent"; then
1942   getmntent="yes"
1943 fi
1944 print_config "getmntent" "$getmntent"
1945
1946 ##########################################
1947 # Check whether we have getmntinfo
1948 # These are originally added for BSDs, but may also work
1949 # on other operating systems with getmntinfo(3).
1950
1951 # getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
1952 # Note that NetBSD needs -Werror to catch warning as error.
1953 if test "$getmntinfo" != "yes" ; then
1954   getmntinfo="no"
1955 fi
1956 cat > $TMPC << EOF
1957 #include <stdio.h>
1958 #include <sys/param.h>
1959 #include <sys/mount.h>
1960 int main(int argc, char **argv)
1961 {
1962   struct statfs *st;
1963   return getmntinfo(&st, MNT_NOWAIT);
1964 }
1965 EOF
1966 if compile_prog "-Werror" "" "getmntinfo"; then
1967   getmntinfo="yes"
1968 fi
1969 print_config "getmntinfo" "$getmntinfo"
1970
1971 # getmntinfo(3) for NetBSD.
1972 if test "$getmntinfo_statvfs" != "yes" ; then
1973   getmntinfo_statvfs="no"
1974 fi
1975 cat > $TMPC << EOF
1976 #include <stdio.h>
1977 #include <sys/statvfs.h>
1978 int main(int argc, char **argv)
1979 {
1980   struct statvfs *st;
1981   return getmntinfo(&st, MNT_NOWAIT);
1982 }
1983 EOF
1984 # Skip the test if the one with statfs arg is detected.
1985 if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
1986   getmntinfo_statvfs="yes"
1987   print_config "getmntinfo_statvfs" "$getmntinfo_statvfs"
1988 fi
1989
1990 ##########################################
1991 # Check whether we have _Static_assert
1992 if test "$static_assert" != "yes" ; then
1993   static_assert="no"
1994 fi
1995 cat > $TMPC << EOF
1996 #include <assert.h>
1997 #include <stdlib.h>
1998 #include <stddef.h>
1999
2000 struct foo {
2001   int a, b;
2002 };
2003
2004 int main(int argc, char **argv)
2005 {
2006   _Static_assert(offsetof(struct foo, a) == 0 , "Check");
2007   return 0 ;
2008 }
2009 EOF
2010 if compile_prog "" "" "static_assert"; then
2011     static_assert="yes"
2012 fi
2013 print_config "Static Assert" "$static_assert"
2014
2015 ##########################################
2016 # Check whether we have bool / stdbool.h
2017 if test "$have_bool" != "yes" ; then
2018   have_bool="no"
2019 fi
2020 cat > $TMPC << EOF
2021 #include <stdbool.h>
2022 int main(int argc, char **argv)
2023 {
2024   bool var = true;
2025   return var != false;
2026 }
2027 EOF
2028 if compile_prog "" "" "bool"; then
2029   have_bool="yes"
2030 fi
2031 print_config "bool" "$have_bool"
2032
2033 ##########################################
2034 # Check whether we have strndup()
2035 strndup="no"
2036 cat > $TMPC << EOF
2037 #include <string.h>
2038 #include <stdlib.h>
2039 int main(int argc, char **argv)
2040 {
2041   char *res = strndup("test string", 8);
2042
2043   free(res);
2044   return 0;
2045 }
2046 EOF
2047 if compile_prog "" "" "strndup"; then
2048   strndup="yes"
2049 fi
2050 print_config "strndup" "$strndup"
2051
2052 ##########################################
2053 # check march=armv8-a+crc+crypto
2054 if test "$march_armv8_a_crc_crypto" != "yes" ; then
2055   march_armv8_a_crc_crypto="no"
2056 fi
2057 if test "$cpu" = "arm64" ; then
2058   cat > $TMPC <<EOF
2059 #include <sys/auxv.h>
2060 #include <arm_acle.h>
2061 #include <arm_neon.h>
2062
2063 int main(void)
2064 {
2065   return 0;
2066 }
2067 EOF
2068   if compile_prog "-march=armv8-a+crc+crypto" "" ""; then
2069     march_armv8_a_crc_crypto="yes"
2070     CFLAGS="$CFLAGS -march=armv8-a+crc+crypto -DARCH_HAVE_CRC_CRYPTO"
2071     march_set="yes"
2072   fi
2073 fi
2074 print_config "march_armv8_a_crc_crypto" "$march_armv8_a_crc_crypto"
2075
2076 ##########################################
2077 # cuda probe
2078 if test "$cuda" != "yes" ; then
2079   cuda="no"
2080 fi
2081 cat > $TMPC << EOF
2082 #include <cuda.h>
2083 int main(int argc, char **argv)
2084 {
2085   return cuInit(0);
2086 }
2087 EOF
2088 if test "$enable_cuda" = "yes" && compile_prog "" "-lcuda" "cuda"; then
2089   cuda="yes"
2090   LIBS="-lcuda $LIBS"
2091 fi
2092 print_config "cuda" "$cuda"
2093
2094 ##########################################
2095 # mkdir() probe. mingw apparently has a one-argument mkdir :/
2096 mkdir_two="no"
2097 cat > $TMPC << EOF
2098 #include <sys/stat.h>
2099 #include <sys/types.h>
2100 int main(int argc, char **argv)
2101 {
2102   return mkdir("/tmp/bla", 0600);
2103 }
2104 EOF
2105 if compile_prog "" "" "mkdir(a, b)"; then
2106   mkdir_two="yes"
2107 fi
2108 print_config "mkdir(a, b)" "$mkdir_two"
2109
2110 ##########################################
2111 # check for cc -march=native
2112 build_native="no"
2113 cat > $TMPC << EOF
2114 int main(int argc, char **argv)
2115 {
2116   return 0;
2117 }
2118 EOF
2119 if test "$disable_native" = "no" && test "$disable_opt" != "yes" && \
2120    compile_prog "-march=native" "" "march=native"; then
2121   build_native="yes"
2122 fi
2123 print_config "Build march=native" "$build_native"
2124
2125 #############################################################################
2126
2127 if test "$wordsize" = "64" ; then
2128   output_sym "CONFIG_64BIT"
2129 elif test "$wordsize" = "32" ; then
2130   output_sym "CONFIG_32BIT"
2131 else
2132   fatal "Unknown wordsize!"
2133 fi
2134 if test "$bigendian" = "yes" ; then
2135   output_sym "CONFIG_BIG_ENDIAN"
2136 else
2137   output_sym "CONFIG_LITTLE_ENDIAN"
2138 fi
2139 if test "$zlib" = "yes" ; then
2140   output_sym "CONFIG_ZLIB"
2141 fi
2142 if test "$libaio" = "yes" ; then
2143   output_sym "CONFIG_LIBAIO"
2144 fi
2145 if test "$posix_aio" = "yes" ; then
2146   output_sym "CONFIG_POSIXAIO"
2147 fi
2148 if test "$posix_aio_fsync" = "yes" ; then
2149   output_sym "CONFIG_POSIXAIO_FSYNC"
2150 fi
2151 if test "$posix_pshared" = "yes" ; then
2152   output_sym "CONFIG_PSHARED"
2153 fi
2154 if test "$linux_fallocate" = "yes" ; then
2155   output_sym "CONFIG_LINUX_FALLOCATE"
2156 fi
2157 if test "$posix_fallocate" = "yes" ; then
2158   output_sym "CONFIG_POSIX_FALLOCATE"
2159 fi
2160 if test "$fdatasync" = "yes" ; then
2161   output_sym "CONFIG_FDATASYNC"
2162 fi
2163 if test "$sync_file_range" = "yes" ; then
2164   output_sym "CONFIG_SYNC_FILE_RANGE"
2165 fi
2166 if test "$sfaa" = "yes" ; then
2167   output_sym "CONFIG_SFAA"
2168 fi
2169 if test "$sync_sync" = "yes" ; then
2170   output_sym "CONFIG_SYNC_SYNC"
2171 fi
2172 if test "$cmp_swap" = "yes" ; then
2173   output_sym "CONFIG_CMP_SWAP"
2174 fi
2175 if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
2176   output_sym "CONFIG_RDMA"
2177 fi
2178 if test "$clock_gettime" = "yes" ; then
2179   output_sym "CONFIG_CLOCK_GETTIME"
2180 fi
2181 if test "$clock_monotonic" = "yes" ; then
2182   output_sym "CONFIG_CLOCK_MONOTONIC"
2183 fi
2184 if test "$clock_monotonic_raw" = "yes" ; then
2185   output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
2186 fi
2187 if test "$clock_monotonic_precise" = "yes" ; then
2188   output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
2189 fi
2190 if test "$clockid_t" = "yes"; then
2191   output_sym "CONFIG_CLOCKID_T"
2192 fi
2193 if test "$gettimeofday" = "yes" ; then
2194   output_sym "CONFIG_GETTIMEOFDAY"
2195 fi
2196 if test "$posix_fadvise" = "yes" ; then
2197   output_sym "CONFIG_POSIX_FADVISE"
2198 fi
2199 if test "$linux_3arg_affinity" = "yes" ; then
2200   output_sym "CONFIG_3ARG_AFFINITY"
2201 elif test "$linux_2arg_affinity" = "yes" ; then
2202   output_sym "CONFIG_2ARG_AFFINITY"
2203 fi
2204 if test "$strsep" = "yes" ; then
2205   output_sym "CONFIG_STRSEP"
2206 fi
2207 if test "$strcasestr" = "yes" ; then
2208   output_sym "CONFIG_STRCASESTR"
2209 fi
2210 if test "$strlcat" = "yes" ; then
2211   output_sym "CONFIG_STRLCAT"
2212 fi
2213 if test "$getopt_long_only" = "yes" ; then
2214   output_sym "CONFIG_GETOPT_LONG_ONLY"
2215 fi
2216 if test "$inet_aton" = "yes" ; then
2217   output_sym "CONFIG_INET_ATON"
2218 fi
2219 if test "$socklen_t" = "yes" ; then
2220   output_sym "CONFIG_SOCKLEN_T"
2221 fi
2222 if test "$ext4_me" = "yes" ; then
2223   output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
2224 fi
2225 if test "$linux_splice" = "yes" ; then
2226   output_sym "CONFIG_LINUX_SPLICE"
2227 fi
2228 if test "$guasi" = "yes" ; then
2229   output_sym "CONFIG_GUASI"
2230 fi
2231 if test "$fusion_aw" = "yes" ; then
2232   output_sym "CONFIG_FUSION_AW"
2233 fi
2234 if test "$libnuma_v2" = "yes" ; then
2235   output_sym "CONFIG_LIBNUMA"
2236 fi
2237 if test "$solaris_aio" = "yes" ; then
2238   output_sym "CONFIG_SOLARISAIO"
2239 fi
2240 if test "$tls_thread" = "yes" ; then
2241   output_sym "CONFIG_TLS_THREAD"
2242 fi
2243 if test "$rusage_thread" = "yes" ; then
2244   output_sym "CONFIG_RUSAGE_THREAD"
2245 fi
2246 if test "$gfio" = "yes" ; then
2247   output_sym "CONFIG_GFIO"
2248 fi
2249 if test "$esx" = "yes" ; then
2250   output_sym "CONFIG_ESX"
2251   output_sym "CONFIG_NO_SHM"
2252 fi
2253 if test "$sched_idle" = "yes" ; then
2254   output_sym "CONFIG_SCHED_IDLE"
2255 fi
2256 if test "$tcp_nodelay" = "yes" ; then
2257   output_sym "CONFIG_TCP_NODELAY"
2258 fi
2259 if test "$window_size" = "yes" ; then
2260   output_sym "CONFIG_NET_WINDOWSIZE"
2261 fi
2262 if test "$mss" = "yes" ; then
2263   output_sym "CONFIG_NET_MSS"
2264 fi
2265 if test "$rlimit_memlock" = "yes" ; then
2266   output_sym "CONFIG_RLIMIT_MEMLOCK"
2267 fi
2268 if test "$pwritev" = "yes" ; then
2269   output_sym "CONFIG_PWRITEV"
2270 fi
2271 if test "$pwritev2" = "yes" ; then
2272   output_sym "CONFIG_PWRITEV2"
2273 fi
2274 if test "$ipv6" = "yes" ; then
2275   output_sym "CONFIG_IPV6"
2276 fi
2277 if test "$rados" = "yes" ; then
2278   output_sym "CONFIG_RADOS"
2279 fi
2280 if test "$rbd" = "yes" ; then
2281   output_sym "CONFIG_RBD"
2282 fi
2283 if test "$rbd_poll" = "yes" ; then
2284   output_sym "CONFIG_RBD_POLL"
2285 fi
2286 if test "$rbd_inval" = "yes" ; then
2287   output_sym "CONFIG_RBD_INVAL"
2288 fi
2289 if test "$setvbuf" = "yes" ; then
2290   output_sym "CONFIG_SETVBUF"
2291 fi
2292 if test "$s390_z196_facilities" = "yes" ; then
2293   output_sym "CONFIG_S390_Z196_FACILITIES"
2294   CFLAGS="$CFLAGS -march=z9-109"
2295   march_set="yes"
2296 fi
2297 if test "$gfapi" = "yes" ; then
2298   output_sym "CONFIG_GFAPI"
2299 fi
2300 if test "$gf_fadvise" = "yes" ; then
2301   output_sym "CONFIG_GF_FADVISE"
2302 fi
2303 if test "$gf_trim" = "yes" ; then
2304   output_sym "CONFIG_GF_TRIM"
2305 fi
2306 if test "$libhdfs" = "yes" ; then
2307   output_sym "CONFIG_LIBHDFS"
2308   echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
2309   echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
2310   echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
2311   echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
2312  fi
2313 if test "$mtd" = "yes" ; then
2314   output_sym "CONFIG_MTD"
2315 fi
2316 if test "$pmemblk" = "yes" ; then
2317   output_sym "CONFIG_PMEMBLK"
2318 fi
2319 if test "$devdax" = "yes" ; then
2320   output_sym "CONFIG_LINUX_DEVDAX"
2321 fi
2322 if test "$pmem" = "yes" ; then
2323   output_sym "CONFIG_LIBPMEM"
2324 fi
2325 if test "$arith" = "yes" ; then
2326   output_sym "CONFIG_ARITHMETIC"
2327   if test "$yacc_is_bison" = "yes" ; then
2328     echo "YACC=$YACC -y" >> $config_host_mak
2329   else
2330     echo "YACC=$YACC" >> $config_host_mak
2331   fi
2332   if test "$lex_use_o" = "yes" ; then
2333     echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
2334   fi
2335 fi
2336 if test "$getmntent" = "yes" ; then
2337   output_sym "CONFIG_GETMNTENT"
2338 fi
2339 if test "$getmntinfo" = "yes" ; then
2340   output_sym "CONFIG_GETMNTINFO"
2341 fi
2342 if test "$getmntinfo_statvfs" = "yes" ; then
2343   output_sym "CONFIG_GETMNTINFO_STATVFS"
2344 fi
2345 if test "$static_assert" = "yes" ; then
2346   output_sym "CONFIG_STATIC_ASSERT"
2347 fi
2348 if test "$have_bool" = "yes" ; then
2349   output_sym "CONFIG_HAVE_BOOL"
2350 fi
2351 if test "$strndup" = "yes" ; then
2352   output_sym "CONFIG_HAVE_STRNDUP"
2353 fi
2354 if test "$disable_opt" = "yes" ; then
2355   output_sym "CONFIG_DISABLE_OPTIMIZATIONS"
2356 fi
2357 if test "$zlib" = "no" ; then
2358   echo "Consider installing zlib-dev (zlib-devel, some fio features depend on it."
2359   if test "$build_static" = "yes"; then
2360     echo "Note that some distros have separate packages for static libraries."
2361   fi
2362 fi
2363 if test "$cuda" = "yes" ; then
2364   output_sym "CONFIG_CUDA"
2365 fi
2366 if test "$mkdir_two" = "yes" ; then
2367   output_sym "CONFIG_HAVE_MKDIR_TWO"
2368 fi
2369 if test "$march_set" = "no" && test "$build_native" = "yes" ; then
2370   output_sym "CONFIG_BUILD_NATIVE"
2371 fi
2372
2373 echo "LIBS+=$LIBS" >> $config_host_mak
2374 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
2375 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
2376 echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
2377 echo "CC=$cc" >> $config_host_mak
2378 echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
2379 echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
2380
2381 if [ `dirname $0` != "." -a ! -e Makefile ]; then
2382     cat > Makefile <<EOF
2383 SRCDIR:=`dirname $0`
2384 include \$(SRCDIR)/Makefile
2385 EOF
2386 fi