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