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