blob: 988fb6375ce9791e5b86823675870091af89e028 [file] [log] [blame]
Jens Axboe67bf9822013-01-10 11:23:19 +01001#!/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"
Jens Axboe4feafb12013-01-24 23:07:55 -070027config_host_h="config-host.h"
28
29rm -rf $config_host_mak
30rm -rf $config_host_h
Jens Axboe67bf9822013-01-10 11:23:19 +010031
Jens Axboed7145a72013-02-11 13:21:54 +010032fatal() {
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
Jens Axboe44404c52013-01-24 14:20:09 -070040# Default CFLAGS
Jens Axboeaf4862b2013-03-29 08:55:32 -060041CFLAGS="-D_GNU_SOURCE -include config-host.h"
42BUILD_CFLAGS=""
Jens Axboe67bf9822013-01-10 11:23:19 +010043
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
Jens Axboe7560fe72013-01-25 08:52:28 -070051# 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
Jens Axboe67bf9822013-01-10 11:23:19 +010059do_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."
Jens Axboed7145a72013-02-11 13:21:54 +010081 fatal "You can run configure with --disable-werror to bypass this check."
Jens Axboe67bf9822013-01-10 11:23:19 +010082}
83
84compile_object() {
85 do_cc $CFLAGS -c -o $TMPO $TMPC
86}
87
88compile_prog() {
89 local_cflags="$1"
Jens Axboeadaa46d2013-02-28 22:10:22 +010090 local_ldflags="$2 $LIBS"
Jens Axboe67bf9822013-01-10 11:23:19 +010091 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
Jens Axboec55d7282013-04-12 10:16:43 +020097 packages=$2
Jens Axboe67bf9822013-01-10 11:23:19 +010098
99 echo "ERROR"
100 echo "ERROR: User requested feature $feature"
Jens Axboec55d7282013-04-12 10:16:43 +0200101 if test ! -z "$packages" ; then
102 echo "ERROR: That feature needs $packages installed"
103 fi
Jens Axboe67bf9822013-01-10 11:23:19 +0100104 echo "ERROR: configure was not able to find it"
Jens Axboed7145a72013-02-11 13:21:54 +0100105 fatal "ERROR"
Jens Axboe67bf9822013-01-10 11:23:19 +0100106}
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
Jens Axboe4feafb12013-01-24 23:07:55 -0700125output_sym() {
126 echo "$1=y" >> $config_host_mak
127 echo "#define $1" >> $config_host_h
128}
129
Jens Axboe67bf9822013-01-10 11:23:19 +0100130targetos=""
131cpu=""
132
Jens Axboe91f94d52013-01-24 10:25:42 -0700133# default options
Jens Axboe47f44632013-01-24 10:34:14 -0700134show_help="no"
135exit_val=0
Jens Axboeb9e839c2014-10-09 18:15:36 -0600136gfio_check="no"
Manish Mandlikd60aa362014-08-13 13:36:52 -0600137libhdfs="no"
Jens Axboe91f94d52013-01-24 10:25:42 -0700138
Jens Axboecb1125b2013-01-23 13:47:54 -0700139# parse options
140for opt do
141 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
142 case "$opt" in
Jens Axboe8b156d82013-02-10 15:48:34 +0100143 --cpu=*) cpu="$optarg"
144 ;;
Jens Axboeef7035a2014-06-18 15:30:09 -0700145 # esx is cross compiled and cannot be detect through simple uname calls
146 --esx)
147 esx="yes"
148 ;;
Jens Axboecb1125b2013-01-23 13:47:54 -0700149 --cc=*) CC="$optarg"
150 ;;
Jens Axboe208e4c82013-01-29 09:26:07 +0100151 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
Jens Axboecb1125b2013-01-23 13:47:54 -0700152 ;;
Jens Axboeb7c12792013-05-01 13:00:26 +0200153 --build-32bit-win) build_32bit_win="yes"
Huadong Liu74097112013-02-05 08:43:14 +0100154 ;;
Jens Axboe91f94d52013-01-24 10:25:42 -0700155 --enable-gfio)
Jens Axboeb9e839c2014-10-09 18:15:36 -0600156 gfio_check="yes"
Jens Axboe899fab32013-01-29 10:06:30 +0100157 ;;
Castor Fu44462512013-10-31 11:00:54 -0600158 --disable-numa) disable_numa="yes"
159 ;;
Tiziano Mülleraa48efe2014-06-26 14:20:20 +0200160 --disable-rbd) disable_rbd="yes"
161 ;;
162 --disable-gfapi) disable_gfapi="yes"
163 ;;
Manish Mandlikd60aa362014-08-13 13:36:52 -0600164 --enable-libhdfs) libhdfs="yes"
165 ;;
Jens Axboe827da4f2013-01-24 10:27:26 -0700166 --help)
Jens Axboe47f44632013-01-24 10:34:14 -0700167 show_help="yes"
Jens Axboe827da4f2013-01-24 10:27:26 -0700168 ;;
Jens Axboecb1125b2013-01-23 13:47:54 -0700169 *)
170 echo "Bad option $opt"
Jens Axboe47f44632013-01-24 10:34:14 -0700171 show_help="yes"
172 exit_val=1
Jens Axboecb1125b2013-01-23 13:47:54 -0700173 esac
174done
175
Jens Axboe47f44632013-01-24 10:34:14 -0700176if test "$show_help" = "yes" ; then
Jens Axboe8b156d82013-02-10 15:48:34 +0100177 echo "--cpu= Specify target CPU if auto-detect fails"
Jens Axboeb7a99312013-02-04 12:46:54 +0100178 echo "--cc= Specify compiler to use"
Jens Axboe899fab32013-01-29 10:06:30 +0100179 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
Jens Axboeb7c12792013-05-01 13:00:26 +0200180 echo "--build-32bit-win Enable 32-bit build on Windows"
Jens Axboeef7035a2014-06-18 15:30:09 -0700181 echo "--esx Configure build options for esx"
Jens Axboeb7a99312013-02-04 12:46:54 +0100182 echo "--enable-gfio Enable building of gtk gfio"
Castor Fu44462512013-10-31 11:00:54 -0600183 echo "--disable-numa Disable libnuma even if found"
Manish Mandlikd60aa362014-08-13 13:36:52 -0600184 echo "--enable-libhdfs Enable hdfs support"
Jens Axboeb7a99312013-02-04 12:46:54 +0100185 exit $exit_val
Jens Axboe47f44632013-01-24 10:34:14 -0700186fi
187
Stefan Hajnoczi47986332014-03-06 18:41:58 +0100188cross_prefix=${cross_prefix-${CROSS_COMPILE}}
189cc="${CC-${cross_prefix}gcc}"
190
Aaron Carroll6d0e9f82013-02-12 09:58:14 +0100191if check_define __ANDROID__ ; then
192 targetos="Android"
193elif check_define __linux__ ; then
Jens Axboe67bf9822013-01-10 11:23:19 +0100194 targetos="Linux"
Jens Axboe67bf9822013-01-10 11:23:19 +0100195elif check_define __OpenBSD__ ; then
196 targetos='OpenBSD'
197elif check_define __sun__ ; then
198 targetos='SunOS'
Jens Axboe7cb024f2013-11-06 15:37:35 -0700199 CFLAGS="$CFLAGS -D_REENTRANT"
Stefan Hajnoczib24f59a2014-03-06 18:41:59 +0100200elif check_define _WIN32 ; then
201 targetos='CYGWIN'
Jens Axboe67bf9822013-01-10 11:23:19 +0100202else
203 targetos=`uname -s`
204fi
205
Aaron Carroll53cd4ee2013-03-14 16:57:38 +1100206echo "# Automatically generated by configure - do not modify" > $config_host_mak
207printf "# Configured with:" >> $config_host_mak
208printf " '%s'" "$0" "$@" >> $config_host_mak
209echo >> $config_host_mak
210echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
211
Jens Axboe67bf9822013-01-10 11:23:19 +0100212# Some host OSes need non-standard checks for which CPU to use.
213# Note that these checks are broken for cross-compilation: if you're
214# cross-compiling to one of these OSes then you'll need to specify
215# the correct CPU with the --cpu option.
216case $targetos in
217Darwin)
218 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
219 # we can run 64-bit userspace code.
220 # If the user didn't specify a CPU explicitly and the kernel says this is
221 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
222 # detection code.
223 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
224 cpu="x86_64"
225 fi
226 ;;
227SunOS)
228 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
229 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
230 cpu="x86_64"
231 fi
Jens Axboeadaa46d2013-02-28 22:10:22 +0100232 LIBS="-lnsl -lsocket"
Jens Axboecfd94f72013-01-23 16:23:48 -0700233 ;;
234CYGWIN*)
235 echo "Forcing known good options on Windows"
Jens Axboe4578d012013-01-23 16:26:12 -0700236 if test -z "$CC" ; then
Huadong Liu74097112013-02-05 08:43:14 +0100237 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
238 CC="i686-w64-mingw32-gcc"
239 else
240 CC="x86_64-w64-mingw32-gcc"
241 fi
Jens Axboe4578d012013-01-23 16:26:12 -0700242 fi
Jens Axboe4feafb12013-01-24 23:07:55 -0700243 output_sym "CONFIG_LITTLE_ENDIAN"
Huadong Liu74097112013-02-05 08:43:14 +0100244 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
245 output_sym "CONFIG_32BIT"
246 else
247 output_sym "CONFIG_64BIT_LLP64"
248 fi
Jens Axboe4feafb12013-01-24 23:07:55 -0700249 output_sym "CONFIG_FADVISE"
250 output_sym "CONFIG_SOCKLEN_T"
Jens Axboe4feafb12013-01-24 23:07:55 -0700251 output_sym "CONFIG_FADVISE"
252 output_sym "CONFIG_SFAA"
253 output_sym "CONFIG_RUSAGE_THREAD"
254 output_sym "CONFIG_WINDOWSAIO"
255 output_sym "CONFIG_FDATASYNC"
Bruce Cran59308a62013-02-02 20:59:31 +0000256 output_sym "CONFIG_CLOCK_MONOTONIC"
Bruce Crandc0518c2013-01-28 16:07:15 +0000257 output_sym "CONFIG_GETTIMEOFDAY"
258 output_sym "CONFIG_CLOCK_GETTIME"
Jens Axboe7e09a9f2013-01-30 13:58:58 +0100259 output_sym "CONFIG_SCHED_IDLE"
Jens Axboe1eafa372013-01-31 10:19:51 +0100260 output_sym "CONFIG_TCP_NODELAY"
Bruce Cran7d6be132013-11-07 14:04:00 +0000261 output_sym "CONFIG_TLS_THREAD"
Bruce Cranef07baa2014-01-28 17:34:08 -0700262 output_sym "CONFIG_IPV6"
Jens Axboe4feafb12013-01-24 23:07:55 -0700263 echo "CC=$CC" >> $config_host_mak
Jens Axboeaf4862b2013-03-29 08:55:32 -0600264 echo "BUILD_CFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
Jens Axboecfd94f72013-01-23 16:23:48 -0700265 exit 0
Aaron Carroll6d0e9f82013-02-12 09:58:14 +0100266 ;;
Jens Axboe67bf9822013-01-10 11:23:19 +0100267esac
268
269if test ! -z "$cpu" ; then
270 # command line argument
271 :
272elif check_define __i386__ ; then
273 cpu="i386"
274elif check_define __x86_64__ ; then
275 cpu="x86_64"
276elif check_define __sparc__ ; then
277 if check_define __arch64__ ; then
278 cpu="sparc64"
279 else
280 cpu="sparc"
281 fi
282elif check_define _ARCH_PPC ; then
283 if check_define _ARCH_PPC64 ; then
284 cpu="ppc64"
285 else
286 cpu="ppc"
287 fi
288elif check_define __mips__ ; then
289 cpu="mips"
290elif check_define __ia64__ ; then
291 cpu="ia64"
292elif check_define __s390__ ; then
293 if check_define __s390x__ ; then
294 cpu="s390x"
295 else
296 cpu="s390"
297 fi
298elif check_define __arm__ ; then
299 cpu="arm"
300elif check_define __hppa__ ; then
301 cpu="hppa"
302else
303 cpu=`uname -m`
304fi
305
306# Normalise host CPU name and set ARCH.
307case "$cpu" in
308 ia64|ppc|ppc64|s390|s390x|sparc64)
309 cpu="$cpu"
310 ;;
311 i386|i486|i586|i686|i86pc|BePC)
312 cpu="i386"
313 ;;
314 x86_64|amd64)
315 cpu="x86_64"
316 ;;
317 armv*b|armv*l|arm)
318 cpu="arm"
319 ;;
320 hppa|parisc|parisc64)
321 cpu="hppa"
322 ;;
323 mips*)
324 cpu="mips"
325 ;;
326 sparc|sun4[cdmuv])
327 cpu="sparc"
328 ;;
329 *)
Jens Axboe8b156d82013-02-10 15:48:34 +0100330 echo "Unknown CPU"
Jens Axboe67bf9822013-01-10 11:23:19 +0100331 ;;
332esac
333
Jens Axboedcbbf5b2013-01-25 14:35:27 -0700334if test -z "$CC" ; then
Jens Axboe67bf9822013-01-10 11:23:19 +0100335 if test "$targetos" = "FreeBSD"; then
336 if has clang; then
337 CC=clang
338 else
339 CC=gcc
340 fi
Jens Axboe67bf9822013-01-10 11:23:19 +0100341 fi
342fi
343
344cc="${CC-${cross_prefix}gcc}"
345
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700346##########################################
Aaron Carroll1a17cfd2013-03-14 16:57:40 +1100347# check cross compile
348
349cross_compile="no"
350cat > $TMPC <<EOF
351int main(void)
352{
353 return 0;
354}
355EOF
356if compile_prog "" "" "cross"; then
357 $TMPE 2>/dev/null || cross_compile="yes"
358else
359 fatal "compile test failed"
360fi
361
362##########################################
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700363# check endianness
364bigendian="no"
Aaron Carroll1a17cfd2013-03-14 16:57:40 +1100365if test "$cross_compile" = "no" ; then
366 cat > $TMPC <<EOF
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700367#include <inttypes.h>
368int main(void)
369{
370 volatile uint32_t i=0x01234567;
371 return (*((uint8_t*)(&i))) == 0x67;
372}
373EOF
Aaron Carroll1a17cfd2013-03-14 16:57:40 +1100374 if compile_prog "" "" "endian"; then
375 $TMPE && bigendian="yes"
376 fi
377else
378 # If we're cross compiling, try our best to work it out and rely on the
379 # run-time check to fail if we get it wrong.
380 cat > $TMPC <<EOF
381#include <endian.h>
382int main(void)
383{
384#if __BYTE_ORDER != __BIG_ENDIAN
385# error "Unknown endianness"
386#endif
387}
388EOF
389 compile_prog "" "" "endian" && bigendian="yes"
390 check_define "__ARMEB__" && bigendian="yes"
391 check_define "__MIPSEB__" && bigendian="yes"
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700392fi
393
394
Jens Axboe67bf9822013-01-10 11:23:19 +0100395echo "Operating system $targetos"
396echo "CPU $cpu"
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700397echo "Big endian $bigendian"
Jens Axboe67bf9822013-01-10 11:23:19 +0100398echo "Compiler $cc"
Aaron Carroll1a17cfd2013-03-14 16:57:40 +1100399echo "Cross compile $cross_compile"
Jens Axboe67bf9822013-01-10 11:23:19 +0100400echo
401
402##########################################
403# check for wordsize
404wordsize="0"
405cat > $TMPC <<EOF
Aaron Carroll142429e2013-03-14 16:57:39 +1100406#include <limits.h>
407#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
Jens Axboe67bf9822013-01-10 11:23:19 +0100408int main(void)
409{
Aaron Carroll142429e2013-03-14 16:57:39 +1100410 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
Jens Axboe67bf9822013-01-10 11:23:19 +0100411 return 0;
412}
413EOF
Aaron Carroll142429e2013-03-14 16:57:39 +1100414if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
415 wordsize="32"
416elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
417 wordsize="64"
418else
419 fatal "Unknown wordsize"
Jens Axboe67bf9822013-01-10 11:23:19 +0100420fi
421echo "Wordsize $wordsize"
422
423##########################################
Jens Axboea9bca4a2013-04-05 12:55:42 +0200424# zlib probe
425zlib="no"
426cat > $TMPC <<EOF
Jens Axboe31c9cd42014-07-03 14:17:02 -0600427#include <zlib.h>
Jens Axboea9bca4a2013-04-05 12:55:42 +0200428int main(void)
429{
430 z_stream stream;
431 if (inflateInit(&stream) != Z_OK)
432 return 1;
433 return 0;
434}
435EOF
436if compile_prog "" "-lz" "zlib" ; then
437 zlib=yes
438 LIBS="-lz $LIBS"
Jens Axboea9bca4a2013-04-05 12:55:42 +0200439fi
440echo "zlib $zlib"
441
442##########################################
Jens Axboe67bf9822013-01-10 11:23:19 +0100443# linux-aio probe
444libaio="no"
445cat > $TMPC <<EOF
446#include <libaio.h>
447#include <stddef.h>
448int main(void)
449{
450 io_setup(0, NULL);
451 return 0;
452}
453EOF
454if compile_prog "" "-laio" "libaio" ; then
455 libaio=yes
456 LIBS="-laio $LIBS"
457else
458 if test "$libaio" = "yes" ; then
Jens Axboec55d7282013-04-12 10:16:43 +0200459 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
Jens Axboe67bf9822013-01-10 11:23:19 +0100460 fi
461 libaio=no
462fi
463echo "Linux AIO support $libaio"
464
465##########################################
466# posix aio probe
467posix_aio="no"
468posix_aio_lrt="no"
469cat > $TMPC <<EOF
470#include <aio.h>
471int main(void)
472{
473 struct aiocb cb;
474 aio_read(&cb);
475 return 0;
476}
477EOF
478if compile_prog "" "" "posixaio" ; then
479 posix_aio="yes"
480elif compile_prog "" "-lrt" "posixaio"; then
481 posix_aio="yes"
482 posix_aio_lrt="yes"
483 LIBS="-lrt $LIBS"
484fi
485echo "POSIX AIO support $posix_aio"
486echo "POSIX AIO support needs -lrt $posix_aio_lrt"
487
488##########################################
489# posix aio fsync probe
490posix_aio_fsync="no"
491if test "$posix_aio" = "yes" ; then
492 cat > $TMPC <<EOF
493#include <fcntl.h>
494#include <aio.h>
495int main(void)
496{
497 struct aiocb cb;
498 return aio_fsync(O_SYNC, &cb);
499 return 0;
500}
501EOF
502 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
503 posix_aio_fsync=yes
504 fi
505fi
506echo "POSIX AIO fsync $posix_aio_fsync"
507
508##########################################
509# solaris aio probe
510solaris_aio="no"
511cat > $TMPC <<EOF
512#include <sys/types.h>
513#include <sys/asynch.h>
514#include <unistd.h>
515int main(void)
516{
517 aio_result_t res;
518 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
519 return 0;
520}
521EOF
522if compile_prog "" "-laio" "solarisaio" ; then
523 solaris_aio=yes
524 LIBS="-laio $LIBS"
525fi
526echo "Solaris AIO support $solaris_aio"
527
528##########################################
529# __sync_fetch_and_and test
530sfaa="no"
531cat > $TMPC << EOF
532static int sfaa(int *ptr)
533{
Jens Axboe9c639a72013-02-28 22:13:29 +0100534 return __sync_fetch_and_add(ptr, 0);
Jens Axboe67bf9822013-01-10 11:23:19 +0100535}
536
537int main(int argc, char **argv)
538{
539 int val = 42;
540 sfaa(&val);
541 return val;
542}
543EOF
544if compile_prog "" "" "__sync_fetch_and_add()" ; then
545 sfaa="yes"
546fi
Jens Axboe9c639a72013-02-28 22:13:29 +0100547echo "__sync_fetch_and_add $sfaa"
Jens Axboe67bf9822013-01-10 11:23:19 +0100548
549##########################################
550# libverbs probe
551libverbs="no"
552cat > $TMPC << EOF
553#include <stdio.h>
554#include <infiniband/arch.h>
555int main(int argc, char **argv)
556{
557 struct ibv_pd *pd = ibv_alloc_pd(NULL);
558 return 0;
559}
560EOF
561if compile_prog "" "-libverbs" "libverbs" ; then
562 libverbs="yes"
563 LIBS="-libverbs $LIBS"
564fi
565echo "libverbs $libverbs"
566
567##########################################
568# rdmacm probe
569rdmacm="no"
570cat > $TMPC << EOF
571#include <stdio.h>
572#include <rdma/rdma_cma.h>
573int main(int argc, char **argv)
574{
575 rdma_destroy_qp(NULL);
576 return 0;
577}
578EOF
579if compile_prog "" "-lrdmacm" "rdma"; then
580 rdmacm="yes"
581 LIBS="-lrdmacm $LIBS"
582fi
583echo "rdmacm $rdmacm"
584
585##########################################
586# Linux fallocate probe
587linux_fallocate="no"
588cat > $TMPC << EOF
589#include <stdio.h>
Castor Fuaa6738a2013-12-19 23:00:46 -0800590#include <fcntl.h>
Jens Axboe67bf9822013-01-10 11:23:19 +0100591#include <linux/falloc.h>
592int main(int argc, char **argv)
593{
594 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
595 return r;
596}
597EOF
598if compile_prog "" "" "linux_fallocate"; then
599 linux_fallocate="yes"
600fi
601echo "Linux fallocate $linux_fallocate"
602
603##########################################
604# POSIX fadvise probe
605posix_fadvise="no"
606cat > $TMPC << EOF
607#include <stdio.h>
608#include <fcntl.h>
609int main(int argc, char **argv)
610{
611 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
612 return r;
613}
614EOF
615if compile_prog "" "" "posix_fadvise"; then
616 posix_fadvise="yes"
617fi
618echo "POSIX fadvise $posix_fadvise"
619
620##########################################
621# POSIX fallocate probe
622posix_fallocate="no"
623cat > $TMPC << EOF
624#include <stdio.h>
625#include <fcntl.h>
626int main(int argc, char **argv)
627{
628 int r = posix_fallocate(0, 0, 1024);
629 return r;
630}
631EOF
632if compile_prog "" "" "posix_fallocate"; then
633 posix_fallocate="yes"
634fi
635echo "POSIX fallocate $posix_fallocate"
636
637##########################################
638# sched_set/getaffinity 2 or 3 argument test
639linux_2arg_affinity="no"
640linux_3arg_affinity="no"
641cat > $TMPC << EOF
Jens Axboe67bf9822013-01-10 11:23:19 +0100642#include <sched.h>
643int main(int argc, char **argv)
644{
645 cpu_set_t mask;
646 return sched_setaffinity(0, sizeof(mask), &mask);
647}
648EOF
649if compile_prog "" "" "sched_setaffinity(,,)"; then
650 linux_3arg_affinity="yes"
651else
652 cat > $TMPC << EOF
Jens Axboe67bf9822013-01-10 11:23:19 +0100653#include <sched.h>
654int main(int argc, char **argv)
655{
656 cpu_set_t mask;
657 return sched_setaffinity(0, &mask);
658}
659EOF
660 if compile_prog "" "" "sched_setaffinity(,)"; then
661 linux_2arg_affinity="yes"
662 fi
663fi
664echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
665echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
666
667##########################################
668# clock_gettime probe
669clock_gettime="no"
670cat > $TMPC << EOF
671#include <stdio.h>
672#include <time.h>
673int main(int argc, char **argv)
674{
675 return clock_gettime(0, NULL);
676}
677EOF
678if compile_prog "" "" "clock_gettime"; then
679 clock_gettime="yes"
680elif compile_prog "" "-lrt" "clock_gettime"; then
681 clock_gettime="yes"
682 LIBS="-lrt $LIBS"
683fi
684echo "clock_gettime $clock_gettime"
685
686##########################################
687# CLOCK_MONOTONIC probe
688clock_monotonic="no"
689if test "$clock_gettime" = "yes" ; then
690 cat > $TMPC << EOF
691#include <stdio.h>
692#include <time.h>
693int main(int argc, char **argv)
694{
695 return clock_gettime(CLOCK_MONOTONIC, NULL);
696}
697EOF
698 if compile_prog "" "$LIBS" "clock monotonic"; then
699 clock_monotonic="yes"
700 fi
701fi
702echo "CLOCK_MONOTONIC $clock_monotonic"
703
704##########################################
705# CLOCK_MONOTONIC_PRECISE probe
706clock_monotonic_precise="no"
707if test "$clock_gettime" = "yes" ; then
708 cat > $TMPC << EOF
709#include <stdio.h>
710#include <time.h>
711int main(int argc, char **argv)
712{
713 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
714}
715EOF
716 if compile_prog "" "$LIBS" "clock monotonic precise"; then
717 clock_monotonic_precise="yes"
718 fi
719fi
720echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
721
722##########################################
723# gettimeofday() probe
724gettimeofday="no"
725cat > $TMPC << EOF
726#include <sys/time.h>
727#include <stdio.h>
728int main(int argc, char **argv)
729{
730 struct timeval tv;
731 return gettimeofday(&tv, NULL);
732}
733EOF
734if compile_prog "" "" "gettimeofday"; then
735 gettimeofday="yes"
736fi
737echo "gettimeofday $gettimeofday"
738
739##########################################
740# fdatasync() probe
741fdatasync="no"
742cat > $TMPC << EOF
743#include <stdio.h>
744#include <unistd.h>
745int main(int argc, char **argv)
746{
747 return fdatasync(0);
748}
749EOF
750if compile_prog "" "" "fdatasync"; then
751 fdatasync="yes"
752fi
753echo "fdatasync $fdatasync"
754
755##########################################
756# sync_file_range() probe
757sync_file_range="no"
758cat > $TMPC << EOF
759#include <stdio.h>
760#include <unistd.h>
Jens Axboe67bf9822013-01-10 11:23:19 +0100761#include <fcntl.h>
762#include <linux/fs.h>
763int main(int argc, char **argv)
764{
765 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
766 SYNC_FILE_RANGE_WAIT_AFTER;
767 return sync_file_range(0, 0, 0, flags);
768}
769EOF
770if compile_prog "" "" "sync_file_range"; then
771 sync_file_range="yes"
772fi
773echo "sync_file_range $sync_file_range"
774
775##########################################
776# ext4 move extent probe
777ext4_me="no"
778cat > $TMPC << EOF
779#include <fcntl.h>
780#include <sys/ioctl.h>
781int main(int argc, char **argv)
782{
783 struct move_extent me;
784 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
785}
786EOF
Jens Axboec7165b82013-01-12 10:27:53 +0100787if compile_prog "" "" "ext4 move extent" ; then
788 ext4_me="yes"
789elif test $targetos = "Linux" ; then
790 # On Linux, just default to it on and let it error at runtime if we really
791 # don't have it. None of my updated systems have it defined, but it does
792 # work. Takes a while to bubble back.
Jens Axboe67bf9822013-01-10 11:23:19 +0100793 ext4_me="yes"
794fi
795echo "EXT4 move extent $ext4_me"
796
797##########################################
798# splice probe
799linux_splice="no"
800cat > $TMPC << EOF
Jens Axboe67bf9822013-01-10 11:23:19 +0100801#include <stdio.h>
802#include <fcntl.h>
803int main(int argc, char **argv)
804{
805 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
806}
807EOF
808if compile_prog "" "" "linux splice"; then
809 linux_splice="yes"
810fi
811echo "Linux splice(2) $linux_splice"
812
813##########################################
814# GUASI probe
815guasi="no"
816cat > $TMPC << EOF
817#include <guasi.h>
818#include <guasi_syscalls.h>
819int main(int argc, char **argv)
820{
821 guasi_t ctx = guasi_create(0, 0, 0);
822 return 0;
823}
824EOF
825if compile_prog "" "" "guasi"; then
826 guasi="yes"
827fi
828echo "GUASI $guasi"
829
830##########################################
831# fusion-aw probe
832fusion_aw="no"
833cat > $TMPC << EOF
Santhosh Koundinyab2c77c22013-05-18 08:44:01 +0200834#include <nvm/nvm_primitives.h>
Jens Axboe67bf9822013-01-10 11:23:19 +0100835int main(int argc, char **argv)
836{
Santhosh Koundinyab2c77c22013-05-18 08:44:01 +0200837 nvm_version_t ver_info;
838 nvm_handle_t handle;
839
840 handle = nvm_get_handle(0, &ver_info);
841 return nvm_atomic_write(handle, 0, 0, 0);
Jens Axboe67bf9822013-01-10 11:23:19 +0100842}
843EOF
Santhosh Koundinyab2c77c22013-05-18 08:44:01 +0200844if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -lvsl -ldl" "fusion-aw"; then
845 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -lvsl -ldl $LIBS"
Jens Axboe67bf9822013-01-10 11:23:19 +0100846 fusion_aw="yes"
847fi
848echo "Fusion-io atomic engine $fusion_aw"
849
850##########################################
851# libnuma probe
852libnuma="no"
853cat > $TMPC << EOF
854#include <numa.h>
855int main(int argc, char **argv)
856{
857 return numa_available();
858}
859EOF
Castor Fu44462512013-10-31 11:00:54 -0600860if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
Jens Axboe67bf9822013-01-10 11:23:19 +0100861 libnuma="yes"
862 LIBS="-lnuma $LIBS"
863fi
864echo "libnuma $libnuma"
865
866##########################################
Jens Axboe50206d92013-03-25 13:20:08 -0600867# libnuma 2.x version API
868if test "$libnuma" = "yes" ; then
869libnuma_v2="no"
870cat > $TMPC << EOF
871#include <numa.h>
872int main(int argc, char **argv)
873{
874 struct bitmask *mask = numa_parse_nodestring(NULL);
875 return 0;
876}
877EOF
878if compile_prog "" "" "libnuma api"; then
879 libnuma_v2="yes"
880fi
881echo "libnuma v2 $libnuma_v2"
882fi
883
884##########################################
Jens Axboe67bf9822013-01-10 11:23:19 +0100885# strsep() probe
886strsep="no"
887cat > $TMPC << EOF
888#include <string.h>
889int main(int argc, char **argv)
890{
891 strsep(NULL, NULL);
892 return 0;
893}
894EOF
895if compile_prog "" "" "strsep"; then
896 strsep="yes"
897fi
898echo "strsep $strsep"
899
900##########################################
Jens Axboe9ad8da82013-04-05 14:44:03 +0200901# strcasestr() probe
902strcasestr="no"
903cat > $TMPC << EOF
904#include <string.h>
905int main(int argc, char **argv)
906{
Castor Fuaa6738a2013-12-19 23:00:46 -0800907 return strcasestr(argv[0], argv[1]) != NULL;
Jens Axboe9ad8da82013-04-05 14:44:03 +0200908}
909EOF
910if compile_prog "" "" "strcasestr"; then
911 strcasestr="yes"
912fi
913echo "strcasestr $strcasestr"
914
915##########################################
Jens Axboe67bf9822013-01-10 11:23:19 +0100916# getopt_long_only() probe
917getopt_long_only="no"
918cat > $TMPC << EOF
919#include <unistd.h>
920#include <stdio.h>
Castor Fuaa6738a2013-12-19 23:00:46 -0800921#include <getopt.h>
Jens Axboe67bf9822013-01-10 11:23:19 +0100922int main(int argc, char **argv)
923{
924 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
925 return c;
926}
927EOF
928if compile_prog "" "" "getopt_long_only"; then
929 getopt_long_only="yes"
930fi
931echo "getopt_long_only() $getopt_long_only"
932
933##########################################
934# inet_aton() probe
935inet_aton="no"
936cat > $TMPC << EOF
937#include <sys/socket.h>
938#include <arpa/inet.h>
939#include <stdio.h>
940int main(int argc, char **argv)
941{
942 struct in_addr in;
943 return inet_aton(NULL, &in);
944}
945EOF
946if compile_prog "" "" "inet_aton"; then
947 inet_aton="yes"
948fi
949echo "inet_aton $inet_aton"
950
951##########################################
952# socklen_t probe
953socklen_t="no"
954cat > $TMPC << EOF
Aaron Carrollf6482612013-03-14 16:57:41 +1100955#include <sys/socket.h>
Jens Axboe67bf9822013-01-10 11:23:19 +0100956int main(int argc, char **argv)
957{
958 socklen_t len = 0;
959 return len;
960}
961EOF
962if compile_prog "" "" "socklen_t"; then
963 socklen_t="yes"
964fi
965echo "socklen_t $socklen_t"
966
967##########################################
968# Whether or not __thread is supported for TLS
969tls_thread="no"
970cat > $TMPC << EOF
971#include <stdio.h>
Castor Fuaa6738a2013-12-19 23:00:46 -0800972static __thread int ret;
Jens Axboe67bf9822013-01-10 11:23:19 +0100973int main(int argc, char **argv)
974{
975 return ret;
976}
977EOF
978if compile_prog "" "" "__thread"; then
979 tls_thread="yes"
980fi
981echo "__thread $tls_thread"
982
Jens Axboe91f94d52013-01-24 10:25:42 -0700983##########################################
Jens Axboe2639f052013-04-10 14:41:08 +0200984# Check if we have required gtk/glib support for gfio
Jens Axboeb9e839c2014-10-09 18:15:36 -0600985gfio="no"
986if test "$gfio_check" = "yes" ; then
Jens Axboe91f94d52013-01-24 10:25:42 -0700987 cat > $TMPC << EOF
988#include <glib.h>
989#include <cairo.h>
990#include <gtk/gtk.h>
991int main(void)
992{
993 gdk_threads_enter();
Jens Axboe91f94d52013-01-24 10:25:42 -0700994 gdk_threads_leave();
Jens Axboeb7a99312013-02-04 12:46:54 +0100995
996 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
Jens Axboe91f94d52013-01-24 10:25:42 -0700997}
998EOF
999GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1000if test "$?" != "0" ; then
1001 echo "configure: gtk and gthread not found"
1002 exit 1
1003fi
1004GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1005if test "$?" != "0" ; then
1006 echo "configure: gtk and gthread not found"
1007 exit 1
1008fi
Jens Axboeb7a99312013-02-04 12:46:54 +01001009if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1010 r=$($TMPE)
1011 if test "$r" != "0" ; then
1012 gfio="yes"
1013 LIBS="$LIBS $GTK_LIBS"
1014 CFLAGS="$CFLAGS $GTK_CFLAGS"
1015 else
1016 echo "GTK found, but need version 2.18 or higher"
1017 gfio="no"
1018 fi
Jens Axboe91f94d52013-01-24 10:25:42 -07001019else
1020 echo "Please install gtk and gdk libraries"
1021 gfio="no"
1022fi
1023fi
1024
Jens Axboeb9e839c2014-10-09 18:15:36 -06001025if test "$gfio_check" = "yes" ; then
1026 echo "gtk 2.18 or higher $gfio"
1027fi
Jens Axboe91f94d52013-01-24 10:25:42 -07001028
Jens Axboe44404c52013-01-24 14:20:09 -07001029# Check whether we have getrusage(RUSAGE_THREAD)
1030rusage_thread="no"
1031cat > $TMPC << EOF
1032#include <sys/time.h>
1033#include <sys/resource.h>
1034int main(int argc, char **argv)
1035{
1036 struct rusage ru;
1037 getrusage(RUSAGE_THREAD, &ru);
1038 return 0;
1039}
1040EOF
1041if compile_prog "" "" "RUSAGE_THREAD"; then
1042 rusage_thread="yes"
1043fi
1044echo "RUSAGE_THREAD $rusage_thread"
1045
Jens Axboe7e09a9f2013-01-30 13:58:58 +01001046##########################################
1047# Check whether we have SCHED_IDLE
1048sched_idle="no"
1049cat > $TMPC << EOF
1050#include <sched.h>
1051int main(int argc, char **argv)
1052{
1053 struct sched_param p;
1054 return sched_setscheduler(0, SCHED_IDLE, &p);
1055}
1056EOF
1057if compile_prog "" "" "SCHED_IDLE"; then
1058 sched_idle="yes"
1059fi
1060echo "SCHED_IDLE $sched_idle"
1061
Jens Axboe1eafa372013-01-31 10:19:51 +01001062##########################################
1063# Check whether we have TCP_NODELAY
1064tcp_nodelay="no"
1065cat > $TMPC << EOF
1066#include <stdio.h>
1067#include <sys/types.h>
1068#include <sys/socket.h>
1069#include <netinet/tcp.h>
1070int main(int argc, char **argv)
1071{
1072 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1073}
1074EOF
1075if compile_prog "" "" "TCP_NODELAY"; then
1076 tcp_nodelay="yes"
1077fi
1078echo "TCP_NODELAY $tcp_nodelay"
1079
Jens Axboe38b93542013-02-28 08:28:05 +01001080##########################################
Jens Axboe531e67a2014-10-09 11:55:16 -06001081# Check whether we have SO_SNDBUF
1082window_size="no"
1083cat > $TMPC << EOF
1084#include <stdio.h>
1085#include <sys/types.h>
1086#include <sys/socket.h>
1087#include <netinet/tcp.h>
1088int main(int argc, char **argv)
1089{
1090 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1091 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1092}
1093EOF
1094if compile_prog "" "" "SO_SNDBUF"; then
1095 window_size="yes"
1096fi
1097echo "Net engine window_size $window_size"
1098
1099##########################################
Jens Axboe5e34cea2014-10-09 12:05:44 -06001100# Check whether we have TCP_MAXSEG
1101mss="no"
1102cat > $TMPC << EOF
1103#include <stdio.h>
1104#include <sys/types.h>
1105#include <sys/socket.h>
1106#include <netinet/tcp.h>
1107#include <arpa/inet.h>
1108#include <netinet/in.h>
1109int main(int argc, char **argv)
1110{
1111 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1112}
1113EOF
1114if compile_prog "" "" "TCP_MAXSEG"; then
1115 mss="yes"
1116fi
1117echo "TCP_MAXSEG $mss"
1118
1119##########################################
Jens Axboe38b93542013-02-28 08:28:05 +01001120# Check whether we have RLIMIT_MEMLOCK
1121rlimit_memlock="no"
1122cat > $TMPC << EOF
1123#include <sys/time.h>
1124#include <sys/resource.h>
1125int main(int argc, char **argv)
1126{
1127 struct rlimit rl;
1128 return getrlimit(RLIMIT_MEMLOCK, &rl);
1129}
1130EOF
1131if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1132 rlimit_memlock="yes"
1133fi
1134echo "RLIMIT_MEMLOCK $rlimit_memlock"
1135
Jens Axboe07fc0ac2013-05-16 20:36:57 +02001136##########################################
1137# Check whether we have pwritev/preadv
1138pwritev="no"
1139cat > $TMPC << EOF
1140#include <stdio.h>
1141#include <sys/uio.h>
1142int main(int argc, char **argv)
1143{
1144 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1145}
1146EOF
1147if compile_prog "" "" "pwritev"; then
1148 pwritev="yes"
1149fi
1150echo "pwritev/preadv $pwritev"
1151
Jens Axboeecad55e2014-01-24 18:56:34 -08001152##########################################
1153# Check whether we have the required functions for ipv6
1154ipv6="no"
1155cat > $TMPC << EOF
1156#include <sys/types.h>
1157#include <sys/socket.h>
Bruce Crand2190282014-02-13 09:06:20 -07001158#include <netinet/in.h>
Jens Axboeecad55e2014-01-24 18:56:34 -08001159#include <netdb.h>
1160#include <stdio.h>
1161int main(int argc, char **argv)
1162{
1163 struct addrinfo hints;
1164 struct in6_addr addr;
1165 int ret;
1166
1167 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1168 freeaddrinfo(NULL);
1169 printf("%s\n", gai_strerror(ret));
1170 addr = in6addr_any;
1171 return 0;
1172}
1173EOF
1174if compile_prog "" "" "ipv6"; then
1175 ipv6="yes"
1176fi
1177echo "IPv6 helpers $ipv6"
Jens Axboe07fc0ac2013-05-16 20:36:57 +02001178
Daniel Gollubfc5c0342014-02-17 14:35:28 +01001179##########################################
1180# check for rbd
1181rbd="no"
1182cat > $TMPC << EOF
1183#include <rbd/librbd.h>
1184
1185int main(int argc, char **argv)
1186{
1187
1188 rados_t cluster;
1189 rados_ioctx_t io_ctx;
1190 const char pool[] = "rbd";
1191
1192 int major, minor, extra;
1193 rbd_version(&major, &minor, &extra);
1194
1195 rados_ioctx_create(cluster, pool, &io_ctx);
1196 return 0;
1197}
1198EOF
Tiziano Mülleraa48efe2014-06-26 14:20:20 +02001199if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
Daniel Gollubfc5c0342014-02-17 14:35:28 +01001200 LIBS="-lrbd -lrados $LIBS"
1201 rbd="yes"
1202fi
1203echo "Rados Block Device engine $rbd"
1204
Jens Axboe2e802282014-04-02 21:47:27 -06001205##########################################
chenh0e55d6b2014-03-27 15:19:43 -04001206# check for gfapi
1207gfapi="no"
Jens Axboe2e802282014-04-02 21:47:27 -06001208cat > $TMPC << EOF
chenh0e55d6b2014-03-27 15:19:43 -04001209#include <glusterfs/api/glfs.h>
1210
Jens Axboe2e802282014-04-02 21:47:27 -06001211int main(int argc, char **argv)
1212{
chenh0e55d6b2014-03-27 15:19:43 -04001213
1214 glfs_t *g = glfs_new("foo");
1215
Jens Axboe2e802282014-04-02 21:47:27 -06001216 return 0;
1217}
1218EOF
Tiziano Mülleraa48efe2014-06-26 14:20:20 +02001219if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
chenh0e55d6b2014-03-27 15:19:43 -04001220 LIBS="-lgfapi -lglusterfs $LIBS"
1221 gfapi="yes"
Jens Axboe2e802282014-04-02 21:47:27 -06001222fi
chenh54fe20f2014-04-08 13:02:26 -04001223 echo "Gluster API engine $gfapi"
chenh0e55d6b2014-03-27 15:19:43 -04001224
chenh54fe20f2014-04-08 13:02:26 -04001225##########################################
1226# check for gfapi fadvise support
1227gf_fadvise="no"
1228cat > $TMPC << EOF
1229#include <glusterfs/api/glfs.h>
1230
1231int main(int argc, char **argv)
1232{
1233 struct glfs_fd *fd;
1234 int ret = glfs_fadvise(fd, 0, 0, 1);
1235
1236 return 0;
1237}
1238EOF
1239
1240if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1241 gf_fadvise="yes"
1242fi
1243echo "Gluster API use fadvise $gf_fadvise"
Daniel Gollubfc5c0342014-02-17 14:35:28 +01001244
Christian Ehrhardt81795ce2014-04-10 15:09:47 +02001245##########################################
1246# Check if we support stckf on s390
1247s390_z196_facilities="no"
1248cat > $TMPC << EOF
1249#define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1250int main(int argc, char **argv)
1251{
1252 /* We want just 1 double word to be returned. */
1253 register unsigned long reg0 asm("0") = 0;
1254 unsigned long stfle_bits;
1255 asm volatile(".machine push" "\n\t"
1256 ".machine \"z9-109\"" "\n\t"
1257 "stfle %0" "\n\t"
1258 ".machine pop" "\n"
1259 : "=QS" (stfle_bits), "+d" (reg0)
1260 : : "cc");
1261
1262 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1263 return 0;
1264 else
1265 return -1;
1266}
1267EOF
1268if compile_prog "" "" "s390_z196_facilities"; then
1269 $TMPE
1270 if [[ $? -eq 0 ]]; then
1271 s390_z196_facilities="yes"
1272 fi
1273fi
1274echo "s390_z196_facilities $s390_z196_facilities"
Manish Mandlikd60aa362014-08-13 13:36:52 -06001275
1276##########################################
1277# Check if we have required environment variables configured for libhdfs
1278if test "$libhdfs" = "yes" ; then
1279 hdfs_conf_error=0
1280 if test "$JAVA_HOME" = "" ; then
1281 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1282 hdfs_conf_error=1
1283 fi
1284 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1285 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1286 hdfs_conf_error=1
1287 fi
1288 if test "$FIO_LIBHDFS_LIB" = "" ; then
1289 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1290 hdfs_conf_error=1
1291 fi
1292 if test "$hdfs_conf_error" = "1" ; then
1293 exit 1
1294 fi
1295fi
1296echo "HDFS engine $libhdfs"
1297
Stephen M. Cameron88b635b2014-09-29 12:10:49 -06001298# Check if we have lex/yacc available
1299yacc="no"
Jens Axboeb50afc42014-09-29 16:44:31 -06001300yacc_is_bison="no"
Stephen M. Cameron88b635b2014-09-29 12:10:49 -06001301lex="no"
1302arith="no"
Jens Axboeb50afc42014-09-29 16:44:31 -06001303LEX=$(which lex 2> /dev/null)
Stephen M. Cameron88b635b2014-09-29 12:10:49 -06001304if test -x "$LEX" ; then
1305 lex="yes"
1306fi
Stephen M. Cameron56a0f462014-10-06 20:18:57 -06001307YACC=$(which bison 2> /dev/null)
Stephen M. Cameron88b635b2014-09-29 12:10:49 -06001308if test -x "$YACC" ; then
1309 yacc="yes"
Stephen M. Cameron56a0f462014-10-06 20:18:57 -06001310 yacc_is_bison="yes"
Jens Axboeb50afc42014-09-29 16:44:31 -06001311else
Stephen M. Cameron56a0f462014-10-06 20:18:57 -06001312 YACC=$(which yacc 2> /dev/null)
Jens Axboeb50afc42014-09-29 16:44:31 -06001313 if test -x "$YACC" ; then
1314 yacc="yes"
Jens Axboeb50afc42014-09-29 16:44:31 -06001315 fi
Stephen M. Cameron88b635b2014-09-29 12:10:49 -06001316fi
1317if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1318 arith="yes"
1319fi
1320
1321if test "$arith" = "yes" ; then
1322cat > $TMPC << EOF
1323extern int yywrap(void);
1324
1325int main(int argc, char **argv)
1326{
1327 yywrap();
1328 return 0;
1329}
1330EOF
1331
Jens Axboe8602b0a2014-09-30 22:16:05 -06001332if compile_prog "" "-ll" "lex"; then
1333 LIBS="-ll $LIBS"
Stephen M. Cameron88b635b2014-09-29 12:10:49 -06001334else
1335 arith="no"
1336fi
1337fi
1338
1339echo "lex/yacc for arithmetic $arith"
1340
Jens Axboe67bf9822013-01-10 11:23:19 +01001341#############################################################################
1342
Jens Axboe67bf9822013-01-10 11:23:19 +01001343if test "$wordsize" = "64" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001344 output_sym "CONFIG_64BIT"
Jens Axboe67bf9822013-01-10 11:23:19 +01001345elif test "$wordsize" = "32" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001346 output_sym "CONFIG_32BIT"
Jens Axboe67bf9822013-01-10 11:23:19 +01001347else
Jens Axboed7145a72013-02-11 13:21:54 +01001348 fatal "Unknown wordsize!"
Jens Axboe67bf9822013-01-10 11:23:19 +01001349fi
Jens Axboe0dcebdf2013-01-23 15:42:16 -07001350if test "$bigendian" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001351 output_sym "CONFIG_BIG_ENDIAN"
Jens Axboe0dcebdf2013-01-23 15:42:16 -07001352else
Jens Axboe4feafb12013-01-24 23:07:55 -07001353 output_sym "CONFIG_LITTLE_ENDIAN"
Jens Axboe0dcebdf2013-01-23 15:42:16 -07001354fi
Jens Axboe3989b142013-04-12 13:13:24 +02001355if test "$zlib" = "yes" ; then
1356 output_sym "CONFIG_ZLIB"
1357fi
Jens Axboe67bf9822013-01-10 11:23:19 +01001358if test "$libaio" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001359 output_sym "CONFIG_LIBAIO"
Jens Axboe67bf9822013-01-10 11:23:19 +01001360fi
1361if test "$posix_aio" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001362 output_sym "CONFIG_POSIXAIO"
Jens Axboe67bf9822013-01-10 11:23:19 +01001363fi
1364if test "$posix_aio_fsync" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001365 output_sym "CONFIG_POSIXAIO_FSYNC"
Jens Axboe67bf9822013-01-10 11:23:19 +01001366fi
1367if test "$linux_fallocate" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001368 output_sym "CONFIG_LINUX_FALLOCATE"
Jens Axboe67bf9822013-01-10 11:23:19 +01001369fi
1370if test "$posix_fallocate" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001371 output_sym "CONFIG_POSIX_FALLOCATE"
Jens Axboe67bf9822013-01-10 11:23:19 +01001372fi
1373if test "$fdatasync" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001374 output_sym "CONFIG_FDATASYNC"
Jens Axboe67bf9822013-01-10 11:23:19 +01001375fi
1376if test "$sync_file_range" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001377 output_sym "CONFIG_SYNC_FILE_RANGE"
Jens Axboe67bf9822013-01-10 11:23:19 +01001378fi
1379if test "$sfaa" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001380 output_sym "CONFIG_SFAA"
Jens Axboe67bf9822013-01-10 11:23:19 +01001381fi
Yufei Ren954cd732013-07-22 20:58:05 -06001382if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001383 output_sym "CONFIG_RDMA"
Jens Axboe67bf9822013-01-10 11:23:19 +01001384fi
1385if test "$clock_gettime" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001386 output_sym "CONFIG_CLOCK_GETTIME"
Jens Axboe67bf9822013-01-10 11:23:19 +01001387fi
1388if test "$clock_monotonic" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001389 output_sym "CONFIG_CLOCK_MONOTONIC"
Jens Axboe67bf9822013-01-10 11:23:19 +01001390fi
1391if test "$clock_monotonic_precise" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001392 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
Jens Axboe67bf9822013-01-10 11:23:19 +01001393fi
1394if test "$gettimeofday" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001395 output_sym "CONFIG_GETTIMEOFDAY"
Jens Axboe67bf9822013-01-10 11:23:19 +01001396fi
1397if test "$posix_fadvise" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001398 output_sym "CONFIG_POSIX_FADVISE"
Jens Axboe67bf9822013-01-10 11:23:19 +01001399fi
1400if test "$linux_3arg_affinity" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001401 output_sym "CONFIG_3ARG_AFFINITY"
Jens Axboe67bf9822013-01-10 11:23:19 +01001402elif test "$linux_2arg_affinity" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001403 output_sym "CONFIG_2ARG_AFFINITY"
Jens Axboe67bf9822013-01-10 11:23:19 +01001404fi
1405if test "$strsep" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001406 output_sym "CONFIG_STRSEP"
Jens Axboe67bf9822013-01-10 11:23:19 +01001407fi
Jens Axboe9ad8da82013-04-05 14:44:03 +02001408if test "$strcasestr" = "yes" ; then
1409 output_sym "CONFIG_STRCASESTR"
1410fi
Jens Axboe67bf9822013-01-10 11:23:19 +01001411if test "$getopt_long_only" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001412 output_sym "CONFIG_GETOPT_LONG_ONLY"
Jens Axboe67bf9822013-01-10 11:23:19 +01001413fi
1414if test "$inet_aton" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001415 output_sym "CONFIG_INET_ATON"
Jens Axboe67bf9822013-01-10 11:23:19 +01001416fi
1417if test "$socklen_t" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001418 output_sym "CONFIG_SOCKLEN_T"
Jens Axboe67bf9822013-01-10 11:23:19 +01001419fi
1420if test "$ext4_me" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001421 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
Jens Axboe67bf9822013-01-10 11:23:19 +01001422fi
1423if test "$linux_splice" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001424 output_sym "CONFIG_LINUX_SPLICE"
Jens Axboe67bf9822013-01-10 11:23:19 +01001425fi
1426if test "$guasi" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001427 output_sym "CONFIG_GUASI"
Jens Axboe67bf9822013-01-10 11:23:19 +01001428fi
1429if test "$fusion_aw" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001430 output_sym "CONFIG_FUSION_AW"
Jens Axboe67bf9822013-01-10 11:23:19 +01001431fi
Jens Axboe50206d92013-03-25 13:20:08 -06001432if test "$libnuma_v2" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001433 output_sym "CONFIG_LIBNUMA"
Jens Axboe67bf9822013-01-10 11:23:19 +01001434fi
1435if test "$solaris_aio" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001436 output_sym "CONFIG_SOLARISAIO"
Jens Axboe67bf9822013-01-10 11:23:19 +01001437fi
1438if test "$tls_thread" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001439 output_sym "CONFIG_TLS_THREAD"
Jens Axboe67bf9822013-01-10 11:23:19 +01001440fi
Jens Axboe44404c52013-01-24 14:20:09 -07001441if test "$rusage_thread" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001442 output_sym "CONFIG_RUSAGE_THREAD"
Jens Axboe67bf9822013-01-10 11:23:19 +01001443fi
Jens Axboe91f94d52013-01-24 10:25:42 -07001444if test "$gfio" = "yes" ; then
1445 echo "CONFIG_GFIO=y" >> $config_host_mak
1446fi
Jens Axboeef7035a2014-06-18 15:30:09 -07001447if test "$esx" = "yes" ; then
1448 output_sym "CONFIG_ESX"
1449 output_sym "CONFIG_NO_SHM"
1450fi
Jens Axboe7e09a9f2013-01-30 13:58:58 +01001451if test "$sched_idle" = "yes" ; then
1452 output_sym "CONFIG_SCHED_IDLE"
1453fi
Jens Axboe1eafa372013-01-31 10:19:51 +01001454if test "$tcp_nodelay" = "yes" ; then
1455 output_sym "CONFIG_TCP_NODELAY"
1456fi
Jens Axboe531e67a2014-10-09 11:55:16 -06001457if test "$window_size" = "yes" ; then
1458 output_sym "CONFIG_NET_WINDOWSIZE"
1459fi
Jens Axboe5e34cea2014-10-09 12:05:44 -06001460if test "$mss" = "yes" ; then
1461 output_sym "CONFIG_NET_MSS"
1462fi
Jens Axboe38b93542013-02-28 08:28:05 +01001463if test "$rlimit_memlock" = "yes" ; then
1464 output_sym "CONFIG_RLIMIT_MEMLOCK"
1465fi
Jens Axboe07fc0ac2013-05-16 20:36:57 +02001466if test "$pwritev" = "yes" ; then
1467 output_sym "CONFIG_PWRITEV"
1468fi
Jens Axboeecad55e2014-01-24 18:56:34 -08001469if test "$ipv6" = "yes" ; then
1470 output_sym "CONFIG_IPV6"
1471fi
Daniel Gollubfc5c0342014-02-17 14:35:28 +01001472if test "$rbd" = "yes" ; then
1473 output_sym "CONFIG_RBD"
1474fi
Jens Axboe2e802282014-04-02 21:47:27 -06001475if test "$setvbuf" = "yes" ; then
1476 output_sym "CONFIG_SETVBUF"
1477fi
Christian Ehrhardt81795ce2014-04-10 15:09:47 +02001478if test "$s390_z196_facilities" = "yes" ; then
1479 output_sym "CONFIG_S390_Z196_FACILITIES"
1480 CFLAGS="$CFLAGS -march=z9-109"
1481fi
chenh0e55d6b2014-03-27 15:19:43 -04001482if test "$gfapi" = "yes" ; then
1483 output_sym "CONFIG_GFAPI"
1484fi
chenh54fe20f2014-04-08 13:02:26 -04001485if test "$gf_fadvise" = "yes" ; then
1486 output_sym "CONFIG_GF_FADVISE"
1487fi
Manish Mandlikd60aa362014-08-13 13:36:52 -06001488if test "$libhdfs" = "yes" ; then
1489 output_sym "CONFIG_LIBHDFS"
1490fi
Stephen M. Cameron88b635b2014-09-29 12:10:49 -06001491if test "$arith" = "yes" ; then
1492 output_sym "CONFIG_ARITHMETIC"
Jens Axboeb50afc42014-09-29 16:44:31 -06001493 if test "$yacc_is_bison" = "yes" ; then
1494 echo "YACC=$YACC -y" >> $config_host_mak
1495 else
1496 echo "YACC=$YACC" >> $config_host_mak
1497 fi
Stephen M. Cameron88b635b2014-09-29 12:10:49 -06001498fi
Jens Axboe67bf9822013-01-10 11:23:19 +01001499
Jens Axboe49986602014-07-03 16:20:27 -06001500if test "$zlib" = "no" ; then
1501 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
1502fi
1503
Jens Axboe67bf9822013-01-10 11:23:19 +01001504echo "LIBS+=$LIBS" >> $config_host_mak
Jens Axboe91f94d52013-01-24 10:25:42 -07001505echo "CFLAGS+=$CFLAGS" >> $config_host_mak
Jens Axboe67bf9822013-01-10 11:23:19 +01001506echo "CC=$cc" >> $config_host_mak
Jens Axboeaf4862b2013-03-29 08:55:32 -06001507echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak