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