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