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