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