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