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