configure: check for gtk version using pkg-config
[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=$(${cross_prefix}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=$(${cross_prefix}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 ! ${cross_prefix}pkg-config --atleast-version 2.18.0 gtk+-2.0; then
1360   echo "GTK found, but need version 2.18 or higher"
1361   gfio="no"
1362 else
1363   if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1364     gfio="yes"
1365     GFIO_LIBS="$LIBS $GTK_LIBS"
1366     CFLAGS="$CFLAGS $GTK_CFLAGS"
1367   else
1368     echo "Please install gtk and gdk libraries"
1369     gfio="no"
1370   fi
1371 fi
1372 LDFLAGS=$ORG_LDFLAGS
1373 fi
1374
1375 if test "$gfio_check" = "yes" ; then
1376   print_config "gtk 2.18 or higher" "$gfio"
1377 fi
1378
1379 ##########################################
1380 # Check whether we have getrusage(RUSAGE_THREAD)
1381 if test "$rusage_thread" != "yes" ; then
1382   rusage_thread="no"
1383 fi
1384 cat > $TMPC << EOF
1385 #include <sys/time.h>
1386 #include <sys/resource.h>
1387 int main(int argc, char **argv)
1388 {
1389   struct rusage ru;
1390   getrusage(RUSAGE_THREAD, &ru);
1391   return 0;
1392 }
1393 EOF
1394 if compile_prog "" "" "RUSAGE_THREAD"; then
1395   rusage_thread="yes"
1396 fi
1397 print_config "RUSAGE_THREAD" "$rusage_thread"
1398
1399 ##########################################
1400 # Check whether we have SCHED_IDLE
1401 if test "$sched_idle" != "yes" ; then
1402   sched_idle="no"
1403 fi
1404 cat > $TMPC << EOF
1405 #include <sched.h>
1406 int main(int argc, char **argv)
1407 {
1408   struct sched_param p;
1409   return sched_setscheduler(0, SCHED_IDLE, &p);
1410 }
1411 EOF
1412 if compile_prog "" "" "SCHED_IDLE"; then
1413   sched_idle="yes"
1414 fi
1415 print_config "SCHED_IDLE" "$sched_idle"
1416
1417 ##########################################
1418 # Check whether we have TCP_NODELAY
1419 if test "$tcp_nodelay" != "yes" ; then
1420   tcp_nodelay="no"
1421 fi
1422 cat > $TMPC << EOF
1423 #include <stdio.h>
1424 #include <sys/types.h>
1425 #include <sys/socket.h>
1426 #include <netinet/tcp.h>
1427 int main(int argc, char **argv)
1428 {
1429   return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1430 }
1431 EOF
1432 if compile_prog "" "" "TCP_NODELAY"; then
1433   tcp_nodelay="yes"
1434 fi
1435 print_config "TCP_NODELAY" "$tcp_nodelay"
1436
1437 ##########################################
1438 # Check whether we have SO_SNDBUF
1439 if test "$window_size" != "yes" ; then
1440   window_size="no"
1441 fi
1442 cat > $TMPC << EOF
1443 #include <stdio.h>
1444 #include <sys/types.h>
1445 #include <sys/socket.h>
1446 #include <netinet/tcp.h>
1447 int main(int argc, char **argv)
1448 {
1449   setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1450   setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1451 }
1452 EOF
1453 if compile_prog "" "" "SO_SNDBUF"; then
1454   window_size="yes"
1455 fi
1456 print_config "Net engine window_size" "$window_size"
1457
1458 ##########################################
1459 # Check whether we have TCP_MAXSEG
1460 if test "$mss" != "yes" ; then
1461   mss="no"
1462 fi
1463 cat > $TMPC << EOF
1464 #include <stdio.h>
1465 #include <sys/types.h>
1466 #include <sys/socket.h>
1467 #include <netinet/tcp.h>
1468 #include <arpa/inet.h>
1469 #include <netinet/in.h>
1470 int main(int argc, char **argv)
1471 {
1472   return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1473 }
1474 EOF
1475 if compile_prog "" "" "TCP_MAXSEG"; then
1476   mss="yes"
1477 fi
1478 print_config "TCP_MAXSEG" "$mss"
1479
1480 ##########################################
1481 # Check whether we have RLIMIT_MEMLOCK
1482 if test "$rlimit_memlock" != "yes" ; then
1483   rlimit_memlock="no"
1484 fi
1485 cat > $TMPC << EOF
1486 #include <sys/time.h>
1487 #include <sys/resource.h>
1488 int main(int argc, char **argv)
1489 {
1490   struct rlimit rl;
1491   return getrlimit(RLIMIT_MEMLOCK, &rl);
1492 }
1493 EOF
1494 if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1495   rlimit_memlock="yes"
1496 fi
1497 print_config "RLIMIT_MEMLOCK" "$rlimit_memlock"
1498
1499 ##########################################
1500 # Check whether we have pwritev/preadv
1501 if test "$pwritev" != "yes" ; then
1502   pwritev="no"
1503 fi
1504 cat > $TMPC << EOF
1505 #include <stdio.h>
1506 #include <sys/uio.h>
1507 int main(int argc, char **argv)
1508 {
1509   return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1510 }
1511 EOF
1512 if compile_prog "" "" "pwritev"; then
1513   pwritev="yes"
1514 fi
1515 print_config "pwritev/preadv" "$pwritev"
1516
1517 ##########################################
1518 # Check whether we have pwritev2/preadv2
1519 if test "$pwritev2" != "yes" ; then
1520   pwritev2="no"
1521 fi
1522 cat > $TMPC << EOF
1523 #include <stdio.h>
1524 #include <sys/uio.h>
1525 int main(int argc, char **argv)
1526 {
1527   return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1528 }
1529 EOF
1530 if compile_prog "" "" "pwritev2"; then
1531   pwritev2="yes"
1532 fi
1533 print_config "pwritev2/preadv2" "$pwritev2"
1534
1535 ##########################################
1536 # Check whether we have the required functions for ipv6
1537 if test "$ipv6" != "yes" ; then
1538   ipv6="no"
1539 fi
1540 cat > $TMPC << EOF
1541 #include <sys/types.h>
1542 #include <sys/socket.h>
1543 #include <netinet/in.h>
1544 #include <netdb.h>
1545 #include <stdio.h>
1546 int main(int argc, char **argv)
1547 {
1548   struct addrinfo hints;
1549   struct in6_addr addr;
1550   int ret;
1551
1552   ret = getaddrinfo(NULL, NULL, &hints, NULL);
1553   freeaddrinfo(NULL);
1554   printf("%s\n", gai_strerror(ret));
1555   addr = in6addr_any;
1556   return 0;
1557 }
1558 EOF
1559 if compile_prog "" "" "ipv6"; then
1560   ipv6="yes"
1561 fi
1562 print_config "IPv6 helpers" "$ipv6"
1563
1564 ##########################################
1565 # check for http
1566 if test "$http" != "yes" ; then
1567   http="no"
1568 fi
1569 # check for openssl >= 1.1.0, which uses an opaque HMAC_CTX pointer
1570 cat > $TMPC << EOF
1571 #include <curl/curl.h>
1572 #include <openssl/hmac.h>
1573
1574 int main(int argc, char **argv)
1575 {
1576   CURL *curl;
1577   HMAC_CTX *ctx;
1578
1579   curl = curl_easy_init();
1580   curl_easy_cleanup(curl);
1581
1582   ctx = HMAC_CTX_new();
1583   HMAC_CTX_reset(ctx);
1584   HMAC_CTX_free(ctx);
1585   return 0;
1586 }
1587 EOF
1588 # openssl < 1.1.0 uses the HMAC_CTX type directly
1589 cat > $TMPC2 << EOF
1590 #include <curl/curl.h>
1591 #include <openssl/hmac.h>
1592
1593 int main(int argc, char **argv)
1594 {
1595   CURL *curl;
1596   HMAC_CTX ctx;
1597
1598   curl = curl_easy_init();
1599   curl_easy_cleanup(curl);
1600
1601   HMAC_CTX_init(&ctx);
1602   HMAC_CTX_cleanup(&ctx);
1603   return 0;
1604 }
1605 EOF
1606 if test "$disable_http" != "yes"; then
1607   HTTP_LIBS="-lcurl -lssl -lcrypto"
1608   if compile_prog "" "$HTTP_LIBS" "curl-new-ssl"; then
1609     output_sym "CONFIG_HAVE_OPAQUE_HMAC_CTX"
1610     http="yes"
1611     LIBS="$HTTP_LIBS $LIBS"
1612   elif mv $TMPC2 $TMPC && compile_prog "" "$HTTP_LIBS" "curl-old-ssl"; then
1613     http="yes"
1614     LIBS="$HTTP_LIBS $LIBS"
1615   fi
1616 fi
1617 print_config "http engine" "$http"
1618
1619 ##########################################
1620 # check for rados
1621 if test "$rados" != "yes" ; then
1622   rados="no"
1623 fi
1624 cat > $TMPC << EOF
1625 #include <rados/librados.h>
1626
1627 int main(int argc, char **argv)
1628 {
1629   rados_t cluster;
1630   rados_ioctx_t io_ctx;
1631   const char cluster_name[] = "ceph";
1632   const char user_name[] = "client.admin";
1633   const char pool[] = "rados";
1634
1635   /* The rados_create2 signature required was only introduced in ceph 0.65 */
1636   rados_create2(&cluster, cluster_name, user_name, 0);
1637   rados_ioctx_create(cluster, pool, &io_ctx);
1638
1639   return 0;
1640 }
1641 EOF
1642 if test "$disable_rados" != "yes"  && compile_prog "" "-lrados" "rados"; then
1643   LIBS="-lrados $LIBS"
1644   rados="yes"
1645 fi
1646 print_config "Rados engine" "$rados"
1647
1648 ##########################################
1649 # check for rbd
1650 if test "$rbd" != "yes" ; then
1651   rbd="no"
1652 fi
1653 cat > $TMPC << EOF
1654 #include <rbd/librbd.h>
1655
1656 int main(int argc, char **argv)
1657 {
1658   rados_t cluster;
1659   rados_ioctx_t io_ctx;
1660   const char cluster_name[] = "ceph";
1661   const char user_name[] = "client.admin";
1662   const char pool[] = "rbd";
1663   int major, minor, extra;
1664
1665   rbd_version(&major, &minor, &extra);
1666   /* The rados_create2 signature required was only introduced in ceph 0.65 */
1667   rados_create2(&cluster, cluster_name, user_name, 0);
1668   rados_ioctx_create(cluster, pool, &io_ctx);
1669
1670   return 0;
1671 }
1672 EOF
1673 if test "$disable_rbd" != "yes"  && compile_prog "" "-lrbd -lrados" "rbd"; then
1674   LIBS="-lrbd -lrados $LIBS"
1675   rbd="yes"
1676 fi
1677 print_config "Rados Block Device engine" "$rbd"
1678
1679 ##########################################
1680 # check for rbd_poll
1681 if test "$rbd_poll" != "yes" ; then
1682   rbd_poll="no"
1683 fi
1684 if test "$rbd" = "yes"; then
1685 cat > $TMPC << EOF
1686 #include <rbd/librbd.h>
1687 #include <sys/eventfd.h>
1688
1689 int main(int argc, char **argv)
1690 {
1691   rbd_image_t image;
1692   rbd_completion_t comp;
1693
1694   int fd = eventfd(0, EFD_NONBLOCK);
1695   rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1696   rbd_poll_io_events(image, comp, 1);
1697
1698   return 0;
1699 }
1700 EOF
1701 if compile_prog "" "-lrbd -lrados" "rbd"; then
1702   rbd_poll="yes"
1703 fi
1704 print_config "rbd_poll" "$rbd_poll"
1705 fi
1706
1707 ##########################################
1708 # check for rbd_invalidate_cache()
1709 if test "$rbd_inval" != "yes" ; then
1710   rbd_inval="no"
1711 fi
1712 if test "$rbd" = "yes"; then
1713 cat > $TMPC << EOF
1714 #include <rbd/librbd.h>
1715
1716 int main(int argc, char **argv)
1717 {
1718   rbd_image_t image;
1719
1720   return rbd_invalidate_cache(image);
1721 }
1722 EOF
1723 if compile_prog "" "-lrbd -lrados" "rbd"; then
1724   rbd_inval="yes"
1725 fi
1726 print_config "rbd_invalidate_cache" "$rbd_inval"
1727 fi
1728
1729 ##########################################
1730 # Check whether we have setvbuf
1731 if test "$setvbuf" != "yes" ; then
1732   setvbuf="no"
1733 fi
1734 cat > $TMPC << EOF
1735 #include <stdio.h>
1736 int main(int argc, char **argv)
1737 {
1738   FILE *f = NULL;
1739   char buf[80];
1740   setvbuf(f, buf, _IOFBF, sizeof(buf));
1741   return 0;
1742 }
1743 EOF
1744 if compile_prog "" "" "setvbuf"; then
1745   setvbuf="yes"
1746 fi
1747 print_config "setvbuf" "$setvbuf"
1748
1749 ##########################################
1750 # check for gfapi
1751 if test "$gfapi" != "yes" ; then
1752   gfapi="no"
1753 fi
1754 cat > $TMPC << EOF
1755 #include <glusterfs/api/glfs.h>
1756
1757 int main(int argc, char **argv)
1758 {
1759   glfs_t *g = glfs_new("foo");
1760
1761   return 0;
1762 }
1763 EOF
1764 if test "$disable_gfapi" != "yes"  && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1765   LIBS="-lgfapi -lglusterfs $LIBS"
1766   gfapi="yes"
1767 fi
1768 print_config "Gluster API engine" "$gfapi"
1769
1770 ##########################################
1771 # check for gfapi fadvise support, initialize with "no" only if $gfapi is set to "yes"
1772 if test "$gfapi" = "yes" ; then
1773 gf_fadvise="no"
1774 cat > $TMPC << EOF
1775 #include <glusterfs/api/glfs.h>
1776
1777 int main(int argc, char **argv)
1778 {
1779   struct glfs_fd *fd;
1780   int ret = glfs_fadvise(fd, 0, 0, 1);
1781
1782   return 0;
1783 }
1784 EOF
1785 if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1786   gf_fadvise="yes"
1787 fi
1788 print_config "Gluster API use fadvise" "$gf_fadvise"
1789 fi
1790
1791 ##########################################
1792 # check for newer gfapi
1793 if test "$gfapi" = "yes" ; then
1794 gf_new="no"
1795 cat > $TMPC << EOF
1796 #include <glusterfs/api/glfs.h>
1797
1798 int main(int argc, char **argv)
1799 {
1800   return glfs_fsync(NULL, NULL, NULL) && glfs_ftruncate(NULL, 0, NULL, NULL);
1801 }
1802 EOF
1803 if compile_prog "" "-lgfapi -lglusterfs" "gf new api"; then
1804   gf_new="yes"
1805 fi
1806 print_config "Gluster new API" "$gf_new"
1807 fi
1808
1809 ##########################################
1810 # check for gfapi trim support
1811 if test "$gf_trim" != "yes" ; then
1812   gf_trim="no"
1813 fi
1814 if test "$gfapi" = "yes" ; then
1815 cat > $TMPC << EOF
1816 #include <glusterfs/api/glfs.h>
1817
1818 int main(int argc, char **argv)
1819 {
1820   return glfs_discard_async(NULL, 0, 0);
1821 }
1822 EOF
1823 if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1824   gf_trim="yes"
1825 fi
1826 print_config "Gluster API trim support" "$gf_trim"
1827 fi
1828
1829 ##########################################
1830 # Check if we support stckf on s390
1831 if test "$s390_z196_facilities" != "yes" ; then
1832   s390_z196_facilities="no"
1833 fi
1834 cat > $TMPC << EOF
1835 #define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1836 int main(int argc, char **argv)
1837 {
1838     /* We want just 1 double word to be returned.  */
1839     register unsigned long reg0 asm("0") = 0;
1840     unsigned long stfle_bits;
1841     asm volatile(".machine push"        "\n\t"
1842                  ".machine \"z9-109\""  "\n\t"
1843                  "stfle %0"             "\n\t"
1844                  ".machine pop"         "\n"
1845                  : "=QS" (stfle_bits), "+d" (reg0)
1846                  : : "cc");
1847
1848     if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1849       return 0;
1850     else
1851       return -1;
1852 }
1853 EOF
1854 if compile_prog "" "" "s390_z196_facilities"; then
1855   $TMPE
1856   if [ $? -eq 0 ]; then
1857         s390_z196_facilities="yes"
1858   fi
1859 fi
1860 print_config "s390_z196_facilities" "$s390_z196_facilities"
1861
1862 ##########################################
1863 # Check if we have required environment variables configured for libhdfs
1864 if test "$libhdfs" = "yes" ; then
1865   hdfs_conf_error=0
1866   if test "$JAVA_HOME" = "" ; then
1867     echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1868     hdfs_conf_error=1
1869   fi
1870   if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1871     echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1872     hdfs_conf_error=1
1873   fi
1874   if test "$FIO_LIBHDFS_LIB" = "" ; then
1875     echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1876     hdfs_conf_error=1
1877   fi
1878   if test "$hdfs_conf_error" = "1" ; then
1879     exit 1
1880   fi
1881   FIO_HDFS_CPU=$cpu
1882   if test "$FIO_HDFS_CPU" = "x86_64" ; then
1883     FIO_HDFS_CPU="amd64"
1884   fi
1885 fi
1886 print_config "HDFS engine" "$libhdfs"
1887
1888 ##########################################
1889 # Check whether we have MTD
1890 if test "$mtd" != "yes" ; then
1891   mtd="no"
1892 fi
1893 cat > $TMPC << EOF
1894 #include <string.h>
1895 #include <mtd/mtd-user.h>
1896 #include <sys/ioctl.h>
1897 int main(int argc, char **argv)
1898 {
1899   struct mtd_write_req ops;
1900   struct mtd_info_user info;
1901   memset(&ops, 0, sizeof(ops));
1902   info.type = MTD_MLCNANDFLASH;
1903   return ioctl(0, MEMGETINFO, &info);
1904 }
1905 EOF
1906 if compile_prog "" "" "mtd"; then
1907   mtd="yes"
1908 fi
1909 print_config "MTD" "$mtd"
1910
1911 ##########################################
1912 # Check whether we have libpmem
1913 if test "$libpmem" != "yes" ; then
1914   libpmem="no"
1915 fi
1916 cat > $TMPC << EOF
1917 #include <libpmem.h>
1918 int main(int argc, char **argv)
1919 {
1920   int rc;
1921   rc = pmem_is_pmem(0, 0);
1922   return 0;
1923 }
1924 EOF
1925 if compile_prog "" "-lpmem" "libpmem"; then
1926   libpmem="yes"
1927   LIBS="-lpmem $LIBS"
1928 fi
1929 print_config "libpmem" "$libpmem"
1930
1931 ##########################################
1932 # Check whether we have libpmemblk
1933 # libpmem is a prerequisite
1934 if test "$libpmemblk" != "yes" ; then
1935   libpmemblk="no"
1936 fi
1937 if test "$libpmem" = "yes"; then
1938   cat > $TMPC << EOF
1939 #include <libpmemblk.h>
1940 int main(int argc, char **argv)
1941 {
1942   PMEMblkpool *pbp;
1943   pbp = pmemblk_open("", 0);
1944   return 0;
1945 }
1946 EOF
1947   if compile_prog "" "-lpmemblk" "libpmemblk"; then
1948     libpmemblk="yes"
1949     LIBS="-lpmemblk $LIBS"
1950   fi
1951 fi
1952 print_config "libpmemblk" "$libpmemblk"
1953
1954 # Choose the ioengines
1955 if test "$libpmem" = "yes" && test "$disable_pmem" = "no"; then
1956   pmem="yes"
1957   devdax="yes"
1958   if test "$libpmemblk" = "yes"; then
1959     pmemblk="yes"
1960   fi
1961 fi
1962
1963 ##########################################
1964 # Report whether pmemblk engine is enabled
1965 print_config "PMDK pmemblk engine" "$pmemblk"
1966
1967 ##########################################
1968 # Report whether dev-dax engine is enabled
1969 print_config "PMDK dev-dax engine" "$devdax"
1970
1971 ##########################################
1972 # Report whether libpmem engine is enabled
1973 print_config "PMDK libpmem engine" "$pmem"
1974
1975 ##########################################
1976 # Check whether we support DDN's IME
1977 if test "$libime" != "yes" ; then
1978   libime="no"
1979 fi
1980 cat > $TMPC << EOF
1981 #include <ime_native.h>
1982 int main(int argc, char **argv)
1983 {
1984   int rc;
1985   ime_native_init();
1986   rc = ime_native_finalize();
1987   return 0;
1988 }
1989 EOF
1990 if compile_prog "-I${ime_path}/include" "-L${ime_path}/lib -lim_client" "libime"; then
1991   libime="yes"
1992   CFLAGS="-I${ime_path}/include $CFLAGS"
1993   LDFLAGS="-Wl,-rpath ${ime_path}/lib -L${ime_path}/lib $LDFLAGS"
1994   LIBS="-lim_client $LIBS"
1995 fi
1996 print_config "DDN's Infinite Memory Engine" "$libime"
1997
1998 ##########################################
1999 # Check if we have required environment variables configured for libiscsi
2000 if test "$libiscsi" = "yes" ; then
2001   if $(pkg-config --atleast-version=1.9.0 libiscsi); then
2002     libiscsi="yes"
2003     libiscsi_cflags=$(pkg-config --cflags libiscsi)
2004     libiscsi_libs=$(pkg-config --libs libiscsi)
2005   else
2006     if test "$libiscsi" = "yes" ; then
2007       echo "libiscsi" "Install libiscsi >= 1.9.0"
2008     fi
2009     libiscsi="no"
2010   fi
2011 fi
2012 print_config "iscsi engine" "$libiscsi"
2013
2014 ##########################################
2015 # Check if we have lex/yacc available
2016 yacc="no"
2017 yacc_is_bison="no"
2018 lex="no"
2019 arith="no"
2020 if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
2021 if test "$targetos" != "SunOS" ; then
2022 LEX=$(which lex 2> /dev/null)
2023 if test -x "$LEX" ; then
2024   lex="yes"
2025 fi
2026 YACC=$(which bison 2> /dev/null)
2027 if test -x "$YACC" ; then
2028   yacc="yes"
2029   yacc_is_bison="yes"
2030 else
2031   YACC=$(which yacc 2> /dev/null)
2032   if test -x "$YACC" ; then
2033     yacc="yes"
2034   fi
2035 fi
2036 if test "$yacc" = "yes" && test "$lex" = "yes" ; then
2037   arith="yes"
2038 fi
2039
2040 if test "$arith" = "yes" ; then
2041 cat > $TMPC << EOF
2042 extern int yywrap(void);
2043
2044 int main(int argc, char **argv)
2045 {
2046   yywrap();
2047   return 0;
2048 }
2049 EOF
2050 if compile_prog "" "-ll" "lex"; then
2051   LIBS="-ll $LIBS"
2052 else
2053   arith="no"
2054 fi
2055 fi
2056 fi
2057 fi
2058
2059 # Check if lex fails using -o
2060 if test "$arith" = "yes" ; then
2061 if test "$force_no_lex_o" = "yes" ; then
2062   lex_use_o="no"
2063 else
2064 $LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
2065 if test "$?" = "0" ; then
2066   lex_use_o="yes"
2067 else
2068   lex_use_o="no"
2069 fi
2070 fi
2071 fi
2072
2073 print_config "lex/yacc for arithmetic" "$arith"
2074
2075 ##########################################
2076 # Check whether we have setmntent/getmntent
2077 if test "$getmntent" != "yes" ; then
2078   getmntent="no"
2079 fi
2080 cat > $TMPC << EOF
2081 #include <stdio.h>
2082 #include <mntent.h>
2083 int main(int argc, char **argv)
2084 {
2085   FILE *mtab = setmntent(NULL, "r");
2086   struct mntent *mnt = getmntent(mtab);
2087   endmntent(mtab);
2088   return 0;
2089 }
2090 EOF
2091 if compile_prog "" "" "getmntent"; then
2092   getmntent="yes"
2093 fi
2094 print_config "getmntent" "$getmntent"
2095
2096 ##########################################
2097 # Check whether we have getmntinfo
2098 # These are originally added for BSDs, but may also work
2099 # on other operating systems with getmntinfo(3).
2100
2101 # getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
2102 # Note that NetBSD needs -Werror to catch warning as error.
2103 if test "$getmntinfo" != "yes" ; then
2104   getmntinfo="no"
2105 fi
2106 cat > $TMPC << EOF
2107 #include <stdio.h>
2108 #include <sys/param.h>
2109 #include <sys/mount.h>
2110 int main(int argc, char **argv)
2111 {
2112   struct statfs *st;
2113   return getmntinfo(&st, MNT_NOWAIT);
2114 }
2115 EOF
2116 if compile_prog "-Werror" "" "getmntinfo"; then
2117   getmntinfo="yes"
2118 fi
2119 print_config "getmntinfo" "$getmntinfo"
2120
2121 # getmntinfo(3) for NetBSD.
2122 if test "$getmntinfo_statvfs" != "yes" ; then
2123   getmntinfo_statvfs="no"
2124 fi
2125 cat > $TMPC << EOF
2126 #include <stdio.h>
2127 #include <sys/statvfs.h>
2128 int main(int argc, char **argv)
2129 {
2130   struct statvfs *st;
2131   return getmntinfo(&st, MNT_NOWAIT);
2132 }
2133 EOF
2134 # Skip the test if the one with statfs arg is detected.
2135 if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
2136   getmntinfo_statvfs="yes"
2137   print_config "getmntinfo_statvfs" "$getmntinfo_statvfs"
2138 fi
2139
2140 ##########################################
2141 # Check whether we have _Static_assert
2142 if test "$static_assert" != "yes" ; then
2143   static_assert="no"
2144 fi
2145 cat > $TMPC << EOF
2146 #include <assert.h>
2147 #include <stdlib.h>
2148 #include <stddef.h>
2149
2150 struct foo {
2151   int a, b;
2152 };
2153
2154 int main(int argc, char **argv)
2155 {
2156   _Static_assert(offsetof(struct foo, a) == 0 , "Check");
2157   return 0 ;
2158 }
2159 EOF
2160 if compile_prog "" "" "static_assert"; then
2161     static_assert="yes"
2162 fi
2163 print_config "Static Assert" "$static_assert"
2164
2165 ##########################################
2166 # Check whether we have bool / stdbool.h
2167 if test "$have_bool" != "yes" ; then
2168   have_bool="no"
2169 fi
2170 cat > $TMPC << EOF
2171 #include <stdbool.h>
2172 int main(int argc, char **argv)
2173 {
2174   bool var = true;
2175   return var != false;
2176 }
2177 EOF
2178 if compile_prog "" "" "bool"; then
2179   have_bool="yes"
2180 fi
2181 print_config "bool" "$have_bool"
2182
2183 ##########################################
2184 # Check whether we have strndup()
2185 strndup="no"
2186 cat > $TMPC << EOF
2187 #include <string.h>
2188 #include <stdlib.h>
2189 int main(int argc, char **argv)
2190 {
2191   char *res = strndup("test string", 8);
2192
2193   free(res);
2194   return 0;
2195 }
2196 EOF
2197 if compile_prog "" "" "strndup"; then
2198   strndup="yes"
2199 fi
2200 print_config "strndup" "$strndup"
2201
2202 ##########################################
2203 # <valgrind/drd.h> probe
2204 # Note: presence of <valgrind/drd.h> implies that <valgrind/valgrind.h> is
2205 # also available but not the other way around.
2206 if test "$valgrind_dev" != "yes" ; then
2207   valgrind_dev="no"
2208 fi
2209 cat > $TMPC << EOF
2210 #include <valgrind/drd.h>
2211 int main(int argc, char **argv)
2212 {
2213   return 0;
2214 }
2215 EOF
2216 if compile_prog "" "" "valgrind_dev"; then
2217   valgrind_dev="yes"
2218 fi
2219 print_config "Valgrind headers" "$valgrind_dev"
2220
2221 ##########################################
2222 # <linux/blkzoned.h> probe
2223 if test "$linux_blkzoned" != "yes" ; then
2224   linux_blkzoned="no"
2225 fi
2226 cat > $TMPC << EOF
2227 #include <linux/blkzoned.h>
2228 int main(int argc, char **argv)
2229 {
2230   return 0;
2231 }
2232 EOF
2233 if compile_prog "" "" "linux_blkzoned"; then
2234   linux_blkzoned="yes"
2235 fi
2236 print_config "Zoned block device support" "$linux_blkzoned"
2237
2238 ##########################################
2239 # check march=armv8-a+crc+crypto
2240 if test "$march_armv8_a_crc_crypto" != "yes" ; then
2241   march_armv8_a_crc_crypto="no"
2242 fi
2243 if test "$cpu" = "arm64" ; then
2244   cat > $TMPC <<EOF
2245 #include <arm_acle.h>
2246 #include <arm_neon.h>
2247 #include <sys/auxv.h>
2248
2249 int main(void)
2250 {
2251   /* Can we also do a runtime probe? */
2252 #if __linux__
2253   return getauxval(AT_HWCAP);
2254 #else
2255 # error "Don't know how to do runtime probe for ARM CRC32c"
2256 #endif
2257 }
2258 EOF
2259   if compile_prog "-march=armv8-a+crc+crypto" "" "ARM CRC32c"; then
2260     march_armv8_a_crc_crypto="yes"
2261     CFLAGS="$CFLAGS -march=armv8-a+crc+crypto"
2262     march_set="yes"
2263   fi
2264 fi
2265 print_config "march_armv8_a_crc_crypto" "$march_armv8_a_crc_crypto"
2266
2267 ##########################################
2268 # cuda probe
2269 if test "$cuda" != "yes" ; then
2270   cuda="no"
2271 fi
2272 cat > $TMPC << EOF
2273 #include <cuda.h>
2274 int main(int argc, char **argv)
2275 {
2276   return cuInit(0);
2277 }
2278 EOF
2279 if test "$enable_cuda" = "yes" && compile_prog "" "-lcuda" "cuda"; then
2280   cuda="yes"
2281   LIBS="-lcuda $LIBS"
2282 fi
2283 print_config "cuda" "$cuda"
2284
2285 ##########################################
2286 # mkdir() probe. mingw apparently has a one-argument mkdir :/
2287 mkdir_two="no"
2288 cat > $TMPC << EOF
2289 #include <sys/stat.h>
2290 #include <sys/types.h>
2291 int main(int argc, char **argv)
2292 {
2293   return mkdir("/tmp/bla", 0600);
2294 }
2295 EOF
2296 if compile_prog "" "" "mkdir(a, b)"; then
2297   mkdir_two="yes"
2298 fi
2299 print_config "mkdir(a, b)" "$mkdir_two"
2300
2301 ##########################################
2302 # check for cc -march=native
2303 build_native="no"
2304 cat > $TMPC << EOF
2305 int main(int argc, char **argv)
2306 {
2307   return 0;
2308 }
2309 EOF
2310 if test "$disable_native" = "no" && test "$disable_opt" != "yes" && \
2311    compile_prog "-march=native" "" "march=native"; then
2312   build_native="yes"
2313 fi
2314 print_config "Build march=native" "$build_native"
2315
2316 ##########################################
2317 # check for -lcunit
2318 if test "$cunit" != "yes" ; then
2319   cunit="no"
2320 fi
2321 cat > $TMPC << EOF
2322 #include <CUnit/CUnit.h>
2323 #include <CUnit/Basic.h>
2324 int main(void)
2325 {
2326   if (CU_initialize_registry() != CUE_SUCCESS)
2327     return CU_get_error();
2328   CU_basic_set_mode(CU_BRM_VERBOSE);
2329   CU_basic_run_tests();
2330   CU_cleanup_registry();
2331   return CU_get_error();
2332 }
2333 EOF
2334 if compile_prog "" "-lcunit" "CUnit"; then
2335   cunit="yes"
2336 fi
2337 print_config "CUnit" "$cunit"
2338
2339 ##########################################
2340 # check for __kernel_rwf_t
2341 __kernel_rwf_t="no"
2342 cat > $TMPC << EOF
2343 #include <linux/fs.h>
2344 int main(int argc, char **argv)
2345 {
2346   __kernel_rwf_t x;
2347   x = 0;
2348   return x;
2349 }
2350 EOF
2351 if compile_prog "" "" "__kernel_rwf_t"; then
2352   __kernel_rwf_t="yes"
2353 fi
2354 print_config "__kernel_rwf_t" "$__kernel_rwf_t"
2355
2356 ##########################################
2357 # check if gcc has -Wimplicit-fallthrough
2358 fallthrough="no"
2359 cat > $TMPC << EOF
2360 int main(int argc, char **argv)
2361 {
2362   return 0;
2363 }
2364 EOF
2365 if compile_prog "-Wimplicit-fallthrough" "" "-Wimplicit-fallthrough"; then
2366   fallthrough="yes"
2367 fi
2368 print_config "-Wimplicit-fallthrough" "$fallthrough"
2369
2370 ##########################################
2371 # check for MADV_HUGEPAGE support
2372 if test "$thp" != "yes" ; then
2373   thp="no"
2374 fi
2375 if test "$esx" != "yes" ; then
2376   cat > $TMPC <<EOF
2377 #include <sys/mman.h>
2378 int main(void)
2379 {
2380   return madvise(0, 0x1000, MADV_HUGEPAGE);
2381 }
2382 EOF
2383   if compile_prog "" "" "thp" ; then
2384     thp=yes
2385   else
2386     if test "$thp" = "yes" ; then
2387       feature_not_found "Transparent Huge Page" ""
2388     fi
2389     thp=no
2390   fi
2391 fi
2392 print_config "MADV_HUGEPAGE" "$thp"
2393
2394 ##########################################
2395 # check for gettid()
2396 gettid="no"
2397 cat > $TMPC << EOF
2398 #include <unistd.h>
2399 int main(int argc, char **argv)
2400 {
2401   return gettid();
2402 }
2403 EOF
2404 if compile_prog "" "" "gettid"; then
2405   gettid="yes"
2406 fi
2407 print_config "gettid" "$gettid"
2408
2409 #############################################################################
2410
2411 if test "$wordsize" = "64" ; then
2412   output_sym "CONFIG_64BIT"
2413 elif test "$wordsize" = "32" ; then
2414   output_sym "CONFIG_32BIT"
2415 else
2416   fatal "Unknown wordsize!"
2417 fi
2418 if test "$bigendian" = "yes" ; then
2419   output_sym "CONFIG_BIG_ENDIAN"
2420 else
2421   output_sym "CONFIG_LITTLE_ENDIAN"
2422 fi
2423 if test "$zlib" = "yes" ; then
2424   output_sym "CONFIG_ZLIB"
2425 fi
2426 if test "$libaio" = "yes" ; then
2427   output_sym "CONFIG_LIBAIO"
2428 fi
2429 if test "$posix_aio" = "yes" ; then
2430   output_sym "CONFIG_POSIXAIO"
2431 fi
2432 if test "$posix_aio_fsync" = "yes" ; then
2433   output_sym "CONFIG_POSIXAIO_FSYNC"
2434 fi
2435 if test "$posix_pshared" = "yes" ; then
2436   output_sym "CONFIG_PSHARED"
2437 fi
2438 if test "$have_asprintf" = "yes" ; then
2439     output_sym "CONFIG_HAVE_ASPRINTF"
2440 fi
2441 if test "$have_vasprintf" = "yes" ; then
2442     output_sym "CONFIG_HAVE_VASPRINTF"
2443 fi
2444 if test "$linux_fallocate" = "yes" ; then
2445   output_sym "CONFIG_LINUX_FALLOCATE"
2446 fi
2447 if test "$posix_fallocate" = "yes" ; then
2448   output_sym "CONFIG_POSIX_FALLOCATE"
2449 fi
2450 if test "$fdatasync" = "yes" ; then
2451   output_sym "CONFIG_FDATASYNC"
2452 fi
2453 if test "$sync_file_range" = "yes" ; then
2454   output_sym "CONFIG_SYNC_FILE_RANGE"
2455 fi
2456 if test "$sfaa" = "yes" ; then
2457   output_sym "CONFIG_SFAA"
2458 fi
2459 if test "$sync_sync" = "yes" ; then
2460   output_sym "CONFIG_SYNC_SYNC"
2461 fi
2462 if test "$cmp_swap" = "yes" ; then
2463   output_sym "CONFIG_CMP_SWAP"
2464 fi
2465 if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
2466   output_sym "CONFIG_RDMA"
2467 fi
2468 if test "$clock_gettime" = "yes" ; then
2469   output_sym "CONFIG_CLOCK_GETTIME"
2470 fi
2471 if test "$clock_monotonic" = "yes" ; then
2472   output_sym "CONFIG_CLOCK_MONOTONIC"
2473 fi
2474 if test "$clock_monotonic_raw" = "yes" ; then
2475   output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
2476 fi
2477 if test "$clock_monotonic_precise" = "yes" ; then
2478   output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
2479 fi
2480 if test "$clockid_t" = "yes"; then
2481   output_sym "CONFIG_CLOCKID_T"
2482 fi
2483 if test "$gettimeofday" = "yes" ; then
2484   output_sym "CONFIG_GETTIMEOFDAY"
2485 fi
2486 if test "$posix_fadvise" = "yes" ; then
2487   output_sym "CONFIG_POSIX_FADVISE"
2488 fi
2489 if test "$linux_3arg_affinity" = "yes" ; then
2490   output_sym "CONFIG_3ARG_AFFINITY"
2491 elif test "$linux_2arg_affinity" = "yes" ; then
2492   output_sym "CONFIG_2ARG_AFFINITY"
2493 fi
2494 if test "$strsep" = "yes" ; then
2495   output_sym "CONFIG_STRSEP"
2496 fi
2497 if test "$strcasestr" = "yes" ; then
2498   output_sym "CONFIG_STRCASESTR"
2499 fi
2500 if test "$strlcat" = "yes" ; then
2501   output_sym "CONFIG_STRLCAT"
2502 fi
2503 if test "$getopt_long_only" = "yes" ; then
2504   output_sym "CONFIG_GETOPT_LONG_ONLY"
2505 fi
2506 if test "$inet_aton" = "yes" ; then
2507   output_sym "CONFIG_INET_ATON"
2508 fi
2509 if test "$socklen_t" = "yes" ; then
2510   output_sym "CONFIG_SOCKLEN_T"
2511 fi
2512 if test "$ext4_me" = "yes" ; then
2513   output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
2514 fi
2515 if test "$linux_splice" = "yes" ; then
2516   output_sym "CONFIG_LINUX_SPLICE"
2517 fi
2518 if test "$guasi" = "yes" ; then
2519   output_sym "CONFIG_GUASI"
2520 fi
2521 if test "$libnuma_v2" = "yes" ; then
2522   output_sym "CONFIG_LIBNUMA"
2523 fi
2524 if test "$solaris_aio" = "yes" ; then
2525   output_sym "CONFIG_SOLARISAIO"
2526 fi
2527 if test "$tls_thread" = "yes" ; then
2528   output_sym "CONFIG_TLS_THREAD"
2529 fi
2530 if test "$rusage_thread" = "yes" ; then
2531   output_sym "CONFIG_RUSAGE_THREAD"
2532 fi
2533 if test "$gfio" = "yes" ; then
2534   output_sym "CONFIG_GFIO"
2535 fi
2536 if test "$esx" = "yes" ; then
2537   output_sym "CONFIG_ESX"
2538   output_sym "CONFIG_NO_SHM"
2539 fi
2540 if test "$sched_idle" = "yes" ; then
2541   output_sym "CONFIG_SCHED_IDLE"
2542 fi
2543 if test "$tcp_nodelay" = "yes" ; then
2544   output_sym "CONFIG_TCP_NODELAY"
2545 fi
2546 if test "$window_size" = "yes" ; then
2547   output_sym "CONFIG_NET_WINDOWSIZE"
2548 fi
2549 if test "$mss" = "yes" ; then
2550   output_sym "CONFIG_NET_MSS"
2551 fi
2552 if test "$rlimit_memlock" = "yes" ; then
2553   output_sym "CONFIG_RLIMIT_MEMLOCK"
2554 fi
2555 if test "$pwritev" = "yes" ; then
2556   output_sym "CONFIG_PWRITEV"
2557 fi
2558 if test "$pwritev2" = "yes" ; then
2559   output_sym "CONFIG_PWRITEV2"
2560 fi
2561 if test "$ipv6" = "yes" ; then
2562   output_sym "CONFIG_IPV6"
2563 fi
2564 if test "$http" = "yes" ; then
2565   output_sym "CONFIG_HTTP"
2566 fi
2567 if test "$rados" = "yes" ; then
2568   output_sym "CONFIG_RADOS"
2569 fi
2570 if test "$rbd" = "yes" ; then
2571   output_sym "CONFIG_RBD"
2572 fi
2573 if test "$rbd_poll" = "yes" ; then
2574   output_sym "CONFIG_RBD_POLL"
2575 fi
2576 if test "$rbd_inval" = "yes" ; then
2577   output_sym "CONFIG_RBD_INVAL"
2578 fi
2579 if test "$setvbuf" = "yes" ; then
2580   output_sym "CONFIG_SETVBUF"
2581 fi
2582 if test "$s390_z196_facilities" = "yes" ; then
2583   output_sym "CONFIG_S390_Z196_FACILITIES"
2584   CFLAGS="$CFLAGS -march=z9-109"
2585   march_set="yes"
2586 fi
2587 if test "$gfapi" = "yes" ; then
2588   output_sym "CONFIG_GFAPI"
2589 fi
2590 if test "$gf_fadvise" = "yes" ; then
2591   output_sym "CONFIG_GF_FADVISE"
2592 fi
2593 if test "$gf_trim" = "yes" ; then
2594   output_sym "CONFIG_GF_TRIM"
2595 fi
2596 if test "$gf_new" = "yes" ; then
2597   output_sym "CONFIG_GF_NEW_API"
2598 fi
2599 if test "$libhdfs" = "yes" ; then
2600   output_sym "CONFIG_LIBHDFS"
2601   echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
2602   echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
2603   echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
2604   echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
2605 fi
2606 if test "$mtd" = "yes" ; then
2607   output_sym "CONFIG_MTD"
2608 fi
2609 if test "$pmemblk" = "yes" ; then
2610   output_sym "CONFIG_PMEMBLK"
2611 fi
2612 if test "$devdax" = "yes" ; then
2613   output_sym "CONFIG_LINUX_DEVDAX"
2614 fi
2615 if test "$pmem" = "yes" ; then
2616   output_sym "CONFIG_LIBPMEM"
2617 fi
2618 if test "$libime" = "yes" ; then
2619   output_sym "CONFIG_IME"
2620 fi
2621 if test "$arith" = "yes" ; then
2622   output_sym "CONFIG_ARITHMETIC"
2623   if test "$yacc_is_bison" = "yes" ; then
2624     echo "YACC=$YACC -y" >> $config_host_mak
2625   else
2626     echo "YACC=$YACC" >> $config_host_mak
2627   fi
2628   if test "$lex_use_o" = "yes" ; then
2629     echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
2630   fi
2631 fi
2632 if test "$getmntent" = "yes" ; then
2633   output_sym "CONFIG_GETMNTENT"
2634 fi
2635 if test "$getmntinfo" = "yes" ; then
2636   output_sym "CONFIG_GETMNTINFO"
2637 fi
2638 if test "$getmntinfo_statvfs" = "yes" ; then
2639   output_sym "CONFIG_GETMNTINFO_STATVFS"
2640 fi
2641 if test "$static_assert" = "yes" ; then
2642   output_sym "CONFIG_STATIC_ASSERT"
2643 fi
2644 if test "$have_bool" = "yes" ; then
2645   output_sym "CONFIG_HAVE_BOOL"
2646 fi
2647 if test "$strndup" = "yes" ; then
2648   output_sym "CONFIG_HAVE_STRNDUP"
2649 fi
2650 if test "$disable_opt" = "yes" ; then
2651   output_sym "CONFIG_DISABLE_OPTIMIZATIONS"
2652 fi
2653 if test "$valgrind_dev" = "yes"; then
2654   output_sym "CONFIG_VALGRIND_DEV"
2655 fi
2656 if test "$linux_blkzoned" = "yes" ; then
2657   output_sym "CONFIG_LINUX_BLKZONED"
2658 fi
2659 if test "$zlib" = "no" ; then
2660   echo "Consider installing zlib-dev (zlib-devel, some fio features depend on it."
2661   if test "$build_static" = "yes"; then
2662     echo "Note that some distros have separate packages for static libraries."
2663   fi
2664 fi
2665 if test "$march_armv8_a_crc_crypto" = "yes" ; then
2666   output_sym "ARCH_HAVE_CRC_CRYPTO"
2667 fi
2668 if test "$cuda" = "yes" ; then
2669   output_sym "CONFIG_CUDA"
2670 fi
2671 if test "$mkdir_two" = "yes" ; then
2672   output_sym "CONFIG_HAVE_MKDIR_TWO"
2673 fi
2674 if test "$march_set" = "no" && test "$build_native" = "yes" ; then
2675   output_sym "CONFIG_BUILD_NATIVE"
2676 fi
2677 if test "$cunit" = "yes" ; then
2678   output_sym "CONFIG_HAVE_CUNIT"
2679 fi
2680 if test "$__kernel_rwf_t" = "yes"; then
2681   output_sym "CONFIG_HAVE_KERNEL_RWF_T"
2682 fi
2683 if test "$gettid" = "yes"; then
2684   output_sym "CONFIG_HAVE_GETTID"
2685 fi
2686 if test "$fallthrough" = "yes"; then
2687   CFLAGS="$CFLAGS -Wimplicit-fallthrough"
2688 fi
2689 if test "$thp" = "yes" ; then
2690   output_sym "CONFIG_HAVE_THP"
2691 fi
2692 if test "$libiscsi" = "yes" ; then
2693   output_sym "CONFIG_LIBISCSI"
2694   echo "CONFIG_LIBISCSI=m" >> $config_host_mak
2695   echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
2696   echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
2697 fi
2698
2699 echo "LIBS+=$LIBS" >> $config_host_mak
2700 echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
2701 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
2702 echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
2703 echo "CC=$cc" >> $config_host_mak
2704 echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
2705 echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
2706
2707 if [ `dirname $0` != "." -a ! -e Makefile ]; then
2708     cat > Makefile <<EOF
2709 SRCDIR:=`dirname $0`
2710 include \$(SRCDIR)/Makefile
2711 EOF
2712 fi