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