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