iolog: fix link without zlib
[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
135be493 136gfio="no"
91f94d5b 137
cb1125b0
JA
138# parse options
139for opt do
140 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
141 case "$opt" in
8b156d8e
JA
142 --cpu=*) cpu="$optarg"
143 ;;
c8931876
JA
144 # esx is cross compiled and cannot be detect through simple uname calls
145 --esx)
146 esx="yes"
147 ;;
cb1125b0
JA
148 --cc=*) CC="$optarg"
149 ;;
208e4c8b
JA
150 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
151 ;;
b7c12794 152 --build-32bit-win) build_32bit_win="yes"
7409711b 153 ;;
91f94d5b 154 --enable-gfio)
9db01ef9 155 gfio="yes"
899fab33 156 ;;
44462517
CF
157 --disable-numa) disable_numa="yes"
158 ;;
ce18290e
TM
159 --disable-rbd) disable_rbd="yes"
160 ;;
161 --disable-gfapi) disable_gfapi="yes"
162 ;;
827da4f5 163 --help)
47f44635 164 show_help="yes"
827da4f5 165 ;;
cb1125b0
JA
166 *)
167 echo "Bad option $opt"
47f44635
JA
168 show_help="yes"
169 exit_val=1
cb1125b0
JA
170 esac
171done
172
47f44635 173if test "$show_help" = "yes" ; then
8b156d8e 174 echo "--cpu= Specify target CPU if auto-detect fails"
b7a99316 175 echo "--cc= Specify compiler to use"
899fab33 176 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
b7c12794 177 echo "--build-32bit-win Enable 32-bit build on Windows"
c8931876 178 echo "--esx Configure build options for esx"
b7a99316 179 echo "--enable-gfio Enable building of gtk gfio"
44462517 180 echo "--disable-numa Disable libnuma even if found"
b7a99316 181 exit $exit_val
47f44635
JA
182fi
183
47986339
SH
184cross_prefix=${cross_prefix-${CROSS_COMPILE}}
185cc="${CC-${cross_prefix}gcc}"
186
6d0e9f83
AC
187if check_define __ANDROID__ ; then
188 targetos="Android"
189elif check_define __linux__ ; then
67bf9823 190 targetos="Linux"
67bf9823
JA
191elif check_define __OpenBSD__ ; then
192 targetos='OpenBSD'
193elif check_define __sun__ ; then
194 targetos='SunOS'
7cb024f8 195 CFLAGS="$CFLAGS -D_REENTRANT"
b24f59ab
SH
196elif check_define _WIN32 ; then
197 targetos='CYGWIN'
67bf9823
JA
198else
199 targetos=`uname -s`
200fi
201
53cd4eee
AC
202echo "# Automatically generated by configure - do not modify" > $config_host_mak
203printf "# Configured with:" >> $config_host_mak
204printf " '%s'" "$0" "$@" >> $config_host_mak
205echo >> $config_host_mak
206echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
207
67bf9823
JA
208# Some host OSes need non-standard checks for which CPU to use.
209# Note that these checks are broken for cross-compilation: if you're
210# cross-compiling to one of these OSes then you'll need to specify
211# the correct CPU with the --cpu option.
212case $targetos in
213Darwin)
214 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
215 # we can run 64-bit userspace code.
216 # If the user didn't specify a CPU explicitly and the kernel says this is
217 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
218 # detection code.
219 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
220 cpu="x86_64"
221 fi
222 ;;
223SunOS)
224 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
225 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
226 cpu="x86_64"
227 fi
adaa46d8 228 LIBS="-lnsl -lsocket"
cfd94f79
JA
229 ;;
230CYGWIN*)
231 echo "Forcing known good options on Windows"
4578d01f 232 if test -z "$CC" ; then
7409711b
HL
233 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
234 CC="i686-w64-mingw32-gcc"
235 else
236 CC="x86_64-w64-mingw32-gcc"
237 fi
4578d01f 238 fi
4feafb1e 239 output_sym "CONFIG_LITTLE_ENDIAN"
7409711b
HL
240 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
241 output_sym "CONFIG_32BIT"
242 else
243 output_sym "CONFIG_64BIT_LLP64"
244 fi
4feafb1e
JA
245 output_sym "CONFIG_FADVISE"
246 output_sym "CONFIG_SOCKLEN_T"
4feafb1e
JA
247 output_sym "CONFIG_FADVISE"
248 output_sym "CONFIG_SFAA"
249 output_sym "CONFIG_RUSAGE_THREAD"
250 output_sym "CONFIG_WINDOWSAIO"
251 output_sym "CONFIG_FDATASYNC"
59308a64 252 output_sym "CONFIG_CLOCK_MONOTONIC"
dc0518ca
BC
253 output_sym "CONFIG_GETTIMEOFDAY"
254 output_sym "CONFIG_CLOCK_GETTIME"
7e09a9f1 255 output_sym "CONFIG_SCHED_IDLE"
1eafa37a 256 output_sym "CONFIG_TCP_NODELAY"
7d6be13a 257 output_sym "CONFIG_TLS_THREAD"
ef07baa1 258 output_sym "CONFIG_IPV6"
4feafb1e 259 echo "CC=$CC" >> $config_host_mak
af4862b3 260 echo "BUILD_CFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
cfd94f79 261 exit 0
6d0e9f83 262 ;;
67bf9823
JA
263esac
264
265if test ! -z "$cpu" ; then
266 # command line argument
267 :
268elif check_define __i386__ ; then
269 cpu="i386"
270elif check_define __x86_64__ ; then
271 cpu="x86_64"
272elif check_define __sparc__ ; then
273 if check_define __arch64__ ; then
274 cpu="sparc64"
275 else
276 cpu="sparc"
277 fi
278elif check_define _ARCH_PPC ; then
279 if check_define _ARCH_PPC64 ; then
280 cpu="ppc64"
281 else
282 cpu="ppc"
283 fi
284elif check_define __mips__ ; then
285 cpu="mips"
286elif check_define __ia64__ ; then
287 cpu="ia64"
288elif check_define __s390__ ; then
289 if check_define __s390x__ ; then
290 cpu="s390x"
291 else
292 cpu="s390"
293 fi
294elif check_define __arm__ ; then
295 cpu="arm"
296elif check_define __hppa__ ; then
297 cpu="hppa"
298else
299 cpu=`uname -m`
300fi
301
302# Normalise host CPU name and set ARCH.
303case "$cpu" in
304 ia64|ppc|ppc64|s390|s390x|sparc64)
305 cpu="$cpu"
306 ;;
307 i386|i486|i586|i686|i86pc|BePC)
308 cpu="i386"
309 ;;
310 x86_64|amd64)
311 cpu="x86_64"
312 ;;
313 armv*b|armv*l|arm)
314 cpu="arm"
315 ;;
316 hppa|parisc|parisc64)
317 cpu="hppa"
318 ;;
319 mips*)
320 cpu="mips"
321 ;;
322 sparc|sun4[cdmuv])
323 cpu="sparc"
324 ;;
325 *)
8b156d8e 326 echo "Unknown CPU"
67bf9823
JA
327 ;;
328esac
329
dcbbf5b0 330if test -z "$CC" ; then
67bf9823
JA
331 if test "$targetos" = "FreeBSD"; then
332 if has clang; then
333 CC=clang
334 else
335 CC=gcc
336 fi
67bf9823
JA
337 fi
338fi
339
340cc="${CC-${cross_prefix}gcc}"
341
1a17cfdb
AC
342##########################################
343# check cross compile
344
345cross_compile="no"
346cat > $TMPC <<EOF
347int main(void)
348{
349 return 0;
350}
351EOF
352if compile_prog "" "" "cross"; then
353 $TMPE 2>/dev/null || cross_compile="yes"
354else
355 fatal "compile test failed"
356fi
357
0dcebdf4
JA
358##########################################
359# check endianness
360bigendian="no"
1a17cfdb
AC
361if test "$cross_compile" = "no" ; then
362 cat > $TMPC <<EOF
0dcebdf4
JA
363#include <inttypes.h>
364int main(void)
365{
366 volatile uint32_t i=0x01234567;
367 return (*((uint8_t*)(&i))) == 0x67;
368}
369EOF
1a17cfdb
AC
370 if compile_prog "" "" "endian"; then
371 $TMPE && bigendian="yes"
372 fi
373else
374 # If we're cross compiling, try our best to work it out and rely on the
375 # run-time check to fail if we get it wrong.
376 cat > $TMPC <<EOF
377#include <endian.h>
378int main(void)
379{
380#if __BYTE_ORDER != __BIG_ENDIAN
381# error "Unknown endianness"
382#endif
383}
384EOF
385 compile_prog "" "" "endian" && bigendian="yes"
386 check_define "__ARMEB__" && bigendian="yes"
387 check_define "__MIPSEB__" && bigendian="yes"
0dcebdf4
JA
388fi
389
390
67bf9823
JA
391echo "Operating system $targetos"
392echo "CPU $cpu"
0dcebdf4 393echo "Big endian $bigendian"
67bf9823 394echo "Compiler $cc"
1a17cfdb 395echo "Cross compile $cross_compile"
67bf9823
JA
396echo
397
398##########################################
399# check for wordsize
400wordsize="0"
401cat > $TMPC <<EOF
142429e5
AC
402#include <limits.h>
403#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
67bf9823
JA
404int main(void)
405{
142429e5 406 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
67bf9823
JA
407 return 0;
408}
409EOF
142429e5
AC
410if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
411 wordsize="32"
412elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
413 wordsize="64"
414else
415 fatal "Unknown wordsize"
67bf9823
JA
416fi
417echo "Wordsize $wordsize"
418
a9bca4aa
JA
419##########################################
420# zlib probe
421zlib="no"
422cat > $TMPC <<EOF
e0186b6f 423#include <zlib.h>
a9bca4aa
JA
424int main(void)
425{
426 z_stream stream;
427 if (inflateInit(&stream) != Z_OK)
428 return 1;
429 return 0;
430}
431EOF
432if compile_prog "" "-lz" "zlib" ; then
433 zlib=yes
434 LIBS="-lz $LIBS"
a9bca4aa
JA
435fi
436echo "zlib $zlib"
437
67bf9823
JA
438##########################################
439# linux-aio probe
440libaio="no"
441cat > $TMPC <<EOF
442#include <libaio.h>
443#include <stddef.h>
444int main(void)
445{
446 io_setup(0, NULL);
447 return 0;
448}
449EOF
450if compile_prog "" "-laio" "libaio" ; then
451 libaio=yes
452 LIBS="-laio $LIBS"
453else
454 if test "$libaio" = "yes" ; then
c55d728b 455 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
67bf9823
JA
456 fi
457 libaio=no
458fi
459echo "Linux AIO support $libaio"
460
461##########################################
462# posix aio probe
463posix_aio="no"
464posix_aio_lrt="no"
465cat > $TMPC <<EOF
466#include <aio.h>
467int main(void)
468{
469 struct aiocb cb;
470 aio_read(&cb);
471 return 0;
472}
473EOF
474if compile_prog "" "" "posixaio" ; then
475 posix_aio="yes"
476elif compile_prog "" "-lrt" "posixaio"; then
477 posix_aio="yes"
478 posix_aio_lrt="yes"
479 LIBS="-lrt $LIBS"
480fi
481echo "POSIX AIO support $posix_aio"
482echo "POSIX AIO support needs -lrt $posix_aio_lrt"
483
484##########################################
485# posix aio fsync probe
486posix_aio_fsync="no"
487if test "$posix_aio" = "yes" ; then
488 cat > $TMPC <<EOF
489#include <fcntl.h>
490#include <aio.h>
491int main(void)
492{
493 struct aiocb cb;
494 return aio_fsync(O_SYNC, &cb);
495 return 0;
496}
497EOF
498 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
499 posix_aio_fsync=yes
500 fi
501fi
502echo "POSIX AIO fsync $posix_aio_fsync"
503
504##########################################
505# solaris aio probe
506solaris_aio="no"
507cat > $TMPC <<EOF
508#include <sys/types.h>
509#include <sys/asynch.h>
510#include <unistd.h>
511int main(void)
512{
513 aio_result_t res;
514 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
515 return 0;
516}
517EOF
518if compile_prog "" "-laio" "solarisaio" ; then
519 solaris_aio=yes
520 LIBS="-laio $LIBS"
521fi
522echo "Solaris AIO support $solaris_aio"
523
524##########################################
525# __sync_fetch_and_and test
526sfaa="no"
527cat > $TMPC << EOF
528static int sfaa(int *ptr)
529{
9c639a76 530 return __sync_fetch_and_add(ptr, 0);
67bf9823
JA
531}
532
533int main(int argc, char **argv)
534{
535 int val = 42;
536 sfaa(&val);
537 return val;
538}
539EOF
540if compile_prog "" "" "__sync_fetch_and_add()" ; then
541 sfaa="yes"
542fi
9c639a76 543echo "__sync_fetch_and_add $sfaa"
67bf9823
JA
544
545##########################################
546# libverbs probe
547libverbs="no"
548cat > $TMPC << EOF
549#include <stdio.h>
550#include <infiniband/arch.h>
551int main(int argc, char **argv)
552{
553 struct ibv_pd *pd = ibv_alloc_pd(NULL);
554 return 0;
555}
556EOF
557if compile_prog "" "-libverbs" "libverbs" ; then
558 libverbs="yes"
559 LIBS="-libverbs $LIBS"
560fi
561echo "libverbs $libverbs"
562
563##########################################
564# rdmacm probe
565rdmacm="no"
566cat > $TMPC << EOF
567#include <stdio.h>
568#include <rdma/rdma_cma.h>
569int main(int argc, char **argv)
570{
571 rdma_destroy_qp(NULL);
572 return 0;
573}
574EOF
575if compile_prog "" "-lrdmacm" "rdma"; then
576 rdmacm="yes"
577 LIBS="-lrdmacm $LIBS"
578fi
579echo "rdmacm $rdmacm"
580
581##########################################
582# Linux fallocate probe
583linux_fallocate="no"
584cat > $TMPC << EOF
585#include <stdio.h>
aa6738a5 586#include <fcntl.h>
67bf9823
JA
587#include <linux/falloc.h>
588int main(int argc, char **argv)
589{
590 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
591 return r;
592}
593EOF
594if compile_prog "" "" "linux_fallocate"; then
595 linux_fallocate="yes"
596fi
597echo "Linux fallocate $linux_fallocate"
598
599##########################################
600# POSIX fadvise probe
601posix_fadvise="no"
602cat > $TMPC << EOF
603#include <stdio.h>
604#include <fcntl.h>
605int main(int argc, char **argv)
606{
607 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
608 return r;
609}
610EOF
611if compile_prog "" "" "posix_fadvise"; then
612 posix_fadvise="yes"
613fi
614echo "POSIX fadvise $posix_fadvise"
615
616##########################################
617# POSIX fallocate probe
618posix_fallocate="no"
619cat > $TMPC << EOF
620#include <stdio.h>
621#include <fcntl.h>
622int main(int argc, char **argv)
623{
624 int r = posix_fallocate(0, 0, 1024);
625 return r;
626}
627EOF
628if compile_prog "" "" "posix_fallocate"; then
629 posix_fallocate="yes"
630fi
631echo "POSIX fallocate $posix_fallocate"
632
633##########################################
634# sched_set/getaffinity 2 or 3 argument test
635linux_2arg_affinity="no"
636linux_3arg_affinity="no"
637cat > $TMPC << EOF
67bf9823
JA
638#include <sched.h>
639int main(int argc, char **argv)
640{
641 cpu_set_t mask;
642 return sched_setaffinity(0, sizeof(mask), &mask);
643}
644EOF
645if compile_prog "" "" "sched_setaffinity(,,)"; then
646 linux_3arg_affinity="yes"
647else
648 cat > $TMPC << EOF
67bf9823
JA
649#include <sched.h>
650int main(int argc, char **argv)
651{
652 cpu_set_t mask;
653 return sched_setaffinity(0, &mask);
654}
655EOF
656 if compile_prog "" "" "sched_setaffinity(,)"; then
657 linux_2arg_affinity="yes"
658 fi
659fi
660echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
661echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
662
663##########################################
664# clock_gettime probe
665clock_gettime="no"
666cat > $TMPC << EOF
667#include <stdio.h>
668#include <time.h>
669int main(int argc, char **argv)
670{
671 return clock_gettime(0, NULL);
672}
673EOF
674if compile_prog "" "" "clock_gettime"; then
675 clock_gettime="yes"
676elif compile_prog "" "-lrt" "clock_gettime"; then
677 clock_gettime="yes"
678 LIBS="-lrt $LIBS"
679fi
680echo "clock_gettime $clock_gettime"
681
682##########################################
683# CLOCK_MONOTONIC probe
684clock_monotonic="no"
685if test "$clock_gettime" = "yes" ; then
686 cat > $TMPC << EOF
687#include <stdio.h>
688#include <time.h>
689int main(int argc, char **argv)
690{
691 return clock_gettime(CLOCK_MONOTONIC, NULL);
692}
693EOF
694 if compile_prog "" "$LIBS" "clock monotonic"; then
695 clock_monotonic="yes"
696 fi
697fi
698echo "CLOCK_MONOTONIC $clock_monotonic"
699
700##########################################
701# CLOCK_MONOTONIC_PRECISE probe
702clock_monotonic_precise="no"
703if test "$clock_gettime" = "yes" ; then
704 cat > $TMPC << EOF
705#include <stdio.h>
706#include <time.h>
707int main(int argc, char **argv)
708{
709 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
710}
711EOF
712 if compile_prog "" "$LIBS" "clock monotonic precise"; then
713 clock_monotonic_precise="yes"
714 fi
715fi
716echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
717
718##########################################
719# gettimeofday() probe
720gettimeofday="no"
721cat > $TMPC << EOF
722#include <sys/time.h>
723#include <stdio.h>
724int main(int argc, char **argv)
725{
726 struct timeval tv;
727 return gettimeofday(&tv, NULL);
728}
729EOF
730if compile_prog "" "" "gettimeofday"; then
731 gettimeofday="yes"
732fi
733echo "gettimeofday $gettimeofday"
734
735##########################################
736# fdatasync() probe
737fdatasync="no"
738cat > $TMPC << EOF
739#include <stdio.h>
740#include <unistd.h>
741int main(int argc, char **argv)
742{
743 return fdatasync(0);
744}
745EOF
746if compile_prog "" "" "fdatasync"; then
747 fdatasync="yes"
748fi
749echo "fdatasync $fdatasync"
750
751##########################################
752# sync_file_range() probe
753sync_file_range="no"
754cat > $TMPC << EOF
755#include <stdio.h>
756#include <unistd.h>
67bf9823
JA
757#include <fcntl.h>
758#include <linux/fs.h>
759int main(int argc, char **argv)
760{
761 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
762 SYNC_FILE_RANGE_WAIT_AFTER;
763 return sync_file_range(0, 0, 0, flags);
764}
765EOF
766if compile_prog "" "" "sync_file_range"; then
767 sync_file_range="yes"
768fi
769echo "sync_file_range $sync_file_range"
770
771##########################################
772# ext4 move extent probe
773ext4_me="no"
774cat > $TMPC << EOF
775#include <fcntl.h>
776#include <sys/ioctl.h>
777int main(int argc, char **argv)
778{
779 struct move_extent me;
780 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
781}
782EOF
c7165b8d
JA
783if compile_prog "" "" "ext4 move extent" ; then
784 ext4_me="yes"
785elif test $targetos = "Linux" ; then
786 # On Linux, just default to it on and let it error at runtime if we really
787 # don't have it. None of my updated systems have it defined, but it does
788 # work. Takes a while to bubble back.
67bf9823
JA
789 ext4_me="yes"
790fi
791echo "EXT4 move extent $ext4_me"
792
793##########################################
794# splice probe
795linux_splice="no"
796cat > $TMPC << EOF
67bf9823
JA
797#include <stdio.h>
798#include <fcntl.h>
799int main(int argc, char **argv)
800{
801 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
802}
803EOF
804if compile_prog "" "" "linux splice"; then
805 linux_splice="yes"
806fi
807echo "Linux splice(2) $linux_splice"
808
809##########################################
810# GUASI probe
811guasi="no"
812cat > $TMPC << EOF
813#include <guasi.h>
814#include <guasi_syscalls.h>
815int main(int argc, char **argv)
816{
817 guasi_t ctx = guasi_create(0, 0, 0);
818 return 0;
819}
820EOF
821if compile_prog "" "" "guasi"; then
822 guasi="yes"
823fi
824echo "GUASI $guasi"
825
826##########################################
827# fusion-aw probe
828fusion_aw="no"
829cat > $TMPC << EOF
b2c77c25 830#include <nvm/nvm_primitives.h>
67bf9823
JA
831int main(int argc, char **argv)
832{
b2c77c25
SK
833 nvm_version_t ver_info;
834 nvm_handle_t handle;
835
836 handle = nvm_get_handle(0, &ver_info);
837 return nvm_atomic_write(handle, 0, 0, 0);
67bf9823
JA
838}
839EOF
b2c77c25
SK
840if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -lvsl -ldl" "fusion-aw"; then
841 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -lvsl -ldl $LIBS"
67bf9823
JA
842 fusion_aw="yes"
843fi
844echo "Fusion-io atomic engine $fusion_aw"
845
846##########################################
847# libnuma probe
848libnuma="no"
849cat > $TMPC << EOF
850#include <numa.h>
851int main(int argc, char **argv)
852{
853 return numa_available();
854}
855EOF
44462517 856if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
67bf9823
JA
857 libnuma="yes"
858 LIBS="-lnuma $LIBS"
859fi
860echo "libnuma $libnuma"
861
50206d9b
JA
862##########################################
863# libnuma 2.x version API
864if test "$libnuma" = "yes" ; then
865libnuma_v2="no"
866cat > $TMPC << EOF
867#include <numa.h>
868int main(int argc, char **argv)
869{
870 struct bitmask *mask = numa_parse_nodestring(NULL);
871 return 0;
872}
873EOF
874if compile_prog "" "" "libnuma api"; then
875 libnuma_v2="yes"
876fi
877echo "libnuma v2 $libnuma_v2"
878fi
879
67bf9823
JA
880##########################################
881# strsep() probe
882strsep="no"
883cat > $TMPC << EOF
884#include <string.h>
885int main(int argc, char **argv)
886{
887 strsep(NULL, NULL);
888 return 0;
889}
890EOF
891if compile_prog "" "" "strsep"; then
892 strsep="yes"
893fi
894echo "strsep $strsep"
895
9ad8da82
JA
896##########################################
897# strcasestr() probe
898strcasestr="no"
899cat > $TMPC << EOF
900#include <string.h>
901int main(int argc, char **argv)
902{
aa6738a5 903 return strcasestr(argv[0], argv[1]) != NULL;
9ad8da82
JA
904}
905EOF
906if compile_prog "" "" "strcasestr"; then
907 strcasestr="yes"
908fi
909echo "strcasestr $strcasestr"
910
67bf9823
JA
911##########################################
912# getopt_long_only() probe
913getopt_long_only="no"
914cat > $TMPC << EOF
915#include <unistd.h>
916#include <stdio.h>
aa6738a5 917#include <getopt.h>
67bf9823
JA
918int main(int argc, char **argv)
919{
920 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
921 return c;
922}
923EOF
924if compile_prog "" "" "getopt_long_only"; then
925 getopt_long_only="yes"
926fi
927echo "getopt_long_only() $getopt_long_only"
928
929##########################################
930# inet_aton() probe
931inet_aton="no"
932cat > $TMPC << EOF
933#include <sys/socket.h>
934#include <arpa/inet.h>
935#include <stdio.h>
936int main(int argc, char **argv)
937{
938 struct in_addr in;
939 return inet_aton(NULL, &in);
940}
941EOF
942if compile_prog "" "" "inet_aton"; then
943 inet_aton="yes"
944fi
945echo "inet_aton $inet_aton"
946
947##########################################
948# socklen_t probe
949socklen_t="no"
950cat > $TMPC << EOF
f6482613 951#include <sys/socket.h>
67bf9823
JA
952int main(int argc, char **argv)
953{
954 socklen_t len = 0;
955 return len;
956}
957EOF
958if compile_prog "" "" "socklen_t"; then
959 socklen_t="yes"
960fi
961echo "socklen_t $socklen_t"
962
963##########################################
964# Whether or not __thread is supported for TLS
965tls_thread="no"
966cat > $TMPC << EOF
967#include <stdio.h>
aa6738a5 968static __thread int ret;
67bf9823
JA
969int main(int argc, char **argv)
970{
971 return ret;
972}
973EOF
974if compile_prog "" "" "__thread"; then
975 tls_thread="yes"
976fi
977echo "__thread $tls_thread"
978
91f94d5b 979##########################################
2639f056 980# Check if we have required gtk/glib support for gfio
91f94d5b
JA
981if test "$gfio" = "yes" ; then
982 cat > $TMPC << EOF
983#include <glib.h>
984#include <cairo.h>
985#include <gtk/gtk.h>
986int main(void)
987{
988 gdk_threads_enter();
91f94d5b 989 gdk_threads_leave();
b7a99316
JA
990
991 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
91f94d5b
JA
992}
993EOF
994GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
995if test "$?" != "0" ; then
996 echo "configure: gtk and gthread not found"
997 exit 1
998fi
999GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1000if test "$?" != "0" ; then
1001 echo "configure: gtk and gthread not found"
1002 exit 1
1003fi
b7a99316
JA
1004if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1005 r=$($TMPE)
1006 if test "$r" != "0" ; then
1007 gfio="yes"
1008 LIBS="$LIBS $GTK_LIBS"
1009 CFLAGS="$CFLAGS $GTK_CFLAGS"
1010 else
1011 echo "GTK found, but need version 2.18 or higher"
1012 gfio="no"
1013 fi
91f94d5b
JA
1014else
1015 echo "Please install gtk and gdk libraries"
1016 gfio="no"
1017fi
1018fi
1019
2639f056 1020echo "gtk 2.18 or higher $gfio"
91f94d5b 1021
44404c5a
JA
1022# Check whether we have getrusage(RUSAGE_THREAD)
1023rusage_thread="no"
1024cat > $TMPC << EOF
1025#include <sys/time.h>
1026#include <sys/resource.h>
1027int main(int argc, char **argv)
1028{
1029 struct rusage ru;
1030 getrusage(RUSAGE_THREAD, &ru);
1031 return 0;
1032}
1033EOF
1034if compile_prog "" "" "RUSAGE_THREAD"; then
1035 rusage_thread="yes"
1036fi
1037echo "RUSAGE_THREAD $rusage_thread"
1038
7e09a9f1
JA
1039##########################################
1040# Check whether we have SCHED_IDLE
1041sched_idle="no"
1042cat > $TMPC << EOF
1043#include <sched.h>
1044int main(int argc, char **argv)
1045{
1046 struct sched_param p;
1047 return sched_setscheduler(0, SCHED_IDLE, &p);
1048}
1049EOF
1050if compile_prog "" "" "SCHED_IDLE"; then
1051 sched_idle="yes"
1052fi
1053echo "SCHED_IDLE $sched_idle"
1054
1eafa37a
JA
1055##########################################
1056# Check whether we have TCP_NODELAY
1057tcp_nodelay="no"
1058cat > $TMPC << EOF
1059#include <stdio.h>
1060#include <sys/types.h>
1061#include <sys/socket.h>
1062#include <netinet/tcp.h>
1063int main(int argc, char **argv)
1064{
1065 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1066}
1067EOF
1068if compile_prog "" "" "TCP_NODELAY"; then
1069 tcp_nodelay="yes"
1070fi
1071echo "TCP_NODELAY $tcp_nodelay"
1072
38b9354a
JA
1073##########################################
1074# Check whether we have RLIMIT_MEMLOCK
1075rlimit_memlock="no"
1076cat > $TMPC << EOF
1077#include <sys/time.h>
1078#include <sys/resource.h>
1079int main(int argc, char **argv)
1080{
1081 struct rlimit rl;
1082 return getrlimit(RLIMIT_MEMLOCK, &rl);
1083}
1084EOF
1085if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1086 rlimit_memlock="yes"
1087fi
1088echo "RLIMIT_MEMLOCK $rlimit_memlock"
1089
07fc0acd
JA
1090##########################################
1091# Check whether we have pwritev/preadv
1092pwritev="no"
1093cat > $TMPC << EOF
1094#include <stdio.h>
1095#include <sys/uio.h>
1096int main(int argc, char **argv)
1097{
1098 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1099}
1100EOF
1101if compile_prog "" "" "pwritev"; then
1102 pwritev="yes"
1103fi
1104echo "pwritev/preadv $pwritev"
1105
ecad55e9
JA
1106##########################################
1107# Check whether we have the required functions for ipv6
1108ipv6="no"
1109cat > $TMPC << EOF
1110#include <sys/types.h>
1111#include <sys/socket.h>
d219028d 1112#include <netinet/in.h>
ecad55e9
JA
1113#include <netdb.h>
1114#include <stdio.h>
1115int main(int argc, char **argv)
1116{
1117 struct addrinfo hints;
1118 struct in6_addr addr;
1119 int ret;
1120
1121 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1122 freeaddrinfo(NULL);
1123 printf("%s\n", gai_strerror(ret));
1124 addr = in6addr_any;
1125 return 0;
1126}
1127EOF
1128if compile_prog "" "" "ipv6"; then
1129 ipv6="yes"
1130fi
1131echo "IPv6 helpers $ipv6"
07fc0acd 1132
fc5c0345
DG
1133##########################################
1134# check for rbd
1135rbd="no"
1136cat > $TMPC << EOF
1137#include <rbd/librbd.h>
1138
1139int main(int argc, char **argv)
1140{
1141
1142 rados_t cluster;
1143 rados_ioctx_t io_ctx;
1144 const char pool[] = "rbd";
1145
1146 int major, minor, extra;
1147 rbd_version(&major, &minor, &extra);
1148
1149 rados_ioctx_create(cluster, pool, &io_ctx);
1150 return 0;
1151}
1152EOF
ce18290e 1153if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
fc5c0345
DG
1154 LIBS="-lrbd -lrados $LIBS"
1155 rbd="yes"
1156fi
1157echo "Rados Block Device engine $rbd"
1158
2e802282
JA
1159##########################################
1160# Check whether we have setvbuf
1161setvbuf="no"
1162cat > $TMPC << EOF
1163#include <stdio.h>
1164int main(int argc, char **argv)
1165{
1166 FILE *f = NULL;
1167 char buf[80];
1168 setvbuf(f, buf, _IOFBF, sizeof(buf));
1169 return 0;
1170}
1171EOF
1172if compile_prog "" "" "setvbuf"; then
1173 setvbuf="yes"
1174fi
1175echo "setvbuf $setvbuf"
fc5c0345 1176
6e7d7dfb 1177# check for gfapi
1178gfapi="no"
1179cat > $TMPC << EOF
1180#include <glusterfs/api/glfs.h>
1181
1182int main(int argc, char **argv)
1183{
1184
1185 glfs_t *g = glfs_new("foo");
1186
1187 return 0;
1188}
1189EOF
ce18290e 1190if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
6e7d7dfb 1191 LIBS="-lgfapi -lglusterfs $LIBS"
1192 gfapi="yes"
1193fi
6fa14b99 1194 echo "Gluster API engine $gfapi"
6e7d7dfb 1195
6fa14b99 1196##########################################
1197# check for gfapi fadvise support
1198gf_fadvise="no"
1199cat > $TMPC << EOF
1200#include <glusterfs/api/glfs.h>
1201
1202int main(int argc, char **argv)
1203{
1204 struct glfs_fd *fd;
1205 int ret = glfs_fadvise(fd, 0, 0, 1);
1206
1207 return 0;
1208}
1209EOF
1210
1211if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1212 gf_fadvise="yes"
1213fi
1214echo "Gluster API use fadvise $gf_fadvise"
fc5c0345 1215
81795ce3
CE
1216##########################################
1217# Check if we support stckf on s390
1218s390_z196_facilities="no"
1219cat > $TMPC << EOF
1220#define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1221int main(int argc, char **argv)
1222{
1223 /* We want just 1 double word to be returned. */
1224 register unsigned long reg0 asm("0") = 0;
1225 unsigned long stfle_bits;
1226 asm volatile(".machine push" "\n\t"
1227 ".machine \"z9-109\"" "\n\t"
1228 "stfle %0" "\n\t"
1229 ".machine pop" "\n"
1230 : "=QS" (stfle_bits), "+d" (reg0)
1231 : : "cc");
1232
1233 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1234 return 0;
1235 else
1236 return -1;
1237}
1238EOF
1239if compile_prog "" "" "s390_z196_facilities"; then
1240 $TMPE
1241 if [[ $? -eq 0 ]]; then
1242 s390_z196_facilities="yes"
1243 fi
1244fi
1245echo "s390_z196_facilities $s390_z196_facilities"
67bf9823
JA
1246#############################################################################
1247
67bf9823 1248if test "$wordsize" = "64" ; then
4feafb1e 1249 output_sym "CONFIG_64BIT"
67bf9823 1250elif test "$wordsize" = "32" ; then
4feafb1e 1251 output_sym "CONFIG_32BIT"
67bf9823 1252else
d7145a78 1253 fatal "Unknown wordsize!"
67bf9823 1254fi
0dcebdf4 1255if test "$bigendian" = "yes" ; then
4feafb1e 1256 output_sym "CONFIG_BIG_ENDIAN"
0dcebdf4 1257else
4feafb1e 1258 output_sym "CONFIG_LITTLE_ENDIAN"
0dcebdf4 1259fi
3989b143
JA
1260if test "$zlib" = "yes" ; then
1261 output_sym "CONFIG_ZLIB"
1262fi
67bf9823 1263if test "$libaio" = "yes" ; then
4feafb1e 1264 output_sym "CONFIG_LIBAIO"
67bf9823
JA
1265fi
1266if test "$posix_aio" = "yes" ; then
4feafb1e 1267 output_sym "CONFIG_POSIXAIO"
67bf9823
JA
1268fi
1269if test "$posix_aio_fsync" = "yes" ; then
4feafb1e 1270 output_sym "CONFIG_POSIXAIO_FSYNC"
67bf9823
JA
1271fi
1272if test "$linux_fallocate" = "yes" ; then
4feafb1e 1273 output_sym "CONFIG_LINUX_FALLOCATE"
67bf9823
JA
1274fi
1275if test "$posix_fallocate" = "yes" ; then
4feafb1e 1276 output_sym "CONFIG_POSIX_FALLOCATE"
67bf9823
JA
1277fi
1278if test "$fdatasync" = "yes" ; then
4feafb1e 1279 output_sym "CONFIG_FDATASYNC"
67bf9823
JA
1280fi
1281if test "$sync_file_range" = "yes" ; then
4feafb1e 1282 output_sym "CONFIG_SYNC_FILE_RANGE"
67bf9823
JA
1283fi
1284if test "$sfaa" = "yes" ; then
4feafb1e 1285 output_sym "CONFIG_SFAA"
67bf9823 1286fi
954cd73a 1287if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
4feafb1e 1288 output_sym "CONFIG_RDMA"
67bf9823
JA
1289fi
1290if test "$clock_gettime" = "yes" ; then
4feafb1e 1291 output_sym "CONFIG_CLOCK_GETTIME"
67bf9823
JA
1292fi
1293if test "$clock_monotonic" = "yes" ; then
4feafb1e 1294 output_sym "CONFIG_CLOCK_MONOTONIC"
67bf9823
JA
1295fi
1296if test "$clock_monotonic_precise" = "yes" ; then
4feafb1e 1297 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
67bf9823
JA
1298fi
1299if test "$gettimeofday" = "yes" ; then
4feafb1e 1300 output_sym "CONFIG_GETTIMEOFDAY"
67bf9823
JA
1301fi
1302if test "$posix_fadvise" = "yes" ; then
4feafb1e 1303 output_sym "CONFIG_POSIX_FADVISE"
67bf9823
JA
1304fi
1305if test "$linux_3arg_affinity" = "yes" ; then
4feafb1e 1306 output_sym "CONFIG_3ARG_AFFINITY"
67bf9823 1307elif test "$linux_2arg_affinity" = "yes" ; then
4feafb1e 1308 output_sym "CONFIG_2ARG_AFFINITY"
67bf9823
JA
1309fi
1310if test "$strsep" = "yes" ; then
4feafb1e 1311 output_sym "CONFIG_STRSEP"
67bf9823 1312fi
9ad8da82
JA
1313if test "$strcasestr" = "yes" ; then
1314 output_sym "CONFIG_STRCASESTR"
1315fi
67bf9823 1316if test "$getopt_long_only" = "yes" ; then
4feafb1e 1317 output_sym "CONFIG_GETOPT_LONG_ONLY"
67bf9823
JA
1318fi
1319if test "$inet_aton" = "yes" ; then
4feafb1e 1320 output_sym "CONFIG_INET_ATON"
67bf9823
JA
1321fi
1322if test "$socklen_t" = "yes" ; then
4feafb1e 1323 output_sym "CONFIG_SOCKLEN_T"
67bf9823
JA
1324fi
1325if test "$ext4_me" = "yes" ; then
4feafb1e 1326 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
67bf9823
JA
1327fi
1328if test "$linux_splice" = "yes" ; then
4feafb1e 1329 output_sym "CONFIG_LINUX_SPLICE"
67bf9823
JA
1330fi
1331if test "$guasi" = "yes" ; then
4feafb1e 1332 output_sym "CONFIG_GUASI"
67bf9823
JA
1333fi
1334if test "$fusion_aw" = "yes" ; then
4feafb1e 1335 output_sym "CONFIG_FUSION_AW"
67bf9823 1336fi
50206d9b 1337if test "$libnuma_v2" = "yes" ; then
4feafb1e 1338 output_sym "CONFIG_LIBNUMA"
67bf9823
JA
1339fi
1340if test "$solaris_aio" = "yes" ; then
4feafb1e 1341 output_sym "CONFIG_SOLARISAIO"
67bf9823
JA
1342fi
1343if test "$tls_thread" = "yes" ; then
4feafb1e 1344 output_sym "CONFIG_TLS_THREAD"
67bf9823 1345fi
44404c5a 1346if test "$rusage_thread" = "yes" ; then
4feafb1e 1347 output_sym "CONFIG_RUSAGE_THREAD"
67bf9823 1348fi
91f94d5b
JA
1349if test "$gfio" = "yes" ; then
1350 echo "CONFIG_GFIO=y" >> $config_host_mak
1351fi
c8931876
JA
1352if test "$esx" = "yes" ; then
1353 output_sym "CONFIG_ESX"
1354 output_sym "CONFIG_NO_SHM"
1355fi
7e09a9f1
JA
1356if test "$sched_idle" = "yes" ; then
1357 output_sym "CONFIG_SCHED_IDLE"
1358fi
1eafa37a
JA
1359if test "$tcp_nodelay" = "yes" ; then
1360 output_sym "CONFIG_TCP_NODELAY"
1361fi
38b9354a
JA
1362if test "$rlimit_memlock" = "yes" ; then
1363 output_sym "CONFIG_RLIMIT_MEMLOCK"
1364fi
07fc0acd
JA
1365if test "$pwritev" = "yes" ; then
1366 output_sym "CONFIG_PWRITEV"
1367fi
ecad55e9
JA
1368if test "$ipv6" = "yes" ; then
1369 output_sym "CONFIG_IPV6"
1370fi
fc5c0345
DG
1371if test "$rbd" = "yes" ; then
1372 output_sym "CONFIG_RBD"
1373fi
2e802282
JA
1374if test "$setvbuf" = "yes" ; then
1375 output_sym "CONFIG_SETVBUF"
1376fi
81795ce3
CE
1377if test "$s390_z196_facilities" = "yes" ; then
1378 output_sym "CONFIG_S390_Z196_FACILITIES"
1379 CFLAGS="$CFLAGS -march=z9-109"
1380fi
6e7d7dfb 1381if test "$gfapi" = "yes" ; then
1382 output_sym "CONFIG_GFAPI"
1383fi
6fa14b99 1384if test "$gf_fadvise" = "yes" ; then
1385 output_sym "CONFIG_GF_FADVISE"
1386fi
67bf9823 1387
605cf82e
JA
1388if test "$zlib" = "no" ; then
1389 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
1390fi
1391
67bf9823 1392echo "LIBS+=$LIBS" >> $config_host_mak
91f94d5b 1393echo "CFLAGS+=$CFLAGS" >> $config_host_mak
67bf9823 1394echo "CC=$cc" >> $config_host_mak
af4862b3 1395echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak