ci: disable __thread support for Windows msys2 build
[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 $CFLAGS"
48 CONFIGURE_CFLAGS="-Werror-implicit-function-declaration"
49 BUILD_CFLAGS=""
50
51 # Print a helpful header at the top of config.log
52 echo "# FIO configure log $(date)" >> config.log
53 printf "# Configured with:" >> config.log
54 printf " '%s'" "$0" "$@" >> config.log
55 echo >> config.log
56 echo "#" >> config.log
57
58 # Print configure header at the top of $config_host_h
59 echo "/*" > $config_host_h
60 echo " * Automatically generated by configure - do not modify" >> $config_host_h
61 printf " * Configured with:" >> $config_host_h
62 printf " * '%s'" "$0" "$@" >> $config_host_h
63 echo "" >> $config_host_h
64 echo " */" >> $config_host_h
65
66 do_cc() {
67     # Run the compiler, capturing its output to the log.
68     echo $cc "$@" >> config.log
69     $cc "$@" >> config.log 2>&1 || return $?
70     # Test passed. If this is an --enable-werror build, rerun
71     # the test with -Werror and bail out if it fails. This
72     # makes warning-generating-errors in configure test code
73     # obvious to developers.
74     if test "$werror" != "yes"; then
75         return 0
76     fi
77     # Don't bother rerunning the compile if we were already using -Werror
78     case "$*" in
79         *-Werror*)
80            return 0
81         ;;
82     esac
83     echo $cc -Werror "$@" >> config.log
84     $cc -Werror "$@" >> config.log 2>&1 && return $?
85     echo "ERROR: configure test passed without -Werror but failed with -Werror."
86     echo "This is probably a bug in the configure script. The failing command"
87     echo "will be at the bottom of config.log."
88     fatal "You can run configure with --disable-werror to bypass this check."
89 }
90
91 compile_object() {
92   do_cc $CFLAGS $CONFIGURE_CFLAGS -c -o $TMPO $TMPC
93 }
94
95 compile_prog() {
96   local_cflags="$1"
97   local_ldflags="$2 $LIBS"
98   echo "Compiling test case $3" >> config.log
99   do_cc $CFLAGS $CONFIGURE_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
100 }
101
102 feature_not_found() {
103   feature=$1
104   packages=$2
105
106   echo "ERROR"
107   echo "ERROR: User requested feature $feature"
108   if test ! -z "$packages" ; then
109     echo "ERROR: That feature needs $packages installed"
110   fi
111   echo "ERROR: configure was not able to find it"
112   fatal "ERROR"
113 }
114
115 has() {
116   type "$1" >/dev/null 2>&1
117 }
118
119 num() {
120   echo "$1" | grep -E -q "^[0-9]+$"
121 }
122
123 check_define() {
124   cat > $TMPC <<EOF
125 #if !defined($1)
126 #error $1 not defined
127 #endif
128 int main(void)
129 {
130   return 0;
131 }
132 EOF
133   compile_object
134 }
135
136 output_sym() {
137   echo "$1=y" >> $config_host_mak
138   echo "#define $1" >> $config_host_h
139 }
140
141 check_min_lib_version() {
142   _feature=$3
143
144   if "${cross_prefix}"pkg-config --atleast-version="$2" "$1" > /dev/null 2>&1; then
145     return 0
146   fi
147   : "${_feature:=${1}}"
148   if "${cross_prefix}"pkg-config --version > /dev/null 2>&1; then
149     if test "$(eval echo \"\$$_feature\")" = "yes" ; then
150       feature_not_found "$_feature" "$1 >= $2"
151     fi
152   else
153     print_config "$1" "missing pkg-config, can't check $_feature version"
154   fi
155   return 1
156 }
157
158 targetos=""
159 cpu=""
160
161 # default options
162 show_help="no"
163 exit_val=0
164 gfio_check="no"
165 libhdfs="no"
166 devdax="no"
167 pmem="no"
168 cuda="no"
169 libcufile="no"
170 disable_lex=""
171 disable_pmem="no"
172 disable_native="no"
173 march_set="no"
174 libiscsi="no"
175 libnbd="no"
176 libnfs=""
177 xnvme=""
178 libblkio=""
179 libzbc=""
180 dfs=""
181 seed_buckets=""
182 dynamic_engines="no"
183 prefix=/usr/local
184
185 # parse options
186 for opt do
187   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
188   case "$opt" in
189   --prefix=*) prefix="$optarg"
190   ;;
191   --cpu=*) cpu="$optarg"
192   ;;
193   #  esx is cross compiled and cannot be detect through simple uname calls
194   --esx)
195   esx="yes"
196   ;;
197   --cc=*) CC="$optarg"
198   ;;
199   --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
200   ;;
201   --build-32bit-win) build_32bit_win="yes"
202   ;;
203   --target-win-ver=*) target_win_ver="$optarg"
204   ;;
205   --enable-pdb) pdb="yes"
206   ;;
207   --build-static) build_static="yes"
208   ;;
209   --enable-gfio) gfio_check="yes"
210   ;;
211   --disable-numa) disable_numa="yes"
212   ;;
213   --disable-rdma) disable_rdma="yes"
214   ;;
215   --disable-rados) disable_rados="yes"
216   ;;
217   --disable-rbd) disable_rbd="yes"
218   ;;
219   --disable-http) disable_http="yes"
220   ;;
221   --disable-gfapi) disable_gfapi="yes"
222   ;;
223   --enable-libhdfs) libhdfs="yes"
224   ;;
225   --disable-lex) disable_lex="yes"
226   ;;
227   --enable-lex) disable_lex="no"
228   ;;
229   --disable-shm) no_shm="yes"
230   ;;
231   --disable-optimizations) disable_opt="yes"
232   ;;
233   --disable-pmem) disable_pmem="yes"
234   ;;
235   --enable-cuda) cuda="yes"
236   ;;
237   --enable-libcufile) libcufile="yes"
238   ;;
239   --disable-native) disable_native="yes"
240   ;;
241   --with-ime=*) ime_path="$optarg"
242   ;;
243   --enable-libiscsi) libiscsi="yes"
244   ;;
245   --enable-libnbd) libnbd="yes"
246   ;;
247   --disable-libzbc) libzbc="no"
248   ;;
249   --disable-xnvme) xnvme="no"
250   ;;
251   --disable-libblkio) libblkio="no"
252   ;;
253   --disable-tcmalloc) disable_tcmalloc="yes"
254   ;;
255   --disable-libnfs) libnfs="no"
256   ;;
257   --enable-libnfs) libnfs="yes"
258   ;;
259   --dynamic-libengines) dynamic_engines="yes"
260   ;;
261   --disable-dfs) dfs="no"
262   ;;
263   --enable-asan) asan="yes"
264   ;;
265   --seed-buckets=*) seed_buckets="$optarg"
266   ;;
267   --disable-tls) tls_check="no"
268   ;;
269   --help)
270     show_help="yes"
271     ;;
272   *)
273   echo "Bad option $opt"
274   show_help="yes"
275   exit_val=1
276   esac
277 done
278
279 if test "$show_help" = "yes" ; then
280   echo "--prefix=               Use this directory as installation prefix"
281   echo "--cpu=                  Specify target CPU if auto-detect fails"
282   echo "--cc=                   Specify compiler to use"
283   echo "--extra-cflags=         Specify extra CFLAGS to pass to compiler"
284   echo "--build-32bit-win       Enable 32-bit build on Windows"
285   echo "--target-win-ver=       Minimum version of Windows to target (only accepts 7)"
286   echo "--enable-pdb            Enable Windows PDB symbols generation (needs clang/lld)"
287   echo "--build-static          Build a static fio"
288   echo "--esx                   Configure build options for esx"
289   echo "--enable-gfio           Enable building of gtk gfio"
290   echo "--disable-numa          Disable libnuma even if found"
291   echo "--disable-rdma          Disable RDMA support even if found"
292   echo "--disable-rados         Disable Rados support even if found"
293   echo "--disable-rbd           Disable Rados Block Device even if found"
294   echo "--disable-http          Disable HTTP support even if found"
295   echo "--disable-gfapi         Disable gfapi"
296   echo "--enable-libhdfs        Enable hdfs support"
297   echo "--enable-libnfs         Enable nfs support"
298   echo "--disable-libnfs        Disable nfs support"
299   echo "--disable-lex           Disable use of lex/yacc for math"
300   echo "--disable-pmem          Disable pmem based engines even if found"
301   echo "--enable-lex            Enable use of lex/yacc for math"
302   echo "--disable-shm           Disable SHM support"
303   echo "--disable-optimizations Don't enable compiler optimizations"
304   echo "--enable-cuda           Enable GPUDirect RDMA support"
305   echo "--enable-libcufile      Enable GPUDirect Storage cuFile support"
306   echo "--disable-native        Don't build for native host"
307   echo "--with-ime=             Install path for DDN's Infinite Memory Engine"
308   echo "--enable-libiscsi       Enable iscsi support"
309   echo "--enable-libnbd         Enable libnbd (NBD engine) support"
310   echo "--disable-xnvme         Disable xnvme support even if found"
311   echo "--disable-libblkio      Disable libblkio support even if found"
312   echo "--disable-libzbc        Disable libzbc even if found"
313   echo "--disable-tcmalloc      Disable tcmalloc support"
314   echo "--dynamic-libengines    Lib-based ioengines as dynamic libraries"
315   echo "--disable-dfs           Disable DAOS File System support even if found"
316   echo "--enable-asan           Enable address sanitizer"
317   echo "--seed-buckets=         Number of seed buckets for the refill-buffer"
318   echo "--disable-tls           Disable __thread local storage"
319   exit $exit_val
320 fi
321
322 cross_prefix=${cross_prefix-${CROSS_COMPILE}}
323 # Preferred compiler (can be overriden later after we know the platform):
324 #  ${CC} (if set)
325 #  ${cross_prefix}gcc (if cross-prefix specified)
326 #  gcc if available
327 #  clang if available
328 if test -z "${CC}${cross_prefix}"; then
329   if has gcc; then
330     cc=gcc
331   elif has clang; then
332     cc=clang
333   fi
334 else
335   cc="${CC-${cross_prefix}gcc}"
336 fi
337
338 if check_define __ANDROID__ ; then
339   targetos="Android"
340 elif check_define __linux__ ; then
341   targetos="Linux"
342 elif check_define __OpenBSD__ ; then
343   targetos='OpenBSD'
344 elif check_define __NetBSD__ ; then
345   targetos='NetBSD'
346 elif check_define __sun__ ; then
347   targetos='SunOS'
348   CFLAGS="$CFLAGS -D_REENTRANT"
349 elif check_define _WIN32 ; then
350   targetos='CYGWIN'
351 else
352   targetos=`uname -s`
353 fi
354
355 echo "# Automatically generated by configure - do not modify" > $config_host_mak
356 printf "# Configured with:" >> $config_host_mak
357 printf " '%s'" "$0" "$@" >> $config_host_mak
358 echo >> $config_host_mak
359 echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
360
361 if test "$no_shm" = "yes" ; then
362   output_sym "CONFIG_NO_SHM"
363 fi
364
365 if test "$disable_opt" = "yes" ; then
366   output_sym "CONFIG_FIO_NO_OPT"
367 fi
368
369 # Some host OSes need non-standard checks for which CPU to use.
370 # Note that these checks are broken for cross-compilation: if you're
371 # cross-compiling to one of these OSes then you'll need to specify
372 # the correct CPU with the --cpu option.
373 case $targetos in
374 AIX|OpenBSD|NetBSD)
375   # Unless explicitly enabled, turn off lex.
376   # OpenBSD will hit syntax error when enabled.
377   if test -z "$disable_lex" ; then
378     disable_lex="yes"
379   else
380     force_no_lex_o="yes"
381   fi
382   ;;
383 FreeBSD)
384   CFLAGS="$CFLAGS -I/usr/local/include"
385   LDFLAGS="$LDFLAGS -L/usr/local/lib"
386   ;;
387 Darwin)
388   # on Leopard most of the system is 32-bit, so we have to ask the kernel if
389   # we can run 64-bit userspace code.
390   # If the user didn't specify a CPU explicitly and the kernel says this is
391   # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
392   # detection code.
393   if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
394     cpu="x86_64"
395   fi
396   # Avoid configure feature detection of features provided by weak symbols
397 cat > $TMPC <<EOF
398 int main(void)
399 {
400   return 0;
401 }
402 EOF
403   if compile_prog "" "-Werror=partial-availability" "error on weak symbols"; then
404     CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Werror=partial-availability"
405   fi
406   ;;
407 SunOS)
408   # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
409   if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
410     cpu="x86_64"
411   fi
412   LIBS="-lnsl -lsocket"
413   ;;
414 CYGWIN*)
415   # We still force some options, so keep this message here.
416   echo "Forcing some known good options on Windows"
417   if test -z "${CC}${cross_prefix}"; then
418     if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
419       cc="i686-w64-mingw32-gcc"
420     else
421       cc="x86_64-w64-mingw32-gcc"
422     fi
423   fi
424
425   target_win_ver=$(echo "$target_win_ver" | tr '[:lower:]' '[:upper:]')
426   if test -z "$target_win_ver"; then
427     # Default Windows API target
428     target_win_ver="7"
429   fi
430   if test "$target_win_ver" = "7"; then
431     output_sym "CONFIG_WINDOWS_7"
432     CFLAGS="$CFLAGS -D_WIN32_WINNT=0x0601"
433   else
434     fatal "Unknown target Windows version"
435   fi
436
437   # We need this to be output_sym'd here because this is Windows specific.
438   # The regular configure path never sets this config.
439   output_sym "CONFIG_WINDOWSAIO"
440   # We now take the regular configuration path without having exit 0 here.
441   # Flags below are still necessary mostly for MinGW.
442   build_static="yes"
443   rusage_thread="yes"
444   fdatasync="yes"
445   clock_gettime="yes" # clock_monotonic probe has dependency on this
446   clock_monotonic="yes"
447   sched_idle="yes"
448   pthread_condattr_setclock="no"
449   pthread_affinity="no"
450   ;;
451 esac
452
453 # Now we know the target platform we can have another guess at the preferred
454 # compiler when it wasn't explictly set
455 if test -z "${CC}${cross_prefix}"; then
456   if test "$targetos" = "FreeBSD" || test "$targetos" = "Darwin"; then
457     if has clang; then
458       cc=clang
459     fi
460   fi
461 fi
462 if test -z "$cc"; then
463     echo "configure: failed to find compiler"
464     exit 1
465 fi
466
467 if test ! -z "$cpu" ; then
468   # command line argument
469   :
470 elif check_define __i386__ ; then
471   cpu="i386"
472 elif check_define __x86_64__ ; then
473   cpu="x86_64"
474 elif check_define __sparc__ ; then
475   if check_define __arch64__ ; then
476     cpu="sparc64"
477   else
478     cpu="sparc"
479   fi
480 elif check_define _ARCH_PPC ; then
481   if check_define _ARCH_PPC64 ; then
482     cpu="ppc64"
483   else
484     cpu="ppc"
485   fi
486 elif check_define __mips__ ; then
487   cpu="mips"
488 elif check_define __ia64__ ; then
489   cpu="ia64"
490 elif check_define __s390__ ; then
491   if check_define __s390x__ ; then
492     cpu="s390x"
493   else
494     cpu="s390"
495   fi
496 elif check_define __arm__ ; then
497   cpu="arm"
498 elif check_define __aarch64__ ; then
499   cpu="aarch64"
500 elif check_define __hppa__ ; then
501   cpu="hppa"
502 else
503   cpu=`uname -m`
504 fi
505
506 # Normalise host CPU name and set ARCH.
507 case "$cpu" in
508   ia64|ppc|ppc64|s390|s390x|sparc64)
509     cpu="$cpu"
510   ;;
511   i386|i486|i586|i686|i86pc|BePC)
512     cpu="x86"
513   ;;
514   x86_64|amd64)
515     cpu="x86_64"
516   ;;
517   armv*b|armv*l|arm)
518     cpu="arm"
519   ;;
520   aarch64)
521     cpu="arm64"
522   ;;
523   hppa|parisc|parisc64)
524     cpu="hppa"
525   ;;
526   mips*)
527     cpu="mips"
528   ;;
529   sparc|sun4[cdmuv])
530     cpu="sparc"
531   ;;
532   *)
533   echo "Unknown CPU"
534   ;;
535 esac
536
537 ##########################################
538 # check cross compile
539
540 if test "$cross_compile" != "yes" ; then
541   cross_compile="no"
542 fi
543 cat > $TMPC <<EOF
544 int main(void)
545 {
546   return 0;
547 }
548 EOF
549 if compile_prog "" "" "cross"; then
550   $TMPE 2>/dev/null || cross_compile="yes"
551 else
552   fatal "compile test failed"
553 fi
554
555 ##########################################
556 # check endianness
557 if test "$bigendian" != "yes" ; then
558   bigendian="no"
559 fi
560 if test "$cross_compile" = "no" ; then
561   cat > $TMPC <<EOF
562 #include <inttypes.h>
563 int main(void)
564 {
565   volatile uint32_t i=0x01234567;
566   return (*((uint8_t*)(&i))) == 0x67;
567 }
568 EOF
569   if compile_prog "" "" "endian"; then
570     $TMPE && bigendian="yes"
571   fi
572 else
573   # If we're cross compiling, try our best to work it out and rely on the
574   # run-time check to fail if we get it wrong.
575   cat > $TMPC <<EOF
576 #include <endian.h>
577 int main(void)
578 {
579 #if __BYTE_ORDER != __BIG_ENDIAN
580 # error "Unknown endianness"
581 #endif
582 }
583 EOF
584   compile_prog "" "" "endian" && bigendian="yes"
585   check_define "__ARMEB__" && bigendian="yes"
586   check_define "__MIPSEB__" && bigendian="yes"
587 fi
588
589
590 print_config "Operating system" "$targetos"
591 print_config "CPU" "$cpu"
592 print_config "Big endian" "$bigendian"
593 if test ! -z "$target_win_ver"; then
594   print_config "Target Windows version" "$target_win_ver"
595 fi
596 print_config "Compiler" "$cc"
597 print_config "Cross compile" "$cross_compile"
598 echo
599
600 ##########################################
601 # See if we need to build a static build
602 if test "$build_static" = "yes" ; then
603   CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
604   LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
605 else
606   build_static="no"
607 fi
608 print_config "Static build" "$build_static"
609
610 ##########################################
611 # check for C11 atomics support
612 cat > $TMPC <<EOF
613 #include <stdatomic.h>
614 int main(void)
615 {
616   _Atomic unsigned v;
617   atomic_load(&v);
618   return 0;
619 }
620 EOF
621 if ! compile_prog "" "" "C11 atomics"; then
622   echo
623   echo "Your compiler doesn't support C11 atomics. gcc 4.9/clang 3.6 are the"
624   echo "minimum versions with it - perhaps your compiler is too old?"
625   fatal "C11 atomics support not found"
626 fi
627
628
629 ##########################################
630 # check for wordsize
631 wordsize="0"
632 cat > $TMPC <<EOF
633 #include <limits.h>
634 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
635 int main(void)
636 {
637   BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
638   return 0;
639 }
640 EOF
641 if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
642   wordsize="32"
643 elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
644   wordsize="64"
645 else
646   fatal "Unknown wordsize"
647 fi
648 print_config "Wordsize" "$wordsize"
649
650 ##########################################
651 # zlib probe
652 if test "$zlib" != "yes" ; then
653   zlib="no"
654 fi
655 cat > $TMPC <<EOF
656 #include <zlib.h>
657 int main(void)
658 {
659   z_stream stream;
660   if (inflateInit(&stream) != Z_OK)
661     return 1;
662   return 0;
663 }
664 EOF
665 if compile_prog "" "-lz" "zlib" ; then
666   zlib=yes
667   LIBS="-lz $LIBS"
668 fi
669 print_config "zlib" "$zlib"
670
671 ##########################################
672 # fcntl(F_FULLFSYNC) support
673 if test "$fcntl_sync" != "yes" ; then
674   fcntl_sync="no"
675 fi
676 cat > $TMPC << EOF
677 #include <unistd.h>
678 #include <fcntl.h>
679
680 int main(int argc, char **argv)
681 {
682   return fcntl(0, F_FULLFSYNC);
683 }
684 EOF
685 if compile_prog "" "" "fcntl(F_FULLFSYNC)" ; then
686     fcntl_sync="yes"
687 fi
688 print_config "fcntl(F_FULLFSYNC)" "$fcntl_sync"
689
690 ##########################################
691 # linux-aio probe
692 if test "$libaio" != "yes" ; then
693   libaio="no"
694 fi
695 if test "$esx" != "yes" ; then
696   cat > $TMPC <<EOF
697 #include <libaio.h>
698 #include <stddef.h>
699 int main(void)
700 {
701   io_setup(0, NULL);
702   return 0;
703 }
704 EOF
705   if compile_prog "" "-laio" "libaio" ; then
706     libaio=yes
707   else
708     if test "$libaio" = "yes" ; then
709       feature_not_found "linux AIO" "libaio-dev or libaio-devel"
710     fi
711     libaio=no
712   fi
713
714   cat > $TMPC <<EOF
715 #include <libaio.h>
716 #include <stddef.h>
717 int main(void)
718 {
719   io_prep_preadv2(NULL, 0, NULL, 0, 0, 0);
720   io_prep_pwritev2(NULL, 0, NULL, 0, 0, 0);
721   return 0;
722 }
723 EOF
724   if compile_prog "" "" "libaio rw flags" ; then
725     libaio_rw_flags=yes
726   else
727     libaio_rw_flags=no
728   fi
729 fi
730 print_config "Linux AIO support" "$libaio"
731 print_config "Linux AIO support rw flags" "$libaio_rw_flags"
732
733 ##########################################
734 # posix aio probe
735 if test "$posix_aio" != "yes" ; then
736   posix_aio="no"
737 fi
738 if test "$posix_aio_lrt" != "yes" ; then
739   posix_aio_lrt="no"
740 fi
741 cat > $TMPC <<EOF
742 #include <aio.h>
743 int main(void)
744 {
745   struct aiocb cb;
746   aio_read(&cb);
747   return 0;
748 }
749 EOF
750 if compile_prog "" "" "posixaio" ; then
751   posix_aio="yes"
752 elif compile_prog "" "-lrt" "posixaio -lrt"; then
753   posix_aio="yes"
754   posix_aio_lrt="yes"
755   LIBS="-lrt $LIBS"
756 fi
757 print_config "POSIX AIO support" "$posix_aio"
758 print_config "POSIX AIO support needs -lrt" "$posix_aio_lrt"
759
760 ##########################################
761 # posix aio fsync probe
762 if test "$posix_aio_fsync" != "yes" ; then
763   posix_aio_fsync="no"
764 fi
765 if test "$posix_aio" = "yes" ; then
766   cat > $TMPC <<EOF
767 #include <fcntl.h>
768 #include <aio.h>
769 int main(void)
770 {
771   struct aiocb cb;
772   return aio_fsync(O_SYNC, &cb);
773   return 0;
774 }
775 EOF
776   if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
777     posix_aio_fsync=yes
778   fi
779 fi
780 print_config "POSIX AIO fsync" "$posix_aio_fsync"
781
782 ##########################################
783 # POSIX pshared attribute probe
784 if test "$posix_pshared" != "yes" ; then
785   posix_pshared="no"
786 fi
787 cat > $TMPC <<EOF
788 #include <unistd.h>
789 int main(void)
790 {
791 #if defined(_POSIX_THREAD_PROCESS_SHARED) && ((_POSIX_THREAD_PROCESS_SHARED + 0) > 0)
792 # if defined(__CYGWIN__)
793 #  error "_POSIX_THREAD_PROCESS_SHARED is buggy on Cygwin"
794 # elif defined(__APPLE__)
795 #  include <AvailabilityMacros.h>
796 #  include <TargetConditionals.h>
797 #  if TARGET_OS_MAC && MAC_OS_X_VERSION_MIN_REQUIRED < 1070
798 #   error "_POSIX_THREAD_PROCESS_SHARED is buggy/unsupported prior to OSX 10.7"
799 #  endif
800 # endif
801 #else
802 # error "_POSIX_THREAD_PROCESS_SHARED is unsupported"
803 #endif
804   return 0;
805 }
806 EOF
807 if compile_prog "" "$LIBS" "posix_pshared" ; then
808   posix_pshared=yes
809 fi
810 print_config "POSIX pshared support" "$posix_pshared"
811
812 ##########################################
813 # POSIX pthread_condattr_setclock() probe
814 if test "$pthread_condattr_setclock" != "no" ; then
815   cat > $TMPC <<EOF
816 #include <pthread.h>
817 int main(void)
818 {
819   pthread_condattr_t condattr;
820   pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC);
821   return 0;
822 }
823 EOF
824   if compile_prog "" "$LIBS" "pthread_condattr_setclock" ; then
825     pthread_condattr_setclock=yes
826   elif compile_prog "" "$LIBS -lpthread" "pthread_condattr_setclock" ; then
827     pthread_condattr_setclock=yes
828     LIBS="$LIBS -lpthread"
829   fi
830 fi
831 print_config "pthread_condattr_setclock()" "$pthread_condattr_setclock"
832
833 ##########################################
834 # pthread_sigmask() probe
835 if test "$pthread_sigmask" != "yes" ; then
836   pthread_sigmask="no"
837 fi
838 cat > $TMPC <<EOF
839 #include <stddef.h> /* NULL */
840 #include <signal.h> /* pthread_sigmask() */
841 int main(void)
842 {
843   return pthread_sigmask(0, NULL, NULL);
844 }
845 EOF
846 if compile_prog "" "$LIBS" "pthread_sigmask" ; then
847   pthread_sigmask=yes
848 elif compile_prog "" "$LIBS -lpthread" "pthread_sigmask" ; then
849   pthread_sigmask=yes
850   LIBS="$LIBS -lpthread"
851 fi
852 print_config "pthread_sigmask()" "$pthread_sigmask"
853
854 ##########################################
855 # pthread_getaffinity_np() probe
856 if test "$pthread_getaffinity" != "yes" ; then
857   pthread_getaffinity="no"
858 fi
859 cat > $TMPC <<EOF
860 #include <stddef.h> /* NULL */
861 #include <signal.h> /* pthread_sigmask() */
862 #include <pthread.h>
863 int main(void)
864 {
865   cpu_set_t set;
866   return pthread_getaffinity_np(pthread_self(), sizeof(set), &set);
867 }
868 EOF
869 if compile_prog "" "$LIBS" "pthread_getaffinity" ; then
870   pthread_getaffinity="yes"
871 elif compile_prog "" "$LIBS -lpthread" "pthread_getaffinity" ; then
872   pthread_getaffinity="yes"
873   LIBS="$LIBS -lpthread"
874 fi
875 print_config "pthread_getaffinity_np()" "$pthread_getaffinity"
876
877 ##########################################
878 # solaris aio probe
879 if test "$solaris_aio" != "yes" ; then
880   solaris_aio="no"
881 fi
882 cat > $TMPC <<EOF
883 #include <sys/types.h>
884 #include <sys/asynch.h>
885 #include <unistd.h>
886 int main(void)
887 {
888   aio_result_t res;
889   return aioread(0, NULL, 0, 0, SEEK_SET, &res);
890   return 0;
891 }
892 EOF
893 if compile_prog "" "-laio" "solarisaio" ; then
894   solaris_aio=yes
895   LIBS="-laio $LIBS"
896 fi
897 print_config "Solaris AIO support" "$solaris_aio"
898
899 ##########################################
900 # __sync_fetch_and_add test
901 if test "$sfaa" != "yes" ; then
902   sfaa="no"
903 fi
904 cat > $TMPC << EOF
905 #include <inttypes.h>
906 static int sfaa(uint64_t *ptr)
907 {
908   return __sync_fetch_and_add(ptr, 0);
909 }
910
911 int main(int argc, char **argv)
912 {
913   uint64_t val = 42;
914   sfaa(&val);
915   return val;
916 }
917 EOF
918 if compile_prog "" "" "__sync_fetch_and_add()" ; then
919     sfaa="yes"
920 fi
921 print_config "__sync_fetch_and_add" "$sfaa"
922
923 ##########################################
924 # __sync_synchronize() test
925 if test "$sync_sync" != "yes" ; then
926   sync_sync="no"
927 fi
928 cat > $TMPC << EOF
929 #include <inttypes.h>
930
931 int main(int argc, char **argv)
932 {
933   __sync_synchronize();
934   return 0;
935 }
936 EOF
937 if compile_prog "" "" "__sync_synchronize()" ; then
938     sync_sync="yes"
939 fi
940 print_config "__sync_synchronize" "$sync_sync"
941
942 ##########################################
943 # __sync_val_compare_and_swap() test
944 if test "$cmp_swap" != "yes" ; then
945   cmp_swap="no"
946 fi
947 cat > $TMPC << EOF
948 #include <inttypes.h>
949
950 int main(int argc, char **argv)
951 {
952   int x = 0;
953   return __sync_val_compare_and_swap(&x, 1, 2);
954 }
955 EOF
956 if compile_prog "" "" "__sync_val_compare_and_swap()" ; then
957     cmp_swap="yes"
958 fi
959 print_config "__sync_val_compare_and_swap" "$cmp_swap"
960
961 ##########################################
962 # libverbs probe
963 if test "$libverbs" != "yes" ; then
964   libverbs="no"
965 fi
966 cat > $TMPC << EOF
967 #include <infiniband/verbs.h>
968 int main(int argc, char **argv)
969 {
970   struct ibv_pd *pd = ibv_alloc_pd(NULL);
971   return pd != NULL;
972 }
973 EOF
974 if test "$disable_rdma" != "yes" && compile_prog "" "-libverbs" "libverbs" ; then
975     libverbs="yes"
976 fi
977 print_config "libverbs" "$libverbs"
978
979 ##########################################
980 # rdmacm probe
981 if test "$rdmacm" != "yes" ; then
982   rdmacm="no"
983 fi
984 cat > $TMPC << EOF
985 #include <stdio.h>
986 #include <rdma/rdma_cma.h>
987 int main(int argc, char **argv)
988 {
989   rdma_destroy_qp(NULL);
990   return 0;
991 }
992 EOF
993 if test "$disable_rdma" != "yes" && compile_prog "" "-lrdmacm" "rdma"; then
994     rdmacm="yes"
995 fi
996 print_config "rdmacm" "$rdmacm"
997
998 ##########################################
999 # librpma probe
1000 # The librpma engines require librpma>=v0.11.0 with rpma_cq_get_wc().
1001 if test "$librpma" != "yes" ; then
1002   librpma="no"
1003 fi
1004 cat > $TMPC << EOF
1005 #include <librpma.h>
1006 int main(void)
1007 {
1008   void *ptr = rpma_cq_get_wc;
1009   (void) ptr; /* unused */
1010   return 0;
1011 }
1012 EOF
1013 if test "$disable_rdma" != "yes" && compile_prog "" "-lrpma" "rpma"; then
1014     librpma="yes"
1015 fi
1016 print_config "librpma" "$librpma"
1017
1018 ##########################################
1019 # libprotobuf-c probe
1020 if test "$libprotobuf_c" != "yes" ; then
1021   libprotobuf_c="no"
1022 fi
1023 cat > $TMPC << EOF
1024 #include <stdio.h>
1025 #include <protobuf-c/protobuf-c.h>
1026 #if !defined(PROTOBUF_C_VERSION_NUMBER)
1027 # error PROTOBUF_C_VERSION_NUMBER is not defined!
1028 #endif
1029 int main(int argc, char **argv)
1030 {
1031   (void)protobuf_c_message_check(NULL);
1032   return 0;
1033 }
1034 EOF
1035 if compile_prog "" "-lprotobuf-c" "protobuf_c"; then
1036     libprotobuf_c="yes"
1037 fi
1038 print_config "libprotobuf_c" "$libprotobuf_c"
1039
1040 ##########################################
1041 # asprintf() and vasprintf() probes
1042 if test "$have_asprintf" != "yes" ; then
1043   have_asprintf="no"
1044 fi
1045 cat > $TMPC << EOF
1046 #include <stdio.h>
1047
1048 int main(int argc, char **argv)
1049 {
1050   char *buf;
1051   return asprintf(&buf, "%s", "str") == 0;
1052 }
1053 EOF
1054 if compile_prog "" "" "have_asprintf"; then
1055     have_asprintf="yes"
1056 fi
1057 print_config "asprintf()" "$have_asprintf"
1058
1059 if test "$have_vasprintf" != "yes" ; then
1060   have_vasprintf="no"
1061 fi
1062 cat > $TMPC << EOF
1063 #include <stdio.h>
1064
1065 int main(int argc, char **argv)
1066 {
1067   va_list ap;
1068   char *buf;
1069   return vasprintf(&buf, "%s", ap) == 0;
1070 }
1071 EOF
1072 if compile_prog "" "" "have_vasprintf"; then
1073     have_vasprintf="yes"
1074 fi
1075 print_config "vasprintf()" "$have_vasprintf"
1076
1077 ##########################################
1078 # Linux fallocate probe
1079 if test "$linux_fallocate" != "yes" ; then
1080   linux_fallocate="no"
1081 fi
1082 cat > $TMPC << EOF
1083 #include <stdio.h>
1084 #include <fcntl.h>
1085 #include <linux/falloc.h>
1086 int main(int argc, char **argv)
1087 {
1088   int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
1089   return r;
1090 }
1091 EOF
1092 if compile_prog "" "" "linux_fallocate"; then
1093     linux_fallocate="yes"
1094 fi
1095 print_config "Linux fallocate" "$linux_fallocate"
1096
1097 ##########################################
1098 # POSIX fadvise probe
1099 if test "$posix_fadvise" != "yes" ; then
1100   posix_fadvise="no"
1101 fi
1102 cat > $TMPC << EOF
1103 #include <stdio.h>
1104 #include <fcntl.h>
1105 int main(int argc, char **argv)
1106 {
1107   int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
1108   return r;
1109 }
1110 EOF
1111 if compile_prog "" "" "posix_fadvise"; then
1112     posix_fadvise="yes"
1113 fi
1114 print_config "POSIX fadvise" "$posix_fadvise"
1115
1116 ##########################################
1117 # POSIX fallocate probe
1118 if test "$posix_fallocate" != "yes" ; then
1119   posix_fallocate="no"
1120 fi
1121 cat > $TMPC << EOF
1122 #include <stdio.h>
1123 #include <fcntl.h>
1124 int main(int argc, char **argv)
1125 {
1126   int r = posix_fallocate(0, 0, 1024);
1127   return r;
1128 }
1129 EOF
1130 if compile_prog "" "" "posix_fallocate"; then
1131     posix_fallocate="yes"
1132 fi
1133 print_config "POSIX fallocate" "$posix_fallocate"
1134
1135 ##########################################
1136 # sched_set/getaffinity 2 or 3 argument test
1137 if test "$linux_2arg_affinity" != "yes" ; then
1138   linux_2arg_affinity="no"
1139 fi
1140 if test "$linux_3arg_affinity" != "yes" ; then
1141   linux_3arg_affinity="no"
1142 fi
1143 cat > $TMPC << EOF
1144 #include <sched.h>
1145 int main(int argc, char **argv)
1146 {
1147   cpu_set_t mask = { };
1148
1149   return sched_setaffinity(0, sizeof(mask), &mask);
1150 }
1151 EOF
1152 if compile_prog "" "" "sched_setaffinity(,,)"; then
1153   linux_3arg_affinity="yes"
1154 else
1155   cat > $TMPC << EOF
1156 #include <sched.h>
1157 int main(int argc, char **argv)
1158 {
1159   cpu_set_t mask = { };
1160
1161   return sched_setaffinity(0, &mask);
1162 }
1163 EOF
1164   if compile_prog "" "" "sched_setaffinity(,)"; then
1165     linux_2arg_affinity="yes"
1166   fi
1167 fi
1168 print_config "sched_setaffinity(3 arg)" "$linux_3arg_affinity"
1169 print_config "sched_setaffinity(2 arg)" "$linux_2arg_affinity"
1170
1171 ##########################################
1172 # clock_gettime probe
1173 if test "$clock_gettime" != "yes" ; then
1174   clock_gettime="no"
1175 fi
1176 cat > $TMPC << EOF
1177 #include <stdio.h>
1178 #include <time.h>
1179 int main(int argc, char **argv)
1180 {
1181   struct timespec ts;
1182
1183   return clock_gettime(0, &ts);
1184 }
1185 EOF
1186 if compile_prog "" "" "clock_gettime"; then
1187     clock_gettime="yes"
1188 elif compile_prog "" "-lrt" "clock_gettime"; then
1189     clock_gettime="yes"
1190     LIBS="-lrt $LIBS"
1191 fi
1192 print_config "clock_gettime" "$clock_gettime"
1193
1194 ##########################################
1195 # CLOCK_MONOTONIC probe
1196 if test "$clock_monotonic" != "yes" ; then
1197   clock_monotonic="no"
1198 fi
1199 if test "$clock_gettime" = "yes" ; then
1200   cat > $TMPC << EOF
1201 #include <stdio.h>
1202 #include <time.h>
1203 int main(int argc, char **argv)
1204 {
1205   struct timespec ts;
1206
1207   return clock_gettime(CLOCK_MONOTONIC, &ts);
1208 }
1209 EOF
1210   if compile_prog "" "$LIBS" "clock monotonic"; then
1211       clock_monotonic="yes"
1212   fi
1213 fi
1214 print_config "CLOCK_MONOTONIC" "$clock_monotonic"
1215
1216 ##########################################
1217 # clockid_t probe
1218 if test "$clockid_t" != "yes" ; then
1219   clockid_t="no"
1220 fi
1221 cat > $TMPC << EOF
1222 #include <time.h>
1223 #include <string.h>
1224 int main(int argc, char **argv)
1225 {
1226   volatile clockid_t cid;
1227   memset((void*)&cid, 0, sizeof(cid));
1228   return 0;
1229 }
1230 EOF
1231 if compile_prog "" "$LIBS" "clockid_t"; then
1232   clockid_t="yes"
1233 fi
1234 print_config "clockid_t" "$clockid_t"
1235
1236 ##########################################
1237 # gettimeofday() probe
1238 if test "$gettimeofday" != "yes" ; then
1239   gettimeofday="no"
1240 fi
1241 cat > $TMPC << EOF
1242 #include <sys/time.h>
1243 #include <stdio.h>
1244 int main(int argc, char **argv)
1245 {
1246   struct timeval tv;
1247   return gettimeofday(&tv, NULL);
1248 }
1249 EOF
1250 if compile_prog "" "" "gettimeofday"; then
1251     gettimeofday="yes"
1252 fi
1253 print_config "gettimeofday" "$gettimeofday"
1254
1255 ##########################################
1256 # fdatasync() probe
1257 if test "$fdatasync" != "yes" ; then
1258   fdatasync="no"
1259 fi
1260 cat > $TMPC << EOF
1261 #include <stdio.h>
1262 #include <unistd.h>
1263 int main(int argc, char **argv)
1264 {
1265   return fdatasync(0);
1266 }
1267 EOF
1268 if compile_prog "" "" "fdatasync"; then
1269   fdatasync="yes"
1270 fi
1271 print_config "fdatasync" "$fdatasync"
1272
1273 ##########################################
1274 # pipe() probe
1275 if test "$pipe" != "yes" ; then
1276   pipe="no"
1277 fi
1278 cat > $TMPC << EOF
1279 #include <unistd.h>
1280 int main(int argc, char **argv)
1281 {
1282   int fd[2];
1283   return pipe(fd);
1284 }
1285 EOF
1286 if compile_prog "" "" "pipe"; then
1287   pipe="yes"
1288 fi
1289 print_config "pipe()" "$pipe"
1290
1291 ##########################################
1292 # pipe2() probe
1293 if test "$pipe2" != "yes" ; then
1294   pipe2="no"
1295 fi
1296 cat > $TMPC << EOF
1297 #include <unistd.h>
1298 int main(int argc, char **argv)
1299 {
1300   int fd[2];
1301   return pipe2(fd, 0);
1302 }
1303 EOF
1304 if compile_prog "" "" "pipe2"; then
1305   pipe2="yes"
1306 fi
1307 print_config "pipe2()" "$pipe2"
1308
1309 ##########################################
1310 # pread() probe
1311 if test "$pread" != "yes" ; then
1312   pread="no"
1313 fi
1314 cat > $TMPC << EOF
1315 #include <unistd.h>
1316 int main(int argc, char **argv)
1317 {
1318   return pread(0, NULL, 0, 0);
1319 }
1320 EOF
1321 if compile_prog "" "" "pread"; then
1322   pread="yes"
1323 fi
1324 print_config "pread()" "$pread"
1325
1326 ##########################################
1327 # sync_file_range() probe
1328 if test "$sync_file_range" != "yes" ; then
1329   sync_file_range="no"
1330 fi
1331 cat > $TMPC << EOF
1332 #include <stdio.h>
1333 #include <unistd.h>
1334 #include <fcntl.h>
1335 #include <linux/fs.h>
1336 int main(int argc, char **argv)
1337 {
1338   unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
1339                         SYNC_FILE_RANGE_WAIT_AFTER;
1340   return sync_file_range(0, 0, 0, flags);
1341 }
1342 EOF
1343 if compile_prog "" "" "sync_file_range"; then
1344   sync_file_range="yes"
1345 fi
1346 print_config "sync_file_range" "$sync_file_range"
1347
1348 ##########################################
1349 # ext4 move extent probe
1350 if test "$ext4_me" != "yes" ; then
1351   ext4_me="no"
1352 fi
1353 cat > $TMPC << EOF
1354 #include <fcntl.h>
1355 #include <sys/ioctl.h>
1356 int main(int argc, char **argv)
1357 {
1358   struct move_extent me;
1359   return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
1360 }
1361 EOF
1362 if compile_prog "" "" "ext4 move extent" ; then
1363   ext4_me="yes"
1364 elif test $targetos = "Linux" ; then
1365   # On Linux, just default to it on and let it error at runtime if we really
1366   # don't have it. None of my updated systems have it defined, but it does
1367   # work. Takes a while to bubble back.
1368   ext4_me="yes"
1369 fi
1370 print_config "EXT4 move extent" "$ext4_me"
1371
1372 ##########################################
1373 # splice probe
1374 if test "$linux_splice" != "yes" ; then
1375   linux_splice="no"
1376 fi
1377 cat > $TMPC << EOF
1378 #include <stdio.h>
1379 #include <fcntl.h>
1380 int main(int argc, char **argv)
1381 {
1382   return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
1383 }
1384 EOF
1385 if compile_prog "" "" "linux splice"; then
1386   linux_splice="yes"
1387 fi
1388 print_config "Linux splice(2)" "$linux_splice"
1389
1390 ##########################################
1391 # libnuma probe
1392 if test "$libnuma" != "yes" ; then
1393   libnuma="no"
1394 fi
1395 cat > $TMPC << EOF
1396 #include <numa.h>
1397 int main(int argc, char **argv)
1398 {
1399   return numa_available();
1400 }
1401 EOF
1402 if test "$disable_numa" != "yes"  && compile_prog "" "-lnuma" "libnuma"; then
1403   libnuma="yes"
1404   LIBS="-lnuma $LIBS"
1405 fi
1406 print_config "libnuma" "$libnuma"
1407
1408 ##########################################
1409 # libnuma 2.x version API, initialize with "no" only if $libnuma is set to "yes"
1410 if test "$libnuma" = "yes" ; then
1411 libnuma_v2="no"
1412 cat > $TMPC << EOF
1413 #include <numa.h>
1414 int main(int argc, char **argv)
1415 {
1416   struct bitmask *mask = numa_parse_nodestring(NULL);
1417   return mask->size == 0;
1418 }
1419 EOF
1420 if compile_prog "" "" "libnuma api"; then
1421   libnuma_v2="yes"
1422 fi
1423 print_config "libnuma v2" "$libnuma_v2"
1424 fi
1425
1426 ##########################################
1427 # strsep() probe
1428 if test "$strsep" != "yes" ; then
1429   strsep="no"
1430 fi
1431 cat > $TMPC << EOF
1432 #include <string.h>
1433 int main(int argc, char **argv)
1434 {
1435   static char *string = "This is a string";
1436   strsep(&string, "needle");
1437   return 0;
1438 }
1439 EOF
1440 if compile_prog "" "" "strsep"; then
1441   strsep="yes"
1442 fi
1443 print_config "strsep" "$strsep"
1444
1445 ##########################################
1446 # strcasestr() probe
1447 if test "$strcasestr" != "yes" ; then
1448   strcasestr="no"
1449 fi
1450 cat > $TMPC << EOF
1451 #include <string.h>
1452 int main(int argc, char **argv)
1453 {
1454   return strcasestr(argv[0], argv[1]) != NULL;
1455 }
1456 EOF
1457 if compile_prog "" "" "strcasestr"; then
1458   strcasestr="yes"
1459 fi
1460 print_config "strcasestr" "$strcasestr"
1461
1462 ##########################################
1463 # strlcat() probe
1464 if test "$strlcat" != "yes" ; then
1465   strlcat="no"
1466 fi
1467 cat > $TMPC << EOF
1468 #include <string.h>
1469 int main(int argc, char **argv)
1470 {
1471   static char dst[64];
1472   static char *string = "This is a string";
1473   memset(dst, 0, sizeof(dst));
1474   strlcat(dst, string, sizeof(dst));
1475   return 0;
1476 }
1477 EOF
1478 if compile_prog "" "" "strlcat"; then
1479   strlcat="yes"
1480 fi
1481 print_config "strlcat" "$strlcat"
1482
1483 ##########################################
1484 # getopt_long_only() probe
1485 if test "$getopt_long_only" != "yes" ; then
1486   getopt_long_only="no"
1487 fi
1488 cat > $TMPC << EOF
1489 #include <unistd.h>
1490 #include <stdio.h>
1491 #include <getopt.h>
1492 int main(int argc, char **argv)
1493 {
1494   int c = getopt_long_only(argc, argv, "", NULL, NULL);
1495   return c;
1496 }
1497 EOF
1498 if compile_prog "" "" "getopt_long_only"; then
1499   getopt_long_only="yes"
1500 fi
1501 print_config "getopt_long_only()" "$getopt_long_only"
1502
1503 ##########################################
1504 # inet_aton() probe
1505 if test "$inet_aton" != "yes" ; then
1506   inet_aton="no"
1507 fi
1508 cat > $TMPC << EOF
1509 #ifdef _WIN32
1510 #include <winsock2.h>
1511 #else
1512 #include <sys/socket.h>
1513 #include <arpa/inet.h>
1514 #endif
1515 #include <stdio.h>
1516 int main(int argc, char **argv)
1517 {
1518   struct in_addr in;
1519   return inet_aton(NULL, &in);
1520 }
1521 EOF
1522 if compile_prog "" "" "inet_aton"; then
1523   inet_aton="yes"
1524 fi
1525 print_config "inet_aton" "$inet_aton"
1526
1527 ##########################################
1528 # socklen_t probe
1529 if test "$socklen_t" != "yes" ; then
1530   socklen_t="no"
1531 fi
1532 cat > $TMPC << EOF
1533 #ifdef _WIN32
1534 #include <winsock2.h>
1535 #include <ws2tcpip.h>
1536 #else
1537 #include <sys/socket.h>
1538 #endif
1539 int main(int argc, char **argv)
1540 {
1541   socklen_t len = 0;
1542   return len;
1543 }
1544 EOF
1545 if compile_prog "" "" "socklen_t"; then
1546   socklen_t="yes"
1547 fi
1548 print_config "socklen_t" "$socklen_t"
1549
1550 ##########################################
1551 # Whether or not __thread is supported for TLS
1552 if test "$tls_thread" != "yes" ; then
1553   tls_thread="no"
1554 fi
1555 if test "$tls_check" != "no"; then
1556   cat > $TMPC << EOF
1557 #include <stdio.h>
1558 static __thread int ret;
1559 int main(int argc, char **argv)
1560 {
1561   return ret;
1562 }
1563 EOF
1564 if compile_prog "" "" "__thread"; then
1565   tls_thread="yes"
1566 fi
1567 fi
1568 print_config "__thread" "$tls_thread"
1569
1570 ##########################################
1571 # Check if we have required gtk/glib support for gfio
1572 if test "$gfio" != "yes" ; then
1573   gfio="no"
1574 fi
1575 if test "$gfio_check" = "yes" ; then
1576   cat > $TMPC << EOF
1577 #include <glib.h>
1578 #include <cairo.h>
1579 #include <gtk/gtk.h>
1580 int main(void)
1581 {
1582   gdk_threads_enter();
1583   gdk_threads_leave();
1584
1585   return GTK_CHECK_VERSION(2, 18, 0) ? 0 : 1; /* 0 on success */
1586 }
1587 EOF
1588 GTK_CFLAGS=$(${cross_prefix}pkg-config --cflags gtk+-2.0 gthread-2.0)
1589 ORG_LDFLAGS=$LDFLAGS
1590 LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1591 if test "$?" != "0" ; then
1592   echo "configure: gtk and gthread not found"
1593   exit 1
1594 fi
1595 GTK_LIBS=$(${cross_prefix}pkg-config --libs gtk+-2.0 gthread-2.0)
1596 if test "$?" != "0" ; then
1597   echo "configure: gtk and gthread not found"
1598   exit 1
1599 fi
1600 gfio="yes"
1601 if check_min_lib_version gtk+-2.0 2.18.0 "gfio"; then
1602   if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1603     GFIO_LIBS="$LIBS $GTK_LIBS"
1604     CFLAGS="$CFLAGS $GTK_CFLAGS"
1605   else
1606     echo "Please install gtk and gdk libraries"
1607     gfio="no"
1608   fi
1609 else
1610   gfio="no"
1611 fi
1612 LDFLAGS=$ORG_LDFLAGS
1613 fi
1614
1615 if test "$gfio_check" = "yes" ; then
1616   print_config "gtk 2.18 or higher" "$gfio"
1617 fi
1618
1619 ##########################################
1620 # Check whether we have getrusage(RUSAGE_THREAD)
1621 if test "$rusage_thread" != "yes" ; then
1622   rusage_thread="no"
1623 fi
1624 cat > $TMPC << EOF
1625 #include <sys/time.h>
1626 #include <sys/resource.h>
1627 int main(int argc, char **argv)
1628 {
1629   struct rusage ru;
1630   getrusage(RUSAGE_THREAD, &ru);
1631   return 0;
1632 }
1633 EOF
1634 if compile_prog "" "" "RUSAGE_THREAD"; then
1635   rusage_thread="yes"
1636 fi
1637 print_config "RUSAGE_THREAD" "$rusage_thread"
1638
1639 ##########################################
1640 # Check whether we have SCHED_IDLE
1641 if test "$sched_idle" != "yes" ; then
1642   sched_idle="no"
1643 fi
1644 cat > $TMPC << EOF
1645 #include <sched.h>
1646 int main(int argc, char **argv)
1647 {
1648   struct sched_param p = { };
1649
1650   return sched_setscheduler(0, SCHED_IDLE, &p);
1651 }
1652 EOF
1653 if compile_prog "" "" "SCHED_IDLE"; then
1654   sched_idle="yes"
1655 fi
1656 print_config "SCHED_IDLE" "$sched_idle"
1657
1658 ##########################################
1659 # Check whether we have TCP_NODELAY
1660 if test "$tcp_nodelay" != "yes" ; then
1661   tcp_nodelay="no"
1662 fi
1663 cat > $TMPC << EOF
1664 #ifdef _WIN32
1665 #include <winsock2.h>
1666 #else
1667 #include <stdio.h>
1668 #include <sys/types.h>
1669 #include <sys/socket.h>
1670 #include <netinet/tcp.h>
1671 #endif
1672 int main(int argc, char **argv)
1673 {
1674   return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1675 }
1676 EOF
1677 if compile_prog "" "" "TCP_NODELAY"; then
1678   tcp_nodelay="yes"
1679 elif compile_prog "" "-lws2_32" "TCP_NODELAY"; then
1680   tcp_nodelay="yes"
1681   LIBS="$LIBS -lws2_32"
1682 fi
1683 print_config "TCP_NODELAY" "$tcp_nodelay"
1684
1685 ##########################################
1686 # Check whether we have SO_SNDBUF
1687 if test "$window_size" != "yes" ; then
1688   window_size="no"
1689 fi
1690 cat > $TMPC << EOF
1691 #ifdef _WIN32
1692 #include <winsock2.h>
1693 #else
1694 #include <stdio.h>
1695 #include <sys/types.h>
1696 #include <sys/socket.h>
1697 #include <netinet/tcp.h>
1698 #endif
1699 int main(int argc, char **argv)
1700 {
1701   setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1702   setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1703 }
1704 EOF
1705 if compile_prog "" "" "SO_SNDBUF"; then
1706   window_size="yes"
1707 elif compile_prog "" "-lws2_32" "SO_SNDBUF"; then
1708   window_size="yes"
1709   LIBS="$LIBS -lws2_32"
1710 fi
1711 print_config "Net engine window_size" "$window_size"
1712
1713 ##########################################
1714 # Check whether we have TCP_MAXSEG
1715 if test "$mss" != "yes" ; then
1716   mss="no"
1717 fi
1718 cat > $TMPC << EOF
1719 #ifdef _WIN32
1720 #include <winsock2.h>
1721 #else
1722 #include <stdio.h>
1723 #include <sys/types.h>
1724 #include <sys/socket.h>
1725 #include <netinet/tcp.h>
1726 #include <arpa/inet.h>
1727 #include <netinet/in.h>
1728 #endif
1729 int main(int argc, char **argv)
1730 {
1731   return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1732 }
1733 EOF
1734 if compile_prog "" "" "TCP_MAXSEG"; then
1735   mss="yes"
1736 elif compile_prog "" "-lws2_32" "TCP_MAXSEG"; then
1737   mss="yes"
1738   LIBS="$LIBS -lws2_32"
1739 fi
1740 print_config "TCP_MAXSEG" "$mss"
1741
1742 ##########################################
1743 # Check whether we have RLIMIT_MEMLOCK
1744 if test "$rlimit_memlock" != "yes" ; then
1745   rlimit_memlock="no"
1746 fi
1747 cat > $TMPC << EOF
1748 #include <sys/time.h>
1749 #include <sys/resource.h>
1750 int main(int argc, char **argv)
1751 {
1752   struct rlimit rl;
1753   return getrlimit(RLIMIT_MEMLOCK, &rl);
1754 }
1755 EOF
1756 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1757   rlimit_memlock="yes"
1758 fi
1759 print_config "RLIMIT_MEMLOCK" "$rlimit_memlock"
1760
1761 ##########################################
1762 # Check whether we have pwritev/preadv
1763 if test "$pwritev" != "yes" ; then
1764   pwritev="no"
1765 fi
1766 cat > $TMPC << EOF
1767 #include <stdio.h>
1768 #include <sys/uio.h>
1769 int main(int argc, char **argv)
1770 {
1771   struct iovec iov[1] = { };
1772
1773   return pwritev(0, iov, 1, 0) + preadv(0, iov, 1, 0);
1774 }
1775 EOF
1776 if compile_prog "" "" "pwritev"; then
1777   pwritev="yes"
1778 fi
1779 print_config "pwritev/preadv" "$pwritev"
1780
1781 ##########################################
1782 # Check whether we have pwritev2/preadv2
1783 if test "$pwritev2" != "yes" ; then
1784   pwritev2="no"
1785 fi
1786 cat > $TMPC << EOF
1787 #include <stdio.h>
1788 #include <sys/uio.h>
1789 int main(int argc, char **argv)
1790 {
1791   struct iovec iov[1] = { };
1792
1793   return pwritev2(0, iov, 1, 0, 0) + preadv2(0, iov, 1, 0, 0);
1794 }
1795 EOF
1796 if compile_prog "" "" "pwritev2"; then
1797   pwritev2="yes"
1798 fi
1799 print_config "pwritev2/preadv2" "$pwritev2"
1800
1801 ##########################################
1802 # Check whether we have the required functions for ipv6
1803 if test "$ipv6" != "yes" ; then
1804   ipv6="no"
1805 fi
1806 cat > $TMPC << EOF
1807 #ifdef _WIN32
1808 #include <winsock2.h>
1809 #include <ws2tcpip.h>
1810 #else
1811 #include <sys/types.h>
1812 #include <sys/socket.h>
1813 #include <netinet/in.h>
1814 #include <netdb.h>
1815 #endif
1816 #include <stdio.h>
1817 int main(int argc, char **argv)
1818 {
1819   struct addrinfo hints = { };
1820   struct in6_addr addr = in6addr_any;
1821   int ret;
1822
1823   ret = getaddrinfo(NULL, NULL, &hints, NULL);
1824   freeaddrinfo(NULL);
1825   printf("%s %d\n", gai_strerror(ret), addr.s6_addr[0]);
1826
1827   return 0;
1828 }
1829 EOF
1830 if compile_prog "" "" "ipv6"; then
1831   ipv6="yes"
1832 fi
1833 print_config "IPv6 helpers" "$ipv6"
1834
1835 ##########################################
1836 # check for http
1837 if test "$http" != "yes" ; then
1838   http="no"
1839 fi
1840 # check for openssl >= 1.1.0, which uses an opaque HMAC_CTX pointer
1841 cat > $TMPC << EOF
1842 #include <curl/curl.h>
1843 #include <openssl/hmac.h>
1844
1845 int main(int argc, char **argv)
1846 {
1847   CURL *curl;
1848   HMAC_CTX *ctx;
1849
1850   curl = curl_easy_init();
1851   curl_easy_cleanup(curl);
1852
1853   ctx = HMAC_CTX_new();
1854   HMAC_CTX_reset(ctx);
1855   HMAC_CTX_free(ctx);
1856   return 0;
1857 }
1858 EOF
1859 # openssl < 1.1.0 uses the HMAC_CTX type directly
1860 cat > $TMPC2 << EOF
1861 #include <curl/curl.h>
1862 #include <openssl/hmac.h>
1863
1864 int main(int argc, char **argv)
1865 {
1866   CURL *curl;
1867   HMAC_CTX ctx;
1868
1869   curl = curl_easy_init();
1870   curl_easy_cleanup(curl);
1871
1872   HMAC_CTX_init(&ctx);
1873   HMAC_CTX_cleanup(&ctx);
1874   return 0;
1875 }
1876 EOF
1877 if test "$disable_http" != "yes"; then
1878   HTTP_LIBS="-lcurl -lssl -lcrypto"
1879   if compile_prog "" "$HTTP_LIBS" "curl-new-ssl"; then
1880     output_sym "CONFIG_HAVE_OPAQUE_HMAC_CTX"
1881     http="yes"
1882   elif mv $TMPC2 $TMPC && compile_prog "" "$HTTP_LIBS" "curl-old-ssl"; then
1883     http="yes"
1884   fi
1885 fi
1886 print_config "http engine" "$http"
1887
1888 ##########################################
1889 # check for rados
1890 if test "$rados" != "yes" ; then
1891   rados="no"
1892 fi
1893 cat > $TMPC << EOF
1894 #include <rados/librados.h>
1895
1896 int main(int argc, char **argv)
1897 {
1898   rados_t cluster;
1899   rados_ioctx_t io_ctx;
1900   const char cluster_name[] = "ceph";
1901   const char user_name[] = "client.admin";
1902   const char pool[] = "rados";
1903
1904   /* The rados_create2 signature required was only introduced in ceph 0.65 */
1905   rados_create2(&cluster, cluster_name, user_name, 0);
1906   rados_ioctx_create(cluster, pool, &io_ctx);
1907
1908   return 0;
1909 }
1910 EOF
1911 if test "$disable_rados" != "yes"  && compile_prog "" "-lrados" "rados"; then
1912   rados="yes"
1913 fi
1914 print_config "Rados engine" "$rados"
1915
1916 ##########################################
1917 # check for rbd
1918 if test "$rbd" != "yes" ; then
1919   rbd="no"
1920 fi
1921 cat > $TMPC << EOF
1922 #include <rbd/librbd.h>
1923
1924 int main(int argc, char **argv)
1925 {
1926   rados_t cluster;
1927   rados_ioctx_t io_ctx;
1928   const char cluster_name[] = "ceph";
1929   const char user_name[] = "client.admin";
1930   const char pool[] = "rbd";
1931   int major, minor, extra;
1932
1933   rbd_version(&major, &minor, &extra);
1934   /* The rados_create2 signature required was only introduced in ceph 0.65 */
1935   rados_create2(&cluster, cluster_name, user_name, 0);
1936   rados_ioctx_create(cluster, pool, &io_ctx);
1937
1938   return 0;
1939 }
1940 EOF
1941 if test "$disable_rbd" != "yes"  && compile_prog "" "-lrbd -lrados" "rbd"; then
1942   rbd="yes"
1943 fi
1944 print_config "Rados Block Device engine" "$rbd"
1945
1946 ##########################################
1947 # check for rbd_poll
1948 if test "$rbd_poll" != "yes" ; then
1949   rbd_poll="no"
1950 fi
1951 if test "$rbd" = "yes"; then
1952 cat > $TMPC << EOF
1953 #include <rbd/librbd.h>
1954 #include <sys/eventfd.h>
1955
1956 int main(int argc, char **argv)
1957 {
1958   rbd_image_t image;
1959   rbd_completion_t comp;
1960
1961   int fd = eventfd(0, EFD_NONBLOCK);
1962   rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1963   rbd_poll_io_events(image, comp, 1);
1964
1965   return 0;
1966 }
1967 EOF
1968 if compile_prog "" "-lrbd -lrados" "rbd"; then
1969   rbd_poll="yes"
1970 fi
1971 print_config "rbd_poll" "$rbd_poll"
1972 fi
1973
1974 ##########################################
1975 # check for rbd_invalidate_cache()
1976 if test "$rbd_inval" != "yes" ; then
1977   rbd_inval="no"
1978 fi
1979 if test "$rbd" = "yes"; then
1980 cat > $TMPC << EOF
1981 #include <rbd/librbd.h>
1982
1983 int main(int argc, char **argv)
1984 {
1985   rbd_image_t image;
1986
1987   return rbd_invalidate_cache(image);
1988 }
1989 EOF
1990 if compile_prog "" "-lrbd -lrados" "rbd"; then
1991   rbd_inval="yes"
1992 fi
1993 print_config "rbd_invalidate_cache" "$rbd_inval"
1994 fi
1995
1996 ##########################################
1997 # Check whether we have setvbuf
1998 if test "$setvbuf" != "yes" ; then
1999   setvbuf="no"
2000 fi
2001 cat > $TMPC << EOF
2002 #include <stdio.h>
2003 int main(int argc, char **argv)
2004 {
2005   FILE *f = NULL;
2006   char buf[80];
2007   setvbuf(f, buf, _IOFBF, sizeof(buf));
2008   return 0;
2009 }
2010 EOF
2011 if compile_prog "" "" "setvbuf"; then
2012   setvbuf="yes"
2013 fi
2014 print_config "setvbuf" "$setvbuf"
2015
2016 ##########################################
2017 # check for gfapi
2018 if test "$gfapi" != "yes" ; then
2019   gfapi="no"
2020 fi
2021 cat > $TMPC << EOF
2022 #include <glusterfs/api/glfs.h>
2023
2024 int main(int argc, char **argv)
2025 {
2026   glfs_t *g = glfs_new("foo");
2027
2028   return 0;
2029 }
2030 EOF
2031 if test "$disable_gfapi" != "yes"  && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
2032   gfapi="yes"
2033 fi
2034 print_config "Gluster API engine" "$gfapi"
2035
2036 ##########################################
2037 # check for gfapi fadvise support, initialize with "no" only if $gfapi is set to "yes"
2038 if test "$gfapi" = "yes" ; then
2039 gf_fadvise="no"
2040 cat > $TMPC << EOF
2041 #include <glusterfs/api/glfs.h>
2042
2043 int main(int argc, char **argv)
2044 {
2045   struct glfs_fd *fd;
2046   int ret = glfs_fadvise(fd, 0, 0, 1);
2047
2048   return 0;
2049 }
2050 EOF
2051 if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
2052   gf_fadvise="yes"
2053 fi
2054 print_config "Gluster API use fadvise" "$gf_fadvise"
2055 fi
2056
2057 ##########################################
2058 # check for newer gfapi
2059 if test "$gfapi" = "yes" ; then
2060 gf_new="no"
2061 cat > $TMPC << EOF
2062 #include <glusterfs/api/glfs.h>
2063
2064 int main(int argc, char **argv)
2065 {
2066   return glfs_fsync(NULL, NULL, NULL) && glfs_ftruncate(NULL, 0, NULL, NULL);
2067 }
2068 EOF
2069 if compile_prog "" "-lgfapi -lglusterfs" "gf new api"; then
2070   gf_new="yes"
2071 fi
2072 print_config "Gluster new API" "$gf_new"
2073 fi
2074
2075 ##########################################
2076 # check for gfapi trim support
2077 if test "$gf_trim" != "yes" ; then
2078   gf_trim="no"
2079 fi
2080 if test "$gfapi" = "yes" ; then
2081 cat > $TMPC << EOF
2082 #include <glusterfs/api/glfs.h>
2083
2084 int main(int argc, char **argv)
2085 {
2086   return glfs_discard_async(NULL, 0, 0);
2087 }
2088 EOF
2089 if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
2090   gf_trim="yes"
2091 fi
2092 print_config "Gluster API trim support" "$gf_trim"
2093 fi
2094
2095 ##########################################
2096 # Check if we support stckf on s390
2097 if test "$s390_z196_facilities" != "yes" ; then
2098   s390_z196_facilities="no"
2099 fi
2100 cat > $TMPC << EOF
2101 #define STFLE_BITS_Z196 45 /* various z196 facilities ... */
2102 int main(int argc, char **argv)
2103 {
2104     /* We want just 1 double word to be returned.  */
2105     register unsigned long reg0 asm("0") = 0;
2106     unsigned long stfle_bits;
2107     asm volatile(".machine push"        "\n\t"
2108                  ".machine \"z9-109\""  "\n\t"
2109                  "stfle %0"             "\n\t"
2110                  ".machine pop"         "\n"
2111                  : "=QS" (stfle_bits), "+d" (reg0)
2112                  : : "cc");
2113
2114     if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
2115       return 0;
2116     else
2117       return -1;
2118 }
2119 EOF
2120 if compile_prog "" "" "s390_z196_facilities"; then
2121   $TMPE
2122   if [ $? -eq 0 ]; then
2123         s390_z196_facilities="yes"
2124   fi
2125 fi
2126 print_config "s390_z196_facilities" "$s390_z196_facilities"
2127
2128 ##########################################
2129 # Check if we have required environment variables configured for libhdfs
2130 if test "$libhdfs" = "yes" ; then
2131   hdfs_conf_error=0
2132   if test "$JAVA_HOME" = "" ; then
2133     echo "configure: JAVA_HOME should be defined to jdk/jvm path"
2134     hdfs_conf_error=1
2135   fi
2136   if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
2137     echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs include path"
2138     hdfs_conf_error=1
2139   fi
2140   if test "$FIO_LIBHDFS_LIB" = "" ; then
2141     echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
2142     hdfs_conf_error=1
2143   fi
2144   if test "$hdfs_conf_error" = "1" ; then
2145     feature_not_found "libhdfs" ""
2146   fi
2147   FIO_HDFS_CPU=$cpu
2148   if test "$FIO_HDFS_CPU" = "x86_64" ; then
2149     FIO_HDFS_CPU="amd64"
2150   fi
2151 fi
2152 print_config "HDFS engine" "$libhdfs"
2153
2154 ##########################################
2155 # Check whether we have MTD
2156 if test "$mtd" != "yes" ; then
2157   mtd="no"
2158 fi
2159 cat > $TMPC << EOF
2160 #include <string.h>
2161 #include <mtd/mtd-user.h>
2162 #include <sys/ioctl.h>
2163 int main(int argc, char **argv)
2164 {
2165   struct mtd_write_req ops;
2166   struct mtd_info_user info;
2167   memset(&ops, 0, sizeof(ops));
2168   info.type = MTD_MLCNANDFLASH;
2169   return ioctl(0, MEMGETINFO, &info);
2170 }
2171 EOF
2172 if compile_prog "" "" "mtd"; then
2173   mtd="yes"
2174 fi
2175 print_config "MTD" "$mtd"
2176
2177 ##########################################
2178 # Check whether we have libpmem
2179 if test "$libpmem" != "yes" ; then
2180   libpmem="no"
2181 fi
2182 cat > $TMPC << EOF
2183 #include <libpmem.h>
2184 #include <stdlib.h>
2185 int main(int argc, char **argv)
2186 {
2187   return pmem_is_pmem(NULL, 0);
2188 }
2189 EOF
2190 if compile_prog "" "-lpmem" "libpmem"; then
2191   libpmem="yes"
2192 fi
2193 print_config "libpmem" "$libpmem"
2194
2195 ##########################################
2196 # Check whether libpmem's version >= 1.5
2197 if test "$libpmem1_5" != "yes" ; then
2198   libpmem1_5="no"
2199 fi
2200 if test "$libpmem" = "yes"; then
2201   cat > $TMPC << EOF
2202 #include <libpmem.h>
2203 #include <stdlib.h>
2204 int main(int argc, char **argv)
2205 {
2206   pmem_memcpy(NULL, NULL, 0, 0);
2207   return 0;
2208 }
2209 EOF
2210   if compile_prog "" "-lpmem" "libpmem1_5"; then
2211     libpmem1_5="yes"
2212   fi
2213 fi
2214 print_config "libpmem1_5" "$libpmem1_5"
2215
2216 ##########################################
2217 # Check whether we have libpmem2
2218 if test "$libpmem2" != "yes" ; then
2219   libpmem2="no"
2220 fi
2221 cat > $TMPC << EOF
2222 #include <libpmem2.h>
2223 int main(int argc, char **argv)
2224 {
2225   struct pmem2_config *cfg;
2226   pmem2_config_new(&cfg);
2227   pmem2_config_delete(&cfg);
2228   return 0;
2229 }
2230 EOF
2231 if compile_prog "" "-lpmem2" "libpmem2"; then
2232   libpmem2="yes"
2233 fi
2234 print_config "libpmem2" "$libpmem2"
2235
2236 # Choose libpmem-based ioengines
2237 if test "$libpmem" = "yes" && test "$disable_pmem" = "no"; then
2238   devdax="yes"
2239   if test "$libpmem1_5" = "yes"; then
2240     pmem="yes"
2241   fi
2242 fi
2243
2244 ##########################################
2245 # Report whether dev-dax engine is enabled
2246 print_config "PMDK dev-dax engine" "$devdax"
2247
2248 ##########################################
2249 # Report whether libpmem engine is enabled
2250 print_config "PMDK libpmem engine" "$pmem"
2251
2252 ##########################################
2253 # Check whether we support DDN's IME
2254 if test "$libime" != "yes" ; then
2255   libime="no"
2256 fi
2257 cat > $TMPC << EOF
2258 #include <ime_native.h>
2259 int main(int argc, char **argv)
2260 {
2261   int rc;
2262   ime_native_init();
2263   rc = ime_native_finalize();
2264   return 0;
2265 }
2266 EOF
2267 if compile_prog "-I${ime_path}/include" "-L${ime_path}/lib -lim_client" "libime"; then
2268   libime="yes"
2269   CFLAGS="-I${ime_path}/include $CFLAGS"
2270   LDFLAGS="-Wl,-rpath ${ime_path}/lib -L${ime_path}/lib $LDFLAGS"
2271   LIBS="-lim_client $LIBS"
2272 fi
2273 print_config "DDN's Infinite Memory Engine" "$libime"
2274
2275 ##########################################
2276 # Check if we have libiscsi
2277 if test "$libiscsi" != "no" ; then
2278   if check_min_lib_version libiscsi 1.9.0; then
2279     libiscsi="yes"
2280     libiscsi_cflags=$(pkg-config --cflags libiscsi)
2281     libiscsi_libs=$(pkg-config --libs libiscsi)
2282   else
2283     libiscsi="no"
2284   fi
2285 fi
2286 print_config "iscsi engine" "$libiscsi"
2287
2288 ##########################################
2289 # Check if we have libnbd (for NBD support)
2290 if test "$libnbd" != "no" ; then
2291   if check_min_lib_version libnbd 0.9.8; then
2292     libnbd="yes"
2293     libnbd_cflags=$(pkg-config --cflags libnbd)
2294     libnbd_libs=$(pkg-config --libs libnbd)
2295   else
2296     libnbd="no"
2297   fi
2298 fi
2299 print_config "NBD engine" "$libnbd"
2300
2301 ##########################################
2302 # check for dfs (DAOS File System)
2303 if test "$dfs" != "no" ; then
2304   cat > $TMPC << EOF
2305 #include <fcntl.h>
2306 #include <daos.h>
2307 #include <daos_fs.h>
2308
2309 int main(int argc, char **argv)
2310 {
2311   daos_handle_t poh;
2312   daos_handle_t coh;
2313   dfs_t         *dfs;
2314
2315   (void) dfs_mount(poh, coh, O_RDWR, &dfs);
2316
2317   return 0;
2318 }
2319 EOF
2320   if compile_prog "" "-luuid -ldfs -ldaos" "dfs"; then
2321     dfs="yes"
2322   else
2323     dfs="no"
2324   fi
2325 fi
2326 print_config "DAOS File System (dfs) Engine" "$dfs"
2327
2328 ##########################################
2329 # Check if we have libnfs (for userspace nfs support).
2330 if test "$libnfs" != "no" ; then
2331   if $(pkg-config libnfs > /dev/null 2>&1); then
2332     libnfs="yes"
2333     libnfs_cflags=$(pkg-config --cflags libnfs)
2334     libnfs_libs=$(pkg-config --libs libnfs)
2335   else
2336     if test "$libnfs" = "yes" ; then
2337       feature_not_found "libnfs" "libnfs"
2338     fi
2339     libnfs="no"
2340   fi
2341 fi
2342 print_config "NFS engine" "$libnfs"
2343
2344 ##########################################
2345 # Check if we have lex/yacc available
2346 yacc="no"
2347 yacc_is_bison="no"
2348 lex="no"
2349 arith="no"
2350 if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
2351 if test "$targetos" != "SunOS" ; then
2352 if has lex; then
2353   lex="yes"
2354 fi
2355 if has bison; then
2356   yacc="yes"
2357   yacc_is_bison="yes"
2358 elif has yacc; then
2359   yacc="yes"
2360 fi
2361 if test "$yacc" = "yes" && test "$lex" = "yes" ; then
2362   arith="yes"
2363 fi
2364
2365 if test "$arith" = "yes" ; then
2366 cat > $TMPC << EOF
2367 extern int yywrap(void);
2368
2369 int main(int argc, char **argv)
2370 {
2371   yywrap();
2372   return 0;
2373 }
2374 EOF
2375 if compile_prog "" "-lfl" "flex"; then
2376   LIBS="-lfl $LIBS"
2377 elif compile_prog "" "-ll" "lex"; then
2378   LIBS="-ll $LIBS"
2379 else
2380   arith="no"
2381 fi
2382 fi
2383 fi
2384 fi
2385
2386 # Check if lex fails using -o
2387 if test "$arith" = "yes" ; then
2388 if test "$force_no_lex_o" = "yes" ; then
2389   lex_use_o="no"
2390 else
2391 if lex -o lex.yy.c exp/expression-parser.l 2> /dev/null; then
2392   lex_use_o="yes"
2393 else
2394   lex_use_o="no"
2395 fi
2396 fi
2397 fi
2398
2399 print_config "lex/yacc for arithmetic" "$arith"
2400
2401 ##########################################
2402 # Check whether we have setmntent/getmntent
2403 if test "$getmntent" != "yes" ; then
2404   getmntent="no"
2405 fi
2406 cat > $TMPC << EOF
2407 #include <stdio.h>
2408 #include <mntent.h>
2409 int main(int argc, char **argv)
2410 {
2411   FILE *mtab = setmntent(NULL, "r");
2412   struct mntent *mnt = getmntent(mtab);
2413   endmntent(mtab);
2414   return mnt != NULL;
2415 }
2416 EOF
2417 if compile_prog "" "" "getmntent"; then
2418   getmntent="yes"
2419 fi
2420 print_config "getmntent" "$getmntent"
2421
2422 ##########################################
2423 # Check whether we have getmntinfo
2424 # These are originally added for BSDs, but may also work
2425 # on other operating systems with getmntinfo(3).
2426
2427 # getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
2428 # Note that NetBSD needs -Werror to catch warning as error.
2429 if test "$getmntinfo" != "yes" ; then
2430   getmntinfo="no"
2431 fi
2432 cat > $TMPC << EOF
2433 #include <stdio.h>
2434 #include <sys/param.h>
2435 #include <sys/mount.h>
2436 int main(int argc, char **argv)
2437 {
2438   struct statfs *st;
2439   return getmntinfo(&st, MNT_NOWAIT);
2440 }
2441 EOF
2442 if compile_prog "-Werror" "" "getmntinfo"; then
2443   getmntinfo="yes"
2444 fi
2445 print_config "getmntinfo" "$getmntinfo"
2446
2447 # getmntinfo(3) for NetBSD.
2448 if test "$getmntinfo_statvfs" != "yes" ; then
2449   getmntinfo_statvfs="no"
2450 fi
2451 cat > $TMPC << EOF
2452 #include <stdio.h>
2453 #include <sys/statvfs.h>
2454 int main(int argc, char **argv)
2455 {
2456   struct statvfs *st;
2457   return getmntinfo(&st, MNT_NOWAIT);
2458 }
2459 EOF
2460 # Skip the test if the one with statfs arg is detected.
2461 if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
2462   getmntinfo_statvfs="yes"
2463   print_config "getmntinfo_statvfs" "$getmntinfo_statvfs"
2464 fi
2465
2466 ##########################################
2467 # Check whether we have _Static_assert
2468 if test "$static_assert" != "yes" ; then
2469   static_assert="no"
2470 fi
2471 cat > $TMPC << EOF
2472 #include <assert.h>
2473 #include <stdlib.h>
2474 #include <stddef.h>
2475
2476 struct foo {
2477   int a, b;
2478 };
2479
2480 int main(int argc, char **argv)
2481 {
2482   _Static_assert(offsetof(struct foo, a) == 0 , "Check");
2483   return 0 ;
2484 }
2485 EOF
2486 if compile_prog "" "" "static_assert"; then
2487     static_assert="yes"
2488 fi
2489 print_config "Static Assert" "$static_assert"
2490
2491 ##########################################
2492 # Check whether we have bool / stdbool.h
2493 if test "$have_bool" != "yes" ; then
2494   have_bool="no"
2495 fi
2496 cat > $TMPC << EOF
2497 #include <stdbool.h>
2498 int main(int argc, char **argv)
2499 {
2500   bool var = true;
2501   return var != false;
2502 }
2503 EOF
2504 if compile_prog "" "" "bool"; then
2505   have_bool="yes"
2506 fi
2507 print_config "bool" "$have_bool"
2508
2509 ##########################################
2510 # Check whether we have strndup()
2511 strndup="no"
2512 cat > $TMPC << EOF
2513 #include <string.h>
2514 #include <stdlib.h>
2515 int main(int argc, char **argv)
2516 {
2517   char *res = strndup("test string", 8);
2518
2519   free(res);
2520   return 0;
2521 }
2522 EOF
2523 if compile_prog "" "" "strndup"; then
2524   strndup="yes"
2525 fi
2526 print_config "strndup" "$strndup"
2527
2528 ##########################################
2529 # <valgrind/drd.h> probe
2530 # Note: presence of <valgrind/drd.h> implies that <valgrind/valgrind.h> is
2531 # also available but not the other way around.
2532 if test "$valgrind_dev" != "yes" ; then
2533   valgrind_dev="no"
2534 fi
2535 cat > $TMPC << EOF
2536 #include <valgrind/drd.h>
2537 int main(int argc, char **argv)
2538 {
2539   return 0;
2540 }
2541 EOF
2542 if compile_prog "" "" "valgrind_dev"; then
2543   valgrind_dev="yes"
2544 fi
2545 print_config "Valgrind headers" "$valgrind_dev"
2546
2547 if test "$targetos" = "Linux" || test "$targetos" = "Android"; then
2548 ##########################################
2549 # <linux/blkzoned.h> probe
2550 if test "$linux_blkzoned" != "yes" ; then
2551   linux_blkzoned="no"
2552 fi
2553 cat > $TMPC << EOF
2554 #include <linux/blkzoned.h>
2555 int main(int argc, char **argv)
2556 {
2557   return 0;
2558 }
2559 EOF
2560 if compile_prog "" "" "linux_blkzoned"; then
2561   linux_blkzoned="yes"
2562 fi
2563 print_config "Zoned block device support" "$linux_blkzoned"
2564
2565 ##########################################
2566 # Check BLK_ZONE_REP_CAPACITY
2567 cat > $TMPC << EOF
2568 #include <linux/blkzoned.h>
2569 int main(void)
2570 {
2571   return BLK_ZONE_REP_CAPACITY;
2572 }
2573 EOF
2574 if compile_prog "" "" "blkzoned report capacity"; then
2575   output_sym "CONFIG_HAVE_REP_CAPACITY"
2576   rep_capacity="yes"
2577 else
2578   rep_capacity="no"
2579 fi
2580 print_config "Zoned block device capacity" "$rep_capacity"
2581 fi
2582
2583 ##########################################
2584 # libzbc probe
2585 cat > $TMPC << EOF
2586 #include <libzbc/zbc.h>
2587 int main(int argc, char **argv)
2588 {
2589   struct zbc_device *dev = NULL;
2590
2591   return zbc_open("foo=bar", O_RDONLY, &dev);
2592 }
2593 EOF
2594 if test "$libzbc" != "no" ; then
2595   if [ -e /usr/include/libzbc/libzbc ]; then
2596     # SUSE Linux.
2597     CFLAGS="$CFLAGS -I/usr/include/libzbc"
2598   fi
2599   if compile_prog "" "-lzbc" "libzbc"; then
2600     libzbc="yes"
2601     if ! check_min_lib_version libzbc 5; then
2602       libzbc="no"
2603     fi
2604   else
2605     if test "$libzbc" = "yes" ; then
2606       feature_not_found "libzbc" "libzbc or libzbc/zbc.h"
2607     fi
2608     libzbc="no"
2609   fi
2610 fi
2611 print_config "libzbc engine" "$libzbc"
2612
2613 if test "$targetos" = "Linux" ; then
2614 ##########################################
2615 # Check NVME_URING_CMD support
2616 cat > $TMPC << EOF
2617 #include <linux/nvme_ioctl.h>
2618 int main(void)
2619 {
2620   return sizeof(struct nvme_uring_cmd);
2621 }
2622 EOF
2623 if compile_prog "" "" "nvme uring cmd"; then
2624   output_sym "CONFIG_NVME_URING_CMD"
2625   nvme_uring_cmd="yes"
2626 else
2627   nvme_uring_cmd="no"
2628 fi
2629 print_config "NVMe uring command support" "$nvme_uring_cmd"
2630 fi
2631
2632 ##########################################
2633 # Check if we have xnvme
2634 if test "$xnvme" != "no" ; then
2635   if check_min_lib_version xnvme 0.2.0; then
2636     xnvme="yes"
2637     xnvme_cflags=$(pkg-config --cflags xnvme)
2638     xnvme_libs=$(pkg-config --libs xnvme)
2639   else
2640     xnvme="no"
2641   fi
2642 fi
2643 print_config "xnvme engine" "$xnvme"
2644
2645 ##########################################
2646 # Check if we have libblkio
2647 if test "$libblkio" != "no" ; then
2648   if check_min_lib_version blkio 1.0.0; then
2649     libblkio="yes"
2650     libblkio_cflags=$(pkg-config --cflags blkio)
2651     libblkio_libs=$(pkg-config --libs blkio)
2652   else
2653     if test "$libblkio" = "yes" ; then
2654       feature_not_found "libblkio" "libblkio-dev or libblkio-devel"
2655     fi
2656     libblkio="no"
2657   fi
2658 fi
2659 print_config "libblkio engine" "$libblkio"
2660
2661 ##########################################
2662 # check march=armv8-a+crc+crypto
2663 march_armv8_a_crc_crypto="no"
2664 if test "$cpu" = "arm64" ; then
2665   cat > $TMPC <<EOF
2666 #if __linux__
2667 #include <arm_acle.h>
2668 #include <arm_neon.h>
2669 #include <sys/auxv.h>
2670 #endif
2671
2672 int main(void)
2673 {
2674   /* Can we also do a runtime probe? */
2675 #if __linux__
2676   return getauxval(AT_HWCAP);
2677 #elif defined(__APPLE__)
2678   return 0;
2679 #else
2680 # error "Don't know how to do runtime probe for ARM CRC32c"
2681 #endif
2682 }
2683 EOF
2684   if compile_prog "-march=armv8-a+crc+crypto" "" "ARM CRC32c"; then
2685     march_armv8_a_crc_crypto="yes"
2686     CFLAGS="$CFLAGS -march=armv8-a+crc+crypto"
2687     march_set="yes"
2688   fi
2689 fi
2690 print_config "march_armv8_a_crc_crypto" "$march_armv8_a_crc_crypto"
2691
2692 ##########################################
2693 # cuda probe
2694 if test "$cuda" != "no" ; then
2695 cat > $TMPC << EOF
2696 #include <cuda.h>
2697 int main(int argc, char **argv)
2698 {
2699   return cuInit(0);
2700 }
2701 EOF
2702   if compile_prog "" "-lcuda" "cuda"; then
2703     cuda="yes"
2704     LIBS="-lcuda $LIBS"
2705   else
2706     if test "$cuda" = "yes" ; then
2707       feature_not_found "cuda" ""
2708     fi
2709     cuda="no"
2710   fi
2711 fi
2712 print_config "cuda" "$cuda"
2713
2714 ##########################################
2715 # libcufile probe
2716 if test "$libcufile" != "no" ; then
2717 cat > $TMPC << EOF
2718 #include <cufile.h>
2719
2720 int main(int argc, char* argv[]) {
2721    cuFileDriverOpen();
2722    return 0;
2723 }
2724 EOF
2725   if compile_prog "" "-lcuda -lcudart -lcufile -ldl" "libcufile"; then
2726     libcufile="yes"
2727     LIBS="-lcuda -lcudart -lcufile -ldl $LIBS"
2728   else
2729     if test "$libcufile" = "yes" ; then
2730       feature_not_found "libcufile" ""
2731     fi
2732     libcufile="no"
2733   fi
2734 fi
2735 print_config "libcufile" "$libcufile"
2736
2737 ##########################################
2738 # check for cc -march=native
2739 build_native="no"
2740 cat > $TMPC << EOF
2741 int main(int argc, char **argv)
2742 {
2743   return 0;
2744 }
2745 EOF
2746 if test "$disable_native" = "no" && test "$disable_opt" != "yes" && \
2747    compile_prog "-march=native" "" "march=native"; then
2748   build_native="yes"
2749 fi
2750 print_config "Build march=native" "$build_native"
2751
2752 ##########################################
2753 # check for -lcunit
2754 if test "$cunit" != "yes" ; then
2755   cunit="no"
2756 fi
2757 cat > $TMPC << EOF
2758 #include <CUnit/CUnit.h>
2759 #include <CUnit/Basic.h>
2760 int main(void)
2761 {
2762   if (CU_initialize_registry() != CUE_SUCCESS)
2763     return CU_get_error();
2764   CU_basic_set_mode(CU_BRM_VERBOSE);
2765   CU_basic_run_tests();
2766   CU_cleanup_registry();
2767   return CU_get_error();
2768 }
2769 EOF
2770 if compile_prog "" "-lcunit" "CUnit"; then
2771   cunit="yes"
2772 fi
2773 print_config "CUnit" "$cunit"
2774
2775 ##########################################
2776 # check for __kernel_rwf_t
2777 __kernel_rwf_t="no"
2778 cat > $TMPC << EOF
2779 #include <linux/fs.h>
2780 int main(int argc, char **argv)
2781 {
2782   __kernel_rwf_t x;
2783   x = 0;
2784   return x;
2785 }
2786 EOF
2787 if compile_prog "" "" "__kernel_rwf_t"; then
2788   __kernel_rwf_t="yes"
2789 fi
2790 print_config "__kernel_rwf_t" "$__kernel_rwf_t"
2791
2792 ##########################################
2793 # check if gcc has -Wimplicit-fallthrough=2
2794 fallthrough="no"
2795 cat > $TMPC << EOF
2796 int main(int argc, char **argv)
2797 {
2798   return 0;
2799 }
2800 EOF
2801 if compile_prog "-Wimplicit-fallthrough=2" "" "-Wimplicit-fallthrough=2"; then
2802   fallthrough="yes"
2803 fi
2804 print_config "-Wimplicit-fallthrough=2" "$fallthrough"
2805
2806 ##########################################
2807 # check if the compiler has -Wno-stringop-concatenation
2808 no_stringop="no"
2809 cat > $TMPC << EOF
2810 #include <stdio.h>
2811
2812 int main(int argc, char **argv)
2813 {
2814         return printf("%s\n", argv[0]);
2815 }
2816 EOF
2817 if compile_prog "-Wno-stringop-truncation -Werror" "" "no_stringop"; then
2818   no_stringop="yes"
2819 fi
2820 print_config "-Wno-stringop-truncation" "$no_stringop"
2821
2822 ##########################################
2823 # check for MADV_HUGEPAGE support
2824 if test "$thp" != "yes" ; then
2825   thp="no"
2826 fi
2827 if test "$esx" != "yes" ; then
2828   cat > $TMPC <<EOF
2829 #include <sys/mman.h>
2830 int main(void)
2831 {
2832   return madvise(0, 0x1000, MADV_HUGEPAGE);
2833 }
2834 EOF
2835   if compile_prog "" "" "thp" ; then
2836     thp=yes
2837   else
2838     if test "$thp" = "yes" ; then
2839       feature_not_found "Transparent Huge Page" ""
2840     fi
2841     thp=no
2842   fi
2843 fi
2844 print_config "MADV_HUGEPAGE" "$thp"
2845
2846 ##########################################
2847 # check for gettid()
2848 gettid="no"
2849 cat > $TMPC << EOF
2850 #include <unistd.h>
2851 int main(int argc, char **argv)
2852 {
2853   return gettid();
2854 }
2855 EOF
2856 if compile_prog "" "" "gettid"; then
2857   gettid="yes"
2858 fi
2859 print_config "gettid" "$gettid"
2860
2861 ##########################################
2862 # check for statx(2) support by libc
2863 statx="no"
2864 cat > $TMPC << EOF
2865 #include <unistd.h>
2866 #include <sys/stat.h>
2867
2868 int main(int argc, char **argv)
2869 {
2870         struct statx st;
2871         return statx(-1, *argv, 0, 0, &st);
2872 }
2873 EOF
2874 if compile_prog "" "" "statx"; then
2875   statx="yes"
2876 fi
2877 print_config "statx(2)/libc" "$statx"
2878
2879 ##########################################
2880 # check for statx(2) support by kernel
2881 statx_syscall="no"
2882 cat > $TMPC << EOF
2883 #include <unistd.h>
2884 #include <linux/stat.h>
2885 #include <sys/stat.h>
2886 #include <sys/syscall.h>
2887
2888 static int _statx(int dfd, const char *pathname, int flags, unsigned int mask,
2889                   struct statx *buffer)
2890 {
2891         return syscall(__NR_statx, dfd, pathname, flags, mask, buffer);
2892 }
2893
2894 int main(int argc, char **argv)
2895 {
2896         struct statx st;
2897         return _statx(-1, *argv, 0, 0, &st);
2898 }
2899 EOF
2900 if compile_prog "" "" "statx_syscall"; then
2901   statx_syscall="yes"
2902 fi
2903 print_config "statx(2)/syscall" "$statx_syscall"
2904
2905 ##########################################
2906 # check for Windows PDB generation support
2907 if test "pdb" != "no" ; then
2908   cat > $TMPC <<EOF
2909 int main(void)
2910 {
2911   return 0;
2912 }
2913 EOF
2914   if compile_prog "-g -gcodeview" "-fuse-ld=lld -Wl,-pdb,$TMPO" "pdb"; then
2915     pdb=yes
2916   else
2917     if test "$pdb" = "yes"; then
2918       feature_not_found "PDB" "clang and lld"
2919     fi
2920     pdb=no
2921   fi
2922 else
2923   pdb=no
2924 fi
2925 print_config "Windows PDB generation" "$pdb"
2926
2927 ##########################################
2928 # check for timerfd support
2929 timerfd_create="no"
2930 if test "$esx" != "yes" ; then
2931 cat > $TMPC << EOF
2932 #include <sys/time.h>
2933 #include <sys/timerfd.h>
2934
2935 int main(int argc, char **argv)
2936 {
2937         return timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
2938 }
2939 EOF
2940   if compile_prog "" "" "timerfd_create"; then
2941     timerfd_create="yes"
2942   fi
2943 fi
2944 print_config "timerfd_create" "$timerfd_create"
2945
2946 #############################################################################
2947
2948 if test "$wordsize" = "64" ; then
2949   output_sym "CONFIG_64BIT"
2950 elif test "$wordsize" = "32" ; then
2951   output_sym "CONFIG_32BIT"
2952 else
2953   fatal "Unknown wordsize!"
2954 fi
2955 if test "$bigendian" = "yes" ; then
2956   output_sym "CONFIG_BIG_ENDIAN"
2957 else
2958   output_sym "CONFIG_LITTLE_ENDIAN"
2959 fi
2960 if test "$zlib" = "yes" ; then
2961   output_sym "CONFIG_ZLIB"
2962 fi
2963 if test "$libaio" = "yes" ; then
2964   output_sym "CONFIG_LIBAIO"
2965   if test "$libaio_rw_flags" = "yes" ; then
2966     output_sym "CONFIG_LIBAIO_RW_FLAGS"
2967   fi
2968 fi
2969 if test "$posix_aio" = "yes" ; then
2970   output_sym "CONFIG_POSIXAIO"
2971 fi
2972 if test "$posix_aio_fsync" = "yes" ; then
2973   output_sym "CONFIG_POSIXAIO_FSYNC"
2974 fi
2975 if test "$posix_pshared" = "yes" ; then
2976   output_sym "CONFIG_PSHARED"
2977 fi
2978 if test "$pthread_condattr_setclock" = "yes" ; then
2979   output_sym "CONFIG_PTHREAD_CONDATTR_SETCLOCK"
2980 fi
2981 if test "$pthread_sigmask" = "yes" ; then
2982   output_sym "CONFIG_PTHREAD_SIGMASK"
2983 fi
2984 if test "$pthread_getaffinity" = "yes" ; then
2985   output_sym "CONFIG_PTHREAD_GETAFFINITY"
2986 fi
2987 if test "$have_asprintf" = "yes" ; then
2988     output_sym "CONFIG_HAVE_ASPRINTF"
2989 fi
2990 if test "$have_vasprintf" = "yes" ; then
2991     output_sym "CONFIG_HAVE_VASPRINTF"
2992 fi
2993 if test "$linux_fallocate" = "yes" ; then
2994   output_sym "CONFIG_LINUX_FALLOCATE"
2995 fi
2996 if test "$posix_fallocate" = "yes" ; then
2997   output_sym "CONFIG_POSIX_FALLOCATE"
2998 fi
2999 if test "$fdatasync" = "yes" ; then
3000   output_sym "CONFIG_FDATASYNC"
3001 fi
3002 if test "$pipe" = "yes" ; then
3003   output_sym "CONFIG_PIPE"
3004 fi
3005 if test "$pipe2" = "yes" ; then
3006   output_sym "CONFIG_PIPE2"
3007 fi
3008 if test "$pread" = "yes" ; then
3009   output_sym "CONFIG_PREAD"
3010 fi
3011 if test "$sync_file_range" = "yes" ; then
3012   output_sym "CONFIG_SYNC_FILE_RANGE"
3013 fi
3014 if test "$sfaa" = "yes" ; then
3015   output_sym "CONFIG_SFAA"
3016 fi
3017 if test "$sync_sync" = "yes" ; then
3018   output_sym "CONFIG_SYNC_SYNC"
3019 fi
3020 if test "$cmp_swap" = "yes" ; then
3021   output_sym "CONFIG_CMP_SWAP"
3022 fi
3023 if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
3024   output_sym "CONFIG_RDMA"
3025 fi
3026 # librpma is supported on the 'x86_64' architecture for now
3027 if test "$cpu" = "x86_64" -a "$libverbs" = "yes" -a "$rdmacm" = "yes" \
3028     -a "$librpma" = "yes" \
3029     && test "$libpmem" = "yes" -o "$libpmem2" = "yes" ; then
3030   output_sym "CONFIG_LIBRPMA_APM"
3031 fi
3032 if test "$cpu" = "x86_64" -a "$libverbs" = "yes" -a "$rdmacm" = "yes" \
3033     -a "$librpma" = "yes" -a "$libprotobuf_c" = "yes" \
3034     && test "$libpmem" = "yes" -o "$libpmem2" = "yes" ; then
3035   output_sym "CONFIG_LIBRPMA_GPSPM"
3036 fi
3037 if test "$clock_gettime" = "yes" ; then
3038   output_sym "CONFIG_CLOCK_GETTIME"
3039 fi
3040 if test "$clock_monotonic" = "yes" ; then
3041   output_sym "CONFIG_CLOCK_MONOTONIC"
3042 fi
3043 if test "$clockid_t" = "yes"; then
3044   output_sym "CONFIG_CLOCKID_T"
3045 fi
3046 if test "$gettimeofday" = "yes" ; then
3047   output_sym "CONFIG_GETTIMEOFDAY"
3048 fi
3049 if test "$posix_fadvise" = "yes" ; then
3050   output_sym "CONFIG_POSIX_FADVISE"
3051 fi
3052 if test "$linux_3arg_affinity" = "yes" ; then
3053   output_sym "CONFIG_3ARG_AFFINITY"
3054 elif test "$linux_2arg_affinity" = "yes" ; then
3055   output_sym "CONFIG_2ARG_AFFINITY"
3056 fi
3057 if test "$strsep" = "yes" ; then
3058   output_sym "CONFIG_STRSEP"
3059 fi
3060 if test "$strcasestr" = "yes" ; then
3061   output_sym "CONFIG_STRCASESTR"
3062 fi
3063 if test "$strlcat" = "yes" ; then
3064   output_sym "CONFIG_STRLCAT"
3065 fi
3066 if test "$getopt_long_only" = "yes" ; then
3067   output_sym "CONFIG_GETOPT_LONG_ONLY"
3068 fi
3069 if test "$inet_aton" = "yes" ; then
3070   output_sym "CONFIG_INET_ATON"
3071 fi
3072 if test "$socklen_t" = "yes" ; then
3073   output_sym "CONFIG_SOCKLEN_T"
3074 fi
3075 if test "$ext4_me" = "yes" ; then
3076   output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
3077 fi
3078 if test "$linux_splice" = "yes" ; then
3079   output_sym "CONFIG_LINUX_SPLICE"
3080 fi
3081 if test "$libnuma_v2" = "yes" ; then
3082   output_sym "CONFIG_LIBNUMA"
3083 fi
3084 if test "$solaris_aio" = "yes" ; then
3085   output_sym "CONFIG_SOLARISAIO"
3086 fi
3087 if test "$tls_thread" = "yes" ; then
3088   output_sym "CONFIG_TLS_THREAD"
3089 fi
3090 if test "$rusage_thread" = "yes" ; then
3091   output_sym "CONFIG_RUSAGE_THREAD"
3092 fi
3093 if test "$gfio" = "yes" ; then
3094   output_sym "CONFIG_GFIO"
3095 fi
3096 if test "$esx" = "yes" ; then
3097   output_sym "CONFIG_ESX"
3098   output_sym "CONFIG_NO_SHM"
3099 fi
3100 if test "$sched_idle" = "yes" ; then
3101   output_sym "CONFIG_SCHED_IDLE"
3102 fi
3103 if test "$tcp_nodelay" = "yes" ; then
3104   output_sym "CONFIG_TCP_NODELAY"
3105 fi
3106 if test "$window_size" = "yes" ; then
3107   output_sym "CONFIG_NET_WINDOWSIZE"
3108 fi
3109 if test "$mss" = "yes" ; then
3110   output_sym "CONFIG_NET_MSS"
3111 fi
3112 if test "$rlimit_memlock" = "yes" ; then
3113   output_sym "CONFIG_RLIMIT_MEMLOCK"
3114 fi
3115 if test "$pwritev" = "yes" ; then
3116   output_sym "CONFIG_PWRITEV"
3117 fi
3118 if test "$pwritev2" = "yes" ; then
3119   output_sym "CONFIG_PWRITEV2"
3120 fi
3121 if test "$ipv6" = "yes" ; then
3122   output_sym "CONFIG_IPV6"
3123 fi
3124 if test "$http" = "yes" ; then
3125   output_sym "CONFIG_HTTP"
3126 fi
3127 if test "$rados" = "yes" ; then
3128   output_sym "CONFIG_RADOS"
3129 fi
3130 if test "$rbd" = "yes" ; then
3131   output_sym "CONFIG_RBD"
3132 fi
3133 if test "$rbd_poll" = "yes" ; then
3134   output_sym "CONFIG_RBD_POLL"
3135 fi
3136 if test "$rbd_inval" = "yes" ; then
3137   output_sym "CONFIG_RBD_INVAL"
3138 fi
3139 if test "$setvbuf" = "yes" ; then
3140   output_sym "CONFIG_SETVBUF"
3141 fi
3142 if test "$s390_z196_facilities" = "yes" ; then
3143   output_sym "CONFIG_S390_Z196_FACILITIES"
3144   CFLAGS="$CFLAGS -march=z9-109"
3145   march_set="yes"
3146 fi
3147 if test "$gfapi" = "yes" ; then
3148   output_sym "CONFIG_GFAPI"
3149 fi
3150 if test "$gf_fadvise" = "yes" ; then
3151   output_sym "CONFIG_GF_FADVISE"
3152 fi
3153 if test "$gf_trim" = "yes" ; then
3154   output_sym "CONFIG_GF_TRIM"
3155 fi
3156 if test "$gf_new" = "yes" ; then
3157   output_sym "CONFIG_GF_NEW_API"
3158 fi
3159 if test "$libhdfs" = "yes" ; then
3160   output_sym "CONFIG_LIBHDFS"
3161   echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
3162   echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
3163   echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
3164   echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
3165 fi
3166 if test "$mtd" = "yes" ; then
3167   output_sym "CONFIG_MTD"
3168 fi
3169 if test "$devdax" = "yes" ; then
3170   output_sym "CONFIG_LINUX_DEVDAX"
3171 fi
3172 if test "$pmem" = "yes" ; then
3173   output_sym "CONFIG_LIBPMEM"
3174 fi
3175 if test "$libpmem2" = "yes" ; then
3176   output_sym "CONFIG_LIBPMEM2_INSTALLED"
3177 fi
3178 if test "$libime" = "yes" ; then
3179   output_sym "CONFIG_IME"
3180 fi
3181 if test "$arith" = "yes" ; then
3182   output_sym "CONFIG_ARITHMETIC"
3183   if test "$yacc_is_bison" = "yes" ; then
3184     echo "YACC=bison -y" >> $config_host_mak
3185   else
3186     echo "YACC=yacc" >> $config_host_mak
3187   fi
3188   if test "$lex_use_o" = "yes" ; then
3189     echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
3190   fi
3191 fi
3192 if test "$getmntent" = "yes" ; then
3193   output_sym "CONFIG_GETMNTENT"
3194 fi
3195 if test "$getmntinfo" = "yes" ; then
3196   output_sym "CONFIG_GETMNTINFO"
3197 fi
3198 if test "$getmntinfo_statvfs" = "yes" ; then
3199   output_sym "CONFIG_GETMNTINFO_STATVFS"
3200 fi
3201 if test "$static_assert" = "yes" ; then
3202   output_sym "CONFIG_STATIC_ASSERT"
3203 fi
3204 if test "$have_bool" = "yes" ; then
3205   output_sym "CONFIG_HAVE_BOOL"
3206 fi
3207 if test "$strndup" = "yes" ; then
3208   output_sym "CONFIG_HAVE_STRNDUP"
3209 fi
3210 if test "$disable_opt" = "yes" ; then
3211   output_sym "CONFIG_DISABLE_OPTIMIZATIONS"
3212 fi
3213 if test "$valgrind_dev" = "yes"; then
3214   output_sym "CONFIG_VALGRIND_DEV"
3215 fi
3216 if test "$linux_blkzoned" = "yes" ; then
3217   output_sym "CONFIG_HAS_BLKZONED"
3218 fi
3219 if test "$libzbc" = "yes" ; then
3220   output_sym "CONFIG_LIBZBC"
3221 fi
3222 if test "$zlib" = "no" ; then
3223   echo "Consider installing zlib1g-dev (zlib-devel) as some fio features depend on it."
3224   if test "$build_static" = "yes"; then
3225     echo "Note that some distros have separate packages for static libraries."
3226   fi
3227 fi
3228 if test "$march_armv8_a_crc_crypto" = "yes" ; then
3229   output_sym "ARCH_HAVE_CRC_CRYPTO"
3230 fi
3231 if test "$cuda" = "yes" ; then
3232   output_sym "CONFIG_CUDA"
3233 fi
3234 if test "$libcufile" = "yes" ; then
3235   output_sym "CONFIG_LIBCUFILE"
3236 fi
3237 if test "$dfs" = "yes" ; then
3238   output_sym "CONFIG_DFS"
3239 fi
3240 if test "$march_set" = "no" && test "$build_native" = "yes" ; then
3241   output_sym "CONFIG_BUILD_NATIVE"
3242 fi
3243 if test "$cunit" = "yes" ; then
3244   output_sym "CONFIG_HAVE_CUNIT"
3245 fi
3246 if test "$__kernel_rwf_t" = "yes"; then
3247   output_sym "CONFIG_HAVE_KERNEL_RWF_T"
3248 fi
3249 if test "$gettid" = "yes"; then
3250   output_sym "CONFIG_HAVE_GETTID"
3251 fi
3252 if test "$statx" = "yes"; then
3253   output_sym "CONFIG_HAVE_STATX"
3254 fi
3255 if test "$statx_syscall" = "yes"; then
3256   output_sym "CONFIG_HAVE_STATX_SYSCALL"
3257 fi
3258 if test "$timerfd_create" = "yes"; then
3259   output_sym "CONFIG_HAVE_TIMERFD_CREATE"
3260 fi
3261 if test "$fallthrough" = "yes"; then
3262   CFLAGS="$CFLAGS -Wimplicit-fallthrough"
3263 fi
3264 if test "$no_stringop" = "yes"; then
3265   output_sym "CONFIG_HAVE_NO_STRINGOP"
3266 fi
3267 if test "$thp" = "yes" ; then
3268   output_sym "CONFIG_HAVE_THP"
3269 fi
3270 if test "$libiscsi" = "yes" ; then
3271   output_sym "CONFIG_LIBISCSI"
3272   echo "CONFIG_LIBISCSI=m" >> $config_host_mak
3273   echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
3274   echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
3275 fi
3276 if test "$libnbd" = "yes" ; then
3277   output_sym "CONFIG_LIBNBD"
3278   echo "CONFIG_LIBNBD=m" >> $config_host_mak
3279   echo "LIBNBD_CFLAGS=$libnbd_cflags" >> $config_host_mak
3280   echo "LIBNBD_LIBS=$libnbd_libs" >> $config_host_mak
3281 fi
3282 if test "$libnfs" = "yes" ; then
3283   output_sym "CONFIG_LIBNFS"
3284   echo "LIBNFS_CFLAGS=$libnfs_cflags" >> $config_host_mak
3285   echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
3286 fi
3287 if test "$xnvme" = "yes" ; then
3288   output_sym "CONFIG_LIBXNVME"
3289   echo "LIBXNVME_CFLAGS=$xnvme_cflags" >> $config_host_mak
3290   echo "LIBXNVME_LIBS=$xnvme_libs" >> $config_host_mak
3291 fi
3292 if test "$libblkio" = "yes" ; then
3293   output_sym "CONFIG_LIBBLKIO"
3294   echo "LIBBLKIO_CFLAGS=$libblkio_cflags" >> $config_host_mak
3295   echo "LIBBLKIO_LIBS=$libblkio_libs" >> $config_host_mak
3296 fi
3297 if test "$dynamic_engines" = "yes" ; then
3298   output_sym "CONFIG_DYNAMIC_ENGINES"
3299 fi
3300 if test "$pdb" = yes; then
3301   output_sym "CONFIG_PDB"
3302 fi
3303 if test "$fcntl_sync" = "yes" ; then
3304   output_sym "CONFIG_FCNTL_SYNC"
3305 fi
3306 if test "$asan" = "yes"; then
3307   CFLAGS="$CFLAGS -fsanitize=address"
3308   LDFLAGS="$LDFLAGS -fsanitize=address"
3309 fi
3310 print_config "Lib-based ioengines dynamic" "$dynamic_engines"
3311 cat > $TMPC << EOF
3312 int main(int argc, char **argv)
3313 {
3314   return 0;
3315 }
3316 EOF
3317 if test "$disable_tcmalloc" != "yes"; then
3318   if compile_prog "" "-ltcmalloc" "tcmalloc"; then
3319     tcmalloc="yes"
3320     LIBS="-ltcmalloc $LIBS"
3321   elif compile_prog "" "-l:libtcmalloc_minimal.so.4" "tcmalloc_minimal4"; then
3322     tcmalloc="yes"
3323     LIBS="-l:libtcmalloc_minimal.so.4 $LIBS"
3324   else
3325     tcmalloc="no"
3326   fi
3327 fi
3328 print_config "TCMalloc support" "$tcmalloc"
3329 if ! num "$seed_buckets"; then
3330   seed_buckets=4
3331 elif test "$seed_buckets" -lt 2; then
3332   seed_buckets=2
3333 elif test "$seed_buckets" -gt 16; then
3334   seed_buckets=16
3335 fi
3336 echo "#define CONFIG_SEED_BUCKETS $seed_buckets" >> $config_host_h
3337 print_config "seed_buckets" "$seed_buckets"
3338
3339 echo "LIBS+=$LIBS" >> $config_host_mak
3340 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
3341 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
3342 echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
3343 echo "CC=$cc" >> $config_host_mak
3344 echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
3345 echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
3346
3347 if [ `dirname $0` != "." -a ! -e Makefile ]; then
3348     cat > Makefile <<EOF
3349 SRCDIR:=`dirname $0`
3350 include \$(SRCDIR)/Makefile
3351 EOF
3352 fi