lib/rand: make __init_randX() static
[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"
7c77ebef 492if test "$esx" != "yes" ; then
493 cat > $TMPC <<EOF
67bf9823
JA
494#include <libaio.h>
495#include <stddef.h>
496int main(void)
497{
498 io_setup(0, NULL);
499 return 0;
500}
501EOF
7c77ebef 502 if compile_prog "" "-laio" "libaio" ; then
503 libaio=yes
504 LIBS="-laio $LIBS"
505 else
506 if test "$libaio" = "yes" ; then
507 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
508 fi
509 libaio=no
67bf9823 510 fi
67bf9823
JA
511fi
512echo "Linux AIO support $libaio"
513
514##########################################
515# posix aio probe
516posix_aio="no"
517posix_aio_lrt="no"
518cat > $TMPC <<EOF
519#include <aio.h>
520int main(void)
521{
522 struct aiocb cb;
523 aio_read(&cb);
524 return 0;
525}
526EOF
527if compile_prog "" "" "posixaio" ; then
528 posix_aio="yes"
529elif compile_prog "" "-lrt" "posixaio"; then
530 posix_aio="yes"
531 posix_aio_lrt="yes"
532 LIBS="-lrt $LIBS"
533fi
534echo "POSIX AIO support $posix_aio"
535echo "POSIX AIO support needs -lrt $posix_aio_lrt"
536
537##########################################
538# posix aio fsync probe
539posix_aio_fsync="no"
540if test "$posix_aio" = "yes" ; then
541 cat > $TMPC <<EOF
542#include <fcntl.h>
543#include <aio.h>
544int main(void)
545{
546 struct aiocb cb;
547 return aio_fsync(O_SYNC, &cb);
548 return 0;
549}
550EOF
551 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
552 posix_aio_fsync=yes
553 fi
554fi
555echo "POSIX AIO fsync $posix_aio_fsync"
556
557##########################################
558# solaris aio probe
559solaris_aio="no"
560cat > $TMPC <<EOF
561#include <sys/types.h>
562#include <sys/asynch.h>
563#include <unistd.h>
564int main(void)
565{
566 aio_result_t res;
567 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
568 return 0;
569}
570EOF
571if compile_prog "" "-laio" "solarisaio" ; then
572 solaris_aio=yes
573 LIBS="-laio $LIBS"
574fi
575echo "Solaris AIO support $solaris_aio"
576
577##########################################
f5cd2907 578# __sync_fetch_and_add test
67bf9823
JA
579sfaa="no"
580cat > $TMPC << EOF
958886d8
JA
581#include <inttypes.h>
582static int sfaa(uint64_t *ptr)
67bf9823 583{
9c639a76 584 return __sync_fetch_and_add(ptr, 0);
67bf9823
JA
585}
586
587int main(int argc, char **argv)
588{
958886d8 589 uint64_t val = 42;
67bf9823
JA
590 sfaa(&val);
591 return val;
592}
593EOF
594if compile_prog "" "" "__sync_fetch_and_add()" ; then
595 sfaa="yes"
596fi
9c639a76 597echo "__sync_fetch_and_add $sfaa"
67bf9823
JA
598
599##########################################
600# libverbs probe
601libverbs="no"
602cat > $TMPC << EOF
603#include <stdio.h>
604#include <infiniband/arch.h>
605int main(int argc, char **argv)
606{
607 struct ibv_pd *pd = ibv_alloc_pd(NULL);
608 return 0;
609}
610EOF
611if compile_prog "" "-libverbs" "libverbs" ; then
612 libverbs="yes"
613 LIBS="-libverbs $LIBS"
614fi
615echo "libverbs $libverbs"
616
617##########################################
618# rdmacm probe
619rdmacm="no"
620cat > $TMPC << EOF
621#include <stdio.h>
622#include <rdma/rdma_cma.h>
623int main(int argc, char **argv)
624{
625 rdma_destroy_qp(NULL);
626 return 0;
627}
628EOF
629if compile_prog "" "-lrdmacm" "rdma"; then
630 rdmacm="yes"
631 LIBS="-lrdmacm $LIBS"
632fi
633echo "rdmacm $rdmacm"
634
635##########################################
636# Linux fallocate probe
637linux_fallocate="no"
638cat > $TMPC << EOF
639#include <stdio.h>
aa6738a5 640#include <fcntl.h>
67bf9823
JA
641#include <linux/falloc.h>
642int main(int argc, char **argv)
643{
644 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
645 return r;
646}
647EOF
648if compile_prog "" "" "linux_fallocate"; then
649 linux_fallocate="yes"
650fi
651echo "Linux fallocate $linux_fallocate"
652
653##########################################
654# POSIX fadvise probe
655posix_fadvise="no"
656cat > $TMPC << EOF
657#include <stdio.h>
658#include <fcntl.h>
659int main(int argc, char **argv)
660{
661 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
662 return r;
663}
664EOF
665if compile_prog "" "" "posix_fadvise"; then
666 posix_fadvise="yes"
667fi
668echo "POSIX fadvise $posix_fadvise"
669
670##########################################
671# POSIX fallocate probe
672posix_fallocate="no"
673cat > $TMPC << EOF
674#include <stdio.h>
675#include <fcntl.h>
676int main(int argc, char **argv)
677{
678 int r = posix_fallocate(0, 0, 1024);
679 return r;
680}
681EOF
682if compile_prog "" "" "posix_fallocate"; then
683 posix_fallocate="yes"
684fi
685echo "POSIX fallocate $posix_fallocate"
686
687##########################################
688# sched_set/getaffinity 2 or 3 argument test
689linux_2arg_affinity="no"
690linux_3arg_affinity="no"
691cat > $TMPC << EOF
67bf9823
JA
692#include <sched.h>
693int main(int argc, char **argv)
694{
695 cpu_set_t mask;
696 return sched_setaffinity(0, sizeof(mask), &mask);
697}
698EOF
699if compile_prog "" "" "sched_setaffinity(,,)"; then
700 linux_3arg_affinity="yes"
701else
702 cat > $TMPC << EOF
67bf9823
JA
703#include <sched.h>
704int main(int argc, char **argv)
705{
706 cpu_set_t mask;
707 return sched_setaffinity(0, &mask);
708}
709EOF
710 if compile_prog "" "" "sched_setaffinity(,)"; then
711 linux_2arg_affinity="yes"
712 fi
713fi
714echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
715echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
716
717##########################################
718# clock_gettime probe
719clock_gettime="no"
720cat > $TMPC << EOF
721#include <stdio.h>
722#include <time.h>
723int main(int argc, char **argv)
724{
725 return clock_gettime(0, NULL);
726}
727EOF
728if compile_prog "" "" "clock_gettime"; then
729 clock_gettime="yes"
730elif compile_prog "" "-lrt" "clock_gettime"; then
731 clock_gettime="yes"
732 LIBS="-lrt $LIBS"
733fi
734echo "clock_gettime $clock_gettime"
735
736##########################################
737# CLOCK_MONOTONIC probe
738clock_monotonic="no"
739if test "$clock_gettime" = "yes" ; then
740 cat > $TMPC << EOF
741#include <stdio.h>
742#include <time.h>
743int main(int argc, char **argv)
744{
745 return clock_gettime(CLOCK_MONOTONIC, NULL);
746}
747EOF
748 if compile_prog "" "$LIBS" "clock monotonic"; then
749 clock_monotonic="yes"
750 fi
751fi
752echo "CLOCK_MONOTONIC $clock_monotonic"
753
c544f604
SN
754##########################################
755# CLOCK_MONOTONIC_RAW probe
756clock_monotonic_raw="no"
757if test "$clock_gettime" = "yes" ; then
758 cat > $TMPC << EOF
759#include <stdio.h>
760#include <time.h>
761int main(int argc, char **argv)
762{
763 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
764}
765EOF
766 if compile_prog "" "$LIBS" "clock monotonic"; then
767 clock_monotonic_raw="yes"
768 fi
769fi
770echo "CLOCK_MONOTONIC_RAW $clock_monotonic_raw"
771
67bf9823
JA
772##########################################
773# CLOCK_MONOTONIC_PRECISE probe
774clock_monotonic_precise="no"
775if test "$clock_gettime" = "yes" ; then
776 cat > $TMPC << EOF
777#include <stdio.h>
778#include <time.h>
779int main(int argc, char **argv)
780{
781 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
782}
783EOF
784 if compile_prog "" "$LIBS" "clock monotonic precise"; then
785 clock_monotonic_precise="yes"
786 fi
787fi
788echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
789
790##########################################
791# gettimeofday() probe
792gettimeofday="no"
793cat > $TMPC << EOF
794#include <sys/time.h>
795#include <stdio.h>
796int main(int argc, char **argv)
797{
798 struct timeval tv;
799 return gettimeofday(&tv, NULL);
800}
801EOF
802if compile_prog "" "" "gettimeofday"; then
803 gettimeofday="yes"
804fi
805echo "gettimeofday $gettimeofday"
806
807##########################################
808# fdatasync() probe
809fdatasync="no"
810cat > $TMPC << EOF
811#include <stdio.h>
812#include <unistd.h>
813int main(int argc, char **argv)
814{
815 return fdatasync(0);
816}
817EOF
818if compile_prog "" "" "fdatasync"; then
819 fdatasync="yes"
820fi
821echo "fdatasync $fdatasync"
822
823##########################################
824# sync_file_range() probe
825sync_file_range="no"
826cat > $TMPC << EOF
827#include <stdio.h>
828#include <unistd.h>
67bf9823
JA
829#include <fcntl.h>
830#include <linux/fs.h>
831int main(int argc, char **argv)
832{
833 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
834 SYNC_FILE_RANGE_WAIT_AFTER;
835 return sync_file_range(0, 0, 0, flags);
836}
837EOF
838if compile_prog "" "" "sync_file_range"; then
839 sync_file_range="yes"
840fi
841echo "sync_file_range $sync_file_range"
842
843##########################################
844# ext4 move extent probe
845ext4_me="no"
846cat > $TMPC << EOF
847#include <fcntl.h>
848#include <sys/ioctl.h>
849int main(int argc, char **argv)
850{
851 struct move_extent me;
852 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
853}
854EOF
c7165b8d
JA
855if compile_prog "" "" "ext4 move extent" ; then
856 ext4_me="yes"
857elif test $targetos = "Linux" ; then
858 # On Linux, just default to it on and let it error at runtime if we really
859 # don't have it. None of my updated systems have it defined, but it does
860 # work. Takes a while to bubble back.
67bf9823
JA
861 ext4_me="yes"
862fi
863echo "EXT4 move extent $ext4_me"
864
865##########################################
866# splice probe
867linux_splice="no"
868cat > $TMPC << EOF
67bf9823
JA
869#include <stdio.h>
870#include <fcntl.h>
871int main(int argc, char **argv)
872{
873 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
874}
875EOF
876if compile_prog "" "" "linux splice"; then
877 linux_splice="yes"
878fi
879echo "Linux splice(2) $linux_splice"
880
881##########################################
882# GUASI probe
883guasi="no"
884cat > $TMPC << EOF
885#include <guasi.h>
886#include <guasi_syscalls.h>
887int main(int argc, char **argv)
888{
889 guasi_t ctx = guasi_create(0, 0, 0);
890 return 0;
891}
892EOF
893if compile_prog "" "" "guasi"; then
894 guasi="yes"
895fi
896echo "GUASI $guasi"
897
898##########################################
899# fusion-aw probe
900fusion_aw="no"
901cat > $TMPC << EOF
b2c77c25 902#include <nvm/nvm_primitives.h>
67bf9823
JA
903int main(int argc, char **argv)
904{
b2c77c25
SK
905 nvm_version_t ver_info;
906 nvm_handle_t handle;
907
908 handle = nvm_get_handle(0, &ver_info);
909 return nvm_atomic_write(handle, 0, 0, 0);
67bf9823
JA
910}
911EOF
92aef550
ARJ
912if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
913 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
67bf9823
JA
914 fusion_aw="yes"
915fi
916echo "Fusion-io atomic engine $fusion_aw"
917
918##########################################
919# libnuma probe
920libnuma="no"
921cat > $TMPC << EOF
922#include <numa.h>
923int main(int argc, char **argv)
924{
925 return numa_available();
926}
927EOF
44462517 928if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
67bf9823
JA
929 libnuma="yes"
930 LIBS="-lnuma $LIBS"
931fi
932echo "libnuma $libnuma"
933
50206d9b
JA
934##########################################
935# libnuma 2.x version API
936if test "$libnuma" = "yes" ; then
937libnuma_v2="no"
938cat > $TMPC << EOF
939#include <numa.h>
940int main(int argc, char **argv)
941{
942 struct bitmask *mask = numa_parse_nodestring(NULL);
61bde962 943 return mask->size == 0;
50206d9b
JA
944}
945EOF
946if compile_prog "" "" "libnuma api"; then
947 libnuma_v2="yes"
948fi
949echo "libnuma v2 $libnuma_v2"
950fi
951
67bf9823
JA
952##########################################
953# strsep() probe
954strsep="no"
955cat > $TMPC << EOF
956#include <string.h>
957int main(int argc, char **argv)
958{
ae156be6
JA
959 static char *string = "This is a string";
960 strsep(&string, "needle");
67bf9823
JA
961 return 0;
962}
963EOF
964if compile_prog "" "" "strsep"; then
965 strsep="yes"
966fi
967echo "strsep $strsep"
968
9ad8da82
JA
969##########################################
970# strcasestr() probe
971strcasestr="no"
972cat > $TMPC << EOF
973#include <string.h>
974int main(int argc, char **argv)
975{
aa6738a5 976 return strcasestr(argv[0], argv[1]) != NULL;
9ad8da82
JA
977}
978EOF
979if compile_prog "" "" "strcasestr"; then
980 strcasestr="yes"
981fi
982echo "strcasestr $strcasestr"
983
5ad7be56
KD
984##########################################
985# strlcat() probe
986strlcat="no"
987cat > $TMPC << EOF
988#include <string.h>
989int main(int argc, char **argv)
990{
991 static char dst[64];
992 static char *string = "This is a string";
993 memset(dst, 0, sizeof(dst));
994 strlcat(dst, string, sizeof(dst));
995 return 0;
996}
997EOF
998if compile_prog "" "" "strlcat"; then
999 strlcat="yes"
1000fi
1001echo "strlcat $strlcat"
1002
67bf9823
JA
1003##########################################
1004# getopt_long_only() probe
1005getopt_long_only="no"
1006cat > $TMPC << EOF
1007#include <unistd.h>
1008#include <stdio.h>
aa6738a5 1009#include <getopt.h>
67bf9823
JA
1010int main(int argc, char **argv)
1011{
1012 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1013 return c;
1014}
1015EOF
1016if compile_prog "" "" "getopt_long_only"; then
1017 getopt_long_only="yes"
1018fi
1019echo "getopt_long_only() $getopt_long_only"
1020
1021##########################################
1022# inet_aton() probe
1023inet_aton="no"
1024cat > $TMPC << EOF
1025#include <sys/socket.h>
1026#include <arpa/inet.h>
1027#include <stdio.h>
1028int main(int argc, char **argv)
1029{
1030 struct in_addr in;
1031 return inet_aton(NULL, &in);
1032}
1033EOF
1034if compile_prog "" "" "inet_aton"; then
1035 inet_aton="yes"
1036fi
1037echo "inet_aton $inet_aton"
1038
1039##########################################
1040# socklen_t probe
1041socklen_t="no"
1042cat > $TMPC << EOF
f6482613 1043#include <sys/socket.h>
67bf9823
JA
1044int main(int argc, char **argv)
1045{
1046 socklen_t len = 0;
1047 return len;
1048}
1049EOF
1050if compile_prog "" "" "socklen_t"; then
1051 socklen_t="yes"
1052fi
1053echo "socklen_t $socklen_t"
1054
1055##########################################
1056# Whether or not __thread is supported for TLS
1057tls_thread="no"
1058cat > $TMPC << EOF
1059#include <stdio.h>
aa6738a5 1060static __thread int ret;
67bf9823
JA
1061int main(int argc, char **argv)
1062{
1063 return ret;
1064}
1065EOF
1066if compile_prog "" "" "__thread"; then
1067 tls_thread="yes"
1068fi
1069echo "__thread $tls_thread"
1070
91f94d5b 1071##########################################
2639f056 1072# Check if we have required gtk/glib support for gfio
ebec2094
JA
1073gfio="no"
1074if test "$gfio_check" = "yes" ; then
91f94d5b
JA
1075 cat > $TMPC << EOF
1076#include <glib.h>
1077#include <cairo.h>
1078#include <gtk/gtk.h>
1079int main(void)
1080{
1081 gdk_threads_enter();
91f94d5b 1082 gdk_threads_leave();
b7a99316
JA
1083
1084 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
91f94d5b
JA
1085}
1086EOF
1087GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
86719845
JA
1088ORG_LDFLAGS=$LDFLAGS
1089LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
91f94d5b
JA
1090if test "$?" != "0" ; then
1091 echo "configure: gtk and gthread not found"
1092 exit 1
1093fi
1094GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1095if test "$?" != "0" ; then
1096 echo "configure: gtk and gthread not found"
1097 exit 1
1098fi
b7a99316
JA
1099if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1100 r=$($TMPE)
1101 if test "$r" != "0" ; then
1102 gfio="yes"
86719845 1103 GFIO_LIBS="$LIBS $GTK_LIBS"
b7a99316
JA
1104 CFLAGS="$CFLAGS $GTK_CFLAGS"
1105 else
1106 echo "GTK found, but need version 2.18 or higher"
1107 gfio="no"
1108 fi
91f94d5b
JA
1109else
1110 echo "Please install gtk and gdk libraries"
1111 gfio="no"
1112fi
86719845 1113LDFLAGS=$ORG_LDFLAGS
91f94d5b
JA
1114fi
1115
ebec2094
JA
1116if test "$gfio_check" = "yes" ; then
1117 echo "gtk 2.18 or higher $gfio"
1118fi
91f94d5b 1119
44404c5a
JA
1120# Check whether we have getrusage(RUSAGE_THREAD)
1121rusage_thread="no"
1122cat > $TMPC << EOF
1123#include <sys/time.h>
1124#include <sys/resource.h>
1125int main(int argc, char **argv)
1126{
1127 struct rusage ru;
1128 getrusage(RUSAGE_THREAD, &ru);
1129 return 0;
1130}
1131EOF
1132if compile_prog "" "" "RUSAGE_THREAD"; then
1133 rusage_thread="yes"
1134fi
1135echo "RUSAGE_THREAD $rusage_thread"
1136
7e09a9f1
JA
1137##########################################
1138# Check whether we have SCHED_IDLE
1139sched_idle="no"
1140cat > $TMPC << EOF
1141#include <sched.h>
1142int main(int argc, char **argv)
1143{
1144 struct sched_param p;
1145 return sched_setscheduler(0, SCHED_IDLE, &p);
1146}
1147EOF
1148if compile_prog "" "" "SCHED_IDLE"; then
1149 sched_idle="yes"
1150fi
1151echo "SCHED_IDLE $sched_idle"
1152
1eafa37a
JA
1153##########################################
1154# Check whether we have TCP_NODELAY
1155tcp_nodelay="no"
1156cat > $TMPC << EOF
1157#include <stdio.h>
1158#include <sys/types.h>
1159#include <sys/socket.h>
1160#include <netinet/tcp.h>
1161int main(int argc, char **argv)
1162{
1163 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1164}
1165EOF
1166if compile_prog "" "" "TCP_NODELAY"; then
1167 tcp_nodelay="yes"
1168fi
1169echo "TCP_NODELAY $tcp_nodelay"
1170
1008602c
JA
1171##########################################
1172# Check whether we have SO_SNDBUF
1173window_size="no"
1174cat > $TMPC << EOF
1175#include <stdio.h>
1176#include <sys/types.h>
1177#include <sys/socket.h>
1178#include <netinet/tcp.h>
1179int main(int argc, char **argv)
1180{
1181 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1182 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1183}
1184EOF
1185if compile_prog "" "" "SO_SNDBUF"; then
1186 window_size="yes"
1187fi
1188echo "Net engine window_size $window_size"
1189
e5f34d95
JA
1190##########################################
1191# Check whether we have TCP_MAXSEG
1192mss="no"
1193cat > $TMPC << EOF
1194#include <stdio.h>
1195#include <sys/types.h>
1196#include <sys/socket.h>
1197#include <netinet/tcp.h>
1198#include <arpa/inet.h>
1199#include <netinet/in.h>
1200int main(int argc, char **argv)
1201{
1202 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1203}
1204EOF
1205if compile_prog "" "" "TCP_MAXSEG"; then
1206 mss="yes"
1207fi
1208echo "TCP_MAXSEG $mss"
1209
38b9354a
JA
1210##########################################
1211# Check whether we have RLIMIT_MEMLOCK
1212rlimit_memlock="no"
1213cat > $TMPC << EOF
1214#include <sys/time.h>
1215#include <sys/resource.h>
1216int main(int argc, char **argv)
1217{
1218 struct rlimit rl;
1219 return getrlimit(RLIMIT_MEMLOCK, &rl);
1220}
1221EOF
1222if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1223 rlimit_memlock="yes"
1224fi
1225echo "RLIMIT_MEMLOCK $rlimit_memlock"
1226
07fc0acd
JA
1227##########################################
1228# Check whether we have pwritev/preadv
1229pwritev="no"
1230cat > $TMPC << EOF
1231#include <stdio.h>
1232#include <sys/uio.h>
1233int main(int argc, char **argv)
1234{
1235 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1236}
1237EOF
1238if compile_prog "" "" "pwritev"; then
1239 pwritev="yes"
1240fi
1241echo "pwritev/preadv $pwritev"
1242
2cafffbe
JA
1243##########################################
1244# Check whether we have pwritev2/preadv2
1245pwritev2="no"
1246cat > $TMPC << EOF
1247#include <stdio.h>
1248#include <sys/uio.h>
1249int main(int argc, char **argv)
1250{
1251 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1252}
1253EOF
1254if compile_prog "" "" "pwritev2"; then
1255 pwritev2="yes"
1256fi
1257echo "pwritev2/preadv2 $pwritev2"
1258
ecad55e9
JA
1259##########################################
1260# Check whether we have the required functions for ipv6
1261ipv6="no"
1262cat > $TMPC << EOF
1263#include <sys/types.h>
1264#include <sys/socket.h>
d219028d 1265#include <netinet/in.h>
ecad55e9
JA
1266#include <netdb.h>
1267#include <stdio.h>
1268int main(int argc, char **argv)
1269{
1270 struct addrinfo hints;
1271 struct in6_addr addr;
1272 int ret;
1273
1274 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1275 freeaddrinfo(NULL);
1276 printf("%s\n", gai_strerror(ret));
1277 addr = in6addr_any;
1278 return 0;
1279}
1280EOF
1281if compile_prog "" "" "ipv6"; then
1282 ipv6="yes"
1283fi
1284echo "IPv6 helpers $ipv6"
07fc0acd 1285
fc5c0345
DG
1286##########################################
1287# check for rbd
1288rbd="no"
1289cat > $TMPC << EOF
1290#include <rbd/librbd.h>
1291
1292int main(int argc, char **argv)
1293{
1294
1295 rados_t cluster;
1296 rados_ioctx_t io_ctx;
1297 const char pool[] = "rbd";
1298
1299 int major, minor, extra;
1300 rbd_version(&major, &minor, &extra);
1301
1302 rados_ioctx_create(cluster, pool, &io_ctx);
1303 return 0;
1304}
1305EOF
ce18290e 1306if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
fc5c0345
DG
1307 LIBS="-lrbd -lrados $LIBS"
1308 rbd="yes"
1309fi
1310echo "Rados Block Device engine $rbd"
1311
903b2812
JA
1312##########################################
1313# check for rbd_invaidate_cache()
1314rbd_inval="no"
1315if test "$rbd" = "yes"; then
1316cat > $TMPC << EOF
1317#include <rbd/librbd.h>
1318
1319int main(int argc, char **argv)
1320{
1321 rbd_image_t image;
1322
1323 return rbd_invalidate_cache(image);
1324}
1325EOF
1326if compile_prog "" "-lrbd -lrados" "rbd"; then
1327 rbd_inval="yes"
1328fi
1329echo "rbd_invalidate_cache $rbd_inval"
1330fi
1331
2e802282
JA
1332##########################################
1333# Check whether we have setvbuf
1334setvbuf="no"
1335cat > $TMPC << EOF
1336#include <stdio.h>
1337int main(int argc, char **argv)
1338{
1339 FILE *f = NULL;
1340 char buf[80];
1341 setvbuf(f, buf, _IOFBF, sizeof(buf));
1342 return 0;
1343}
1344EOF
1345if compile_prog "" "" "setvbuf"; then
1346 setvbuf="yes"
1347fi
1348echo "setvbuf $setvbuf"
fc5c0345 1349
6e7d7dfb 1350# check for gfapi
1351gfapi="no"
1352cat > $TMPC << EOF
1353#include <glusterfs/api/glfs.h>
1354
1355int main(int argc, char **argv)
1356{
1357
1358 glfs_t *g = glfs_new("foo");
1359
1360 return 0;
1361}
1362EOF
ce18290e 1363if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
6e7d7dfb 1364 LIBS="-lgfapi -lglusterfs $LIBS"
1365 gfapi="yes"
1366fi
6fa14b99 1367 echo "Gluster API engine $gfapi"
6e7d7dfb 1368
6fa14b99 1369##########################################
1370# check for gfapi fadvise support
6876c98c 1371if test "$gfapi" = "yes" ; then
6fa14b99 1372gf_fadvise="no"
1373cat > $TMPC << EOF
1374#include <glusterfs/api/glfs.h>
1375
1376int main(int argc, char **argv)
1377{
1378 struct glfs_fd *fd;
1379 int ret = glfs_fadvise(fd, 0, 0, 1);
1380
1381 return 0;
1382}
1383EOF
6fa14b99 1384if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1385 gf_fadvise="yes"
1386fi
1387echo "Gluster API use fadvise $gf_fadvise"
6876c98c
JA
1388fi
1389
1390##########################################
1391# check for gfapi trim support
1392gf_trim="no"
1393if test "$gfapi" = "yes" ; then
1394cat > $TMPC << EOF
1395#include <glusterfs/api/glfs.h>
1396
1397int main(int argc, char **argv)
1398{
1399 return glfs_discard_async(NULL, 0, 0);
1400}
1401EOF
1402if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1403 gf_trim="yes"
1404fi
1405echo "Gluster API trim support $gf_trim"
1406fi
fc5c0345 1407
81795ce3
CE
1408##########################################
1409# Check if we support stckf on s390
1410s390_z196_facilities="no"
1411cat > $TMPC << EOF
1412#define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1413int main(int argc, char **argv)
1414{
1415 /* We want just 1 double word to be returned. */
1416 register unsigned long reg0 asm("0") = 0;
1417 unsigned long stfle_bits;
1418 asm volatile(".machine push" "\n\t"
1419 ".machine \"z9-109\"" "\n\t"
1420 "stfle %0" "\n\t"
1421 ".machine pop" "\n"
1422 : "=QS" (stfle_bits), "+d" (reg0)
1423 : : "cc");
1424
1425 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1426 return 0;
1427 else
1428 return -1;
1429}
1430EOF
1431if compile_prog "" "" "s390_z196_facilities"; then
1432 $TMPE
1433 if [[ $? -eq 0 ]]; then
1434 s390_z196_facilities="yes"
1435 fi
1436fi
1437echo "s390_z196_facilities $s390_z196_facilities"
1b10477b
MM
1438
1439##########################################
1440# Check if we have required environment variables configured for libhdfs
1441if test "$libhdfs" = "yes" ; then
1442 hdfs_conf_error=0
1443 if test "$JAVA_HOME" = "" ; then
1444 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1445 hdfs_conf_error=1
1446 fi
1447 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1448 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1449 hdfs_conf_error=1
1450 fi
1451 if test "$FIO_LIBHDFS_LIB" = "" ; then
1452 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1453 hdfs_conf_error=1
1454 fi
1455 if test "$hdfs_conf_error" = "1" ; then
1456 exit 1
1457 fi
1458fi
1459echo "HDFS engine $libhdfs"
1460
b8116a87
DE
1461##########################################
1462# Check whether we have MTD
1463mtd="no"
1464cat > $TMPC << EOF
0e1c454a 1465#include <string.h>
b8116a87
DE
1466#include <mtd/mtd-user.h>
1467#include <sys/ioctl.h>
1468int main(int argc, char **argv)
1469{
0e1c454a 1470 struct mtd_write_req ops;
b8116a87 1471 struct mtd_info_user info;
0e1c454a 1472 memset(&ops, 0, sizeof(ops));
400cd0ff 1473 info.type = MTD_MLCNANDFLASH;
b8116a87
DE
1474 return ioctl(0, MEMGETINFO, &info);
1475}
1476EOF
1477if compile_prog "" "" "mtd"; then
1478 mtd="yes"
1479fi
1480echo "MTD $mtd"
1481
b470a02c
SC
1482# Check if we have lex/yacc available
1483yacc="no"
e7b2c7a3 1484yacc_is_bison="no"
b470a02c
SC
1485lex="no"
1486arith="no"
de26b824 1487if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
cf6dd80e 1488if test "$targetos" != "SunOS" ; then
e7b2c7a3 1489LEX=$(which lex 2> /dev/null)
b470a02c
SC
1490if test -x "$LEX" ; then
1491 lex="yes"
1492fi
7e0049e9 1493YACC=$(which bison 2> /dev/null)
b470a02c
SC
1494if test -x "$YACC" ; then
1495 yacc="yes"
7e0049e9 1496 yacc_is_bison="yes"
e7b2c7a3 1497else
7e0049e9 1498 YACC=$(which yacc 2> /dev/null)
e7b2c7a3
JA
1499 if test -x "$YACC" ; then
1500 yacc="yes"
e7b2c7a3 1501 fi
b470a02c
SC
1502fi
1503if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1504 arith="yes"
1505fi
1506
1507if test "$arith" = "yes" ; then
1508cat > $TMPC << EOF
1509extern int yywrap(void);
1510
1511int main(int argc, char **argv)
1512{
1513 yywrap();
1514 return 0;
1515}
1516EOF
719cda03
JA
1517if compile_prog "" "-ll" "lex"; then
1518 LIBS="-ll $LIBS"
b470a02c
SC
1519else
1520 arith="no"
1521fi
1522fi
cf6dd80e 1523fi
a655bbc4 1524fi
b470a02c 1525
63bda378
JA
1526# Check if lex fails using -o
1527if test "$arith" = "yes" ; then
daf705b5
JA
1528if test "$force_no_lex_o" = "yes" ; then
1529 lex_use_o="no"
1530else
63bda378
JA
1531$LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1532if test "$?" = "0" ; then
1533 lex_use_o="yes"
1534else
1535 lex_use_o="no"
1536fi
1537fi
daf705b5 1538fi
63bda378 1539
b470a02c
SC
1540echo "lex/yacc for arithmetic $arith"
1541
aae599ba
JA
1542##########################################
1543# Check whether we have setmntent/getmntent
1544getmntent="no"
1545cat > $TMPC << EOF
1546#include <stdio.h>
1547#include <mntent.h>
1548int main(int argc, char **argv)
1549{
1550 FILE *mtab = setmntent(NULL, "r");
1551 struct mntent *mnt = getmntent(mtab);
1581b82a 1552 endmntent(mtab);
aae599ba
JA
1553 return 0;
1554}
1555EOF
1556if compile_prog "" "" "getmntent"; then
1557 getmntent="yes"
1558fi
1559echo "getmntent $getmntent"
1560
e7e136da
TK
1561##########################################
1562# Check whether we have getmntinfo
1563getmntinfo="no"
1564cat > $TMPC << EOF
1565#include <stdio.h>
1566#include <sys/param.h>
1567#include <sys/mount.h>
1568int main(int argc, char **argv)
1569{
1570 struct statfs st;
1571 return getmntinfo(&st, MNT_NOWAIT);
1572}
1573EOF
1574if compile_prog "" "" "getmntinfo"; then
1575 getmntinfo="yes"
1576fi
1577echo "getmntinfo $getmntinfo"
1578
5018f79f
AH
1579##########################################
1580# Check whether we have _Static_assert
1581static_assert="no"
1582cat > $TMPC << EOF
1583#include <assert.h>
94815a5c
JA
1584#include <stdlib.h>
1585#undef offsetof
1586#ifdef __compiler_offsetof
1587#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
1588#else
1589#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1590#endif
1591
1592#define container_of(ptr, type, member) ({ \
1593 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
1594 (type *)( (char *)__mptr - offsetof(type,member) );})
1595
1596struct foo {
1597 int a, b;
1598};
1599
5018f79f
AH
1600int main(int argc, char **argv)
1601{
94815a5c 1602 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
5018f79f
AH
1603 return 0 ;
1604}
1605EOF
1606if compile_prog "" "" "static_assert"; then
1607 static_assert="yes"
1608fi
1609echo "Static Assert $static_assert"
e39c0676
JA
1610
1611##########################################
1612# Check whether we have bool / stdbool.h
1613have_bool="no"
1614cat > $TMPC << EOF
1615#include <stdbool.h>
1616int main(int argc, char **argv)
1617{
1618 bool var = true;
1619 return var != false;
1620}
1621EOF
1622if compile_prog "" "" "bool"; then
1623 have_bool="yes"
1624fi
1625echo "bool $have_bool"
1626
67bf9823
JA
1627#############################################################################
1628
67bf9823 1629if test "$wordsize" = "64" ; then
4feafb1e 1630 output_sym "CONFIG_64BIT"
67bf9823 1631elif test "$wordsize" = "32" ; then
4feafb1e 1632 output_sym "CONFIG_32BIT"
67bf9823 1633else
d7145a78 1634 fatal "Unknown wordsize!"
67bf9823 1635fi
0dcebdf4 1636if test "$bigendian" = "yes" ; then
4feafb1e 1637 output_sym "CONFIG_BIG_ENDIAN"
0dcebdf4 1638else
4feafb1e 1639 output_sym "CONFIG_LITTLE_ENDIAN"
0dcebdf4 1640fi
3989b143
JA
1641if test "$zlib" = "yes" ; then
1642 output_sym "CONFIG_ZLIB"
1643fi
67bf9823 1644if test "$libaio" = "yes" ; then
4feafb1e 1645 output_sym "CONFIG_LIBAIO"
67bf9823
JA
1646fi
1647if test "$posix_aio" = "yes" ; then
4feafb1e 1648 output_sym "CONFIG_POSIXAIO"
67bf9823
JA
1649fi
1650if test "$posix_aio_fsync" = "yes" ; then
4feafb1e 1651 output_sym "CONFIG_POSIXAIO_FSYNC"
67bf9823
JA
1652fi
1653if test "$linux_fallocate" = "yes" ; then
4feafb1e 1654 output_sym "CONFIG_LINUX_FALLOCATE"
67bf9823
JA
1655fi
1656if test "$posix_fallocate" = "yes" ; then
4feafb1e 1657 output_sym "CONFIG_POSIX_FALLOCATE"
67bf9823
JA
1658fi
1659if test "$fdatasync" = "yes" ; then
4feafb1e 1660 output_sym "CONFIG_FDATASYNC"
67bf9823
JA
1661fi
1662if test "$sync_file_range" = "yes" ; then
4feafb1e 1663 output_sym "CONFIG_SYNC_FILE_RANGE"
67bf9823
JA
1664fi
1665if test "$sfaa" = "yes" ; then
4feafb1e 1666 output_sym "CONFIG_SFAA"
67bf9823 1667fi
954cd73a 1668if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
4feafb1e 1669 output_sym "CONFIG_RDMA"
67bf9823
JA
1670fi
1671if test "$clock_gettime" = "yes" ; then
4feafb1e 1672 output_sym "CONFIG_CLOCK_GETTIME"
67bf9823
JA
1673fi
1674if test "$clock_monotonic" = "yes" ; then
4feafb1e 1675 output_sym "CONFIG_CLOCK_MONOTONIC"
67bf9823 1676fi
c544f604
SN
1677if test "$clock_monotonic_raw" = "yes" ; then
1678 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
1679fi
67bf9823 1680if test "$clock_monotonic_precise" = "yes" ; then
4feafb1e 1681 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
67bf9823
JA
1682fi
1683if test "$gettimeofday" = "yes" ; then
4feafb1e 1684 output_sym "CONFIG_GETTIMEOFDAY"
67bf9823
JA
1685fi
1686if test "$posix_fadvise" = "yes" ; then
4feafb1e 1687 output_sym "CONFIG_POSIX_FADVISE"
67bf9823
JA
1688fi
1689if test "$linux_3arg_affinity" = "yes" ; then
4feafb1e 1690 output_sym "CONFIG_3ARG_AFFINITY"
67bf9823 1691elif test "$linux_2arg_affinity" = "yes" ; then
4feafb1e 1692 output_sym "CONFIG_2ARG_AFFINITY"
67bf9823
JA
1693fi
1694if test "$strsep" = "yes" ; then
4feafb1e 1695 output_sym "CONFIG_STRSEP"
67bf9823 1696fi
9ad8da82
JA
1697if test "$strcasestr" = "yes" ; then
1698 output_sym "CONFIG_STRCASESTR"
1699fi
5ad7be56
KD
1700if test "$strlcat" = "yes" ; then
1701 output_sym "CONFIG_STRLCAT"
1702fi
67bf9823 1703if test "$getopt_long_only" = "yes" ; then
4feafb1e 1704 output_sym "CONFIG_GETOPT_LONG_ONLY"
67bf9823
JA
1705fi
1706if test "$inet_aton" = "yes" ; then
4feafb1e 1707 output_sym "CONFIG_INET_ATON"
67bf9823
JA
1708fi
1709if test "$socklen_t" = "yes" ; then
4feafb1e 1710 output_sym "CONFIG_SOCKLEN_T"
67bf9823
JA
1711fi
1712if test "$ext4_me" = "yes" ; then
4feafb1e 1713 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
67bf9823
JA
1714fi
1715if test "$linux_splice" = "yes" ; then
4feafb1e 1716 output_sym "CONFIG_LINUX_SPLICE"
67bf9823
JA
1717fi
1718if test "$guasi" = "yes" ; then
4feafb1e 1719 output_sym "CONFIG_GUASI"
67bf9823
JA
1720fi
1721if test "$fusion_aw" = "yes" ; then
4feafb1e 1722 output_sym "CONFIG_FUSION_AW"
67bf9823 1723fi
50206d9b 1724if test "$libnuma_v2" = "yes" ; then
4feafb1e 1725 output_sym "CONFIG_LIBNUMA"
67bf9823
JA
1726fi
1727if test "$solaris_aio" = "yes" ; then
4feafb1e 1728 output_sym "CONFIG_SOLARISAIO"
67bf9823
JA
1729fi
1730if test "$tls_thread" = "yes" ; then
4feafb1e 1731 output_sym "CONFIG_TLS_THREAD"
67bf9823 1732fi
44404c5a 1733if test "$rusage_thread" = "yes" ; then
4feafb1e 1734 output_sym "CONFIG_RUSAGE_THREAD"
67bf9823 1735fi
91f94d5b
JA
1736if test "$gfio" = "yes" ; then
1737 echo "CONFIG_GFIO=y" >> $config_host_mak
1738fi
c8931876
JA
1739if test "$esx" = "yes" ; then
1740 output_sym "CONFIG_ESX"
1741 output_sym "CONFIG_NO_SHM"
1742fi
7e09a9f1
JA
1743if test "$sched_idle" = "yes" ; then
1744 output_sym "CONFIG_SCHED_IDLE"
1745fi
1eafa37a
JA
1746if test "$tcp_nodelay" = "yes" ; then
1747 output_sym "CONFIG_TCP_NODELAY"
1748fi
1008602c
JA
1749if test "$window_size" = "yes" ; then
1750 output_sym "CONFIG_NET_WINDOWSIZE"
1751fi
e5f34d95
JA
1752if test "$mss" = "yes" ; then
1753 output_sym "CONFIG_NET_MSS"
1754fi
38b9354a
JA
1755if test "$rlimit_memlock" = "yes" ; then
1756 output_sym "CONFIG_RLIMIT_MEMLOCK"
1757fi
07fc0acd
JA
1758if test "$pwritev" = "yes" ; then
1759 output_sym "CONFIG_PWRITEV"
1760fi
2cafffbe
JA
1761if test "$pwritev2" = "yes" ; then
1762 output_sym "CONFIG_PWRITEV2"
1763fi
ecad55e9
JA
1764if test "$ipv6" = "yes" ; then
1765 output_sym "CONFIG_IPV6"
1766fi
fc5c0345
DG
1767if test "$rbd" = "yes" ; then
1768 output_sym "CONFIG_RBD"
1769fi
903b2812
JA
1770if test "$rbd_inval" = "yes" ; then
1771 output_sym "CONFIG_RBD_INVAL"
1772fi
2e802282
JA
1773if test "$setvbuf" = "yes" ; then
1774 output_sym "CONFIG_SETVBUF"
1775fi
81795ce3
CE
1776if test "$s390_z196_facilities" = "yes" ; then
1777 output_sym "CONFIG_S390_Z196_FACILITIES"
1778 CFLAGS="$CFLAGS -march=z9-109"
1779fi
6e7d7dfb 1780if test "$gfapi" = "yes" ; then
1781 output_sym "CONFIG_GFAPI"
1782fi
6fa14b99 1783if test "$gf_fadvise" = "yes" ; then
1784 output_sym "CONFIG_GF_FADVISE"
1785fi
6876c98c
JA
1786if test "$gf_trim" = "yes" ; then
1787 output_sym "CONFIG_GF_TRIM"
1788fi
1b10477b
MM
1789if test "$libhdfs" = "yes" ; then
1790 output_sym "CONFIG_LIBHDFS"
1527dc50
FB
1791 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
1792 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
1793 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
1794 fi
b8116a87
DE
1795if test "$mtd" = "yes" ; then
1796 output_sym "CONFIG_MTD"
1797fi
b470a02c
SC
1798if test "$arith" = "yes" ; then
1799 output_sym "CONFIG_ARITHMETIC"
e7b2c7a3
JA
1800 if test "$yacc_is_bison" = "yes" ; then
1801 echo "YACC=$YACC -y" >> $config_host_mak
1802 else
1803 echo "YACC=$YACC" >> $config_host_mak
1804 fi
63bda378
JA
1805 if test "$lex_use_o" = "yes" ; then
1806 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
1807 fi
b470a02c 1808fi
aae599ba
JA
1809if test "$getmntent" = "yes" ; then
1810 output_sym "CONFIG_GETMNTENT"
1811fi
e7e136da
TK
1812if test "$getmntinfo" = "yes" ; then
1813 output_sym "CONFIG_GETMNTINFO"
1814fi
5018f79f
AH
1815if test "$static_assert" = "yes" ; then
1816 output_sym "CONFIG_STATIC_ASSERT"
1817fi
e39c0676
JA
1818if test "$have_bool" = "yes" ; then
1819 output_sym "CONFIG_HAVE_BOOL"
1820fi
67bf9823 1821
605cf82e
JA
1822if test "$zlib" = "no" ; then
1823 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
1824fi
1825
67bf9823 1826echo "LIBS+=$LIBS" >> $config_host_mak
86719845 1827echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
91f94d5b 1828echo "CFLAGS+=$CFLAGS" >> $config_host_mak
d2aeedb9 1829echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
67bf9823 1830echo "CC=$cc" >> $config_host_mak
af4862b3 1831echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
020d54bd 1832echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
c61a3a44 1833
59d8f412 1834if [ `dirname $0` != "." -a ! -e Makefile ]; then
c61a3a44
JF
1835 cat > Makefile <<EOF
1836SRCDIR:=`dirname $0`
1837include \$(SRCDIR)/Makefile
1838EOF
1839fi