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