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