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