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