Makefile: fix path to tools/fiologparser.py
[fio.git] / configure
CommitLineData
67bf9823
JA
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"
4feafb1e
JA
27config_host_h="config-host.h"
28
29rm -rf $config_host_mak
30rm -rf $config_host_h
67bf9823 31
d7145a78
JA
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
44404c5a 40# Default CFLAGS
af4862b3
JA
41CFLAGS="-D_GNU_SOURCE -include config-host.h"
42BUILD_CFLAGS=""
67bf9823
JA
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
7560fe7c
JA
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
67bf9823
JA
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."
d7145a78 81 fatal "You can run configure with --disable-werror to bypass this check."
67bf9823
JA
82}
83
84compile_object() {
85 do_cc $CFLAGS -c -o $TMPO $TMPC
86}
87
88compile_prog() {
89 local_cflags="$1"
adaa46d8 90 local_ldflags="$2 $LIBS"
67bf9823
JA
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
c55d728b 97 packages=$2
67bf9823
JA
98
99 echo "ERROR"
100 echo "ERROR: User requested feature $feature"
c55d728b
JA
101 if test ! -z "$packages" ; then
102 echo "ERROR: That feature needs $packages installed"
103 fi
67bf9823 104 echo "ERROR: configure was not able to find it"
d7145a78 105 fatal "ERROR"
67bf9823
JA
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
4feafb1e
JA
125output_sym() {
126 echo "$1=y" >> $config_host_mak
127 echo "#define $1" >> $config_host_h
128}
129
67bf9823
JA
130targetos=""
131cpu=""
132
91f94d5b 133# default options
47f44635
JA
134show_help="no"
135exit_val=0
ebec2094 136gfio_check="no"
1b10477b 137libhdfs="no"
43f3cec2 138pmemblk="no"
de26b824 139disable_lex=""
020d54bd 140prefix=/usr/local
91f94d5b 141
cb1125b0
JA
142# parse options
143for opt do
144 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
145 case "$opt" in
020d54bd
JA
146 --prefix=*) prefix="$optarg"
147 ;;
8b156d8e
JA
148 --cpu=*) cpu="$optarg"
149 ;;
c8931876
JA
150 # esx is cross compiled and cannot be detect through simple uname calls
151 --esx)
152 esx="yes"
153 ;;
cb1125b0
JA
154 --cc=*) CC="$optarg"
155 ;;
208e4c8b
JA
156 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
157 ;;
b7c12794 158 --build-32bit-win) build_32bit_win="yes"
7409711b 159 ;;
d2aeedb9
JA
160 --build-static) build_static="yes"
161 ;;
91f94d5b 162 --enable-gfio)
ebec2094 163 gfio_check="yes"
899fab33 164 ;;
44462517
CF
165 --disable-numa) disable_numa="yes"
166 ;;
ce18290e
TM
167 --disable-rbd) disable_rbd="yes"
168 ;;
169 --disable-gfapi) disable_gfapi="yes"
170 ;;
1b10477b
MM
171 --enable-libhdfs) libhdfs="yes"
172 ;;
43f3cec2
BB
173 --enable-pmemblk) pmemblk="yes"
174 ;;
a655bbc4
JA
175 --disable-lex) disable_lex="yes"
176 ;;
de26b824
JA
177 --enable-lex) disable_lex="no"
178 ;;
61054f0d
JA
179 --disable-shm) no_shm="yes"
180 ;;
181 --disable-optimizations) disable_opt="yes"
ba40757e 182 ;;
827da4f5 183 --help)
47f44635 184 show_help="yes"
827da4f5 185 ;;
cb1125b0
JA
186 *)
187 echo "Bad option $opt"
47f44635
JA
188 show_help="yes"
189 exit_val=1
cb1125b0
JA
190 esac
191done
192
47f44635 193if test "$show_help" = "yes" ; then
020d54bd 194 echo "--prefix= Use this directory as installation prefix"
8b156d8e 195 echo "--cpu= Specify target CPU if auto-detect fails"
b7a99316 196 echo "--cc= Specify compiler to use"
899fab33 197 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
b7c12794 198 echo "--build-32bit-win Enable 32-bit build on Windows"
d2aeedb9 199 echo "--build-static Build a static fio"
c8931876 200 echo "--esx Configure build options for esx"
b7a99316 201 echo "--enable-gfio Enable building of gtk gfio"
44462517 202 echo "--disable-numa Disable libnuma even if found"
c44ff511 203 echo "--disable-gfapi Disable gfapi"
1b10477b 204 echo "--enable-libhdfs Enable hdfs support"
43f3cec2 205 echo "--enable-pmemblk Enable NVML libpmemblk support"
a655bbc4 206 echo "--disable-lex Disable use of lex/yacc for math"
de26b824 207 echo "--enable-lex Enable use of lex/yacc for math"
c44ff511 208 echo "--disable-shm Disable SHM support"
61054f0d 209 echo "--disable-optimizations Don't enable compiler optimizations"
b7a99316 210 exit $exit_val
47f44635
JA
211fi
212
47986339
SH
213cross_prefix=${cross_prefix-${CROSS_COMPILE}}
214cc="${CC-${cross_prefix}gcc}"
215
6d0e9f83
AC
216if check_define __ANDROID__ ; then
217 targetos="Android"
218elif check_define __linux__ ; then
67bf9823 219 targetos="Linux"
67bf9823
JA
220elif check_define __OpenBSD__ ; then
221 targetos='OpenBSD'
222elif check_define __sun__ ; then
223 targetos='SunOS'
7cb024f8 224 CFLAGS="$CFLAGS -D_REENTRANT"
b24f59ab
SH
225elif check_define _WIN32 ; then
226 targetos='CYGWIN'
67bf9823
JA
227else
228 targetos=`uname -s`
229fi
230
53cd4eee
AC
231echo "# Automatically generated by configure - do not modify" > $config_host_mak
232printf "# Configured with:" >> $config_host_mak
233printf " '%s'" "$0" "$@" >> $config_host_mak
234echo >> $config_host_mak
235echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
236
61054f0d
JA
237if test "$no_shm" = "yes" ; then
238 output_sym "CONFIG_NO_SHM"
239fi
240
241if test "$disable_opt" = "yes" ; then
242 output_sym "CONFIG_FIO_NO_OPT"
243fi
244
67bf9823
JA
245# Some host OSes need non-standard checks for which CPU to use.
246# Note that these checks are broken for cross-compilation: if you're
247# cross-compiling to one of these OSes then you'll need to specify
248# the correct CPU with the --cpu option.
249case $targetos in
de26b824
JA
250AIX)
251 # Unless explicitly enabled, turn off lex.
252 if test -z "$disable_lex" ; then
253 disable_lex="yes"
daf705b5
JA
254 else
255 force_no_lex_o="yes"
de26b824
JA
256 fi
257 ;;
67bf9823
JA
258Darwin)
259 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
260 # we can run 64-bit userspace code.
261 # If the user didn't specify a CPU explicitly and the kernel says this is
262 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
263 # detection code.
264 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
265 cpu="x86_64"
266 fi
267 ;;
268SunOS)
269 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
270 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
271 cpu="x86_64"
272 fi
adaa46d8 273 LIBS="-lnsl -lsocket"
cfd94f79
JA
274 ;;
275CYGWIN*)
276 echo "Forcing known good options on Windows"
4578d01f 277 if test -z "$CC" ; then
7409711b
HL
278 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
279 CC="i686-w64-mingw32-gcc"
280 else
281 CC="x86_64-w64-mingw32-gcc"
282 fi
4578d01f 283 fi
4feafb1e 284 output_sym "CONFIG_LITTLE_ENDIAN"
7409711b
HL
285 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
286 output_sym "CONFIG_32BIT"
287 else
288 output_sym "CONFIG_64BIT_LLP64"
289 fi
4feafb1e
JA
290 output_sym "CONFIG_FADVISE"
291 output_sym "CONFIG_SOCKLEN_T"
4feafb1e
JA
292 output_sym "CONFIG_FADVISE"
293 output_sym "CONFIG_SFAA"
294 output_sym "CONFIG_RUSAGE_THREAD"
295 output_sym "CONFIG_WINDOWSAIO"
296 output_sym "CONFIG_FDATASYNC"
59308a64 297 output_sym "CONFIG_CLOCK_MONOTONIC"
dc0518ca
BC
298 output_sym "CONFIG_GETTIMEOFDAY"
299 output_sym "CONFIG_CLOCK_GETTIME"
7e09a9f1 300 output_sym "CONFIG_SCHED_IDLE"
1eafa37a 301 output_sym "CONFIG_TCP_NODELAY"
7d6be13a 302 output_sym "CONFIG_TLS_THREAD"
ef07baa1 303 output_sym "CONFIG_IPV6"
4feafb1e 304 echo "CC=$CC" >> $config_host_mak
af4862b3 305 echo "BUILD_CFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
cfd94f79 306 exit 0
6d0e9f83 307 ;;
67bf9823
JA
308esac
309
310if test ! -z "$cpu" ; then
311 # command line argument
312 :
313elif check_define __i386__ ; then
314 cpu="i386"
315elif check_define __x86_64__ ; then
316 cpu="x86_64"
317elif check_define __sparc__ ; then
318 if check_define __arch64__ ; then
319 cpu="sparc64"
320 else
321 cpu="sparc"
322 fi
323elif check_define _ARCH_PPC ; then
324 if check_define _ARCH_PPC64 ; then
325 cpu="ppc64"
326 else
327 cpu="ppc"
328 fi
329elif check_define __mips__ ; then
330 cpu="mips"
331elif check_define __ia64__ ; then
332 cpu="ia64"
333elif check_define __s390__ ; then
334 if check_define __s390x__ ; then
335 cpu="s390x"
336 else
337 cpu="s390"
338 fi
339elif check_define __arm__ ; then
340 cpu="arm"
341elif check_define __hppa__ ; then
342 cpu="hppa"
343else
344 cpu=`uname -m`
345fi
346
347# Normalise host CPU name and set ARCH.
348case "$cpu" in
349 ia64|ppc|ppc64|s390|s390x|sparc64)
350 cpu="$cpu"
351 ;;
352 i386|i486|i586|i686|i86pc|BePC)
353 cpu="i386"
354 ;;
355 x86_64|amd64)
356 cpu="x86_64"
357 ;;
358 armv*b|armv*l|arm)
359 cpu="arm"
360 ;;
361 hppa|parisc|parisc64)
362 cpu="hppa"
363 ;;
364 mips*)
365 cpu="mips"
366 ;;
367 sparc|sun4[cdmuv])
368 cpu="sparc"
369 ;;
370 *)
8b156d8e 371 echo "Unknown CPU"
67bf9823
JA
372 ;;
373esac
374
dcbbf5b0 375if test -z "$CC" ; then
67bf9823
JA
376 if test "$targetos" = "FreeBSD"; then
377 if has clang; then
378 CC=clang
379 else
380 CC=gcc
381 fi
67bf9823
JA
382 fi
383fi
384
385cc="${CC-${cross_prefix}gcc}"
386
1a17cfdb
AC
387##########################################
388# check cross compile
389
390cross_compile="no"
391cat > $TMPC <<EOF
392int main(void)
393{
394 return 0;
395}
396EOF
397if compile_prog "" "" "cross"; then
398 $TMPE 2>/dev/null || cross_compile="yes"
399else
400 fatal "compile test failed"
401fi
402
0dcebdf4
JA
403##########################################
404# check endianness
405bigendian="no"
1a17cfdb
AC
406if test "$cross_compile" = "no" ; then
407 cat > $TMPC <<EOF
0dcebdf4
JA
408#include <inttypes.h>
409int main(void)
410{
411 volatile uint32_t i=0x01234567;
412 return (*((uint8_t*)(&i))) == 0x67;
413}
414EOF
1a17cfdb
AC
415 if compile_prog "" "" "endian"; then
416 $TMPE && bigendian="yes"
417 fi
418else
419 # If we're cross compiling, try our best to work it out and rely on the
420 # run-time check to fail if we get it wrong.
421 cat > $TMPC <<EOF
422#include <endian.h>
423int main(void)
424{
425#if __BYTE_ORDER != __BIG_ENDIAN
426# error "Unknown endianness"
427#endif
428}
429EOF
430 compile_prog "" "" "endian" && bigendian="yes"
431 check_define "__ARMEB__" && bigendian="yes"
432 check_define "__MIPSEB__" && bigendian="yes"
0dcebdf4
JA
433fi
434
435
67bf9823
JA
436echo "Operating system $targetos"
437echo "CPU $cpu"
0dcebdf4 438echo "Big endian $bigendian"
67bf9823 439echo "Compiler $cc"
1a17cfdb 440echo "Cross compile $cross_compile"
67bf9823
JA
441echo
442
d2aeedb9
JA
443##########################################
444# See if we need to build a static build
445if test "$build_static" = "yes" ; then
446 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
447 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
448else
449 build_static="no"
450fi
451echo "Static build $build_static"
452
67bf9823
JA
453##########################################
454# check for wordsize
455wordsize="0"
456cat > $TMPC <<EOF
142429e5
AC
457#include <limits.h>
458#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
67bf9823
JA
459int main(void)
460{
142429e5 461 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
67bf9823
JA
462 return 0;
463}
464EOF
142429e5
AC
465if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
466 wordsize="32"
467elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
468 wordsize="64"
469else
470 fatal "Unknown wordsize"
67bf9823
JA
471fi
472echo "Wordsize $wordsize"
473
a9bca4aa
JA
474##########################################
475# zlib probe
476zlib="no"
477cat > $TMPC <<EOF
804a1e05 478#include <zlib.h>
a9bca4aa
JA
479int main(void)
480{
481 z_stream stream;
482 if (inflateInit(&stream) != Z_OK)
483 return 1;
484 return 0;
485}
486EOF
487if compile_prog "" "-lz" "zlib" ; then
488 zlib=yes
489 LIBS="-lz $LIBS"
a9bca4aa
JA
490fi
491echo "zlib $zlib"
492
67bf9823
JA
493##########################################
494# linux-aio probe
495libaio="no"
7c77ebef 496if test "$esx" != "yes" ; then
497 cat > $TMPC <<EOF
67bf9823
JA
498#include <libaio.h>
499#include <stddef.h>
500int main(void)
501{
502 io_setup(0, NULL);
503 return 0;
504}
505EOF
7c77ebef 506 if compile_prog "" "-laio" "libaio" ; then
507 libaio=yes
508 LIBS="-laio $LIBS"
509 else
510 if test "$libaio" = "yes" ; then
511 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
512 fi
513 libaio=no
67bf9823 514 fi
67bf9823
JA
515fi
516echo "Linux AIO support $libaio"
517
518##########################################
519# posix aio probe
520posix_aio="no"
521posix_aio_lrt="no"
522cat > $TMPC <<EOF
523#include <aio.h>
524int main(void)
525{
526 struct aiocb cb;
527 aio_read(&cb);
528 return 0;
529}
530EOF
531if compile_prog "" "" "posixaio" ; then
532 posix_aio="yes"
533elif compile_prog "" "-lrt" "posixaio"; then
534 posix_aio="yes"
535 posix_aio_lrt="yes"
536 LIBS="-lrt $LIBS"
537fi
538echo "POSIX AIO support $posix_aio"
539echo "POSIX AIO support needs -lrt $posix_aio_lrt"
540
541##########################################
542# posix aio fsync probe
543posix_aio_fsync="no"
544if test "$posix_aio" = "yes" ; then
545 cat > $TMPC <<EOF
546#include <fcntl.h>
547#include <aio.h>
548int main(void)
549{
550 struct aiocb cb;
551 return aio_fsync(O_SYNC, &cb);
552 return 0;
553}
554EOF
555 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
556 posix_aio_fsync=yes
557 fi
558fi
559echo "POSIX AIO fsync $posix_aio_fsync"
560
561##########################################
562# solaris aio probe
563solaris_aio="no"
564cat > $TMPC <<EOF
565#include <sys/types.h>
566#include <sys/asynch.h>
567#include <unistd.h>
568int main(void)
569{
570 aio_result_t res;
571 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
572 return 0;
573}
574EOF
575if compile_prog "" "-laio" "solarisaio" ; then
576 solaris_aio=yes
577 LIBS="-laio $LIBS"
578fi
579echo "Solaris AIO support $solaris_aio"
580
581##########################################
f5cd2907 582# __sync_fetch_and_add test
67bf9823
JA
583sfaa="no"
584cat > $TMPC << EOF
958886d8
JA
585#include <inttypes.h>
586static int sfaa(uint64_t *ptr)
67bf9823 587{
9c639a76 588 return __sync_fetch_and_add(ptr, 0);
67bf9823
JA
589}
590
591int main(int argc, char **argv)
592{
958886d8 593 uint64_t val = 42;
67bf9823
JA
594 sfaa(&val);
595 return val;
596}
597EOF
598if compile_prog "" "" "__sync_fetch_and_add()" ; then
599 sfaa="yes"
600fi
9c639a76 601echo "__sync_fetch_and_add $sfaa"
67bf9823
JA
602
603##########################################
604# libverbs probe
605libverbs="no"
606cat > $TMPC << EOF
607#include <stdio.h>
608#include <infiniband/arch.h>
609int main(int argc, char **argv)
610{
611 struct ibv_pd *pd = ibv_alloc_pd(NULL);
612 return 0;
613}
614EOF
615if compile_prog "" "-libverbs" "libverbs" ; then
616 libverbs="yes"
617 LIBS="-libverbs $LIBS"
618fi
619echo "libverbs $libverbs"
620
621##########################################
622# rdmacm probe
623rdmacm="no"
624cat > $TMPC << EOF
625#include <stdio.h>
626#include <rdma/rdma_cma.h>
627int main(int argc, char **argv)
628{
629 rdma_destroy_qp(NULL);
630 return 0;
631}
632EOF
633if compile_prog "" "-lrdmacm" "rdma"; then
634 rdmacm="yes"
635 LIBS="-lrdmacm $LIBS"
636fi
637echo "rdmacm $rdmacm"
638
639##########################################
640# Linux fallocate probe
641linux_fallocate="no"
642cat > $TMPC << EOF
643#include <stdio.h>
aa6738a5 644#include <fcntl.h>
67bf9823
JA
645#include <linux/falloc.h>
646int main(int argc, char **argv)
647{
648 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
649 return r;
650}
651EOF
652if compile_prog "" "" "linux_fallocate"; then
653 linux_fallocate="yes"
654fi
655echo "Linux fallocate $linux_fallocate"
656
657##########################################
658# POSIX fadvise probe
659posix_fadvise="no"
660cat > $TMPC << EOF
661#include <stdio.h>
662#include <fcntl.h>
663int main(int argc, char **argv)
664{
665 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
666 return r;
667}
668EOF
669if compile_prog "" "" "posix_fadvise"; then
670 posix_fadvise="yes"
671fi
672echo "POSIX fadvise $posix_fadvise"
673
674##########################################
675# POSIX fallocate probe
676posix_fallocate="no"
677cat > $TMPC << EOF
678#include <stdio.h>
679#include <fcntl.h>
680int main(int argc, char **argv)
681{
682 int r = posix_fallocate(0, 0, 1024);
683 return r;
684}
685EOF
686if compile_prog "" "" "posix_fallocate"; then
687 posix_fallocate="yes"
688fi
689echo "POSIX fallocate $posix_fallocate"
690
691##########################################
692# sched_set/getaffinity 2 or 3 argument test
693linux_2arg_affinity="no"
694linux_3arg_affinity="no"
695cat > $TMPC << EOF
67bf9823
JA
696#include <sched.h>
697int main(int argc, char **argv)
698{
699 cpu_set_t mask;
700 return sched_setaffinity(0, sizeof(mask), &mask);
701}
702EOF
703if compile_prog "" "" "sched_setaffinity(,,)"; then
704 linux_3arg_affinity="yes"
705else
706 cat > $TMPC << EOF
67bf9823
JA
707#include <sched.h>
708int main(int argc, char **argv)
709{
710 cpu_set_t mask;
711 return sched_setaffinity(0, &mask);
712}
713EOF
714 if compile_prog "" "" "sched_setaffinity(,)"; then
715 linux_2arg_affinity="yes"
716 fi
717fi
718echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
719echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
720
721##########################################
722# clock_gettime probe
723clock_gettime="no"
724cat > $TMPC << EOF
725#include <stdio.h>
726#include <time.h>
727int main(int argc, char **argv)
728{
729 return clock_gettime(0, NULL);
730}
731EOF
732if compile_prog "" "" "clock_gettime"; then
733 clock_gettime="yes"
734elif compile_prog "" "-lrt" "clock_gettime"; then
735 clock_gettime="yes"
736 LIBS="-lrt $LIBS"
737fi
738echo "clock_gettime $clock_gettime"
739
740##########################################
741# CLOCK_MONOTONIC probe
742clock_monotonic="no"
743if test "$clock_gettime" = "yes" ; then
744 cat > $TMPC << EOF
745#include <stdio.h>
746#include <time.h>
747int main(int argc, char **argv)
748{
749 return clock_gettime(CLOCK_MONOTONIC, NULL);
750}
751EOF
752 if compile_prog "" "$LIBS" "clock monotonic"; then
753 clock_monotonic="yes"
754 fi
755fi
756echo "CLOCK_MONOTONIC $clock_monotonic"
757
c544f604
SN
758##########################################
759# CLOCK_MONOTONIC_RAW probe
760clock_monotonic_raw="no"
761if test "$clock_gettime" = "yes" ; then
762 cat > $TMPC << EOF
763#include <stdio.h>
764#include <time.h>
765int main(int argc, char **argv)
766{
767 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
768}
769EOF
770 if compile_prog "" "$LIBS" "clock monotonic"; then
771 clock_monotonic_raw="yes"
772 fi
773fi
774echo "CLOCK_MONOTONIC_RAW $clock_monotonic_raw"
775
67bf9823
JA
776##########################################
777# CLOCK_MONOTONIC_PRECISE probe
778clock_monotonic_precise="no"
779if test "$clock_gettime" = "yes" ; then
780 cat > $TMPC << EOF
781#include <stdio.h>
782#include <time.h>
783int main(int argc, char **argv)
784{
785 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
786}
787EOF
788 if compile_prog "" "$LIBS" "clock monotonic precise"; then
789 clock_monotonic_precise="yes"
790 fi
791fi
792echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
793
794##########################################
795# gettimeofday() probe
796gettimeofday="no"
797cat > $TMPC << EOF
798#include <sys/time.h>
799#include <stdio.h>
800int main(int argc, char **argv)
801{
802 struct timeval tv;
803 return gettimeofday(&tv, NULL);
804}
805EOF
806if compile_prog "" "" "gettimeofday"; then
807 gettimeofday="yes"
808fi
809echo "gettimeofday $gettimeofday"
810
811##########################################
812# fdatasync() probe
813fdatasync="no"
814cat > $TMPC << EOF
815#include <stdio.h>
816#include <unistd.h>
817int main(int argc, char **argv)
818{
819 return fdatasync(0);
820}
821EOF
822if compile_prog "" "" "fdatasync"; then
823 fdatasync="yes"
824fi
825echo "fdatasync $fdatasync"
826
827##########################################
828# sync_file_range() probe
829sync_file_range="no"
830cat > $TMPC << EOF
831#include <stdio.h>
832#include <unistd.h>
67bf9823
JA
833#include <fcntl.h>
834#include <linux/fs.h>
835int main(int argc, char **argv)
836{
837 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
838 SYNC_FILE_RANGE_WAIT_AFTER;
839 return sync_file_range(0, 0, 0, flags);
840}
841EOF
842if compile_prog "" "" "sync_file_range"; then
843 sync_file_range="yes"
844fi
845echo "sync_file_range $sync_file_range"
846
847##########################################
848# ext4 move extent probe
849ext4_me="no"
850cat > $TMPC << EOF
851#include <fcntl.h>
852#include <sys/ioctl.h>
853int main(int argc, char **argv)
854{
855 struct move_extent me;
856 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
857}
858EOF
c7165b8d
JA
859if compile_prog "" "" "ext4 move extent" ; then
860 ext4_me="yes"
861elif test $targetos = "Linux" ; then
862 # On Linux, just default to it on and let it error at runtime if we really
863 # don't have it. None of my updated systems have it defined, but it does
864 # work. Takes a while to bubble back.
67bf9823
JA
865 ext4_me="yes"
866fi
867echo "EXT4 move extent $ext4_me"
868
869##########################################
870# splice probe
871linux_splice="no"
872cat > $TMPC << EOF
67bf9823
JA
873#include <stdio.h>
874#include <fcntl.h>
875int main(int argc, char **argv)
876{
877 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
878}
879EOF
880if compile_prog "" "" "linux splice"; then
881 linux_splice="yes"
882fi
883echo "Linux splice(2) $linux_splice"
884
885##########################################
886# GUASI probe
887guasi="no"
888cat > $TMPC << EOF
889#include <guasi.h>
890#include <guasi_syscalls.h>
891int main(int argc, char **argv)
892{
893 guasi_t ctx = guasi_create(0, 0, 0);
894 return 0;
895}
896EOF
897if compile_prog "" "" "guasi"; then
898 guasi="yes"
899fi
900echo "GUASI $guasi"
901
902##########################################
903# fusion-aw probe
904fusion_aw="no"
905cat > $TMPC << EOF
b2c77c25 906#include <nvm/nvm_primitives.h>
67bf9823
JA
907int main(int argc, char **argv)
908{
b2c77c25
SK
909 nvm_version_t ver_info;
910 nvm_handle_t handle;
911
912 handle = nvm_get_handle(0, &ver_info);
913 return nvm_atomic_write(handle, 0, 0, 0);
67bf9823
JA
914}
915EOF
92aef550
ARJ
916if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
917 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
67bf9823
JA
918 fusion_aw="yes"
919fi
920echo "Fusion-io atomic engine $fusion_aw"
921
922##########################################
923# libnuma probe
924libnuma="no"
925cat > $TMPC << EOF
926#include <numa.h>
927int main(int argc, char **argv)
928{
929 return numa_available();
930}
931EOF
44462517 932if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
67bf9823
JA
933 libnuma="yes"
934 LIBS="-lnuma $LIBS"
935fi
936echo "libnuma $libnuma"
937
50206d9b
JA
938##########################################
939# libnuma 2.x version API
940if test "$libnuma" = "yes" ; then
941libnuma_v2="no"
942cat > $TMPC << EOF
943#include <numa.h>
944int main(int argc, char **argv)
945{
946 struct bitmask *mask = numa_parse_nodestring(NULL);
61bde962 947 return mask->size == 0;
50206d9b
JA
948}
949EOF
950if compile_prog "" "" "libnuma api"; then
951 libnuma_v2="yes"
952fi
953echo "libnuma v2 $libnuma_v2"
954fi
955
67bf9823
JA
956##########################################
957# strsep() probe
958strsep="no"
959cat > $TMPC << EOF
960#include <string.h>
961int main(int argc, char **argv)
962{
ae156be6
JA
963 static char *string = "This is a string";
964 strsep(&string, "needle");
67bf9823
JA
965 return 0;
966}
967EOF
968if compile_prog "" "" "strsep"; then
969 strsep="yes"
970fi
971echo "strsep $strsep"
972
9ad8da82
JA
973##########################################
974# strcasestr() probe
975strcasestr="no"
976cat > $TMPC << EOF
977#include <string.h>
978int main(int argc, char **argv)
979{
aa6738a5 980 return strcasestr(argv[0], argv[1]) != NULL;
9ad8da82
JA
981}
982EOF
983if compile_prog "" "" "strcasestr"; then
984 strcasestr="yes"
985fi
986echo "strcasestr $strcasestr"
987
5ad7be56
KD
988##########################################
989# strlcat() probe
990strlcat="no"
991cat > $TMPC << EOF
992#include <string.h>
993int main(int argc, char **argv)
994{
995 static char dst[64];
996 static char *string = "This is a string";
997 memset(dst, 0, sizeof(dst));
998 strlcat(dst, string, sizeof(dst));
999 return 0;
1000}
1001EOF
1002if compile_prog "" "" "strlcat"; then
1003 strlcat="yes"
1004fi
1005echo "strlcat $strlcat"
1006
67bf9823
JA
1007##########################################
1008# getopt_long_only() probe
1009getopt_long_only="no"
1010cat > $TMPC << EOF
1011#include <unistd.h>
1012#include <stdio.h>
aa6738a5 1013#include <getopt.h>
67bf9823
JA
1014int main(int argc, char **argv)
1015{
1016 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1017 return c;
1018}
1019EOF
1020if compile_prog "" "" "getopt_long_only"; then
1021 getopt_long_only="yes"
1022fi
1023echo "getopt_long_only() $getopt_long_only"
1024
1025##########################################
1026# inet_aton() probe
1027inet_aton="no"
1028cat > $TMPC << EOF
1029#include <sys/socket.h>
1030#include <arpa/inet.h>
1031#include <stdio.h>
1032int main(int argc, char **argv)
1033{
1034 struct in_addr in;
1035 return inet_aton(NULL, &in);
1036}
1037EOF
1038if compile_prog "" "" "inet_aton"; then
1039 inet_aton="yes"
1040fi
1041echo "inet_aton $inet_aton"
1042
1043##########################################
1044# socklen_t probe
1045socklen_t="no"
1046cat > $TMPC << EOF
f6482613 1047#include <sys/socket.h>
67bf9823
JA
1048int main(int argc, char **argv)
1049{
1050 socklen_t len = 0;
1051 return len;
1052}
1053EOF
1054if compile_prog "" "" "socklen_t"; then
1055 socklen_t="yes"
1056fi
1057echo "socklen_t $socklen_t"
1058
1059##########################################
1060# Whether or not __thread is supported for TLS
1061tls_thread="no"
1062cat > $TMPC << EOF
1063#include <stdio.h>
aa6738a5 1064static __thread int ret;
67bf9823
JA
1065int main(int argc, char **argv)
1066{
1067 return ret;
1068}
1069EOF
1070if compile_prog "" "" "__thread"; then
1071 tls_thread="yes"
1072fi
1073echo "__thread $tls_thread"
1074
91f94d5b 1075##########################################
2639f056 1076# Check if we have required gtk/glib support for gfio
ebec2094
JA
1077gfio="no"
1078if test "$gfio_check" = "yes" ; then
91f94d5b
JA
1079 cat > $TMPC << EOF
1080#include <glib.h>
1081#include <cairo.h>
1082#include <gtk/gtk.h>
1083int main(void)
1084{
1085 gdk_threads_enter();
91f94d5b 1086 gdk_threads_leave();
b7a99316
JA
1087
1088 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
91f94d5b
JA
1089}
1090EOF
1091GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
86719845
JA
1092ORG_LDFLAGS=$LDFLAGS
1093LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
91f94d5b
JA
1094if test "$?" != "0" ; then
1095 echo "configure: gtk and gthread not found"
1096 exit 1
1097fi
1098GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1099if test "$?" != "0" ; then
1100 echo "configure: gtk and gthread not found"
1101 exit 1
1102fi
b7a99316
JA
1103if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1104 r=$($TMPE)
1105 if test "$r" != "0" ; then
1106 gfio="yes"
86719845 1107 GFIO_LIBS="$LIBS $GTK_LIBS"
b7a99316
JA
1108 CFLAGS="$CFLAGS $GTK_CFLAGS"
1109 else
1110 echo "GTK found, but need version 2.18 or higher"
1111 gfio="no"
1112 fi
91f94d5b
JA
1113else
1114 echo "Please install gtk and gdk libraries"
1115 gfio="no"
1116fi
86719845 1117LDFLAGS=$ORG_LDFLAGS
91f94d5b
JA
1118fi
1119
ebec2094
JA
1120if test "$gfio_check" = "yes" ; then
1121 echo "gtk 2.18 or higher $gfio"
1122fi
91f94d5b 1123
44404c5a
JA
1124# Check whether we have getrusage(RUSAGE_THREAD)
1125rusage_thread="no"
1126cat > $TMPC << EOF
1127#include <sys/time.h>
1128#include <sys/resource.h>
1129int main(int argc, char **argv)
1130{
1131 struct rusage ru;
1132 getrusage(RUSAGE_THREAD, &ru);
1133 return 0;
1134}
1135EOF
1136if compile_prog "" "" "RUSAGE_THREAD"; then
1137 rusage_thread="yes"
1138fi
1139echo "RUSAGE_THREAD $rusage_thread"
1140
7e09a9f1
JA
1141##########################################
1142# Check whether we have SCHED_IDLE
1143sched_idle="no"
1144cat > $TMPC << EOF
1145#include <sched.h>
1146int main(int argc, char **argv)
1147{
1148 struct sched_param p;
1149 return sched_setscheduler(0, SCHED_IDLE, &p);
1150}
1151EOF
1152if compile_prog "" "" "SCHED_IDLE"; then
1153 sched_idle="yes"
1154fi
1155echo "SCHED_IDLE $sched_idle"
1156
1eafa37a
JA
1157##########################################
1158# Check whether we have TCP_NODELAY
1159tcp_nodelay="no"
1160cat > $TMPC << EOF
1161#include <stdio.h>
1162#include <sys/types.h>
1163#include <sys/socket.h>
1164#include <netinet/tcp.h>
1165int main(int argc, char **argv)
1166{
1167 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1168}
1169EOF
1170if compile_prog "" "" "TCP_NODELAY"; then
1171 tcp_nodelay="yes"
1172fi
1173echo "TCP_NODELAY $tcp_nodelay"
1174
1008602c
JA
1175##########################################
1176# Check whether we have SO_SNDBUF
1177window_size="no"
1178cat > $TMPC << EOF
1179#include <stdio.h>
1180#include <sys/types.h>
1181#include <sys/socket.h>
1182#include <netinet/tcp.h>
1183int main(int argc, char **argv)
1184{
1185 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1186 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1187}
1188EOF
1189if compile_prog "" "" "SO_SNDBUF"; then
1190 window_size="yes"
1191fi
1192echo "Net engine window_size $window_size"
1193
e5f34d95
JA
1194##########################################
1195# Check whether we have TCP_MAXSEG
1196mss="no"
1197cat > $TMPC << EOF
1198#include <stdio.h>
1199#include <sys/types.h>
1200#include <sys/socket.h>
1201#include <netinet/tcp.h>
1202#include <arpa/inet.h>
1203#include <netinet/in.h>
1204int main(int argc, char **argv)
1205{
1206 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1207}
1208EOF
1209if compile_prog "" "" "TCP_MAXSEG"; then
1210 mss="yes"
1211fi
1212echo "TCP_MAXSEG $mss"
1213
38b9354a
JA
1214##########################################
1215# Check whether we have RLIMIT_MEMLOCK
1216rlimit_memlock="no"
1217cat > $TMPC << EOF
1218#include <sys/time.h>
1219#include <sys/resource.h>
1220int main(int argc, char **argv)
1221{
1222 struct rlimit rl;
1223 return getrlimit(RLIMIT_MEMLOCK, &rl);
1224}
1225EOF
1226if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1227 rlimit_memlock="yes"
1228fi
1229echo "RLIMIT_MEMLOCK $rlimit_memlock"
1230
07fc0acd
JA
1231##########################################
1232# Check whether we have pwritev/preadv
1233pwritev="no"
1234cat > $TMPC << EOF
1235#include <stdio.h>
1236#include <sys/uio.h>
1237int main(int argc, char **argv)
1238{
1239 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1240}
1241EOF
1242if compile_prog "" "" "pwritev"; then
1243 pwritev="yes"
1244fi
1245echo "pwritev/preadv $pwritev"
1246
2cafffbe
JA
1247##########################################
1248# Check whether we have pwritev2/preadv2
1249pwritev2="no"
1250cat > $TMPC << EOF
1251#include <stdio.h>
1252#include <sys/uio.h>
1253int main(int argc, char **argv)
1254{
1255 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1256}
1257EOF
1258if compile_prog "" "" "pwritev2"; then
1259 pwritev2="yes"
1260fi
1261echo "pwritev2/preadv2 $pwritev2"
1262
ecad55e9
JA
1263##########################################
1264# Check whether we have the required functions for ipv6
1265ipv6="no"
1266cat > $TMPC << EOF
1267#include <sys/types.h>
1268#include <sys/socket.h>
d219028d 1269#include <netinet/in.h>
ecad55e9
JA
1270#include <netdb.h>
1271#include <stdio.h>
1272int main(int argc, char **argv)
1273{
1274 struct addrinfo hints;
1275 struct in6_addr addr;
1276 int ret;
1277
1278 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1279 freeaddrinfo(NULL);
1280 printf("%s\n", gai_strerror(ret));
1281 addr = in6addr_any;
1282 return 0;
1283}
1284EOF
1285if compile_prog "" "" "ipv6"; then
1286 ipv6="yes"
1287fi
1288echo "IPv6 helpers $ipv6"
07fc0acd 1289
fc5c0345
DG
1290##########################################
1291# check for rbd
1292rbd="no"
1293cat > $TMPC << EOF
1294#include <rbd/librbd.h>
1295
1296int main(int argc, char **argv)
1297{
1298
1299 rados_t cluster;
1300 rados_ioctx_t io_ctx;
1301 const char pool[] = "rbd";
1302
1303 int major, minor, extra;
1304 rbd_version(&major, &minor, &extra);
1305
1306 rados_ioctx_create(cluster, pool, &io_ctx);
1307 return 0;
1308}
1309EOF
ce18290e 1310if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
fc5c0345
DG
1311 LIBS="-lrbd -lrados $LIBS"
1312 rbd="yes"
1313fi
1314echo "Rados Block Device engine $rbd"
1315
903b2812
JA
1316##########################################
1317# check for rbd_invaidate_cache()
1318rbd_inval="no"
1319if test "$rbd" = "yes"; then
1320cat > $TMPC << EOF
1321#include <rbd/librbd.h>
1322
1323int main(int argc, char **argv)
1324{
1325 rbd_image_t image;
1326
1327 return rbd_invalidate_cache(image);
1328}
1329EOF
1330if compile_prog "" "-lrbd -lrados" "rbd"; then
1331 rbd_inval="yes"
1332fi
1333echo "rbd_invalidate_cache $rbd_inval"
1334fi
1335
2e802282
JA
1336##########################################
1337# Check whether we have setvbuf
1338setvbuf="no"
1339cat > $TMPC << EOF
1340#include <stdio.h>
1341int main(int argc, char **argv)
1342{
1343 FILE *f = NULL;
1344 char buf[80];
1345 setvbuf(f, buf, _IOFBF, sizeof(buf));
1346 return 0;
1347}
1348EOF
1349if compile_prog "" "" "setvbuf"; then
1350 setvbuf="yes"
1351fi
1352echo "setvbuf $setvbuf"
fc5c0345 1353
6e7d7dfb 1354# check for gfapi
1355gfapi="no"
1356cat > $TMPC << EOF
1357#include <glusterfs/api/glfs.h>
1358
1359int main(int argc, char **argv)
1360{
1361
1362 glfs_t *g = glfs_new("foo");
1363
1364 return 0;
1365}
1366EOF
ce18290e 1367if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
6e7d7dfb 1368 LIBS="-lgfapi -lglusterfs $LIBS"
1369 gfapi="yes"
1370fi
6fa14b99 1371 echo "Gluster API engine $gfapi"
6e7d7dfb 1372
6fa14b99 1373##########################################
1374# check for gfapi fadvise support
6876c98c 1375if test "$gfapi" = "yes" ; then
6fa14b99 1376gf_fadvise="no"
1377cat > $TMPC << EOF
1378#include <glusterfs/api/glfs.h>
1379
1380int main(int argc, char **argv)
1381{
1382 struct glfs_fd *fd;
1383 int ret = glfs_fadvise(fd, 0, 0, 1);
1384
1385 return 0;
1386}
1387EOF
6fa14b99 1388if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1389 gf_fadvise="yes"
1390fi
1391echo "Gluster API use fadvise $gf_fadvise"
6876c98c
JA
1392fi
1393
1394##########################################
1395# check for gfapi trim support
1396gf_trim="no"
1397if test "$gfapi" = "yes" ; then
1398cat > $TMPC << EOF
1399#include <glusterfs/api/glfs.h>
1400
1401int main(int argc, char **argv)
1402{
1403 return glfs_discard_async(NULL, 0, 0);
1404}
1405EOF
1406if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1407 gf_trim="yes"
1408fi
1409echo "Gluster API trim support $gf_trim"
1410fi
fc5c0345 1411
81795ce3
CE
1412##########################################
1413# Check if we support stckf on s390
1414s390_z196_facilities="no"
1415cat > $TMPC << EOF
1416#define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1417int main(int argc, char **argv)
1418{
1419 /* We want just 1 double word to be returned. */
1420 register unsigned long reg0 asm("0") = 0;
1421 unsigned long stfle_bits;
1422 asm volatile(".machine push" "\n\t"
1423 ".machine \"z9-109\"" "\n\t"
1424 "stfle %0" "\n\t"
1425 ".machine pop" "\n"
1426 : "=QS" (stfle_bits), "+d" (reg0)
1427 : : "cc");
1428
1429 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1430 return 0;
1431 else
1432 return -1;
1433}
1434EOF
1435if compile_prog "" "" "s390_z196_facilities"; then
1436 $TMPE
1437 if [[ $? -eq 0 ]]; then
1438 s390_z196_facilities="yes"
1439 fi
1440fi
1441echo "s390_z196_facilities $s390_z196_facilities"
1b10477b
MM
1442
1443##########################################
1444# Check if we have required environment variables configured for libhdfs
1445if test "$libhdfs" = "yes" ; then
1446 hdfs_conf_error=0
1447 if test "$JAVA_HOME" = "" ; then
1448 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1449 hdfs_conf_error=1
1450 fi
1451 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1452 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1453 hdfs_conf_error=1
1454 fi
1455 if test "$FIO_LIBHDFS_LIB" = "" ; then
1456 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1457 hdfs_conf_error=1
1458 fi
1459 if test "$hdfs_conf_error" = "1" ; then
1460 exit 1
1461 fi
1462fi
1463echo "HDFS engine $libhdfs"
1464
b8116a87
DE
1465##########################################
1466# Check whether we have MTD
1467mtd="no"
1468cat > $TMPC << EOF
0e1c454a 1469#include <string.h>
b8116a87
DE
1470#include <mtd/mtd-user.h>
1471#include <sys/ioctl.h>
1472int main(int argc, char **argv)
1473{
0e1c454a 1474 struct mtd_write_req ops;
b8116a87 1475 struct mtd_info_user info;
0e1c454a 1476 memset(&ops, 0, sizeof(ops));
400cd0ff 1477 info.type = MTD_MLCNANDFLASH;
b8116a87
DE
1478 return ioctl(0, MEMGETINFO, &info);
1479}
1480EOF
1481if compile_prog "" "" "mtd"; then
1482 mtd="yes"
1483fi
1484echo "MTD $mtd"
1485
43f3cec2
BB
1486##########################################
1487# Report whether pmemblk engine is enabled
1488echo "NVML libpmemblk engine $pmemblk"
1489
b470a02c
SC
1490# Check if we have lex/yacc available
1491yacc="no"
e7b2c7a3 1492yacc_is_bison="no"
b470a02c
SC
1493lex="no"
1494arith="no"
de26b824 1495if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
cf6dd80e 1496if test "$targetos" != "SunOS" ; then
e7b2c7a3 1497LEX=$(which lex 2> /dev/null)
b470a02c
SC
1498if test -x "$LEX" ; then
1499 lex="yes"
1500fi
7e0049e9 1501YACC=$(which bison 2> /dev/null)
b470a02c
SC
1502if test -x "$YACC" ; then
1503 yacc="yes"
7e0049e9 1504 yacc_is_bison="yes"
e7b2c7a3 1505else
7e0049e9 1506 YACC=$(which yacc 2> /dev/null)
e7b2c7a3
JA
1507 if test -x "$YACC" ; then
1508 yacc="yes"
e7b2c7a3 1509 fi
b470a02c
SC
1510fi
1511if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1512 arith="yes"
1513fi
1514
1515if test "$arith" = "yes" ; then
1516cat > $TMPC << EOF
1517extern int yywrap(void);
1518
1519int main(int argc, char **argv)
1520{
1521 yywrap();
1522 return 0;
1523}
1524EOF
719cda03
JA
1525if compile_prog "" "-ll" "lex"; then
1526 LIBS="-ll $LIBS"
b470a02c
SC
1527else
1528 arith="no"
1529fi
1530fi
cf6dd80e 1531fi
a655bbc4 1532fi
b470a02c 1533
63bda378
JA
1534# Check if lex fails using -o
1535if test "$arith" = "yes" ; then
daf705b5
JA
1536if test "$force_no_lex_o" = "yes" ; then
1537 lex_use_o="no"
1538else
63bda378
JA
1539$LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1540if test "$?" = "0" ; then
1541 lex_use_o="yes"
1542else
1543 lex_use_o="no"
1544fi
1545fi
daf705b5 1546fi
63bda378 1547
b470a02c
SC
1548echo "lex/yacc for arithmetic $arith"
1549
aae599ba
JA
1550##########################################
1551# Check whether we have setmntent/getmntent
1552getmntent="no"
1553cat > $TMPC << EOF
1554#include <stdio.h>
1555#include <mntent.h>
1556int main(int argc, char **argv)
1557{
1558 FILE *mtab = setmntent(NULL, "r");
1559 struct mntent *mnt = getmntent(mtab);
1581b82a 1560 endmntent(mtab);
aae599ba
JA
1561 return 0;
1562}
1563EOF
1564if compile_prog "" "" "getmntent"; then
1565 getmntent="yes"
1566fi
1567echo "getmntent $getmntent"
1568
e7e136da
TK
1569##########################################
1570# Check whether we have getmntinfo
1571getmntinfo="no"
1572cat > $TMPC << EOF
1573#include <stdio.h>
1574#include <sys/param.h>
1575#include <sys/mount.h>
1576int main(int argc, char **argv)
1577{
1578 struct statfs st;
1579 return getmntinfo(&st, MNT_NOWAIT);
1580}
1581EOF
1582if compile_prog "" "" "getmntinfo"; then
1583 getmntinfo="yes"
1584fi
1585echo "getmntinfo $getmntinfo"
1586
5018f79f
AH
1587##########################################
1588# Check whether we have _Static_assert
1589static_assert="no"
1590cat > $TMPC << EOF
1591#include <assert.h>
94815a5c
JA
1592#include <stdlib.h>
1593#undef offsetof
1594#ifdef __compiler_offsetof
1595#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
1596#else
1597#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1598#endif
1599
1600#define container_of(ptr, type, member) ({ \
1601 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
1602 (type *)( (char *)__mptr - offsetof(type,member) );})
1603
1604struct foo {
1605 int a, b;
1606};
1607
5018f79f
AH
1608int main(int argc, char **argv)
1609{
94815a5c 1610 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
5018f79f
AH
1611 return 0 ;
1612}
1613EOF
1614if compile_prog "" "" "static_assert"; then
1615 static_assert="yes"
1616fi
1617echo "Static Assert $static_assert"
e39c0676
JA
1618
1619##########################################
1620# Check whether we have bool / stdbool.h
1621have_bool="no"
1622cat > $TMPC << EOF
1623#include <stdbool.h>
1624int main(int argc, char **argv)
1625{
1626 bool var = true;
1627 return var != false;
1628}
1629EOF
1630if compile_prog "" "" "bool"; then
1631 have_bool="yes"
1632fi
1633echo "bool $have_bool"
1634
67bf9823
JA
1635#############################################################################
1636
67bf9823 1637if test "$wordsize" = "64" ; then
4feafb1e 1638 output_sym "CONFIG_64BIT"
67bf9823 1639elif test "$wordsize" = "32" ; then
4feafb1e 1640 output_sym "CONFIG_32BIT"
67bf9823 1641else
d7145a78 1642 fatal "Unknown wordsize!"
67bf9823 1643fi
0dcebdf4 1644if test "$bigendian" = "yes" ; then
4feafb1e 1645 output_sym "CONFIG_BIG_ENDIAN"
0dcebdf4 1646else
4feafb1e 1647 output_sym "CONFIG_LITTLE_ENDIAN"
0dcebdf4 1648fi
3989b143
JA
1649if test "$zlib" = "yes" ; then
1650 output_sym "CONFIG_ZLIB"
1651fi
67bf9823 1652if test "$libaio" = "yes" ; then
4feafb1e 1653 output_sym "CONFIG_LIBAIO"
67bf9823
JA
1654fi
1655if test "$posix_aio" = "yes" ; then
4feafb1e 1656 output_sym "CONFIG_POSIXAIO"
67bf9823
JA
1657fi
1658if test "$posix_aio_fsync" = "yes" ; then
4feafb1e 1659 output_sym "CONFIG_POSIXAIO_FSYNC"
67bf9823
JA
1660fi
1661if test "$linux_fallocate" = "yes" ; then
4feafb1e 1662 output_sym "CONFIG_LINUX_FALLOCATE"
67bf9823
JA
1663fi
1664if test "$posix_fallocate" = "yes" ; then
4feafb1e 1665 output_sym "CONFIG_POSIX_FALLOCATE"
67bf9823
JA
1666fi
1667if test "$fdatasync" = "yes" ; then
4feafb1e 1668 output_sym "CONFIG_FDATASYNC"
67bf9823
JA
1669fi
1670if test "$sync_file_range" = "yes" ; then
4feafb1e 1671 output_sym "CONFIG_SYNC_FILE_RANGE"
67bf9823
JA
1672fi
1673if test "$sfaa" = "yes" ; then
4feafb1e 1674 output_sym "CONFIG_SFAA"
67bf9823 1675fi
954cd73a 1676if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
4feafb1e 1677 output_sym "CONFIG_RDMA"
67bf9823
JA
1678fi
1679if test "$clock_gettime" = "yes" ; then
4feafb1e 1680 output_sym "CONFIG_CLOCK_GETTIME"
67bf9823
JA
1681fi
1682if test "$clock_monotonic" = "yes" ; then
4feafb1e 1683 output_sym "CONFIG_CLOCK_MONOTONIC"
67bf9823 1684fi
c544f604
SN
1685if test "$clock_monotonic_raw" = "yes" ; then
1686 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
1687fi
67bf9823 1688if test "$clock_monotonic_precise" = "yes" ; then
4feafb1e 1689 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
67bf9823
JA
1690fi
1691if test "$gettimeofday" = "yes" ; then
4feafb1e 1692 output_sym "CONFIG_GETTIMEOFDAY"
67bf9823
JA
1693fi
1694if test "$posix_fadvise" = "yes" ; then
4feafb1e 1695 output_sym "CONFIG_POSIX_FADVISE"
67bf9823
JA
1696fi
1697if test "$linux_3arg_affinity" = "yes" ; then
4feafb1e 1698 output_sym "CONFIG_3ARG_AFFINITY"
67bf9823 1699elif test "$linux_2arg_affinity" = "yes" ; then
4feafb1e 1700 output_sym "CONFIG_2ARG_AFFINITY"
67bf9823
JA
1701fi
1702if test "$strsep" = "yes" ; then
4feafb1e 1703 output_sym "CONFIG_STRSEP"
67bf9823 1704fi
9ad8da82
JA
1705if test "$strcasestr" = "yes" ; then
1706 output_sym "CONFIG_STRCASESTR"
1707fi
5ad7be56
KD
1708if test "$strlcat" = "yes" ; then
1709 output_sym "CONFIG_STRLCAT"
1710fi
67bf9823 1711if test "$getopt_long_only" = "yes" ; then
4feafb1e 1712 output_sym "CONFIG_GETOPT_LONG_ONLY"
67bf9823
JA
1713fi
1714if test "$inet_aton" = "yes" ; then
4feafb1e 1715 output_sym "CONFIG_INET_ATON"
67bf9823
JA
1716fi
1717if test "$socklen_t" = "yes" ; then
4feafb1e 1718 output_sym "CONFIG_SOCKLEN_T"
67bf9823
JA
1719fi
1720if test "$ext4_me" = "yes" ; then
4feafb1e 1721 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
67bf9823
JA
1722fi
1723if test "$linux_splice" = "yes" ; then
4feafb1e 1724 output_sym "CONFIG_LINUX_SPLICE"
67bf9823
JA
1725fi
1726if test "$guasi" = "yes" ; then
4feafb1e 1727 output_sym "CONFIG_GUASI"
67bf9823
JA
1728fi
1729if test "$fusion_aw" = "yes" ; then
4feafb1e 1730 output_sym "CONFIG_FUSION_AW"
67bf9823 1731fi
50206d9b 1732if test "$libnuma_v2" = "yes" ; then
4feafb1e 1733 output_sym "CONFIG_LIBNUMA"
67bf9823
JA
1734fi
1735if test "$solaris_aio" = "yes" ; then
4feafb1e 1736 output_sym "CONFIG_SOLARISAIO"
67bf9823
JA
1737fi
1738if test "$tls_thread" = "yes" ; then
4feafb1e 1739 output_sym "CONFIG_TLS_THREAD"
67bf9823 1740fi
44404c5a 1741if test "$rusage_thread" = "yes" ; then
4feafb1e 1742 output_sym "CONFIG_RUSAGE_THREAD"
67bf9823 1743fi
91f94d5b
JA
1744if test "$gfio" = "yes" ; then
1745 echo "CONFIG_GFIO=y" >> $config_host_mak
1746fi
c8931876
JA
1747if test "$esx" = "yes" ; then
1748 output_sym "CONFIG_ESX"
1749 output_sym "CONFIG_NO_SHM"
1750fi
7e09a9f1
JA
1751if test "$sched_idle" = "yes" ; then
1752 output_sym "CONFIG_SCHED_IDLE"
1753fi
1eafa37a
JA
1754if test "$tcp_nodelay" = "yes" ; then
1755 output_sym "CONFIG_TCP_NODELAY"
1756fi
1008602c
JA
1757if test "$window_size" = "yes" ; then
1758 output_sym "CONFIG_NET_WINDOWSIZE"
1759fi
e5f34d95
JA
1760if test "$mss" = "yes" ; then
1761 output_sym "CONFIG_NET_MSS"
1762fi
38b9354a
JA
1763if test "$rlimit_memlock" = "yes" ; then
1764 output_sym "CONFIG_RLIMIT_MEMLOCK"
1765fi
07fc0acd
JA
1766if test "$pwritev" = "yes" ; then
1767 output_sym "CONFIG_PWRITEV"
1768fi
2cafffbe
JA
1769if test "$pwritev2" = "yes" ; then
1770 output_sym "CONFIG_PWRITEV2"
1771fi
ecad55e9
JA
1772if test "$ipv6" = "yes" ; then
1773 output_sym "CONFIG_IPV6"
1774fi
fc5c0345
DG
1775if test "$rbd" = "yes" ; then
1776 output_sym "CONFIG_RBD"
1777fi
903b2812
JA
1778if test "$rbd_inval" = "yes" ; then
1779 output_sym "CONFIG_RBD_INVAL"
1780fi
2e802282
JA
1781if test "$setvbuf" = "yes" ; then
1782 output_sym "CONFIG_SETVBUF"
1783fi
81795ce3
CE
1784if test "$s390_z196_facilities" = "yes" ; then
1785 output_sym "CONFIG_S390_Z196_FACILITIES"
1786 CFLAGS="$CFLAGS -march=z9-109"
1787fi
6e7d7dfb 1788if test "$gfapi" = "yes" ; then
1789 output_sym "CONFIG_GFAPI"
1790fi
6fa14b99 1791if test "$gf_fadvise" = "yes" ; then
1792 output_sym "CONFIG_GF_FADVISE"
1793fi
6876c98c
JA
1794if test "$gf_trim" = "yes" ; then
1795 output_sym "CONFIG_GF_TRIM"
1796fi
1b10477b
MM
1797if test "$libhdfs" = "yes" ; then
1798 output_sym "CONFIG_LIBHDFS"
1527dc50
FB
1799 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
1800 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
1801 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
1802 fi
b8116a87
DE
1803if test "$mtd" = "yes" ; then
1804 output_sym "CONFIG_MTD"
1805fi
43f3cec2
BB
1806if test "$pmemblk" = "yes" ; then
1807 output_sym "CONFIG_PMEMBLK"
1808fi
b470a02c
SC
1809if test "$arith" = "yes" ; then
1810 output_sym "CONFIG_ARITHMETIC"
e7b2c7a3
JA
1811 if test "$yacc_is_bison" = "yes" ; then
1812 echo "YACC=$YACC -y" >> $config_host_mak
1813 else
1814 echo "YACC=$YACC" >> $config_host_mak
1815 fi
63bda378
JA
1816 if test "$lex_use_o" = "yes" ; then
1817 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
1818 fi
b470a02c 1819fi
aae599ba
JA
1820if test "$getmntent" = "yes" ; then
1821 output_sym "CONFIG_GETMNTENT"
1822fi
e7e136da
TK
1823if test "$getmntinfo" = "yes" ; then
1824 output_sym "CONFIG_GETMNTINFO"
1825fi
5018f79f
AH
1826if test "$static_assert" = "yes" ; then
1827 output_sym "CONFIG_STATIC_ASSERT"
1828fi
e39c0676
JA
1829if test "$have_bool" = "yes" ; then
1830 output_sym "CONFIG_HAVE_BOOL"
1831fi
67bf9823 1832
605cf82e
JA
1833if test "$zlib" = "no" ; then
1834 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
1835fi
1836
67bf9823 1837echo "LIBS+=$LIBS" >> $config_host_mak
86719845 1838echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
91f94d5b 1839echo "CFLAGS+=$CFLAGS" >> $config_host_mak
d2aeedb9 1840echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
67bf9823 1841echo "CC=$cc" >> $config_host_mak
af4862b3 1842echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
020d54bd 1843echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
c61a3a44 1844
59d8f412 1845if [ `dirname $0` != "." -a ! -e Makefile ]; then
c61a3a44
JF
1846 cat > Makefile <<EOF
1847SRCDIR:=`dirname $0`
1848include \$(SRCDIR)/Makefile
1849EOF
1850fi