glusterfs: update for new API
[fio.git] / configure
... / ...
CommitLineData
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
8if test ! -z "$TMPDIR" ; then
9 TMPDIR1="${TMPDIR}"
10elif test ! -z "$TEMPDIR" ; then
11 TMPDIR1="${TEMPDIR}"
12else
13 TMPDIR1="/tmp"
14fi
15
16TMPC="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.c"
17TMPC2="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}-2.c"
18TMPO="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.o"
19TMPE="${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>
23trap "rm -f $TMPC $TMPC2 $TMPO $TMPE" EXIT INT QUIT TERM
24
25rm -rf config.log
26
27config_host_mak="config-host.mak"
28config_host_h="config-host.h"
29
30rm -rf $config_host_mak
31rm -rf $config_host_h
32
33fatal() {
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
42print_config() {
43 printf "%-30s%s\n" "$1" "$2"
44}
45
46# Default CFLAGS
47CFLAGS="-D_GNU_SOURCE -include config-host.h"
48BUILD_CFLAGS=""
49
50# Print a helpful header at the top of config.log
51echo "# FIO configure log $(date)" >> config.log
52printf "# Configured with:" >> config.log
53printf " '%s'" "$0" "$@" >> config.log
54echo >> config.log
55echo "#" >> config.log
56
57# Print configure header at the top of $config_host_h
58echo "/*" > $config_host_h
59echo " * Automatically generated by configure - do not modify" >> $config_host_h
60printf " * Configured with:" >> $config_host_h
61printf " * '%s'" "$0" "$@" >> $config_host_h
62echo "" >> $config_host_h
63echo " */" >> $config_host_h
64
65do_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
90compile_object() {
91 do_cc $CFLAGS -c -o $TMPO $TMPC
92}
93
94compile_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
101feature_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
114has() {
115 type "$1" >/dev/null 2>&1
116}
117
118check_define() {
119 cat > $TMPC <<EOF
120#if !defined($1)
121#error $1 not defined
122#endif
123int main(void)
124{
125 return 0;
126}
127EOF
128 compile_object
129}
130
131output_sym() {
132 echo "$1=y" >> $config_host_mak
133 echo "#define $1" >> $config_host_h
134}
135
136targetos=""
137cpu=""
138
139# default options
140show_help="no"
141exit_val=0
142gfio_check="no"
143libhdfs="no"
144pmemblk="no"
145devdax="no"
146pmem="no"
147disable_lex=""
148disable_pmem="no"
149disable_native="no"
150march_set="no"
151libiscsi="no"
152prefix=/usr/local
153
154# parse options
155for 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
218done
219
220if 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
247fi
248
249cross_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
255if test -z "${CC}${cross_prefix}"; then
256 if has gcc; then
257 cc=gcc
258 elif has clang; then
259 cc=clang
260 fi
261else
262 cc="${CC-${cross_prefix}gcc}"
263fi
264
265if check_define __ANDROID__ ; then
266 targetos="Android"
267elif check_define __linux__ ; then
268 targetos="Linux"
269elif check_define __OpenBSD__ ; then
270 targetos='OpenBSD'
271elif check_define __NetBSD__ ; then
272 targetos='NetBSD'
273elif check_define __sun__ ; then
274 targetos='SunOS'
275 CFLAGS="$CFLAGS -D_REENTRANT"
276elif check_define _WIN32 ; then
277 targetos='CYGWIN'
278else
279 targetos=`uname -s`
280fi
281
282echo "# Automatically generated by configure - do not modify" > $config_host_mak
283printf "# Configured with:" >> $config_host_mak
284printf " '%s'" "$0" "$@" >> $config_host_mak
285echo >> $config_host_mak
286echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
287
288if test "$no_shm" = "yes" ; then
289 output_sym "CONFIG_NO_SHM"
290fi
291
292if test "$disable_opt" = "yes" ; then
293 output_sym "CONFIG_FIO_NO_OPT"
294fi
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.
300case $targetos in
301AIX|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 ;;
310FreeBSD)
311 CFLAGS="$CFLAGS -I/usr/local/include"
312 LDFLAGS="$LDFLAGS -L/usr/local/lib"
313 ;;
314Darwin)
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...
324cat > $TMPC <<EOF
325int main(void)
326{
327 return 0;
328}
329EOF
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 ;;
335SunOS)
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 ;;
342CYGWIN*)
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 ;;
383esac
384
385# Now we know the target platform we can have another guess at the preferred
386# compiler when it wasn't explictly set
387if 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
393fi
394if test -z "$cc"; then
395 echo "configure: failed to find compiler"
396 exit 1
397fi
398
399if test ! -z "$cpu" ; then
400 # command line argument
401 :
402elif check_define __i386__ ; then
403 cpu="i386"
404elif check_define __x86_64__ ; then
405 cpu="x86_64"
406elif check_define __sparc__ ; then
407 if check_define __arch64__ ; then
408 cpu="sparc64"
409 else
410 cpu="sparc"
411 fi
412elif check_define _ARCH_PPC ; then
413 if check_define _ARCH_PPC64 ; then
414 cpu="ppc64"
415 else
416 cpu="ppc"
417 fi
418elif check_define __mips__ ; then
419 cpu="mips"
420elif check_define __ia64__ ; then
421 cpu="ia64"
422elif check_define __s390__ ; then
423 if check_define __s390x__ ; then
424 cpu="s390x"
425 else
426 cpu="s390"
427 fi
428elif check_define __arm__ ; then
429 cpu="arm"
430elif check_define __aarch64__ ; then
431 cpu="aarch64"
432elif check_define __hppa__ ; then
433 cpu="hppa"
434else
435 cpu=`uname -m`
436fi
437
438# Normalise host CPU name and set ARCH.
439case "$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 ;;
467esac
468
469##########################################
470# check cross compile
471
472if test "$cross_compile" != "yes" ; then
473 cross_compile="no"
474fi
475cat > $TMPC <<EOF
476int main(void)
477{
478 return 0;
479}
480EOF
481if compile_prog "" "" "cross"; then
482 $TMPE 2>/dev/null || cross_compile="yes"
483else
484 fatal "compile test failed"
485fi
486
487##########################################
488# check endianness
489if test "$bigendian" != "yes" ; then
490 bigendian="no"
491fi
492if test "$cross_compile" = "no" ; then
493 cat > $TMPC <<EOF
494#include <inttypes.h>
495int main(void)
496{
497 volatile uint32_t i=0x01234567;
498 return (*((uint8_t*)(&i))) == 0x67;
499}
500EOF
501 if compile_prog "" "" "endian"; then
502 $TMPE && bigendian="yes"
503 fi
504else
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>
509int main(void)
510{
511#if __BYTE_ORDER != __BIG_ENDIAN
512# error "Unknown endianness"
513#endif
514}
515EOF
516 compile_prog "" "" "endian" && bigendian="yes"
517 check_define "__ARMEB__" && bigendian="yes"
518 check_define "__MIPSEB__" && bigendian="yes"
519fi
520
521
522print_config "Operating system" "$targetos"
523print_config "CPU" "$cpu"
524print_config "Big endian" "$bigendian"
525if test ! -z "$target_win_ver"; then
526 print_config "Target Windows version" "$target_win_ver"
527fi
528print_config "Compiler" "$cc"
529print_config "Cross compile" "$cross_compile"
530echo
531
532##########################################
533# See if we need to build a static build
534if test "$build_static" = "yes" ; then
535 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
536 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
537else
538 build_static="no"
539fi
540print_config "Static build" "$build_static"
541
542##########################################
543# check for wordsize
544wordsize="0"
545cat > $TMPC <<EOF
546#include <limits.h>
547#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
548int main(void)
549{
550 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
551 return 0;
552}
553EOF
554if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
555 wordsize="32"
556elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
557 wordsize="64"
558else
559 fatal "Unknown wordsize"
560fi
561print_config "Wordsize" "$wordsize"
562
563##########################################
564# zlib probe
565if test "$zlib" != "yes" ; then
566 zlib="no"
567fi
568cat > $TMPC <<EOF
569#include <zlib.h>
570int main(void)
571{
572 z_stream stream;
573 if (inflateInit(&stream) != Z_OK)
574 return 1;
575 return 0;
576}
577EOF
578if compile_prog "" "-lz" "zlib" ; then
579 zlib=yes
580 LIBS="-lz $LIBS"
581fi
582print_config "zlib" "$zlib"
583
584##########################################
585# linux-aio probe
586if test "$libaio" != "yes" ; then
587 libaio="no"
588fi
589if test "$esx" != "yes" ; then
590 cat > $TMPC <<EOF
591#include <libaio.h>
592#include <stddef.h>
593int main(void)
594{
595 io_setup(0, NULL);
596 return 0;
597}
598EOF
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
608fi
609print_config "Linux AIO support" "$libaio"
610
611##########################################
612# posix aio probe
613if test "$posix_aio" != "yes" ; then
614 posix_aio="no"
615fi
616if test "$posix_aio_lrt" != "yes" ; then
617 posix_aio_lrt="no"
618fi
619cat > $TMPC <<EOF
620#include <aio.h>
621int main(void)
622{
623 struct aiocb cb;
624 aio_read(&cb);
625 return 0;
626}
627EOF
628if compile_prog "" "" "posixaio" ; then
629 posix_aio="yes"
630elif compile_prog "" "-lrt" "posixaio -lrt"; then
631 posix_aio="yes"
632 posix_aio_lrt="yes"
633 LIBS="-lrt $LIBS"
634fi
635print_config "POSIX AIO support" "$posix_aio"
636print_config "POSIX AIO support needs -lrt" "$posix_aio_lrt"
637
638##########################################
639# posix aio fsync probe
640if test "$posix_aio_fsync" != "yes" ; then
641 posix_aio_fsync="no"
642fi
643if test "$posix_aio" = "yes" ; then
644 cat > $TMPC <<EOF
645#include <fcntl.h>
646#include <aio.h>
647int main(void)
648{
649 struct aiocb cb;
650 return aio_fsync(O_SYNC, &cb);
651 return 0;
652}
653EOF
654 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
655 posix_aio_fsync=yes
656 fi
657fi
658print_config "POSIX AIO fsync" "$posix_aio_fsync"
659
660##########################################
661# POSIX pshared attribute probe
662if test "$posix_pshared" != "yes" ; then
663 posix_pshared="no"
664fi
665cat > $TMPC <<EOF
666#include <unistd.h>
667int 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}
684EOF
685if compile_prog "" "$LIBS" "posix_pshared" ; then
686 posix_pshared=yes
687fi
688print_config "POSIX pshared support" "$posix_pshared"
689
690##########################################
691# solaris aio probe
692if test "$solaris_aio" != "yes" ; then
693 solaris_aio="no"
694fi
695cat > $TMPC <<EOF
696#include <sys/types.h>
697#include <sys/asynch.h>
698#include <unistd.h>
699int main(void)
700{
701 aio_result_t res;
702 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
703 return 0;
704}
705EOF
706if compile_prog "" "-laio" "solarisaio" ; then
707 solaris_aio=yes
708 LIBS="-laio $LIBS"
709fi
710print_config "Solaris AIO support" "$solaris_aio"
711
712##########################################
713# __sync_fetch_and_add test
714if test "$sfaa" != "yes" ; then
715 sfaa="no"
716fi
717cat > $TMPC << EOF
718#include <inttypes.h>
719static int sfaa(uint64_t *ptr)
720{
721 return __sync_fetch_and_add(ptr, 0);
722}
723
724int main(int argc, char **argv)
725{
726 uint64_t val = 42;
727 sfaa(&val);
728 return val;
729}
730EOF
731if compile_prog "" "" "__sync_fetch_and_add()" ; then
732 sfaa="yes"
733fi
734print_config "__sync_fetch_and_add" "$sfaa"
735
736##########################################
737# __sync_synchronize() test
738if test "$sync_sync" != "yes" ; then
739 sync_sync="no"
740fi
741cat > $TMPC << EOF
742#include <inttypes.h>
743
744int main(int argc, char **argv)
745{
746 __sync_synchronize();
747 return 0;
748}
749EOF
750if compile_prog "" "" "__sync_synchronize()" ; then
751 sync_sync="yes"
752fi
753print_config "__sync_synchronize" "$sync_sync"
754
755##########################################
756# __sync_val_compare_and_swap() test
757if test "$cmp_swap" != "yes" ; then
758 cmp_swap="no"
759fi
760cat > $TMPC << EOF
761#include <inttypes.h>
762
763int main(int argc, char **argv)
764{
765 int x = 0;
766 return __sync_val_compare_and_swap(&x, 1, 2);
767}
768EOF
769if compile_prog "" "" "__sync_val_compare_and_swap()" ; then
770 cmp_swap="yes"
771fi
772print_config "__sync_val_compare_and_swap" "$cmp_swap"
773
774##########################################
775# libverbs probe
776if test "$libverbs" != "yes" ; then
777 libverbs="no"
778fi
779cat > $TMPC << EOF
780#include <infiniband/verbs.h>
781int main(int argc, char **argv)
782{
783 struct ibv_pd *pd = ibv_alloc_pd(NULL);
784 return 0;
785}
786EOF
787if test "$disable_rdma" != "yes" && compile_prog "" "-libverbs" "libverbs" ; then
788 libverbs="yes"
789 LIBS="-libverbs $LIBS"
790fi
791print_config "libverbs" "$libverbs"
792
793##########################################
794# rdmacm probe
795if test "$rdmacm" != "yes" ; then
796 rdmacm="no"
797fi
798cat > $TMPC << EOF
799#include <stdio.h>
800#include <rdma/rdma_cma.h>
801int main(int argc, char **argv)
802{
803 rdma_destroy_qp(NULL);
804 return 0;
805}
806EOF
807if test "$disable_rdma" != "yes" && compile_prog "" "-lrdmacm" "rdma"; then
808 rdmacm="yes"
809 LIBS="-lrdmacm $LIBS"
810fi
811print_config "rdmacm" "$rdmacm"
812
813##########################################
814# asprintf() and vasprintf() probes
815if test "$have_asprintf" != "yes" ; then
816 have_asprintf="no"
817fi
818cat > $TMPC << EOF
819#include <stdio.h>
820
821int main(int argc, char **argv)
822{
823 return asprintf(NULL, "%s", "str") == 0;
824}
825EOF
826if compile_prog "" "" "have_asprintf"; then
827 have_asprintf="yes"
828fi
829print_config "asprintf()" "$have_asprintf"
830
831if test "$have_vasprintf" != "yes" ; then
832 have_vasprintf="no"
833fi
834cat > $TMPC << EOF
835#include <stdio.h>
836
837int main(int argc, char **argv)
838{
839 return vasprintf(NULL, "%s", NULL) == 0;
840}
841EOF
842if compile_prog "" "" "have_vasprintf"; then
843 have_vasprintf="yes"
844fi
845print_config "vasprintf()" "$have_vasprintf"
846
847##########################################
848# Linux fallocate probe
849if test "$linux_fallocate" != "yes" ; then
850 linux_fallocate="no"
851fi
852cat > $TMPC << EOF
853#include <stdio.h>
854#include <fcntl.h>
855#include <linux/falloc.h>
856int main(int argc, char **argv)
857{
858 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
859 return r;
860}
861EOF
862if compile_prog "" "" "linux_fallocate"; then
863 linux_fallocate="yes"
864fi
865print_config "Linux fallocate" "$linux_fallocate"
866
867##########################################
868# POSIX fadvise probe
869if test "$posix_fadvise" != "yes" ; then
870 posix_fadvise="no"
871fi
872cat > $TMPC << EOF
873#include <stdio.h>
874#include <fcntl.h>
875int main(int argc, char **argv)
876{
877 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
878 return r;
879}
880EOF
881if compile_prog "" "" "posix_fadvise"; then
882 posix_fadvise="yes"
883fi
884print_config "POSIX fadvise" "$posix_fadvise"
885
886##########################################
887# POSIX fallocate probe
888if test "$posix_fallocate" != "yes" ; then
889 posix_fallocate="no"
890fi
891cat > $TMPC << EOF
892#include <stdio.h>
893#include <fcntl.h>
894int main(int argc, char **argv)
895{
896 int r = posix_fallocate(0, 0, 1024);
897 return r;
898}
899EOF
900if compile_prog "" "" "posix_fallocate"; then
901 posix_fallocate="yes"
902fi
903print_config "POSIX fallocate" "$posix_fallocate"
904
905##########################################
906# sched_set/getaffinity 2 or 3 argument test
907if test "$linux_2arg_affinity" != "yes" ; then
908 linux_2arg_affinity="no"
909fi
910if test "$linux_3arg_affinity" != "yes" ; then
911 linux_3arg_affinity="no"
912fi
913cat > $TMPC << EOF
914#include <sched.h>
915int main(int argc, char **argv)
916{
917 cpu_set_t mask;
918 return sched_setaffinity(0, sizeof(mask), &mask);
919}
920EOF
921if compile_prog "" "" "sched_setaffinity(,,)"; then
922 linux_3arg_affinity="yes"
923else
924 cat > $TMPC << EOF
925#include <sched.h>
926int main(int argc, char **argv)
927{
928 cpu_set_t mask;
929 return sched_setaffinity(0, &mask);
930}
931EOF
932 if compile_prog "" "" "sched_setaffinity(,)"; then
933 linux_2arg_affinity="yes"
934 fi
935fi
936print_config "sched_setaffinity(3 arg)" "$linux_3arg_affinity"
937print_config "sched_setaffinity(2 arg)" "$linux_2arg_affinity"
938
939##########################################
940# clock_gettime probe
941if test "$clock_gettime" != "yes" ; then
942 clock_gettime="no"
943fi
944cat > $TMPC << EOF
945#include <stdio.h>
946#include <time.h>
947int main(int argc, char **argv)
948{
949 return clock_gettime(0, NULL);
950}
951EOF
952if compile_prog "" "" "clock_gettime"; then
953 clock_gettime="yes"
954elif compile_prog "" "-lrt" "clock_gettime"; then
955 clock_gettime="yes"
956 LIBS="-lrt $LIBS"
957fi
958print_config "clock_gettime" "$clock_gettime"
959
960##########################################
961# CLOCK_MONOTONIC probe
962if test "$clock_monotonic" != "yes" ; then
963 clock_monotonic="no"
964fi
965if test "$clock_gettime" = "yes" ; then
966 cat > $TMPC << EOF
967#include <stdio.h>
968#include <time.h>
969int main(int argc, char **argv)
970{
971 return clock_gettime(CLOCK_MONOTONIC, NULL);
972}
973EOF
974 if compile_prog "" "$LIBS" "clock monotonic"; then
975 clock_monotonic="yes"
976 fi
977fi
978print_config "CLOCK_MONOTONIC" "$clock_monotonic"
979
980##########################################
981# CLOCK_MONOTONIC_RAW probe
982if test "$clock_monotonic_raw" != "yes" ; then
983 clock_monotonic_raw="no"
984fi
985if test "$clock_gettime" = "yes" ; then
986 cat > $TMPC << EOF
987#include <stdio.h>
988#include <time.h>
989int main(int argc, char **argv)
990{
991 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
992}
993EOF
994 if compile_prog "" "$LIBS" "clock monotonic"; then
995 clock_monotonic_raw="yes"
996 fi
997fi
998print_config "CLOCK_MONOTONIC_RAW" "$clock_monotonic_raw"
999
1000##########################################
1001# CLOCK_MONOTONIC_PRECISE probe
1002if test "$clock_monotonic_precise" != "yes" ; then
1003 clock_monotonic_precise="no"
1004fi
1005if test "$clock_gettime" = "yes" ; then
1006 cat > $TMPC << EOF
1007#include <stdio.h>
1008#include <time.h>
1009int main(int argc, char **argv)
1010{
1011 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
1012}
1013EOF
1014 if compile_prog "" "$LIBS" "clock monotonic precise"; then
1015 clock_monotonic_precise="yes"
1016 fi
1017fi
1018print_config "CLOCK_MONOTONIC_PRECISE" "$clock_monotonic_precise"
1019
1020##########################################
1021# clockid_t probe
1022if test "$clockid_t" != "yes" ; then
1023 clockid_t="no"
1024fi
1025cat > $TMPC << EOF
1026#include <time.h>
1027#include <string.h>
1028int main(int argc, char **argv)
1029{
1030 volatile clockid_t cid;
1031 memset((void*)&cid, 0, sizeof(cid));
1032 return 0;
1033}
1034EOF
1035if compile_prog "" "$LIBS" "clockid_t"; then
1036 clockid_t="yes"
1037fi
1038print_config "clockid_t" "$clockid_t"
1039
1040##########################################
1041# gettimeofday() probe
1042if test "$gettimeofday" != "yes" ; then
1043 gettimeofday="no"
1044fi
1045cat > $TMPC << EOF
1046#include <sys/time.h>
1047#include <stdio.h>
1048int main(int argc, char **argv)
1049{
1050 struct timeval tv;
1051 return gettimeofday(&tv, NULL);
1052}
1053EOF
1054if compile_prog "" "" "gettimeofday"; then
1055 gettimeofday="yes"
1056fi
1057print_config "gettimeofday" "$gettimeofday"
1058
1059##########################################
1060# fdatasync() probe
1061if test "$fdatasync" != "yes" ; then
1062 fdatasync="no"
1063fi
1064cat > $TMPC << EOF
1065#include <stdio.h>
1066#include <unistd.h>
1067int main(int argc, char **argv)
1068{
1069 return fdatasync(0);
1070}
1071EOF
1072if compile_prog "" "" "fdatasync"; then
1073 fdatasync="yes"
1074fi
1075print_config "fdatasync" "$fdatasync"
1076
1077##########################################
1078# sync_file_range() probe
1079if test "$sync_file_range" != "yes" ; then
1080 sync_file_range="no"
1081fi
1082cat > $TMPC << EOF
1083#include <stdio.h>
1084#include <unistd.h>
1085#include <fcntl.h>
1086#include <linux/fs.h>
1087int 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}
1093EOF
1094if compile_prog "" "" "sync_file_range"; then
1095 sync_file_range="yes"
1096fi
1097print_config "sync_file_range" "$sync_file_range"
1098
1099##########################################
1100# ext4 move extent probe
1101if test "$ext4_me" != "yes" ; then
1102 ext4_me="no"
1103fi
1104cat > $TMPC << EOF
1105#include <fcntl.h>
1106#include <sys/ioctl.h>
1107int main(int argc, char **argv)
1108{
1109 struct move_extent me;
1110 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
1111}
1112EOF
1113if compile_prog "" "" "ext4 move extent" ; then
1114 ext4_me="yes"
1115elif 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"
1120fi
1121print_config "EXT4 move extent" "$ext4_me"
1122
1123##########################################
1124# splice probe
1125if test "$linux_splice" != "yes" ; then
1126 linux_splice="no"
1127fi
1128cat > $TMPC << EOF
1129#include <stdio.h>
1130#include <fcntl.h>
1131int main(int argc, char **argv)
1132{
1133 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
1134}
1135EOF
1136if compile_prog "" "" "linux splice"; then
1137 linux_splice="yes"
1138fi
1139print_config "Linux splice(2)" "$linux_splice"
1140
1141##########################################
1142# GUASI probe
1143if test "$guasi" != "yes" ; then
1144 guasi="no"
1145fi
1146cat > $TMPC << EOF
1147#include <guasi.h>
1148#include <guasi_syscalls.h>
1149int main(int argc, char **argv)
1150{
1151 guasi_t ctx = guasi_create(0, 0, 0);
1152 return 0;
1153}
1154EOF
1155if compile_prog "" "" "guasi"; then
1156 guasi="yes"
1157fi
1158print_config "GUASI" "$guasi"
1159
1160##########################################
1161# libnuma probe
1162if test "$libnuma" != "yes" ; then
1163 libnuma="no"
1164fi
1165cat > $TMPC << EOF
1166#include <numa.h>
1167int main(int argc, char **argv)
1168{
1169 return numa_available();
1170}
1171EOF
1172if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
1173 libnuma="yes"
1174 LIBS="-lnuma $LIBS"
1175fi
1176print_config "libnuma" "$libnuma"
1177
1178##########################################
1179# libnuma 2.x version API, initialize with "no" only if $libnuma is set to "yes"
1180if test "$libnuma" = "yes" ; then
1181libnuma_v2="no"
1182cat > $TMPC << EOF
1183#include <numa.h>
1184int main(int argc, char **argv)
1185{
1186 struct bitmask *mask = numa_parse_nodestring(NULL);
1187 return mask->size == 0;
1188}
1189EOF
1190if compile_prog "" "" "libnuma api"; then
1191 libnuma_v2="yes"
1192fi
1193print_config "libnuma v2" "$libnuma_v2"
1194fi
1195
1196##########################################
1197# strsep() probe
1198if test "$strsep" != "yes" ; then
1199 strsep="no"
1200fi
1201cat > $TMPC << EOF
1202#include <string.h>
1203int main(int argc, char **argv)
1204{
1205 static char *string = "This is a string";
1206 strsep(&string, "needle");
1207 return 0;
1208}
1209EOF
1210if compile_prog "" "" "strsep"; then
1211 strsep="yes"
1212fi
1213print_config "strsep" "$strsep"
1214
1215##########################################
1216# strcasestr() probe
1217if test "$strcasestr" != "yes" ; then
1218 strcasestr="no"
1219fi
1220cat > $TMPC << EOF
1221#include <string.h>
1222int main(int argc, char **argv)
1223{
1224 return strcasestr(argv[0], argv[1]) != NULL;
1225}
1226EOF
1227if compile_prog "" "" "strcasestr"; then
1228 strcasestr="yes"
1229fi
1230print_config "strcasestr" "$strcasestr"
1231
1232##########################################
1233# strlcat() probe
1234if test "$strlcat" != "yes" ; then
1235 strlcat="no"
1236fi
1237cat > $TMPC << EOF
1238#include <string.h>
1239int 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}
1247EOF
1248if compile_prog "" "" "strlcat"; then
1249 strlcat="yes"
1250fi
1251print_config "strlcat" "$strlcat"
1252
1253##########################################
1254# getopt_long_only() probe
1255if test "$getopt_long_only" != "yes" ; then
1256 getopt_long_only="no"
1257fi
1258cat > $TMPC << EOF
1259#include <unistd.h>
1260#include <stdio.h>
1261#include <getopt.h>
1262int main(int argc, char **argv)
1263{
1264 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1265 return c;
1266}
1267EOF
1268if compile_prog "" "" "getopt_long_only"; then
1269 getopt_long_only="yes"
1270fi
1271print_config "getopt_long_only()" "$getopt_long_only"
1272
1273##########################################
1274# inet_aton() probe
1275if test "$inet_aton" != "yes" ; then
1276 inet_aton="no"
1277fi
1278cat > $TMPC << EOF
1279#include <sys/socket.h>
1280#include <arpa/inet.h>
1281#include <stdio.h>
1282int main(int argc, char **argv)
1283{
1284 struct in_addr in;
1285 return inet_aton(NULL, &in);
1286}
1287EOF
1288if compile_prog "" "" "inet_aton"; then
1289 inet_aton="yes"
1290fi
1291print_config "inet_aton" "$inet_aton"
1292
1293##########################################
1294# socklen_t probe
1295if test "$socklen_t" != "yes" ; then
1296 socklen_t="no"
1297fi
1298cat > $TMPC << EOF
1299#include <sys/socket.h>
1300int main(int argc, char **argv)
1301{
1302 socklen_t len = 0;
1303 return len;
1304}
1305EOF
1306if compile_prog "" "" "socklen_t"; then
1307 socklen_t="yes"
1308fi
1309print_config "socklen_t" "$socklen_t"
1310
1311##########################################
1312# Whether or not __thread is supported for TLS
1313if test "$tls_thread" != "yes" ; then
1314 tls_thread="no"
1315fi
1316cat > $TMPC << EOF
1317#include <stdio.h>
1318static __thread int ret;
1319int main(int argc, char **argv)
1320{
1321 return ret;
1322}
1323EOF
1324if compile_prog "" "" "__thread"; then
1325 tls_thread="yes"
1326fi
1327print_config "__thread" "$tls_thread"
1328
1329##########################################
1330# Check if we have required gtk/glib support for gfio
1331if test "$gfio" != "yes" ; then
1332 gfio="no"
1333fi
1334if test "$gfio_check" = "yes" ; then
1335 cat > $TMPC << EOF
1336#include <glib.h>
1337#include <cairo.h>
1338#include <gtk/gtk.h>
1339int 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}
1346EOF
1347GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1348ORG_LDFLAGS=$LDFLAGS
1349LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1350if test "$?" != "0" ; then
1351 echo "configure: gtk and gthread not found"
1352 exit 1
1353fi
1354GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1355if test "$?" != "0" ; then
1356 echo "configure: gtk and gthread not found"
1357 exit 1
1358fi
1359if 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
1369else
1370 echo "Please install gtk and gdk libraries"
1371 gfio="no"
1372fi
1373LDFLAGS=$ORG_LDFLAGS
1374fi
1375
1376if test "$gfio_check" = "yes" ; then
1377 print_config "gtk 2.18 or higher" "$gfio"
1378fi
1379
1380##########################################
1381# Check whether we have getrusage(RUSAGE_THREAD)
1382if test "$rusage_thread" != "yes" ; then
1383 rusage_thread="no"
1384fi
1385cat > $TMPC << EOF
1386#include <sys/time.h>
1387#include <sys/resource.h>
1388int main(int argc, char **argv)
1389{
1390 struct rusage ru;
1391 getrusage(RUSAGE_THREAD, &ru);
1392 return 0;
1393}
1394EOF
1395if compile_prog "" "" "RUSAGE_THREAD"; then
1396 rusage_thread="yes"
1397fi
1398print_config "RUSAGE_THREAD" "$rusage_thread"
1399
1400##########################################
1401# Check whether we have SCHED_IDLE
1402if test "$sched_idle" != "yes" ; then
1403 sched_idle="no"
1404fi
1405cat > $TMPC << EOF
1406#include <sched.h>
1407int main(int argc, char **argv)
1408{
1409 struct sched_param p;
1410 return sched_setscheduler(0, SCHED_IDLE, &p);
1411}
1412EOF
1413if compile_prog "" "" "SCHED_IDLE"; then
1414 sched_idle="yes"
1415fi
1416print_config "SCHED_IDLE" "$sched_idle"
1417
1418##########################################
1419# Check whether we have TCP_NODELAY
1420if test "$tcp_nodelay" != "yes" ; then
1421 tcp_nodelay="no"
1422fi
1423cat > $TMPC << EOF
1424#include <stdio.h>
1425#include <sys/types.h>
1426#include <sys/socket.h>
1427#include <netinet/tcp.h>
1428int main(int argc, char **argv)
1429{
1430 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1431}
1432EOF
1433if compile_prog "" "" "TCP_NODELAY"; then
1434 tcp_nodelay="yes"
1435fi
1436print_config "TCP_NODELAY" "$tcp_nodelay"
1437
1438##########################################
1439# Check whether we have SO_SNDBUF
1440if test "$window_size" != "yes" ; then
1441 window_size="no"
1442fi
1443cat > $TMPC << EOF
1444#include <stdio.h>
1445#include <sys/types.h>
1446#include <sys/socket.h>
1447#include <netinet/tcp.h>
1448int 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}
1453EOF
1454if compile_prog "" "" "SO_SNDBUF"; then
1455 window_size="yes"
1456fi
1457print_config "Net engine window_size" "$window_size"
1458
1459##########################################
1460# Check whether we have TCP_MAXSEG
1461if test "$mss" != "yes" ; then
1462 mss="no"
1463fi
1464cat > $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>
1471int main(int argc, char **argv)
1472{
1473 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1474}
1475EOF
1476if compile_prog "" "" "TCP_MAXSEG"; then
1477 mss="yes"
1478fi
1479print_config "TCP_MAXSEG" "$mss"
1480
1481##########################################
1482# Check whether we have RLIMIT_MEMLOCK
1483if test "$rlimit_memlock" != "yes" ; then
1484 rlimit_memlock="no"
1485fi
1486cat > $TMPC << EOF
1487#include <sys/time.h>
1488#include <sys/resource.h>
1489int main(int argc, char **argv)
1490{
1491 struct rlimit rl;
1492 return getrlimit(RLIMIT_MEMLOCK, &rl);
1493}
1494EOF
1495if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1496 rlimit_memlock="yes"
1497fi
1498print_config "RLIMIT_MEMLOCK" "$rlimit_memlock"
1499
1500##########################################
1501# Check whether we have pwritev/preadv
1502if test "$pwritev" != "yes" ; then
1503 pwritev="no"
1504fi
1505cat > $TMPC << EOF
1506#include <stdio.h>
1507#include <sys/uio.h>
1508int main(int argc, char **argv)
1509{
1510 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1511}
1512EOF
1513if compile_prog "" "" "pwritev"; then
1514 pwritev="yes"
1515fi
1516print_config "pwritev/preadv" "$pwritev"
1517
1518##########################################
1519# Check whether we have pwritev2/preadv2
1520if test "$pwritev2" != "yes" ; then
1521 pwritev2="no"
1522fi
1523cat > $TMPC << EOF
1524#include <stdio.h>
1525#include <sys/uio.h>
1526int main(int argc, char **argv)
1527{
1528 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1529}
1530EOF
1531if compile_prog "" "" "pwritev2"; then
1532 pwritev2="yes"
1533fi
1534print_config "pwritev2/preadv2" "$pwritev2"
1535
1536##########################################
1537# Check whether we have the required functions for ipv6
1538if test "$ipv6" != "yes" ; then
1539 ipv6="no"
1540fi
1541cat > $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>
1547int 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}
1559EOF
1560if compile_prog "" "" "ipv6"; then
1561 ipv6="yes"
1562fi
1563print_config "IPv6 helpers" "$ipv6"
1564
1565##########################################
1566# check for http
1567if test "$http" != "yes" ; then
1568 http="no"
1569fi
1570# check for openssl >= 1.1.0, which uses an opaque HMAC_CTX pointer
1571cat > $TMPC << EOF
1572#include <curl/curl.h>
1573#include <openssl/hmac.h>
1574
1575int 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}
1588EOF
1589# openssl < 1.1.0 uses the HMAC_CTX type directly
1590cat > $TMPC2 << EOF
1591#include <curl/curl.h>
1592#include <openssl/hmac.h>
1593
1594int 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}
1606EOF
1607if 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
1617fi
1618print_config "http engine" "$http"
1619
1620##########################################
1621# check for rados
1622if test "$rados" != "yes" ; then
1623 rados="no"
1624fi
1625cat > $TMPC << EOF
1626#include <rados/librados.h>
1627
1628int 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}
1642EOF
1643if test "$disable_rados" != "yes" && compile_prog "" "-lrados" "rados"; then
1644 LIBS="-lrados $LIBS"
1645 rados="yes"
1646fi
1647print_config "Rados engine" "$rados"
1648
1649##########################################
1650# check for rbd
1651if test "$rbd" != "yes" ; then
1652 rbd="no"
1653fi
1654cat > $TMPC << EOF
1655#include <rbd/librbd.h>
1656
1657int 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}
1673EOF
1674if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
1675 LIBS="-lrbd -lrados $LIBS"
1676 rbd="yes"
1677fi
1678print_config "Rados Block Device engine" "$rbd"
1679
1680##########################################
1681# check for rbd_poll
1682if test "$rbd_poll" != "yes" ; then
1683 rbd_poll="no"
1684fi
1685if test "$rbd" = "yes"; then
1686cat > $TMPC << EOF
1687#include <rbd/librbd.h>
1688#include <sys/eventfd.h>
1689
1690int 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}
1701EOF
1702if compile_prog "" "-lrbd -lrados" "rbd"; then
1703 rbd_poll="yes"
1704fi
1705print_config "rbd_poll" "$rbd_poll"
1706fi
1707
1708##########################################
1709# check for rbd_invalidate_cache()
1710if test "$rbd_inval" != "yes" ; then
1711 rbd_inval="no"
1712fi
1713if test "$rbd" = "yes"; then
1714cat > $TMPC << EOF
1715#include <rbd/librbd.h>
1716
1717int main(int argc, char **argv)
1718{
1719 rbd_image_t image;
1720
1721 return rbd_invalidate_cache(image);
1722}
1723EOF
1724if compile_prog "" "-lrbd -lrados" "rbd"; then
1725 rbd_inval="yes"
1726fi
1727print_config "rbd_invalidate_cache" "$rbd_inval"
1728fi
1729
1730##########################################
1731# Check whether we have setvbuf
1732if test "$setvbuf" != "yes" ; then
1733 setvbuf="no"
1734fi
1735cat > $TMPC << EOF
1736#include <stdio.h>
1737int 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}
1744EOF
1745if compile_prog "" "" "setvbuf"; then
1746 setvbuf="yes"
1747fi
1748print_config "setvbuf" "$setvbuf"
1749
1750##########################################
1751# check for gfapi
1752if test "$gfapi" != "yes" ; then
1753 gfapi="no"
1754fi
1755cat > $TMPC << EOF
1756#include <glusterfs/api/glfs.h>
1757
1758int main(int argc, char **argv)
1759{
1760 glfs_t *g = glfs_new("foo");
1761
1762 return 0;
1763}
1764EOF
1765if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1766 LIBS="-lgfapi -lglusterfs $LIBS"
1767 gfapi="yes"
1768fi
1769print_config "Gluster API engine" "$gfapi"
1770
1771##########################################
1772# check for gfapi fadvise support, initialize with "no" only if $gfapi is set to "yes"
1773if test "$gfapi" = "yes" ; then
1774gf_fadvise="no"
1775cat > $TMPC << EOF
1776#include <glusterfs/api/glfs.h>
1777
1778int 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}
1785EOF
1786if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1787 gf_fadvise="yes"
1788fi
1789print_config "Gluster API use fadvise" "$gf_fadvise"
1790fi
1791
1792##########################################
1793# check for newer gfapi
1794if test "$gfapi" = "yes" ; then
1795gf_new="no"
1796cat > $TMPC << EOF
1797#include <glusterfs/api/glfs.h>
1798
1799int main(int argc, char **argv)
1800{
1801 return glfs_fsync(NULL, NULL, NULL) && glfs_ftruncate(NULL, 0, NULL, NULL);
1802}
1803EOF
1804if compile_prog "" "-lgfapi -lglusterfs" "gf new api"; then
1805 gf_new="yes"
1806fi
1807print_config "Gluster new API" "$gf_new"
1808fi
1809
1810##########################################
1811# check for gfapi trim support
1812if test "$gf_trim" != "yes" ; then
1813 gf_trim="no"
1814fi
1815if test "$gfapi" = "yes" ; then
1816cat > $TMPC << EOF
1817#include <glusterfs/api/glfs.h>
1818
1819int main(int argc, char **argv)
1820{
1821 return glfs_discard_async(NULL, 0, 0);
1822}
1823EOF
1824if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1825 gf_trim="yes"
1826fi
1827print_config "Gluster API trim support" "$gf_trim"
1828fi
1829
1830##########################################
1831# Check if we support stckf on s390
1832if test "$s390_z196_facilities" != "yes" ; then
1833 s390_z196_facilities="no"
1834fi
1835cat > $TMPC << EOF
1836#define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1837int main(int argc, char **argv)
1838{
1839 /* We want just 1 double word to be returned. */
1840 register unsigned long reg0 asm("0") = 0;
1841 unsigned long stfle_bits;
1842 asm volatile(".machine push" "\n\t"
1843 ".machine \"z9-109\"" "\n\t"
1844 "stfle %0" "\n\t"
1845 ".machine pop" "\n"
1846 : "=QS" (stfle_bits), "+d" (reg0)
1847 : : "cc");
1848
1849 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1850 return 0;
1851 else
1852 return -1;
1853}
1854EOF
1855if compile_prog "" "" "s390_z196_facilities"; then
1856 $TMPE
1857 if [ $? -eq 0 ]; then
1858 s390_z196_facilities="yes"
1859 fi
1860fi
1861print_config "s390_z196_facilities" "$s390_z196_facilities"
1862
1863##########################################
1864# Check if we have required environment variables configured for libhdfs
1865if test "$libhdfs" = "yes" ; then
1866 hdfs_conf_error=0
1867 if test "$JAVA_HOME" = "" ; then
1868 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1869 hdfs_conf_error=1
1870 fi
1871 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1872 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1873 hdfs_conf_error=1
1874 fi
1875 if test "$FIO_LIBHDFS_LIB" = "" ; then
1876 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1877 hdfs_conf_error=1
1878 fi
1879 if test "$hdfs_conf_error" = "1" ; then
1880 exit 1
1881 fi
1882 FIO_HDFS_CPU=$cpu
1883 if test "$FIO_HDFS_CPU" = "x86_64" ; then
1884 FIO_HDFS_CPU="amd64"
1885 fi
1886fi
1887print_config "HDFS engine" "$libhdfs"
1888
1889##########################################
1890# Check whether we have MTD
1891if test "$mtd" != "yes" ; then
1892 mtd="no"
1893fi
1894cat > $TMPC << EOF
1895#include <string.h>
1896#include <mtd/mtd-user.h>
1897#include <sys/ioctl.h>
1898int main(int argc, char **argv)
1899{
1900 struct mtd_write_req ops;
1901 struct mtd_info_user info;
1902 memset(&ops, 0, sizeof(ops));
1903 info.type = MTD_MLCNANDFLASH;
1904 return ioctl(0, MEMGETINFO, &info);
1905}
1906EOF
1907if compile_prog "" "" "mtd"; then
1908 mtd="yes"
1909fi
1910print_config "MTD" "$mtd"
1911
1912##########################################
1913# Check whether we have libpmem
1914if test "$libpmem" != "yes" ; then
1915 libpmem="no"
1916fi
1917cat > $TMPC << EOF
1918#include <libpmem.h>
1919int main(int argc, char **argv)
1920{
1921 int rc;
1922 rc = pmem_is_pmem(0, 0);
1923 return 0;
1924}
1925EOF
1926if compile_prog "" "-lpmem" "libpmem"; then
1927 libpmem="yes"
1928 LIBS="-lpmem $LIBS"
1929fi
1930print_config "libpmem" "$libpmem"
1931
1932##########################################
1933# Check whether we have libpmemblk
1934# libpmem is a prerequisite
1935if test "$libpmemblk" != "yes" ; then
1936 libpmemblk="no"
1937fi
1938if test "$libpmem" = "yes"; then
1939 cat > $TMPC << EOF
1940#include <libpmemblk.h>
1941int main(int argc, char **argv)
1942{
1943 PMEMblkpool *pbp;
1944 pbp = pmemblk_open("", 0);
1945 return 0;
1946}
1947EOF
1948 if compile_prog "" "-lpmemblk" "libpmemblk"; then
1949 libpmemblk="yes"
1950 LIBS="-lpmemblk $LIBS"
1951 fi
1952fi
1953print_config "libpmemblk" "$libpmemblk"
1954
1955# Choose the ioengines
1956if test "$libpmem" = "yes" && test "$disable_pmem" = "no"; then
1957 pmem="yes"
1958 devdax="yes"
1959 if test "$libpmemblk" = "yes"; then
1960 pmemblk="yes"
1961 fi
1962fi
1963
1964##########################################
1965# Report whether pmemblk engine is enabled
1966print_config "PMDK pmemblk engine" "$pmemblk"
1967
1968##########################################
1969# Report whether dev-dax engine is enabled
1970print_config "PMDK dev-dax engine" "$devdax"
1971
1972##########################################
1973# Report whether libpmem engine is enabled
1974print_config "PMDK libpmem engine" "$pmem"
1975
1976##########################################
1977# Check whether we support DDN's IME
1978if test "$libime" != "yes" ; then
1979 libime="no"
1980fi
1981cat > $TMPC << EOF
1982#include <ime_native.h>
1983int main(int argc, char **argv)
1984{
1985 int rc;
1986 ime_native_init();
1987 rc = ime_native_finalize();
1988 return 0;
1989}
1990EOF
1991if compile_prog "-I${ime_path}/include" "-L${ime_path}/lib -lim_client" "libime"; then
1992 libime="yes"
1993 CFLAGS="-I${ime_path}/include $CFLAGS"
1994 LDFLAGS="-Wl,-rpath ${ime_path}/lib -L${ime_path}/lib $LDFLAGS"
1995 LIBS="-lim_client $LIBS"
1996fi
1997print_config "DDN's Infinite Memory Engine" "$libime"
1998
1999##########################################
2000# Check if we have required environment variables configured for libiscsi
2001if test "$libiscsi" = "yes" ; then
2002 if $(pkg-config --atleast-version=1.9.0 libiscsi); then
2003 libiscsi="yes"
2004 libiscsi_cflags=$(pkg-config --cflags libiscsi)
2005 libiscsi_libs=$(pkg-config --libs libiscsi)
2006 else
2007 if test "$libiscsi" = "yes" ; then
2008 echo "libiscsi" "Install libiscsi >= 1.9.0"
2009 fi
2010 libiscsi="no"
2011 fi
2012fi
2013print_config "iscsi engine" "$libiscsi"
2014
2015##########################################
2016# Check if we have lex/yacc available
2017yacc="no"
2018yacc_is_bison="no"
2019lex="no"
2020arith="no"
2021if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
2022if test "$targetos" != "SunOS" ; then
2023LEX=$(which lex 2> /dev/null)
2024if test -x "$LEX" ; then
2025 lex="yes"
2026fi
2027YACC=$(which bison 2> /dev/null)
2028if test -x "$YACC" ; then
2029 yacc="yes"
2030 yacc_is_bison="yes"
2031else
2032 YACC=$(which yacc 2> /dev/null)
2033 if test -x "$YACC" ; then
2034 yacc="yes"
2035 fi
2036fi
2037if test "$yacc" = "yes" && test "$lex" = "yes" ; then
2038 arith="yes"
2039fi
2040
2041if test "$arith" = "yes" ; then
2042cat > $TMPC << EOF
2043extern int yywrap(void);
2044
2045int main(int argc, char **argv)
2046{
2047 yywrap();
2048 return 0;
2049}
2050EOF
2051if compile_prog "" "-ll" "lex"; then
2052 LIBS="-ll $LIBS"
2053else
2054 arith="no"
2055fi
2056fi
2057fi
2058fi
2059
2060# Check if lex fails using -o
2061if test "$arith" = "yes" ; then
2062if test "$force_no_lex_o" = "yes" ; then
2063 lex_use_o="no"
2064else
2065$LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
2066if test "$?" = "0" ; then
2067 lex_use_o="yes"
2068else
2069 lex_use_o="no"
2070fi
2071fi
2072fi
2073
2074print_config "lex/yacc for arithmetic" "$arith"
2075
2076##########################################
2077# Check whether we have setmntent/getmntent
2078if test "$getmntent" != "yes" ; then
2079 getmntent="no"
2080fi
2081cat > $TMPC << EOF
2082#include <stdio.h>
2083#include <mntent.h>
2084int main(int argc, char **argv)
2085{
2086 FILE *mtab = setmntent(NULL, "r");
2087 struct mntent *mnt = getmntent(mtab);
2088 endmntent(mtab);
2089 return 0;
2090}
2091EOF
2092if compile_prog "" "" "getmntent"; then
2093 getmntent="yes"
2094fi
2095print_config "getmntent" "$getmntent"
2096
2097##########################################
2098# Check whether we have getmntinfo
2099# These are originally added for BSDs, but may also work
2100# on other operating systems with getmntinfo(3).
2101
2102# getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
2103# Note that NetBSD needs -Werror to catch warning as error.
2104if test "$getmntinfo" != "yes" ; then
2105 getmntinfo="no"
2106fi
2107cat > $TMPC << EOF
2108#include <stdio.h>
2109#include <sys/param.h>
2110#include <sys/mount.h>
2111int main(int argc, char **argv)
2112{
2113 struct statfs *st;
2114 return getmntinfo(&st, MNT_NOWAIT);
2115}
2116EOF
2117if compile_prog "-Werror" "" "getmntinfo"; then
2118 getmntinfo="yes"
2119fi
2120print_config "getmntinfo" "$getmntinfo"
2121
2122# getmntinfo(3) for NetBSD.
2123if test "$getmntinfo_statvfs" != "yes" ; then
2124 getmntinfo_statvfs="no"
2125fi
2126cat > $TMPC << EOF
2127#include <stdio.h>
2128#include <sys/statvfs.h>
2129int main(int argc, char **argv)
2130{
2131 struct statvfs *st;
2132 return getmntinfo(&st, MNT_NOWAIT);
2133}
2134EOF
2135# Skip the test if the one with statfs arg is detected.
2136if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
2137 getmntinfo_statvfs="yes"
2138 print_config "getmntinfo_statvfs" "$getmntinfo_statvfs"
2139fi
2140
2141##########################################
2142# Check whether we have _Static_assert
2143if test "$static_assert" != "yes" ; then
2144 static_assert="no"
2145fi
2146cat > $TMPC << EOF
2147#include <assert.h>
2148#include <stdlib.h>
2149#include <stddef.h>
2150
2151struct foo {
2152 int a, b;
2153};
2154
2155int main(int argc, char **argv)
2156{
2157 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
2158 return 0 ;
2159}
2160EOF
2161if compile_prog "" "" "static_assert"; then
2162 static_assert="yes"
2163fi
2164print_config "Static Assert" "$static_assert"
2165
2166##########################################
2167# Check whether we have bool / stdbool.h
2168if test "$have_bool" != "yes" ; then
2169 have_bool="no"
2170fi
2171cat > $TMPC << EOF
2172#include <stdbool.h>
2173int main(int argc, char **argv)
2174{
2175 bool var = true;
2176 return var != false;
2177}
2178EOF
2179if compile_prog "" "" "bool"; then
2180 have_bool="yes"
2181fi
2182print_config "bool" "$have_bool"
2183
2184##########################################
2185# Check whether we have strndup()
2186strndup="no"
2187cat > $TMPC << EOF
2188#include <string.h>
2189#include <stdlib.h>
2190int main(int argc, char **argv)
2191{
2192 char *res = strndup("test string", 8);
2193
2194 free(res);
2195 return 0;
2196}
2197EOF
2198if compile_prog "" "" "strndup"; then
2199 strndup="yes"
2200fi
2201print_config "strndup" "$strndup"
2202
2203##########################################
2204# <valgrind/drd.h> probe
2205# Note: presence of <valgrind/drd.h> implies that <valgrind/valgrind.h> is
2206# also available but not the other way around.
2207if test "$valgrind_dev" != "yes" ; then
2208 valgrind_dev="no"
2209fi
2210cat > $TMPC << EOF
2211#include <valgrind/drd.h>
2212int main(int argc, char **argv)
2213{
2214 return 0;
2215}
2216EOF
2217if compile_prog "" "" "valgrind_dev"; then
2218 valgrind_dev="yes"
2219fi
2220print_config "Valgrind headers" "$valgrind_dev"
2221
2222##########################################
2223# <linux/blkzoned.h> probe
2224if test "$linux_blkzoned" != "yes" ; then
2225 linux_blkzoned="no"
2226fi
2227cat > $TMPC << EOF
2228#include <linux/blkzoned.h>
2229int main(int argc, char **argv)
2230{
2231 return 0;
2232}
2233EOF
2234if compile_prog "" "" "linux_blkzoned"; then
2235 linux_blkzoned="yes"
2236fi
2237print_config "Zoned block device support" "$linux_blkzoned"
2238
2239##########################################
2240# check march=armv8-a+crc+crypto
2241if test "$march_armv8_a_crc_crypto" != "yes" ; then
2242 march_armv8_a_crc_crypto="no"
2243fi
2244if test "$cpu" = "arm64" ; then
2245 cat > $TMPC <<EOF
2246#include <arm_acle.h>
2247#include <arm_neon.h>
2248#include <sys/auxv.h>
2249
2250int main(void)
2251{
2252 /* Can we also do a runtime probe? */
2253#if __linux__
2254 return getauxval(AT_HWCAP);
2255#else
2256# error "Don't know how to do runtime probe for ARM CRC32c"
2257#endif
2258}
2259EOF
2260 if compile_prog "-march=armv8-a+crc+crypto" "" "ARM CRC32c"; then
2261 march_armv8_a_crc_crypto="yes"
2262 CFLAGS="$CFLAGS -march=armv8-a+crc+crypto"
2263 march_set="yes"
2264 fi
2265fi
2266print_config "march_armv8_a_crc_crypto" "$march_armv8_a_crc_crypto"
2267
2268##########################################
2269# cuda probe
2270if test "$cuda" != "yes" ; then
2271 cuda="no"
2272fi
2273cat > $TMPC << EOF
2274#include <cuda.h>
2275int main(int argc, char **argv)
2276{
2277 return cuInit(0);
2278}
2279EOF
2280if test "$enable_cuda" = "yes" && compile_prog "" "-lcuda" "cuda"; then
2281 cuda="yes"
2282 LIBS="-lcuda $LIBS"
2283fi
2284print_config "cuda" "$cuda"
2285
2286##########################################
2287# mkdir() probe. mingw apparently has a one-argument mkdir :/
2288mkdir_two="no"
2289cat > $TMPC << EOF
2290#include <sys/stat.h>
2291#include <sys/types.h>
2292int main(int argc, char **argv)
2293{
2294 return mkdir("/tmp/bla", 0600);
2295}
2296EOF
2297if compile_prog "" "" "mkdir(a, b)"; then
2298 mkdir_two="yes"
2299fi
2300print_config "mkdir(a, b)" "$mkdir_two"
2301
2302##########################################
2303# check for cc -march=native
2304build_native="no"
2305cat > $TMPC << EOF
2306int main(int argc, char **argv)
2307{
2308 return 0;
2309}
2310EOF
2311if test "$disable_native" = "no" && test "$disable_opt" != "yes" && \
2312 compile_prog "-march=native" "" "march=native"; then
2313 build_native="yes"
2314fi
2315print_config "Build march=native" "$build_native"
2316
2317##########################################
2318# check for -lcunit
2319if test "$cunit" != "yes" ; then
2320 cunit="no"
2321fi
2322cat > $TMPC << EOF
2323#include <CUnit/CUnit.h>
2324#include <CUnit/Basic.h>
2325int main(void)
2326{
2327 if (CU_initialize_registry() != CUE_SUCCESS)
2328 return CU_get_error();
2329 CU_basic_set_mode(CU_BRM_VERBOSE);
2330 CU_basic_run_tests();
2331 CU_cleanup_registry();
2332 return CU_get_error();
2333}
2334EOF
2335if compile_prog "" "-lcunit" "CUnit"; then
2336 cunit="yes"
2337fi
2338print_config "CUnit" "$cunit"
2339
2340##########################################
2341# check for __kernel_rwf_t
2342__kernel_rwf_t="no"
2343cat > $TMPC << EOF
2344#include <linux/fs.h>
2345int main(int argc, char **argv)
2346{
2347 __kernel_rwf_t x;
2348 x = 0;
2349 return x;
2350}
2351EOF
2352if compile_prog "" "" "__kernel_rwf_t"; then
2353 __kernel_rwf_t="yes"
2354fi
2355print_config "__kernel_rwf_t" "$__kernel_rwf_t"
2356
2357##########################################
2358# check if gcc has -Wimplicit-fallthrough
2359fallthrough="no"
2360cat > $TMPC << EOF
2361int main(int argc, char **argv)
2362{
2363 return 0;
2364}
2365EOF
2366if compile_prog "-Wimplicit-fallthrough" "" "-Wimplicit-fallthrough"; then
2367 fallthrough="yes"
2368fi
2369print_config "-Wimplicit-fallthrough" "$fallthrough"
2370
2371##########################################
2372# check for MADV_HUGEPAGE support
2373if test "$thp" != "yes" ; then
2374 thp="no"
2375fi
2376if test "$esx" != "yes" ; then
2377 cat > $TMPC <<EOF
2378#include <sys/mman.h>
2379int main(void)
2380{
2381 return madvise(0, 0x1000, MADV_HUGEPAGE);
2382}
2383EOF
2384 if compile_prog "" "" "thp" ; then
2385 thp=yes
2386 else
2387 if test "$thp" = "yes" ; then
2388 feature_not_found "Transparent Huge Page" ""
2389 fi
2390 thp=no
2391 fi
2392fi
2393print_config "MADV_HUGEPAGE" "$thp"
2394
2395##########################################
2396# check for gettid()
2397gettid="no"
2398cat > $TMPC << EOF
2399#include <unistd.h>
2400int main(int argc, char **argv)
2401{
2402 return gettid();
2403}
2404EOF
2405if compile_prog "" "" "gettid"; then
2406 gettid="yes"
2407fi
2408print_config "gettid" "$gettid"
2409
2410#############################################################################
2411
2412if test "$wordsize" = "64" ; then
2413 output_sym "CONFIG_64BIT"
2414elif test "$wordsize" = "32" ; then
2415 output_sym "CONFIG_32BIT"
2416else
2417 fatal "Unknown wordsize!"
2418fi
2419if test "$bigendian" = "yes" ; then
2420 output_sym "CONFIG_BIG_ENDIAN"
2421else
2422 output_sym "CONFIG_LITTLE_ENDIAN"
2423fi
2424if test "$zlib" = "yes" ; then
2425 output_sym "CONFIG_ZLIB"
2426fi
2427if test "$libaio" = "yes" ; then
2428 output_sym "CONFIG_LIBAIO"
2429fi
2430if test "$posix_aio" = "yes" ; then
2431 output_sym "CONFIG_POSIXAIO"
2432fi
2433if test "$posix_aio_fsync" = "yes" ; then
2434 output_sym "CONFIG_POSIXAIO_FSYNC"
2435fi
2436if test "$posix_pshared" = "yes" ; then
2437 output_sym "CONFIG_PSHARED"
2438fi
2439if test "$have_asprintf" = "yes" ; then
2440 output_sym "CONFIG_HAVE_ASPRINTF"
2441fi
2442if test "$have_vasprintf" = "yes" ; then
2443 output_sym "CONFIG_HAVE_VASPRINTF"
2444fi
2445if test "$linux_fallocate" = "yes" ; then
2446 output_sym "CONFIG_LINUX_FALLOCATE"
2447fi
2448if test "$posix_fallocate" = "yes" ; then
2449 output_sym "CONFIG_POSIX_FALLOCATE"
2450fi
2451if test "$fdatasync" = "yes" ; then
2452 output_sym "CONFIG_FDATASYNC"
2453fi
2454if test "$sync_file_range" = "yes" ; then
2455 output_sym "CONFIG_SYNC_FILE_RANGE"
2456fi
2457if test "$sfaa" = "yes" ; then
2458 output_sym "CONFIG_SFAA"
2459fi
2460if test "$sync_sync" = "yes" ; then
2461 output_sym "CONFIG_SYNC_SYNC"
2462fi
2463if test "$cmp_swap" = "yes" ; then
2464 output_sym "CONFIG_CMP_SWAP"
2465fi
2466if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
2467 output_sym "CONFIG_RDMA"
2468fi
2469if test "$clock_gettime" = "yes" ; then
2470 output_sym "CONFIG_CLOCK_GETTIME"
2471fi
2472if test "$clock_monotonic" = "yes" ; then
2473 output_sym "CONFIG_CLOCK_MONOTONIC"
2474fi
2475if test "$clock_monotonic_raw" = "yes" ; then
2476 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
2477fi
2478if test "$clock_monotonic_precise" = "yes" ; then
2479 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
2480fi
2481if test "$clockid_t" = "yes"; then
2482 output_sym "CONFIG_CLOCKID_T"
2483fi
2484if test "$gettimeofday" = "yes" ; then
2485 output_sym "CONFIG_GETTIMEOFDAY"
2486fi
2487if test "$posix_fadvise" = "yes" ; then
2488 output_sym "CONFIG_POSIX_FADVISE"
2489fi
2490if test "$linux_3arg_affinity" = "yes" ; then
2491 output_sym "CONFIG_3ARG_AFFINITY"
2492elif test "$linux_2arg_affinity" = "yes" ; then
2493 output_sym "CONFIG_2ARG_AFFINITY"
2494fi
2495if test "$strsep" = "yes" ; then
2496 output_sym "CONFIG_STRSEP"
2497fi
2498if test "$strcasestr" = "yes" ; then
2499 output_sym "CONFIG_STRCASESTR"
2500fi
2501if test "$strlcat" = "yes" ; then
2502 output_sym "CONFIG_STRLCAT"
2503fi
2504if test "$getopt_long_only" = "yes" ; then
2505 output_sym "CONFIG_GETOPT_LONG_ONLY"
2506fi
2507if test "$inet_aton" = "yes" ; then
2508 output_sym "CONFIG_INET_ATON"
2509fi
2510if test "$socklen_t" = "yes" ; then
2511 output_sym "CONFIG_SOCKLEN_T"
2512fi
2513if test "$ext4_me" = "yes" ; then
2514 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
2515fi
2516if test "$linux_splice" = "yes" ; then
2517 output_sym "CONFIG_LINUX_SPLICE"
2518fi
2519if test "$guasi" = "yes" ; then
2520 output_sym "CONFIG_GUASI"
2521fi
2522if test "$libnuma_v2" = "yes" ; then
2523 output_sym "CONFIG_LIBNUMA"
2524fi
2525if test "$solaris_aio" = "yes" ; then
2526 output_sym "CONFIG_SOLARISAIO"
2527fi
2528if test "$tls_thread" = "yes" ; then
2529 output_sym "CONFIG_TLS_THREAD"
2530fi
2531if test "$rusage_thread" = "yes" ; then
2532 output_sym "CONFIG_RUSAGE_THREAD"
2533fi
2534if test "$gfio" = "yes" ; then
2535 output_sym "CONFIG_GFIO"
2536fi
2537if test "$esx" = "yes" ; then
2538 output_sym "CONFIG_ESX"
2539 output_sym "CONFIG_NO_SHM"
2540fi
2541if test "$sched_idle" = "yes" ; then
2542 output_sym "CONFIG_SCHED_IDLE"
2543fi
2544if test "$tcp_nodelay" = "yes" ; then
2545 output_sym "CONFIG_TCP_NODELAY"
2546fi
2547if test "$window_size" = "yes" ; then
2548 output_sym "CONFIG_NET_WINDOWSIZE"
2549fi
2550if test "$mss" = "yes" ; then
2551 output_sym "CONFIG_NET_MSS"
2552fi
2553if test "$rlimit_memlock" = "yes" ; then
2554 output_sym "CONFIG_RLIMIT_MEMLOCK"
2555fi
2556if test "$pwritev" = "yes" ; then
2557 output_sym "CONFIG_PWRITEV"
2558fi
2559if test "$pwritev2" = "yes" ; then
2560 output_sym "CONFIG_PWRITEV2"
2561fi
2562if test "$ipv6" = "yes" ; then
2563 output_sym "CONFIG_IPV6"
2564fi
2565if test "$http" = "yes" ; then
2566 output_sym "CONFIG_HTTP"
2567fi
2568if test "$rados" = "yes" ; then
2569 output_sym "CONFIG_RADOS"
2570fi
2571if test "$rbd" = "yes" ; then
2572 output_sym "CONFIG_RBD"
2573fi
2574if test "$rbd_poll" = "yes" ; then
2575 output_sym "CONFIG_RBD_POLL"
2576fi
2577if test "$rbd_inval" = "yes" ; then
2578 output_sym "CONFIG_RBD_INVAL"
2579fi
2580if test "$setvbuf" = "yes" ; then
2581 output_sym "CONFIG_SETVBUF"
2582fi
2583if test "$s390_z196_facilities" = "yes" ; then
2584 output_sym "CONFIG_S390_Z196_FACILITIES"
2585 CFLAGS="$CFLAGS -march=z9-109"
2586 march_set="yes"
2587fi
2588if test "$gfapi" = "yes" ; then
2589 output_sym "CONFIG_GFAPI"
2590fi
2591if test "$gf_fadvise" = "yes" ; then
2592 output_sym "CONFIG_GF_FADVISE"
2593fi
2594if test "$gf_trim" = "yes" ; then
2595 output_sym "CONFIG_GF_TRIM"
2596fi
2597if test "$gf_new" = "yes" ; then
2598 output_sym "CONFIG_GF_NEW_API"
2599fi
2600if test "$libhdfs" = "yes" ; then
2601 output_sym "CONFIG_LIBHDFS"
2602 echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
2603 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
2604 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
2605 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
2606fi
2607if test "$mtd" = "yes" ; then
2608 output_sym "CONFIG_MTD"
2609fi
2610if test "$pmemblk" = "yes" ; then
2611 output_sym "CONFIG_PMEMBLK"
2612fi
2613if test "$devdax" = "yes" ; then
2614 output_sym "CONFIG_LINUX_DEVDAX"
2615fi
2616if test "$pmem" = "yes" ; then
2617 output_sym "CONFIG_LIBPMEM"
2618fi
2619if test "$libime" = "yes" ; then
2620 output_sym "CONFIG_IME"
2621fi
2622if test "$arith" = "yes" ; then
2623 output_sym "CONFIG_ARITHMETIC"
2624 if test "$yacc_is_bison" = "yes" ; then
2625 echo "YACC=$YACC -y" >> $config_host_mak
2626 else
2627 echo "YACC=$YACC" >> $config_host_mak
2628 fi
2629 if test "$lex_use_o" = "yes" ; then
2630 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
2631 fi
2632fi
2633if test "$getmntent" = "yes" ; then
2634 output_sym "CONFIG_GETMNTENT"
2635fi
2636if test "$getmntinfo" = "yes" ; then
2637 output_sym "CONFIG_GETMNTINFO"
2638fi
2639if test "$getmntinfo_statvfs" = "yes" ; then
2640 output_sym "CONFIG_GETMNTINFO_STATVFS"
2641fi
2642if test "$static_assert" = "yes" ; then
2643 output_sym "CONFIG_STATIC_ASSERT"
2644fi
2645if test "$have_bool" = "yes" ; then
2646 output_sym "CONFIG_HAVE_BOOL"
2647fi
2648if test "$strndup" = "yes" ; then
2649 output_sym "CONFIG_HAVE_STRNDUP"
2650fi
2651if test "$disable_opt" = "yes" ; then
2652 output_sym "CONFIG_DISABLE_OPTIMIZATIONS"
2653fi
2654if test "$valgrind_dev" = "yes"; then
2655 output_sym "CONFIG_VALGRIND_DEV"
2656fi
2657if test "$linux_blkzoned" = "yes" ; then
2658 output_sym "CONFIG_LINUX_BLKZONED"
2659fi
2660if test "$zlib" = "no" ; then
2661 echo "Consider installing zlib-dev (zlib-devel, some fio features depend on it."
2662 if test "$build_static" = "yes"; then
2663 echo "Note that some distros have separate packages for static libraries."
2664 fi
2665fi
2666if test "$march_armv8_a_crc_crypto" = "yes" ; then
2667 output_sym "ARCH_HAVE_CRC_CRYPTO"
2668fi
2669if test "$cuda" = "yes" ; then
2670 output_sym "CONFIG_CUDA"
2671fi
2672if test "$mkdir_two" = "yes" ; then
2673 output_sym "CONFIG_HAVE_MKDIR_TWO"
2674fi
2675if test "$march_set" = "no" && test "$build_native" = "yes" ; then
2676 output_sym "CONFIG_BUILD_NATIVE"
2677fi
2678if test "$cunit" = "yes" ; then
2679 output_sym "CONFIG_HAVE_CUNIT"
2680fi
2681if test "$__kernel_rwf_t" = "yes"; then
2682 output_sym "CONFIG_HAVE_KERNEL_RWF_T"
2683fi
2684if test "$gettid" = "yes"; then
2685 output_sym "CONFIG_HAVE_GETTID"
2686fi
2687if test "$fallthrough" = "yes"; then
2688 CFLAGS="$CFLAGS -Wimplicit-fallthrough"
2689fi
2690if test "$thp" = "yes" ; then
2691 output_sym "CONFIG_HAVE_THP"
2692fi
2693if test "$libiscsi" = "yes" ; then
2694 output_sym "CONFIG_LIBISCSI"
2695 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
2696 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
2697 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
2698fi
2699
2700echo "LIBS+=$LIBS" >> $config_host_mak
2701echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
2702echo "CFLAGS+=$CFLAGS" >> $config_host_mak
2703echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
2704echo "CC=$cc" >> $config_host_mak
2705echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
2706echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
2707
2708if [ `dirname $0` != "." -a ! -e Makefile ]; then
2709 cat > Makefile <<EOF
2710SRCDIR:=`dirname $0`
2711include \$(SRCDIR)/Makefile
2712EOF
2713fi