Make oslib/linux-dev-lookup.c a stand-alone library
[fio.git] / configure
... / ...
CommitLineData
1#!/bin/sh
2#
3# Fio configure script. Heavily influenced by the manual qemu configure
4# script. Sad this 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"
17TMPO="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.o"
18TMPE="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.exe"
19
20# NB: do not call "exit" in the trap handler; this is buggy with some shells;
21# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
22trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
23
24rm -rf config.log
25
26config_host_mak="config-host.mak"
27config_host_h="config-host.h"
28
29rm -rf $config_host_mak
30rm -rf $config_host_h
31
32fatal() {
33 echo $@
34 echo "Configure failed, check config.log and/or the above output"
35 rm -rf $config_host_mak
36 rm -rf $config_host_h
37 exit 1
38}
39
40# Default CFLAGS
41CFLAGS="-D_GNU_SOURCE -include config-host.h"
42BUILD_CFLAGS=""
43
44# Print a helpful header at the top of config.log
45echo "# FIO configure log $(date)" >> config.log
46printf "# Configured with:" >> config.log
47printf " '%s'" "$0" "$@" >> config.log
48echo >> config.log
49echo "#" >> config.log
50
51# Print configure header at the top of $config_host_h
52echo "/*" > $config_host_h
53echo " * Automatically generated by configure - do not modify" >> $config_host_h
54printf " * Configured with:" >> $config_host_h
55printf " * '%s'" "$0" "$@" >> $config_host_h
56echo "" >> $config_host_h
57echo " */" >> $config_host_h
58
59do_cc() {
60 # Run the compiler, capturing its output to the log.
61 echo $cc "$@" >> config.log
62 $cc "$@" >> config.log 2>&1 || return $?
63 # Test passed. If this is an --enable-werror build, rerun
64 # the test with -Werror and bail out if it fails. This
65 # makes warning-generating-errors in configure test code
66 # obvious to developers.
67 if test "$werror" != "yes"; then
68 return 0
69 fi
70 # Don't bother rerunning the compile if we were already using -Werror
71 case "$*" in
72 *-Werror*)
73 return 0
74 ;;
75 esac
76 echo $cc -Werror "$@" >> config.log
77 $cc -Werror "$@" >> config.log 2>&1 && return $?
78 echo "ERROR: configure test passed without -Werror but failed with -Werror."
79 echo "This is probably a bug in the configure script. The failing command"
80 echo "will be at the bottom of config.log."
81 fatal "You can run configure with --disable-werror to bypass this check."
82}
83
84compile_object() {
85 do_cc $CFLAGS -c -o $TMPO $TMPC
86}
87
88compile_prog() {
89 local_cflags="$1"
90 local_ldflags="$2 $LIBS"
91 echo "Compiling test case $3" >> config.log
92 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
93}
94
95feature_not_found() {
96 feature=$1
97 packages=$2
98
99 echo "ERROR"
100 echo "ERROR: User requested feature $feature"
101 if test ! -z "$packages" ; then
102 echo "ERROR: That feature needs $packages installed"
103 fi
104 echo "ERROR: configure was not able to find it"
105 fatal "ERROR"
106}
107
108has() {
109 type "$1" >/dev/null 2>&1
110}
111
112check_define() {
113 cat > $TMPC <<EOF
114#if !defined($1)
115#error $1 not defined
116#endif
117int main(void)
118{
119 return 0;
120}
121EOF
122 compile_object
123}
124
125output_sym() {
126 echo "$1=y" >> $config_host_mak
127 echo "#define $1" >> $config_host_h
128}
129
130targetos=""
131cpu=""
132
133# default options
134show_help="no"
135exit_val=0
136gfio_check="no"
137libhdfs="no"
138pmemblk="no"
139devdax="no"
140disable_lex=""
141disable_pmem="no"
142prefix=/usr/local
143
144# parse options
145for opt do
146 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
147 case "$opt" in
148 --prefix=*) prefix="$optarg"
149 ;;
150 --cpu=*) cpu="$optarg"
151 ;;
152 # esx is cross compiled and cannot be detect through simple uname calls
153 --esx)
154 esx="yes"
155 ;;
156 --cc=*) CC="$optarg"
157 ;;
158 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
159 ;;
160 --build-32bit-win) build_32bit_win="yes"
161 ;;
162 --build-static) build_static="yes"
163 ;;
164 --enable-gfio)
165 gfio_check="yes"
166 ;;
167 --disable-numa) disable_numa="yes"
168 ;;
169 --disable-rdma) disable_rdma="yes"
170 ;;
171 --disable-rbd) disable_rbd="yes"
172 ;;
173 --disable-rbd-blkin) disable_rbd_blkin="yes"
174 ;;
175 --disable-gfapi) disable_gfapi="yes"
176 ;;
177 --enable-libhdfs) libhdfs="yes"
178 ;;
179 --disable-lex) disable_lex="yes"
180 ;;
181 --enable-lex) disable_lex="no"
182 ;;
183 --disable-shm) no_shm="yes"
184 ;;
185 --disable-optimizations) disable_opt="yes"
186 ;;
187 --disable-pmem) disable_pmem="yes"
188 ;;
189 --help)
190 show_help="yes"
191 ;;
192 *)
193 echo "Bad option $opt"
194 show_help="yes"
195 exit_val=1
196 esac
197done
198
199if test "$show_help" = "yes" ; then
200 echo "--prefix= Use this directory as installation prefix"
201 echo "--cpu= Specify target CPU if auto-detect fails"
202 echo "--cc= Specify compiler to use"
203 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
204 echo "--build-32bit-win Enable 32-bit build on Windows"
205 echo "--build-static Build a static fio"
206 echo "--esx Configure build options for esx"
207 echo "--enable-gfio Enable building of gtk gfio"
208 echo "--disable-numa Disable libnuma even if found"
209 echo "--disable-rdma Disable RDMA support even if found"
210 echo "--disable-gfapi Disable gfapi"
211 echo "--enable-libhdfs Enable hdfs support"
212 echo "--disable-lex Disable use of lex/yacc for math"
213 echo "--disable-pmem Disable pmem based engines even if found"
214 echo "--enable-lex Enable use of lex/yacc for math"
215 echo "--disable-shm Disable SHM support"
216 echo "--disable-optimizations Don't enable compiler optimizations"
217 exit $exit_val
218fi
219
220cross_prefix=${cross_prefix-${CROSS_COMPILE}}
221cc="${CC-${cross_prefix}gcc}"
222
223if check_define __ANDROID__ ; then
224 targetos="Android"
225elif check_define __linux__ ; then
226 targetos="Linux"
227elif check_define __OpenBSD__ ; then
228 targetos='OpenBSD'
229elif check_define __sun__ ; then
230 targetos='SunOS'
231 CFLAGS="$CFLAGS -D_REENTRANT"
232elif check_define _WIN32 ; then
233 targetos='CYGWIN'
234else
235 targetos=`uname -s`
236fi
237
238echo "# Automatically generated by configure - do not modify" > $config_host_mak
239printf "# Configured with:" >> $config_host_mak
240printf " '%s'" "$0" "$@" >> $config_host_mak
241echo >> $config_host_mak
242echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
243
244if test "$no_shm" = "yes" ; then
245 output_sym "CONFIG_NO_SHM"
246fi
247
248if test "$disable_opt" = "yes" ; then
249 output_sym "CONFIG_FIO_NO_OPT"
250fi
251
252# Some host OSes need non-standard checks for which CPU to use.
253# Note that these checks are broken for cross-compilation: if you're
254# cross-compiling to one of these OSes then you'll need to specify
255# the correct CPU with the --cpu option.
256case $targetos in
257AIX)
258 # Unless explicitly enabled, turn off lex.
259 if test -z "$disable_lex" ; then
260 disable_lex="yes"
261 else
262 force_no_lex_o="yes"
263 fi
264 ;;
265Darwin)
266 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
267 # we can run 64-bit userspace code.
268 # If the user didn't specify a CPU explicitly and the kernel says this is
269 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
270 # detection code.
271 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
272 cpu="x86_64"
273 fi
274 # Error at compile time linking of weak/partial symbols if possible...
275cat > $TMPC <<EOF
276int main(void)
277{
278 return 0;
279}
280EOF
281 if compile_prog "" "-Wl,-no_weak_imports" "disable weak symbols"; then
282 echo "Disabling weak symbols"
283 LDFLAGS="$LDFLAGS -Wl,-no_weak_imports"
284 fi
285 ;;
286SunOS)
287 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
288 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
289 cpu="x86_64"
290 fi
291 LIBS="-lnsl -lsocket"
292 ;;
293CYGWIN*)
294 # We still force some options, so keep this message here.
295 echo "Forcing some known good options on Windows"
296 if test -z "$CC" ; then
297 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
298 CC="i686-w64-mingw32-gcc"
299 if test -e "../zlib/contrib/vstudio/vc14/x86/ZlibStatReleaseWithoutAsm/zlibstat.lib"; then
300 echo "Building with zlib support"
301 output_sym "CONFIG_ZLIB"
302 echo "LIBS=../zlib/contrib/vstudio/vc14/x86/ZlibStatReleaseWithoutAsm/zlibstat.lib" >> $config_host_mak
303 fi
304 else
305 CC="x86_64-w64-mingw32-gcc"
306 if test -e "../zlib/contrib/vstudio/vc14/x64/ZlibStatReleaseWithoutAsm/zlibstat.lib"; then
307 echo "Building with zlib support"
308 output_sym "CONFIG_ZLIB"
309 echo "LIBS=../zlib/contrib/vstudio/vc14/x64/ZlibStatReleaseWithoutAsm/zlibstat.lib" >> $config_host_mak
310 fi
311 fi
312 fi
313 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
314 output_sym "CONFIG_32BIT"
315 else
316 output_sym "CONFIG_64BIT_LLP64"
317 fi
318 # We need this to be output_sym'd here because this is Windows specific.
319 # The regular configure path never sets this config.
320 output_sym "CONFIG_WINDOWSAIO"
321 # We now take the regular configuration path without having exit 0 here.
322 # Flags below are still necessary mostly for MinGW.
323 socklen_t="yes"
324 sfaa="yes"
325 rusage_thread="yes"
326 fdatasync="yes"
327 clock_gettime="yes" # clock_monotonic probe has dependency on this
328 clock_monotonic="yes"
329 gettimeofday="yes"
330 sched_idle="yes"
331 tcp_nodelay="yes"
332 tls_thread="yes"
333 static_assert="yes"
334 ipv6="yes"
335 echo "CC=$CC" >> $config_host_mak
336 echo "BUILD_CFLAGS=$CFLAGS -I../zlib -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
337 ;;
338esac
339
340if test ! -z "$cpu" ; then
341 # command line argument
342 :
343elif check_define __i386__ ; then
344 cpu="i386"
345elif check_define __x86_64__ ; then
346 cpu="x86_64"
347elif check_define __sparc__ ; then
348 if check_define __arch64__ ; then
349 cpu="sparc64"
350 else
351 cpu="sparc"
352 fi
353elif check_define _ARCH_PPC ; then
354 if check_define _ARCH_PPC64 ; then
355 cpu="ppc64"
356 else
357 cpu="ppc"
358 fi
359elif check_define __mips__ ; then
360 cpu="mips"
361elif check_define __ia64__ ; then
362 cpu="ia64"
363elif check_define __s390__ ; then
364 if check_define __s390x__ ; then
365 cpu="s390x"
366 else
367 cpu="s390"
368 fi
369elif check_define __arm__ ; then
370 cpu="arm"
371elif check_define __aarch64__ ; then
372 cpu="aarch64"
373elif check_define __hppa__ ; then
374 cpu="hppa"
375else
376 cpu=`uname -m`
377fi
378
379# Normalise host CPU name and set ARCH.
380case "$cpu" in
381 ia64|ppc|ppc64|s390|s390x|sparc64)
382 cpu="$cpu"
383 ;;
384 i386|i486|i586|i686|i86pc|BePC)
385 cpu="x86"
386 ;;
387 x86_64|amd64)
388 cpu="x86_64"
389 ;;
390 armv*b|armv*l|arm)
391 cpu="arm"
392 ;;
393 aarch64)
394 cpu="arm64"
395 ;;
396 hppa|parisc|parisc64)
397 cpu="hppa"
398 ;;
399 mips*)
400 cpu="mips"
401 ;;
402 sparc|sun4[cdmuv])
403 cpu="sparc"
404 ;;
405 *)
406 echo "Unknown CPU"
407 ;;
408esac
409
410if test -z "$CC" ; then
411 if test "$targetos" = "FreeBSD"; then
412 if has clang; then
413 CC=clang
414 else
415 CC=gcc
416 fi
417 fi
418fi
419
420cc="${CC-${cross_prefix}gcc}"
421
422##########################################
423# check cross compile
424
425if test "$cross_compile" != "yes" ; then
426 cross_compile="no"
427fi
428cat > $TMPC <<EOF
429int main(void)
430{
431 return 0;
432}
433EOF
434if compile_prog "" "" "cross"; then
435 $TMPE 2>/dev/null || cross_compile="yes"
436else
437 fatal "compile test failed"
438fi
439
440##########################################
441# check endianness
442if test "$bigendian" != "yes" ; then
443 bigendian="no"
444fi
445if test "$cross_compile" = "no" ; then
446 cat > $TMPC <<EOF
447#include <inttypes.h>
448int main(void)
449{
450 volatile uint32_t i=0x01234567;
451 return (*((uint8_t*)(&i))) == 0x67;
452}
453EOF
454 if compile_prog "" "" "endian"; then
455 $TMPE && bigendian="yes"
456 fi
457else
458 # If we're cross compiling, try our best to work it out and rely on the
459 # run-time check to fail if we get it wrong.
460 cat > $TMPC <<EOF
461#include <endian.h>
462int main(void)
463{
464#if __BYTE_ORDER != __BIG_ENDIAN
465# error "Unknown endianness"
466#endif
467}
468EOF
469 compile_prog "" "" "endian" && bigendian="yes"
470 check_define "__ARMEB__" && bigendian="yes"
471 check_define "__MIPSEB__" && bigendian="yes"
472fi
473
474
475echo "Operating system $targetos"
476echo "CPU $cpu"
477echo "Big endian $bigendian"
478echo "Compiler $cc"
479echo "Cross compile $cross_compile"
480echo
481
482##########################################
483# See if we need to build a static build
484if test "$build_static" = "yes" ; then
485 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
486 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
487else
488 build_static="no"
489fi
490echo "Static build $build_static"
491
492##########################################
493# check for wordsize
494wordsize="0"
495cat > $TMPC <<EOF
496#include <limits.h>
497#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
498int main(void)
499{
500 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
501 return 0;
502}
503EOF
504if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
505 wordsize="32"
506elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
507 wordsize="64"
508else
509 fatal "Unknown wordsize"
510fi
511echo "Wordsize $wordsize"
512
513##########################################
514# zlib probe
515if test "$zlib" != "yes" ; then
516 zlib="no"
517fi
518cat > $TMPC <<EOF
519#include <zlib.h>
520int main(void)
521{
522 z_stream stream;
523 if (inflateInit(&stream) != Z_OK)
524 return 1;
525 return 0;
526}
527EOF
528if compile_prog "" "-lz" "zlib" ; then
529 zlib=yes
530 LIBS="-lz $LIBS"
531fi
532echo "zlib $zlib"
533
534##########################################
535# linux-aio probe
536if test "$libaio" != "yes" ; then
537 libaio="no"
538fi
539if test "$esx" != "yes" ; then
540 cat > $TMPC <<EOF
541#include <libaio.h>
542#include <stddef.h>
543int main(void)
544{
545 io_setup(0, NULL);
546 return 0;
547}
548EOF
549 if compile_prog "" "-laio" "libaio" ; then
550 libaio=yes
551 LIBS="-laio $LIBS"
552 else
553 if test "$libaio" = "yes" ; then
554 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
555 fi
556 libaio=no
557 fi
558fi
559echo "Linux AIO support $libaio"
560
561##########################################
562# posix aio probe
563if test "$posix_aio" != "yes" ; then
564 posix_aio="no"
565fi
566if test "$posix_aio_lrt" != "yes" ; then
567 posix_aio_lrt="no"
568fi
569cat > $TMPC <<EOF
570#include <aio.h>
571int main(void)
572{
573 struct aiocb cb;
574 aio_read(&cb);
575 return 0;
576}
577EOF
578if compile_prog "" "" "posixaio" ; then
579 posix_aio="yes"
580elif compile_prog "" "-lrt" "posixaio"; then
581 posix_aio="yes"
582 posix_aio_lrt="yes"
583 LIBS="-lrt $LIBS"
584fi
585echo "POSIX AIO support $posix_aio"
586echo "POSIX AIO support needs -lrt $posix_aio_lrt"
587
588##########################################
589# posix aio fsync probe
590if test "$posix_aio_fsync" != "yes" ; then
591 posix_aio_fsync="no"
592fi
593if test "$posix_aio" = "yes" ; then
594 cat > $TMPC <<EOF
595#include <fcntl.h>
596#include <aio.h>
597int main(void)
598{
599 struct aiocb cb;
600 return aio_fsync(O_SYNC, &cb);
601 return 0;
602}
603EOF
604 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
605 posix_aio_fsync=yes
606 fi
607fi
608echo "POSIX AIO fsync $posix_aio_fsync"
609
610##########################################
611# POSIX pshared attribute probe
612posix_pshared="no"
613cat > $TMPC <<EOF
614#include <unistd.h>
615int main(void)
616{
617#if defined(_POSIX_THREAD_PROCESS_SHARED) && ((_POSIX_THREAD_PROCESS_SHARED + 0) > 0)
618# if defined(__CYGWIN__)
619# error "_POSIX_THREAD_PROCESS_SHARED is buggy on Cygwin"
620# elif defined(__APPLE__)
621# include <AvailabilityMacros.h>
622# include <TargetConditionals.h>
623# if TARGET_OS_MAC && MAC_OS_X_VERSION_MIN_REQUIRED < 1070
624# error "_POSIX_THREAD_PROCESS_SHARED is buggy/unsupported prior to OSX 10.7"
625# endif
626# endif
627#else
628# error "_POSIX_THREAD_PROCESS_SHARED is unsupported"
629#endif
630 return 0;
631}
632EOF
633if compile_prog "" "$LIBS" "posix_pshared" ; then
634 posix_pshared=yes
635fi
636echo "POSIX pshared support $posix_pshared"
637
638##########################################
639# solaris aio probe
640if test "$solaris_aio" != "yes" ; then
641 solaris_aio="no"
642fi
643cat > $TMPC <<EOF
644#include <sys/types.h>
645#include <sys/asynch.h>
646#include <unistd.h>
647int main(void)
648{
649 aio_result_t res;
650 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
651 return 0;
652}
653EOF
654if compile_prog "" "-laio" "solarisaio" ; then
655 solaris_aio=yes
656 LIBS="-laio $LIBS"
657fi
658echo "Solaris AIO support $solaris_aio"
659
660##########################################
661# __sync_fetch_and_add test
662if test "$sfaa" != "yes" ; then
663 sfaa="no"
664fi
665cat > $TMPC << EOF
666#include <inttypes.h>
667static int sfaa(uint64_t *ptr)
668{
669 return __sync_fetch_and_add(ptr, 0);
670}
671
672int main(int argc, char **argv)
673{
674 uint64_t val = 42;
675 sfaa(&val);
676 return val;
677}
678EOF
679if compile_prog "" "" "__sync_fetch_and_add()" ; then
680 sfaa="yes"
681fi
682echo "__sync_fetch_and_add $sfaa"
683
684##########################################
685# libverbs probe
686if test "$libverbs" != "yes" ; then
687 libverbs="no"
688fi
689cat > $TMPC << EOF
690#include <stdio.h>
691#include <infiniband/arch.h>
692int main(int argc, char **argv)
693{
694 struct ibv_pd *pd = ibv_alloc_pd(NULL);
695 return 0;
696}
697EOF
698if test "$disable_rdma" != "yes" && compile_prog "" "-libverbs" "libverbs" ; then
699 libverbs="yes"
700 LIBS="-libverbs $LIBS"
701fi
702echo "libverbs $libverbs"
703
704##########################################
705# rdmacm probe
706if test "$rdmacm" != "yes" ; then
707 rdmacm="no"
708fi
709cat > $TMPC << EOF
710#include <stdio.h>
711#include <rdma/rdma_cma.h>
712int main(int argc, char **argv)
713{
714 rdma_destroy_qp(NULL);
715 return 0;
716}
717EOF
718if test "$disable_rdma" != "yes" && compile_prog "" "-lrdmacm" "rdma"; then
719 rdmacm="yes"
720 LIBS="-lrdmacm $LIBS"
721fi
722echo "rdmacm $rdmacm"
723
724##########################################
725# Linux fallocate probe
726if test "$linux_fallocate" != "yes" ; then
727 linux_fallocate="no"
728fi
729cat > $TMPC << EOF
730#include <stdio.h>
731#include <fcntl.h>
732#include <linux/falloc.h>
733int main(int argc, char **argv)
734{
735 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
736 return r;
737}
738EOF
739if compile_prog "" "" "linux_fallocate"; then
740 linux_fallocate="yes"
741fi
742echo "Linux fallocate $linux_fallocate"
743
744##########################################
745# POSIX fadvise probe
746if test "$posix_fadvise" != "yes" ; then
747 posix_fadvise="no"
748fi
749cat > $TMPC << EOF
750#include <stdio.h>
751#include <fcntl.h>
752int main(int argc, char **argv)
753{
754 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
755 return r;
756}
757EOF
758if compile_prog "" "" "posix_fadvise"; then
759 posix_fadvise="yes"
760fi
761echo "POSIX fadvise $posix_fadvise"
762
763##########################################
764# POSIX fallocate probe
765if test "$posix_fallocate" != "yes" ; then
766 posix_fallocate="no"
767fi
768cat > $TMPC << EOF
769#include <stdio.h>
770#include <fcntl.h>
771int main(int argc, char **argv)
772{
773 int r = posix_fallocate(0, 0, 1024);
774 return r;
775}
776EOF
777if compile_prog "" "" "posix_fallocate"; then
778 posix_fallocate="yes"
779fi
780echo "POSIX fallocate $posix_fallocate"
781
782##########################################
783# sched_set/getaffinity 2 or 3 argument test
784if test "$linux_2arg_affinity" != "yes" ; then
785 linux_2arg_affinity="no"
786fi
787if test "$linux_3arg_affinity" != "yes" ; then
788 linux_3arg_affinity="no"
789fi
790cat > $TMPC << EOF
791#include <sched.h>
792int main(int argc, char **argv)
793{
794 cpu_set_t mask;
795 return sched_setaffinity(0, sizeof(mask), &mask);
796}
797EOF
798if compile_prog "" "" "sched_setaffinity(,,)"; then
799 linux_3arg_affinity="yes"
800else
801 cat > $TMPC << EOF
802#include <sched.h>
803int main(int argc, char **argv)
804{
805 cpu_set_t mask;
806 return sched_setaffinity(0, &mask);
807}
808EOF
809 if compile_prog "" "" "sched_setaffinity(,)"; then
810 linux_2arg_affinity="yes"
811 fi
812fi
813echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
814echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
815
816##########################################
817# clock_gettime probe
818if test "$clock_gettime" != "yes" ; then
819 clock_gettime="no"
820fi
821cat > $TMPC << EOF
822#include <stdio.h>
823#include <time.h>
824int main(int argc, char **argv)
825{
826 return clock_gettime(0, NULL);
827}
828EOF
829if compile_prog "" "" "clock_gettime"; then
830 clock_gettime="yes"
831elif compile_prog "" "-lrt" "clock_gettime"; then
832 clock_gettime="yes"
833 LIBS="-lrt $LIBS"
834fi
835echo "clock_gettime $clock_gettime"
836
837##########################################
838# CLOCK_MONOTONIC probe
839if test "$clock_monotonic" != "yes" ; then
840 clock_monotonic="no"
841fi
842if test "$clock_gettime" = "yes" ; then
843 cat > $TMPC << EOF
844#include <stdio.h>
845#include <time.h>
846int main(int argc, char **argv)
847{
848 return clock_gettime(CLOCK_MONOTONIC, NULL);
849}
850EOF
851 if compile_prog "" "$LIBS" "clock monotonic"; then
852 clock_monotonic="yes"
853 fi
854fi
855echo "CLOCK_MONOTONIC $clock_monotonic"
856
857##########################################
858# CLOCK_MONOTONIC_RAW probe
859if test "$clock_monotonic_raw" != "yes" ; then
860 clock_monotonic_raw="no"
861fi
862if test "$clock_gettime" = "yes" ; then
863 cat > $TMPC << EOF
864#include <stdio.h>
865#include <time.h>
866int main(int argc, char **argv)
867{
868 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
869}
870EOF
871 if compile_prog "" "$LIBS" "clock monotonic"; then
872 clock_monotonic_raw="yes"
873 fi
874fi
875echo "CLOCK_MONOTONIC_RAW $clock_monotonic_raw"
876
877##########################################
878# CLOCK_MONOTONIC_PRECISE probe
879if test "$clock_monotonic_precise" != "yes" ; then
880 clock_monotonic_precise="no"
881fi
882if test "$clock_gettime" = "yes" ; then
883 cat > $TMPC << EOF
884#include <stdio.h>
885#include <time.h>
886int main(int argc, char **argv)
887{
888 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
889}
890EOF
891 if compile_prog "" "$LIBS" "clock monotonic precise"; then
892 clock_monotonic_precise="yes"
893 fi
894fi
895echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
896
897##########################################
898# clockid_t probe
899if test "$clockid_t" != "yes" ; then
900 clockid_t="no"
901fi
902cat > $TMPC << EOF
903#include <time.h>
904int main(int argc, char **argv)
905{
906 volatile clockid_t cid;
907 memset(&cid, 0, sizeof(cid));
908 return 0;
909}
910EOF
911if compile_prog "" "$LIBS" "clockid_t"; then
912 clockid_t="yes"
913fi
914echo "clockid_t $clockid_t"
915
916##########################################
917# gettimeofday() probe
918if test "$gettimeofday" != "yes" ; then
919 gettimeofday="no"
920fi
921cat > $TMPC << EOF
922#include <sys/time.h>
923#include <stdio.h>
924int main(int argc, char **argv)
925{
926 struct timeval tv;
927 return gettimeofday(&tv, NULL);
928}
929EOF
930if compile_prog "" "" "gettimeofday"; then
931 gettimeofday="yes"
932fi
933echo "gettimeofday $gettimeofday"
934
935##########################################
936# fdatasync() probe
937if test "$fdatasync" != "yes" ; then
938 fdatasync="no"
939fi
940cat > $TMPC << EOF
941#include <stdio.h>
942#include <unistd.h>
943int main(int argc, char **argv)
944{
945 return fdatasync(0);
946}
947EOF
948if compile_prog "" "" "fdatasync"; then
949 fdatasync="yes"
950fi
951echo "fdatasync $fdatasync"
952
953##########################################
954# sync_file_range() probe
955if test "$sync_file_range" != "yes" ; then
956 sync_file_range="no"
957fi
958cat > $TMPC << EOF
959#include <stdio.h>
960#include <unistd.h>
961#include <fcntl.h>
962#include <linux/fs.h>
963int main(int argc, char **argv)
964{
965 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
966 SYNC_FILE_RANGE_WAIT_AFTER;
967 return sync_file_range(0, 0, 0, flags);
968}
969EOF
970if compile_prog "" "" "sync_file_range"; then
971 sync_file_range="yes"
972fi
973echo "sync_file_range $sync_file_range"
974
975##########################################
976# ext4 move extent probe
977if test "$ext4_me" != "yes" ; then
978 ext4_me="no"
979fi
980cat > $TMPC << EOF
981#include <fcntl.h>
982#include <sys/ioctl.h>
983int main(int argc, char **argv)
984{
985 struct move_extent me;
986 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
987}
988EOF
989if compile_prog "" "" "ext4 move extent" ; then
990 ext4_me="yes"
991elif test $targetos = "Linux" ; then
992 # On Linux, just default to it on and let it error at runtime if we really
993 # don't have it. None of my updated systems have it defined, but it does
994 # work. Takes a while to bubble back.
995 ext4_me="yes"
996fi
997echo "EXT4 move extent $ext4_me"
998
999##########################################
1000# splice probe
1001if test "$linux_splice" != "yes" ; then
1002 linux_splice="no"
1003fi
1004cat > $TMPC << EOF
1005#include <stdio.h>
1006#include <fcntl.h>
1007int main(int argc, char **argv)
1008{
1009 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
1010}
1011EOF
1012if compile_prog "" "" "linux splice"; then
1013 linux_splice="yes"
1014fi
1015echo "Linux splice(2) $linux_splice"
1016
1017##########################################
1018# GUASI probe
1019if test "$guasi" != "yes" ; then
1020 guasi="no"
1021fi
1022cat > $TMPC << EOF
1023#include <guasi.h>
1024#include <guasi_syscalls.h>
1025int main(int argc, char **argv)
1026{
1027 guasi_t ctx = guasi_create(0, 0, 0);
1028 return 0;
1029}
1030EOF
1031if compile_prog "" "" "guasi"; then
1032 guasi="yes"
1033fi
1034echo "GUASI $guasi"
1035
1036##########################################
1037# fusion-aw probe
1038if test "$fusion_aw" != "yes" ; then
1039 fusion_aw="no"
1040fi
1041cat > $TMPC << EOF
1042#include <nvm/nvm_primitives.h>
1043int main(int argc, char **argv)
1044{
1045 nvm_version_t ver_info;
1046 nvm_handle_t handle;
1047
1048 handle = nvm_get_handle(0, &ver_info);
1049 return nvm_atomic_write(handle, 0, 0, 0);
1050}
1051EOF
1052if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
1053 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
1054 fusion_aw="yes"
1055fi
1056echo "Fusion-io atomic engine $fusion_aw"
1057
1058##########################################
1059# libnuma probe
1060if test "$libnuma" != "yes" ; then
1061 libnuma="no"
1062fi
1063cat > $TMPC << EOF
1064#include <numa.h>
1065int main(int argc, char **argv)
1066{
1067 return numa_available();
1068}
1069EOF
1070if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
1071 libnuma="yes"
1072 LIBS="-lnuma $LIBS"
1073fi
1074echo "libnuma $libnuma"
1075
1076##########################################
1077# libnuma 2.x version API, initialize with "no" only if $libnuma is set to "yes"
1078if test "$libnuma" = "yes" ; then
1079libnuma_v2="no"
1080cat > $TMPC << EOF
1081#include <numa.h>
1082int main(int argc, char **argv)
1083{
1084 struct bitmask *mask = numa_parse_nodestring(NULL);
1085 return mask->size == 0;
1086}
1087EOF
1088if compile_prog "" "" "libnuma api"; then
1089 libnuma_v2="yes"
1090fi
1091echo "libnuma v2 $libnuma_v2"
1092fi
1093
1094##########################################
1095# strsep() probe
1096if test "$strsep" != "yes" ; then
1097 strsep="no"
1098fi
1099cat > $TMPC << EOF
1100#include <string.h>
1101int main(int argc, char **argv)
1102{
1103 static char *string = "This is a string";
1104 strsep(&string, "needle");
1105 return 0;
1106}
1107EOF
1108if compile_prog "" "" "strsep"; then
1109 strsep="yes"
1110fi
1111echo "strsep $strsep"
1112
1113##########################################
1114# strcasestr() probe
1115if test "$strcasestr" != "yes" ; then
1116 strcasestr="no"
1117fi
1118cat > $TMPC << EOF
1119#include <string.h>
1120int main(int argc, char **argv)
1121{
1122 return strcasestr(argv[0], argv[1]) != NULL;
1123}
1124EOF
1125if compile_prog "" "" "strcasestr"; then
1126 strcasestr="yes"
1127fi
1128echo "strcasestr $strcasestr"
1129
1130##########################################
1131# strlcat() probe
1132if test "$strlcat" != "yes" ; then
1133 strlcat="no"
1134fi
1135cat > $TMPC << EOF
1136#include <string.h>
1137int main(int argc, char **argv)
1138{
1139 static char dst[64];
1140 static char *string = "This is a string";
1141 memset(dst, 0, sizeof(dst));
1142 strlcat(dst, string, sizeof(dst));
1143 return 0;
1144}
1145EOF
1146if compile_prog "" "" "strlcat"; then
1147 strlcat="yes"
1148fi
1149echo "strlcat $strlcat"
1150
1151##########################################
1152# getopt_long_only() probe
1153if test "$getopt_long_only" != "yes" ; then
1154 getopt_long_only="no"
1155fi
1156cat > $TMPC << EOF
1157#include <unistd.h>
1158#include <stdio.h>
1159#include <getopt.h>
1160int main(int argc, char **argv)
1161{
1162 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1163 return c;
1164}
1165EOF
1166if compile_prog "" "" "getopt_long_only"; then
1167 getopt_long_only="yes"
1168fi
1169echo "getopt_long_only() $getopt_long_only"
1170
1171##########################################
1172# inet_aton() probe
1173if test "$inet_aton" != "yes" ; then
1174 inet_aton="no"
1175fi
1176cat > $TMPC << EOF
1177#include <sys/socket.h>
1178#include <arpa/inet.h>
1179#include <stdio.h>
1180int main(int argc, char **argv)
1181{
1182 struct in_addr in;
1183 return inet_aton(NULL, &in);
1184}
1185EOF
1186if compile_prog "" "" "inet_aton"; then
1187 inet_aton="yes"
1188fi
1189echo "inet_aton $inet_aton"
1190
1191##########################################
1192# socklen_t probe
1193if test "$socklen_t" != "yes" ; then
1194 socklen_t="no"
1195fi
1196cat > $TMPC << EOF
1197#include <sys/socket.h>
1198int main(int argc, char **argv)
1199{
1200 socklen_t len = 0;
1201 return len;
1202}
1203EOF
1204if compile_prog "" "" "socklen_t"; then
1205 socklen_t="yes"
1206fi
1207echo "socklen_t $socklen_t"
1208
1209##########################################
1210# Whether or not __thread is supported for TLS
1211if test "$tls_thread" != "yes" ; then
1212 tls_thread="no"
1213fi
1214cat > $TMPC << EOF
1215#include <stdio.h>
1216static __thread int ret;
1217int main(int argc, char **argv)
1218{
1219 return ret;
1220}
1221EOF
1222if compile_prog "" "" "__thread"; then
1223 tls_thread="yes"
1224fi
1225echo "__thread $tls_thread"
1226
1227##########################################
1228# Check if we have required gtk/glib support for gfio
1229if test "$gfio" != "yes" ; then
1230 gfio="no"
1231fi
1232if test "$gfio_check" = "yes" ; then
1233 cat > $TMPC << EOF
1234#include <glib.h>
1235#include <cairo.h>
1236#include <gtk/gtk.h>
1237int main(void)
1238{
1239 gdk_threads_enter();
1240 gdk_threads_leave();
1241
1242 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
1243}
1244EOF
1245GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1246ORG_LDFLAGS=$LDFLAGS
1247LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1248if test "$?" != "0" ; then
1249 echo "configure: gtk and gthread not found"
1250 exit 1
1251fi
1252GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1253if test "$?" != "0" ; then
1254 echo "configure: gtk and gthread not found"
1255 exit 1
1256fi
1257if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1258 r=$($TMPE)
1259 if test "$r" != "0" ; then
1260 gfio="yes"
1261 GFIO_LIBS="$LIBS $GTK_LIBS"
1262 CFLAGS="$CFLAGS $GTK_CFLAGS"
1263 else
1264 echo "GTK found, but need version 2.18 or higher"
1265 gfio="no"
1266 fi
1267else
1268 echo "Please install gtk and gdk libraries"
1269 gfio="no"
1270fi
1271LDFLAGS=$ORG_LDFLAGS
1272fi
1273
1274if test "$gfio_check" = "yes" ; then
1275 echo "gtk 2.18 or higher $gfio"
1276fi
1277
1278# Check whether we have getrusage(RUSAGE_THREAD)
1279if test "$rusage_thread" != "yes" ; then
1280 rusage_thread="no"
1281fi
1282cat > $TMPC << EOF
1283#include <sys/time.h>
1284#include <sys/resource.h>
1285int main(int argc, char **argv)
1286{
1287 struct rusage ru;
1288 getrusage(RUSAGE_THREAD, &ru);
1289 return 0;
1290}
1291EOF
1292if compile_prog "" "" "RUSAGE_THREAD"; then
1293 rusage_thread="yes"
1294fi
1295echo "RUSAGE_THREAD $rusage_thread"
1296
1297##########################################
1298# Check whether we have SCHED_IDLE
1299if test "$sched_idle" != "yes" ; then
1300 sched_idle="no"
1301fi
1302cat > $TMPC << EOF
1303#include <sched.h>
1304int main(int argc, char **argv)
1305{
1306 struct sched_param p;
1307 return sched_setscheduler(0, SCHED_IDLE, &p);
1308}
1309EOF
1310if compile_prog "" "" "SCHED_IDLE"; then
1311 sched_idle="yes"
1312fi
1313echo "SCHED_IDLE $sched_idle"
1314
1315##########################################
1316# Check whether we have TCP_NODELAY
1317if test "$tcp_nodelay" != "yes" ; then
1318 tcp_nodelay="no"
1319fi
1320cat > $TMPC << EOF
1321#include <stdio.h>
1322#include <sys/types.h>
1323#include <sys/socket.h>
1324#include <netinet/tcp.h>
1325int main(int argc, char **argv)
1326{
1327 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1328}
1329EOF
1330if compile_prog "" "" "TCP_NODELAY"; then
1331 tcp_nodelay="yes"
1332fi
1333echo "TCP_NODELAY $tcp_nodelay"
1334
1335##########################################
1336# Check whether we have SO_SNDBUF
1337if test "$window_size" != "yes" ; then
1338 window_size="no"
1339fi
1340cat > $TMPC << EOF
1341#include <stdio.h>
1342#include <sys/types.h>
1343#include <sys/socket.h>
1344#include <netinet/tcp.h>
1345int main(int argc, char **argv)
1346{
1347 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1348 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1349}
1350EOF
1351if compile_prog "" "" "SO_SNDBUF"; then
1352 window_size="yes"
1353fi
1354echo "Net engine window_size $window_size"
1355
1356##########################################
1357# Check whether we have TCP_MAXSEG
1358if test "$mss" != "yes" ; then
1359 mss="no"
1360fi
1361cat > $TMPC << EOF
1362#include <stdio.h>
1363#include <sys/types.h>
1364#include <sys/socket.h>
1365#include <netinet/tcp.h>
1366#include <arpa/inet.h>
1367#include <netinet/in.h>
1368int main(int argc, char **argv)
1369{
1370 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1371}
1372EOF
1373if compile_prog "" "" "TCP_MAXSEG"; then
1374 mss="yes"
1375fi
1376echo "TCP_MAXSEG $mss"
1377
1378##########################################
1379# Check whether we have RLIMIT_MEMLOCK
1380if test "$rlimit_memlock" != "yes" ; then
1381 rlimit_memlock="no"
1382fi
1383cat > $TMPC << EOF
1384#include <sys/time.h>
1385#include <sys/resource.h>
1386int main(int argc, char **argv)
1387{
1388 struct rlimit rl;
1389 return getrlimit(RLIMIT_MEMLOCK, &rl);
1390}
1391EOF
1392if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1393 rlimit_memlock="yes"
1394fi
1395echo "RLIMIT_MEMLOCK $rlimit_memlock"
1396
1397##########################################
1398# Check whether we have pwritev/preadv
1399if test "$pwritev" != "yes" ; then
1400 pwritev="no"
1401fi
1402cat > $TMPC << EOF
1403#include <stdio.h>
1404#include <sys/uio.h>
1405int main(int argc, char **argv)
1406{
1407 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1408}
1409EOF
1410if compile_prog "" "" "pwritev"; then
1411 pwritev="yes"
1412fi
1413echo "pwritev/preadv $pwritev"
1414
1415##########################################
1416# Check whether we have pwritev2/preadv2
1417if test "$pwritev2" != "yes" ; then
1418 pwritev2="no"
1419fi
1420cat > $TMPC << EOF
1421#include <stdio.h>
1422#include <sys/uio.h>
1423int main(int argc, char **argv)
1424{
1425 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1426}
1427EOF
1428if compile_prog "" "" "pwritev2"; then
1429 pwritev2="yes"
1430fi
1431echo "pwritev2/preadv2 $pwritev2"
1432
1433##########################################
1434# Check whether we have the required functions for ipv6
1435if test "$ipv6" != "yes" ; then
1436 ipv6="no"
1437fi
1438cat > $TMPC << EOF
1439#include <sys/types.h>
1440#include <sys/socket.h>
1441#include <netinet/in.h>
1442#include <netdb.h>
1443#include <stdio.h>
1444int main(int argc, char **argv)
1445{
1446 struct addrinfo hints;
1447 struct in6_addr addr;
1448 int ret;
1449
1450 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1451 freeaddrinfo(NULL);
1452 printf("%s\n", gai_strerror(ret));
1453 addr = in6addr_any;
1454 return 0;
1455}
1456EOF
1457if compile_prog "" "" "ipv6"; then
1458 ipv6="yes"
1459fi
1460echo "IPv6 helpers $ipv6"
1461
1462##########################################
1463# check for rbd
1464if test "$rbd" != "yes" ; then
1465 rbd="no"
1466fi
1467cat > $TMPC << EOF
1468#include <rbd/librbd.h>
1469
1470int main(int argc, char **argv)
1471{
1472
1473 rados_t cluster;
1474 rados_ioctx_t io_ctx;
1475 const char pool[] = "rbd";
1476
1477 int major, minor, extra;
1478 rbd_version(&major, &minor, &extra);
1479
1480 rados_ioctx_create(cluster, pool, &io_ctx);
1481 return 0;
1482}
1483EOF
1484if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
1485 LIBS="-lrbd -lrados $LIBS"
1486 rbd="yes"
1487fi
1488echo "Rados Block Device engine $rbd"
1489
1490##########################################
1491# check for rbd_poll
1492if test "$rbd_poll" != "yes" ; then
1493 rbd_poll="no"
1494fi
1495if test "$rbd" = "yes"; then
1496cat > $TMPC << EOF
1497#include <rbd/librbd.h>
1498#include <sys/eventfd.h>
1499
1500int main(int argc, char **argv)
1501{
1502 rbd_image_t image;
1503 rbd_completion_t comp;
1504
1505 int fd = eventfd(0, EFD_NONBLOCK);
1506 rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1507 rbd_poll_io_events(image, comp, 1);
1508
1509 return 0;
1510}
1511EOF
1512if compile_prog "" "-lrbd -lrados" "rbd"; then
1513 rbd_poll="yes"
1514fi
1515echo "rbd_poll $rbd_poll"
1516fi
1517
1518##########################################
1519# check for rbd_invaidate_cache()
1520if test "$rbd_inval" != "yes" ; then
1521 rbd_inval="no"
1522fi
1523if test "$rbd" = "yes"; then
1524cat > $TMPC << EOF
1525#include <rbd/librbd.h>
1526
1527int main(int argc, char **argv)
1528{
1529 rbd_image_t image;
1530
1531 return rbd_invalidate_cache(image);
1532}
1533EOF
1534if compile_prog "" "-lrbd -lrados" "rbd"; then
1535 rbd_inval="yes"
1536fi
1537echo "rbd_invalidate_cache $rbd_inval"
1538fi
1539
1540##########################################
1541# check for blkin
1542if test "$rbd_blkin" != "yes" ; then
1543 rbd_blkin="no"
1544fi
1545cat > $TMPC << EOF
1546#include <rbd/librbd.h>
1547#include <zipkin_c.h>
1548
1549int main(int argc, char **argv)
1550{
1551 int r;
1552 struct blkin_trace_info t_info;
1553 blkin_init_trace_info(&t_info);
1554 rbd_completion_t completion;
1555 rbd_image_t image;
1556 uint64_t off;
1557 size_t len;
1558 const char *buf;
1559 r = rbd_aio_write_traced(image, off, len, buf, completion, &t_info);
1560 return 0;
1561}
1562EOF
1563if test "$disable_rbd" != "yes" && test "$disable_rbd_blkin" != "yes" \
1564 && compile_prog "" "-lrbd -lrados -lblkin" "rbd_blkin"; then
1565 LIBS="-lblkin $LIBS"
1566 rbd_blkin="yes"
1567fi
1568echo "rbd blkin tracing $rbd_blkin"
1569
1570##########################################
1571# Check whether we have setvbuf
1572if test "$setvbuf" != "yes" ; then
1573 setvbuf="no"
1574fi
1575cat > $TMPC << EOF
1576#include <stdio.h>
1577int main(int argc, char **argv)
1578{
1579 FILE *f = NULL;
1580 char buf[80];
1581 setvbuf(f, buf, _IOFBF, sizeof(buf));
1582 return 0;
1583}
1584EOF
1585if compile_prog "" "" "setvbuf"; then
1586 setvbuf="yes"
1587fi
1588echo "setvbuf $setvbuf"
1589
1590# check for gfapi
1591if test "$gfapi" != "yes" ; then
1592 gfapi="no"
1593fi
1594cat > $TMPC << EOF
1595#include <glusterfs/api/glfs.h>
1596
1597int main(int argc, char **argv)
1598{
1599
1600 glfs_t *g = glfs_new("foo");
1601
1602 return 0;
1603}
1604EOF
1605if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1606 LIBS="-lgfapi -lglusterfs $LIBS"
1607 gfapi="yes"
1608fi
1609 echo "Gluster API engine $gfapi"
1610
1611##########################################
1612# check for gfapi fadvise support, initialize with "no" only if $gfapi is set to "yes"
1613if test "$gfapi" = "yes" ; then
1614gf_fadvise="no"
1615cat > $TMPC << EOF
1616#include <glusterfs/api/glfs.h>
1617
1618int main(int argc, char **argv)
1619{
1620 struct glfs_fd *fd;
1621 int ret = glfs_fadvise(fd, 0, 0, 1);
1622
1623 return 0;
1624}
1625EOF
1626if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1627 gf_fadvise="yes"
1628fi
1629echo "Gluster API use fadvise $gf_fadvise"
1630fi
1631
1632##########################################
1633# check for gfapi trim support
1634if test "$gf_trim" != "yes" ; then
1635 gf_trim="no"
1636fi
1637if test "$gfapi" = "yes" ; then
1638cat > $TMPC << EOF
1639#include <glusterfs/api/glfs.h>
1640
1641int main(int argc, char **argv)
1642{
1643 return glfs_discard_async(NULL, 0, 0);
1644}
1645EOF
1646if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1647 gf_trim="yes"
1648fi
1649echo "Gluster API trim support $gf_trim"
1650fi
1651
1652##########################################
1653# Check if we support stckf on s390
1654if test "$s390_z196_facilities" != "yes" ; then
1655 s390_z196_facilities="no"
1656fi
1657cat > $TMPC << EOF
1658#define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1659int main(int argc, char **argv)
1660{
1661 /* We want just 1 double word to be returned. */
1662 register unsigned long reg0 asm("0") = 0;
1663 unsigned long stfle_bits;
1664 asm volatile(".machine push" "\n\t"
1665 ".machine \"z9-109\"" "\n\t"
1666 "stfle %0" "\n\t"
1667 ".machine pop" "\n"
1668 : "=QS" (stfle_bits), "+d" (reg0)
1669 : : "cc");
1670
1671 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1672 return 0;
1673 else
1674 return -1;
1675}
1676EOF
1677if compile_prog "" "" "s390_z196_facilities"; then
1678 $TMPE
1679 if [[ $? -eq 0 ]]; then
1680 s390_z196_facilities="yes"
1681 fi
1682fi
1683echo "s390_z196_facilities $s390_z196_facilities"
1684
1685##########################################
1686# Check if we have required environment variables configured for libhdfs
1687if test "$libhdfs" = "yes" ; then
1688 hdfs_conf_error=0
1689 if test "$JAVA_HOME" = "" ; then
1690 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1691 hdfs_conf_error=1
1692 fi
1693 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1694 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1695 hdfs_conf_error=1
1696 fi
1697 if test "$FIO_LIBHDFS_LIB" = "" ; then
1698 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1699 hdfs_conf_error=1
1700 fi
1701 if test "$hdfs_conf_error" = "1" ; then
1702 exit 1
1703 fi
1704 FIO_HDFS_CPU=$cpu
1705 if test "$FIO_HDFS_CPU" = "x86_64" ; then
1706 FIO_HDFS_CPU="amd64"
1707 fi
1708fi
1709echo "HDFS engine $libhdfs"
1710
1711##########################################
1712# Check whether we have MTD
1713if test "$mtd" != "yes" ; then
1714 mtd="no"
1715fi
1716cat > $TMPC << EOF
1717#include <string.h>
1718#include <mtd/mtd-user.h>
1719#include <sys/ioctl.h>
1720int main(int argc, char **argv)
1721{
1722 struct mtd_write_req ops;
1723 struct mtd_info_user info;
1724 memset(&ops, 0, sizeof(ops));
1725 info.type = MTD_MLCNANDFLASH;
1726 return ioctl(0, MEMGETINFO, &info);
1727}
1728EOF
1729if compile_prog "" "" "mtd"; then
1730 mtd="yes"
1731fi
1732echo "MTD $mtd"
1733
1734##########################################
1735# Check whether we have libpmem
1736if test "$libpmem" != "yes" ; then
1737 libpmem="no"
1738fi
1739cat > $TMPC << EOF
1740#include <libpmem.h>
1741int main(int argc, char **argv)
1742{
1743 int rc;
1744 rc = pmem_is_pmem(0, 0);
1745 return 0;
1746}
1747EOF
1748if compile_prog "" "-lpmem" "libpmem"; then
1749 libpmem="yes"
1750 LIBS="-lpmem $LIBS"
1751fi
1752echo "libpmem $libpmem"
1753
1754##########################################
1755# Check whether we have libpmemblk
1756# libpmem is a prerequisite
1757if test "$libpmemblk" != "yes" ; then
1758 libpmemblk="no"
1759fi
1760if test "$libpmem" = "yes"; then
1761 cat > $TMPC << EOF
1762#include <libpmemblk.h>
1763int main(int argc, char **argv)
1764{
1765 PMEMblkpool *pbp;
1766 pbp = pmemblk_open("", 0);
1767 return 0;
1768}
1769EOF
1770 if compile_prog "" "-lpmemblk" "libpmemblk"; then
1771 libpmemblk="yes"
1772 LIBS="-lpmemblk $LIBS"
1773 fi
1774fi
1775echo "libpmemblk $libpmemblk"
1776
1777# Choose the ioengines
1778if test "$libpmem" = "yes" && test "$disable_pmem" = "no"; then
1779 devdax="yes"
1780 if test "$libpmemblk" = "yes"; then
1781 pmemblk="yes"
1782 fi
1783fi
1784
1785##########################################
1786# Report whether pmemblk engine is enabled
1787echo "NVML pmemblk engine $pmemblk"
1788
1789##########################################
1790# Report whether dev-dax engine is enabled
1791echo "NVML dev-dax engine $devdax"
1792
1793# Check if we have lex/yacc available
1794yacc="no"
1795yacc_is_bison="no"
1796lex="no"
1797arith="no"
1798if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
1799if test "$targetos" != "SunOS" ; then
1800LEX=$(which lex 2> /dev/null)
1801if test -x "$LEX" ; then
1802 lex="yes"
1803fi
1804YACC=$(which bison 2> /dev/null)
1805if test -x "$YACC" ; then
1806 yacc="yes"
1807 yacc_is_bison="yes"
1808else
1809 YACC=$(which yacc 2> /dev/null)
1810 if test -x "$YACC" ; then
1811 yacc="yes"
1812 fi
1813fi
1814if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1815 arith="yes"
1816fi
1817
1818if test "$arith" = "yes" ; then
1819cat > $TMPC << EOF
1820extern int yywrap(void);
1821
1822int main(int argc, char **argv)
1823{
1824 yywrap();
1825 return 0;
1826}
1827EOF
1828if compile_prog "" "-ll" "lex"; then
1829 LIBS="-ll $LIBS"
1830else
1831 arith="no"
1832fi
1833fi
1834fi
1835fi
1836
1837# Check if lex fails using -o
1838if test "$arith" = "yes" ; then
1839if test "$force_no_lex_o" = "yes" ; then
1840 lex_use_o="no"
1841else
1842$LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1843if test "$?" = "0" ; then
1844 lex_use_o="yes"
1845else
1846 lex_use_o="no"
1847fi
1848fi
1849fi
1850
1851echo "lex/yacc for arithmetic $arith"
1852
1853##########################################
1854# Check whether we have setmntent/getmntent
1855if test "$getmntent" != "yes" ; then
1856 getmntent="no"
1857fi
1858cat > $TMPC << EOF
1859#include <stdio.h>
1860#include <mntent.h>
1861int main(int argc, char **argv)
1862{
1863 FILE *mtab = setmntent(NULL, "r");
1864 struct mntent *mnt = getmntent(mtab);
1865 endmntent(mtab);
1866 return 0;
1867}
1868EOF
1869if compile_prog "" "" "getmntent"; then
1870 getmntent="yes"
1871fi
1872echo "getmntent $getmntent"
1873
1874##########################################
1875# Check whether we have getmntinfo
1876# These are originally added for BSDs, but may also work
1877# on other operating systems with getmntinfo(3).
1878
1879# getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
1880# Note that NetBSD needs -Werror to catch warning as error.
1881if test "$getmntinfo" != "yes" ; then
1882 getmntinfo="no"
1883fi
1884cat > $TMPC << EOF
1885#include <stdio.h>
1886#include <sys/param.h>
1887#include <sys/mount.h>
1888int main(int argc, char **argv)
1889{
1890 struct statfs *st;
1891 return getmntinfo(&st, MNT_NOWAIT);
1892}
1893EOF
1894if compile_prog "-Werror" "" "getmntinfo"; then
1895 getmntinfo="yes"
1896fi
1897echo "getmntinfo $getmntinfo"
1898
1899# getmntinfo(3) for NetBSD.
1900if test "$getmntinfo_statvfs" != "yes" ; then
1901 getmntinfo_statvfs="no"
1902fi
1903cat > $TMPC << EOF
1904#include <stdio.h>
1905#include <sys/statvfs.h>
1906int main(int argc, char **argv)
1907{
1908 struct statvfs *st;
1909 return getmntinfo(&st, MNT_NOWAIT);
1910}
1911EOF
1912# Skip the test if the one with statfs arg is detected.
1913if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
1914 getmntinfo_statvfs="yes"
1915 echo "getmntinfo_statvfs $getmntinfo_statvfs"
1916fi
1917
1918##########################################
1919# Check whether we have _Static_assert
1920if test "$static_assert" != "yes" ; then
1921 static_assert="no"
1922fi
1923cat > $TMPC << EOF
1924#include <assert.h>
1925#include <stdlib.h>
1926#undef offsetof
1927#ifdef __compiler_offsetof
1928#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
1929#else
1930#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1931#endif
1932
1933#define container_of(ptr, type, member) ({ \
1934 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
1935 (type *)( (char *)__mptr - offsetof(type,member) );})
1936
1937struct foo {
1938 int a, b;
1939};
1940
1941int main(int argc, char **argv)
1942{
1943 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
1944 return 0 ;
1945}
1946EOF
1947if compile_prog "" "" "static_assert"; then
1948 static_assert="yes"
1949fi
1950echo "Static Assert $static_assert"
1951
1952##########################################
1953# Check whether we have bool / stdbool.h
1954if test "$have_bool" != "yes" ; then
1955 have_bool="no"
1956fi
1957cat > $TMPC << EOF
1958#include <stdbool.h>
1959int main(int argc, char **argv)
1960{
1961 bool var = true;
1962 return var != false;
1963}
1964EOF
1965if compile_prog "" "" "bool"; then
1966 have_bool="yes"
1967fi
1968echo "bool $have_bool"
1969
1970##########################################
1971# check march=armv8-a+crc+crypto
1972if test "$march_armv8_a_crc_crypto" != "yes" ; then
1973 march_armv8_a_crc_crypto="no"
1974fi
1975if test "$cpu" = "arm64" ; then
1976 cat > $TMPC <<EOF
1977#include <sys/auxv.h>
1978#include <arm_acle.h>
1979#include <arm_neon.h>
1980
1981int main(void)
1982{
1983 return 0;
1984}
1985EOF
1986 if compile_prog "-march=armv8-a+crc+crypto" "" ""; then
1987 march_armv8_a_crc_crypto="yes"
1988 CFLAGS="$CFLAGS -march=armv8-a+crc+crypto -DARCH_HAVE_CRC_CRYPTO"
1989 fi
1990fi
1991echo "march_armv8_a_crc_crypto $march_armv8_a_crc_crypto"
1992
1993
1994#############################################################################
1995
1996if test "$wordsize" = "64" ; then
1997 output_sym "CONFIG_64BIT"
1998elif test "$wordsize" = "32" ; then
1999 output_sym "CONFIG_32BIT"
2000else
2001 fatal "Unknown wordsize!"
2002fi
2003if test "$bigendian" = "yes" ; then
2004 output_sym "CONFIG_BIG_ENDIAN"
2005else
2006 output_sym "CONFIG_LITTLE_ENDIAN"
2007fi
2008if test "$zlib" = "yes" ; then
2009 output_sym "CONFIG_ZLIB"
2010fi
2011if test "$libaio" = "yes" ; then
2012 output_sym "CONFIG_LIBAIO"
2013fi
2014if test "$posix_aio" = "yes" ; then
2015 output_sym "CONFIG_POSIXAIO"
2016fi
2017if test "$posix_aio_fsync" = "yes" ; then
2018 output_sym "CONFIG_POSIXAIO_FSYNC"
2019fi
2020if test "$posix_pshared" = "yes" ; then
2021 output_sym "CONFIG_PSHARED"
2022fi
2023if test "$linux_fallocate" = "yes" ; then
2024 output_sym "CONFIG_LINUX_FALLOCATE"
2025fi
2026if test "$posix_fallocate" = "yes" ; then
2027 output_sym "CONFIG_POSIX_FALLOCATE"
2028fi
2029if test "$fdatasync" = "yes" ; then
2030 output_sym "CONFIG_FDATASYNC"
2031fi
2032if test "$sync_file_range" = "yes" ; then
2033 output_sym "CONFIG_SYNC_FILE_RANGE"
2034fi
2035if test "$sfaa" = "yes" ; then
2036 output_sym "CONFIG_SFAA"
2037fi
2038if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
2039 output_sym "CONFIG_RDMA"
2040fi
2041if test "$clock_gettime" = "yes" ; then
2042 output_sym "CONFIG_CLOCK_GETTIME"
2043fi
2044if test "$clock_monotonic" = "yes" ; then
2045 output_sym "CONFIG_CLOCK_MONOTONIC"
2046fi
2047if test "$clock_monotonic_raw" = "yes" ; then
2048 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
2049fi
2050if test "$clock_monotonic_precise" = "yes" ; then
2051 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
2052fi
2053if test "$clockid_t" = "yes"; then
2054 output_sym "CONFIG_CLOCKID_T"
2055fi
2056if test "$gettimeofday" = "yes" ; then
2057 output_sym "CONFIG_GETTIMEOFDAY"
2058fi
2059if test "$posix_fadvise" = "yes" ; then
2060 output_sym "CONFIG_POSIX_FADVISE"
2061fi
2062if test "$linux_3arg_affinity" = "yes" ; then
2063 output_sym "CONFIG_3ARG_AFFINITY"
2064elif test "$linux_2arg_affinity" = "yes" ; then
2065 output_sym "CONFIG_2ARG_AFFINITY"
2066fi
2067if test "$strsep" = "yes" ; then
2068 output_sym "CONFIG_STRSEP"
2069fi
2070if test "$strcasestr" = "yes" ; then
2071 output_sym "CONFIG_STRCASESTR"
2072fi
2073if test "$strlcat" = "yes" ; then
2074 output_sym "CONFIG_STRLCAT"
2075fi
2076if test "$getopt_long_only" = "yes" ; then
2077 output_sym "CONFIG_GETOPT_LONG_ONLY"
2078fi
2079if test "$inet_aton" = "yes" ; then
2080 output_sym "CONFIG_INET_ATON"
2081fi
2082if test "$socklen_t" = "yes" ; then
2083 output_sym "CONFIG_SOCKLEN_T"
2084fi
2085if test "$ext4_me" = "yes" ; then
2086 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
2087fi
2088if test "$linux_splice" = "yes" ; then
2089 output_sym "CONFIG_LINUX_SPLICE"
2090fi
2091if test "$guasi" = "yes" ; then
2092 output_sym "CONFIG_GUASI"
2093fi
2094if test "$fusion_aw" = "yes" ; then
2095 output_sym "CONFIG_FUSION_AW"
2096fi
2097if test "$libnuma_v2" = "yes" ; then
2098 output_sym "CONFIG_LIBNUMA"
2099fi
2100if test "$solaris_aio" = "yes" ; then
2101 output_sym "CONFIG_SOLARISAIO"
2102fi
2103if test "$tls_thread" = "yes" ; then
2104 output_sym "CONFIG_TLS_THREAD"
2105fi
2106if test "$rusage_thread" = "yes" ; then
2107 output_sym "CONFIG_RUSAGE_THREAD"
2108fi
2109if test "$gfio" = "yes" ; then
2110 echo "CONFIG_GFIO=y" >> $config_host_mak
2111fi
2112if test "$esx" = "yes" ; then
2113 output_sym "CONFIG_ESX"
2114 output_sym "CONFIG_NO_SHM"
2115fi
2116if test "$sched_idle" = "yes" ; then
2117 output_sym "CONFIG_SCHED_IDLE"
2118fi
2119if test "$tcp_nodelay" = "yes" ; then
2120 output_sym "CONFIG_TCP_NODELAY"
2121fi
2122if test "$window_size" = "yes" ; then
2123 output_sym "CONFIG_NET_WINDOWSIZE"
2124fi
2125if test "$mss" = "yes" ; then
2126 output_sym "CONFIG_NET_MSS"
2127fi
2128if test "$rlimit_memlock" = "yes" ; then
2129 output_sym "CONFIG_RLIMIT_MEMLOCK"
2130fi
2131if test "$pwritev" = "yes" ; then
2132 output_sym "CONFIG_PWRITEV"
2133fi
2134if test "$pwritev2" = "yes" ; then
2135 output_sym "CONFIG_PWRITEV2"
2136fi
2137if test "$ipv6" = "yes" ; then
2138 output_sym "CONFIG_IPV6"
2139fi
2140if test "$rbd" = "yes" ; then
2141 output_sym "CONFIG_RBD"
2142fi
2143if test "$rbd_poll" = "yes" ; then
2144 output_sym "CONFIG_RBD_POLL"
2145fi
2146if test "$rbd_inval" = "yes" ; then
2147 output_sym "CONFIG_RBD_INVAL"
2148fi
2149if test "$rbd_blkin" = "yes" ; then
2150 output_sym "CONFIG_RBD_BLKIN"
2151fi
2152if test "$setvbuf" = "yes" ; then
2153 output_sym "CONFIG_SETVBUF"
2154fi
2155if test "$s390_z196_facilities" = "yes" ; then
2156 output_sym "CONFIG_S390_Z196_FACILITIES"
2157 CFLAGS="$CFLAGS -march=z9-109"
2158fi
2159if test "$gfapi" = "yes" ; then
2160 output_sym "CONFIG_GFAPI"
2161fi
2162if test "$gf_fadvise" = "yes" ; then
2163 output_sym "CONFIG_GF_FADVISE"
2164fi
2165if test "$gf_trim" = "yes" ; then
2166 output_sym "CONFIG_GF_TRIM"
2167fi
2168if test "$libhdfs" = "yes" ; then
2169 output_sym "CONFIG_LIBHDFS"
2170 echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
2171 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
2172 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
2173 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
2174 fi
2175if test "$mtd" = "yes" ; then
2176 output_sym "CONFIG_MTD"
2177fi
2178if test "$pmemblk" = "yes" ; then
2179 output_sym "CONFIG_PMEMBLK"
2180fi
2181if test "$devdax" = "yes" ; then
2182 output_sym "CONFIG_LINUX_DEVDAX"
2183fi
2184if test "$arith" = "yes" ; then
2185 output_sym "CONFIG_ARITHMETIC"
2186 if test "$yacc_is_bison" = "yes" ; then
2187 echo "YACC=$YACC -y" >> $config_host_mak
2188 else
2189 echo "YACC=$YACC" >> $config_host_mak
2190 fi
2191 if test "$lex_use_o" = "yes" ; then
2192 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
2193 fi
2194fi
2195if test "$getmntent" = "yes" ; then
2196 output_sym "CONFIG_GETMNTENT"
2197fi
2198if test "$getmntinfo" = "yes" ; then
2199 output_sym "CONFIG_GETMNTINFO"
2200fi
2201if test "$getmntinfo_statvfs" = "yes" ; then
2202 output_sym "CONFIG_GETMNTINFO_STATVFS"
2203fi
2204if test "$static_assert" = "yes" ; then
2205 output_sym "CONFIG_STATIC_ASSERT"
2206fi
2207if test "$have_bool" = "yes" ; then
2208 output_sym "CONFIG_HAVE_BOOL"
2209fi
2210if test "$disable_opt" = "yes" ; then
2211 output_sym "CONFIG_DISABLE_OPTIMIZATIONS"
2212fi
2213
2214if test "$zlib" = "no" ; then
2215 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
2216fi
2217
2218echo "LIBS+=$LIBS" >> $config_host_mak
2219echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
2220echo "CFLAGS+=$CFLAGS" >> $config_host_mak
2221echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
2222echo "CC=$cc" >> $config_host_mak
2223echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
2224echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
2225
2226if [ `dirname $0` != "." -a ! -e Makefile ]; then
2227 cat > Makefile <<EOF
2228SRCDIR:=`dirname $0`
2229include \$(SRCDIR)/Makefile
2230EOF
2231fi