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