Move rbtree to lib/
[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=""
44404c5a 43
67bf9823
JA
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
97
98 echo "ERROR"
99 echo "ERROR: User requested feature $feature"
100 echo "ERROR: configure was not able to find it"
d7145a78 101 fatal "ERROR"
67bf9823
JA
102}
103
104has() {
105 type "$1" >/dev/null 2>&1
106}
107
108check_define() {
109 cat > $TMPC <<EOF
110#if !defined($1)
111#error $1 not defined
112#endif
113int main(void)
114{
115 return 0;
116}
117EOF
118 compile_object
119}
120
4feafb1e
JA
121output_sym() {
122 echo "$1=y" >> $config_host_mak
123 echo "#define $1" >> $config_host_h
124}
125
67bf9823
JA
126targetos=""
127cpu=""
128
53cd4eee 129cross_prefix=${cross_prefix-${CROSS_COMPILE}}
67bf9823
JA
130cc="${CC-${cross_prefix}gcc}"
131
899fab33
JA
132show_help="no"
133exit_val=0
134
cb1125b0
JA
135# parse options
136for opt do
137 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
138 case "$opt" in
8b156d8e
JA
139 --cpu=*) cpu="$optarg"
140 ;;
cb1125b0
JA
141 --cc=*) CC="$optarg"
142 ;;
208e4c8b
JA
143 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
144 ;;
7409711b
HL
145 --build-32bit-win=*) build_32bit_win="$optarg"
146 ;;
899fab33
JA
147 --help)
148 show_help="yes"
149 ;;
cb1125b0
JA
150 *)
151 echo "Bad option $opt"
899fab33
JA
152 show_help="yes"
153 exit_val=1
cb1125b0
JA
154 esac
155done
156
899fab33 157if test "$show_help" = "yes" ; then
8b156d8e 158 echo "--cpu= Specify target CPU if auto-detect fails"
899fab33
JA
159 echo "--cc= Specify compiler to use"
160 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
723d7b34 161 echo "--build-32bit-win= Specify yes for a 32-bit build on Windows"
899fab33
JA
162 exit $exit_val
163fi
164
6d0e9f83
AC
165if check_define __ANDROID__ ; then
166 targetos="Android"
167elif check_define __linux__ ; then
67bf9823 168 targetos="Linux"
67bf9823
JA
169elif check_define __OpenBSD__ ; then
170 targetos='OpenBSD'
171elif check_define __sun__ ; then
172 targetos='SunOS'
173else
174 targetos=`uname -s`
175fi
176
53cd4eee
AC
177echo "# Automatically generated by configure - do not modify" > $config_host_mak
178printf "# Configured with:" >> $config_host_mak
179printf " '%s'" "$0" "$@" >> $config_host_mak
180echo >> $config_host_mak
181echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
182
67bf9823
JA
183# Some host OSes need non-standard checks for which CPU to use.
184# Note that these checks are broken for cross-compilation: if you're
185# cross-compiling to one of these OSes then you'll need to specify
186# the correct CPU with the --cpu option.
187case $targetos in
188Darwin)
189 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
190 # we can run 64-bit userspace code.
191 # If the user didn't specify a CPU explicitly and the kernel says this is
192 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
193 # detection code.
194 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
195 cpu="x86_64"
196 fi
197 ;;
198SunOS)
199 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
200 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
201 cpu="x86_64"
202 fi
adaa46d8 203 LIBS="-lnsl -lsocket"
cfd94f79
JA
204 ;;
205CYGWIN*)
206 echo "Forcing known good options on Windows"
4578d01f 207 if test -z "$CC" ; then
7409711b
HL
208 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
209 CC="i686-w64-mingw32-gcc"
210 else
211 CC="x86_64-w64-mingw32-gcc"
212 fi
4578d01f 213 fi
4feafb1e 214 output_sym "CONFIG_LITTLE_ENDIAN"
7409711b
HL
215 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
216 output_sym "CONFIG_32BIT"
217 else
218 output_sym "CONFIG_64BIT_LLP64"
219 fi
4feafb1e
JA
220 output_sym "CONFIG_FADVISE"
221 output_sym "CONFIG_SOCKLEN_T"
4feafb1e
JA
222 output_sym "CONFIG_FADVISE"
223 output_sym "CONFIG_SFAA"
224 output_sym "CONFIG_RUSAGE_THREAD"
225 output_sym "CONFIG_WINDOWSAIO"
226 output_sym "CONFIG_FDATASYNC"
59308a64 227 output_sym "CONFIG_CLOCK_MONOTONIC"
dc0518ca
BC
228 output_sym "CONFIG_GETTIMEOFDAY"
229 output_sym "CONFIG_CLOCK_GETTIME"
7e09a9f1 230 output_sym "CONFIG_SCHED_IDLE"
1eafa37a 231 output_sym "CONFIG_TCP_NODELAY"
4feafb1e 232 echo "CC=$CC" >> $config_host_mak
af4862b3 233 echo "BUILD_CFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
cfd94f79 234 exit 0
6d0e9f83 235 ;;
67bf9823
JA
236esac
237
238if test ! -z "$cpu" ; then
239 # command line argument
240 :
241elif check_define __i386__ ; then
242 cpu="i386"
243elif check_define __x86_64__ ; then
244 cpu="x86_64"
245elif check_define __sparc__ ; then
246 if check_define __arch64__ ; then
247 cpu="sparc64"
248 else
249 cpu="sparc"
250 fi
251elif check_define _ARCH_PPC ; then
252 if check_define _ARCH_PPC64 ; then
253 cpu="ppc64"
254 else
255 cpu="ppc"
256 fi
257elif check_define __mips__ ; then
258 cpu="mips"
259elif check_define __ia64__ ; then
260 cpu="ia64"
261elif check_define __s390__ ; then
262 if check_define __s390x__ ; then
263 cpu="s390x"
264 else
265 cpu="s390"
266 fi
267elif check_define __arm__ ; then
268 cpu="arm"
269elif check_define __hppa__ ; then
270 cpu="hppa"
271else
272 cpu=`uname -m`
273fi
274
275# Normalise host CPU name and set ARCH.
276case "$cpu" in
277 ia64|ppc|ppc64|s390|s390x|sparc64)
278 cpu="$cpu"
279 ;;
280 i386|i486|i586|i686|i86pc|BePC)
281 cpu="i386"
282 ;;
283 x86_64|amd64)
284 cpu="x86_64"
285 ;;
286 armv*b|armv*l|arm)
287 cpu="arm"
288 ;;
289 hppa|parisc|parisc64)
290 cpu="hppa"
291 ;;
292 mips*)
293 cpu="mips"
294 ;;
295 sparc|sun4[cdmuv])
296 cpu="sparc"
297 ;;
298 *)
8b156d8e 299 echo "Unknown CPU"
67bf9823
JA
300 ;;
301esac
302
dcbbf5b0 303if test -z "$CC" ; then
67bf9823
JA
304 if test "$targetos" = "FreeBSD"; then
305 if has clang; then
306 CC=clang
307 else
308 CC=gcc
309 fi
67bf9823
JA
310 fi
311fi
312
313cc="${CC-${cross_prefix}gcc}"
314
1a17cfdb
AC
315##########################################
316# check cross compile
317
318cross_compile="no"
319cat > $TMPC <<EOF
320int main(void)
321{
322 return 0;
323}
324EOF
325if compile_prog "" "" "cross"; then
326 $TMPE 2>/dev/null || cross_compile="yes"
327else
328 fatal "compile test failed"
329fi
330
0dcebdf4
JA
331##########################################
332# check endianness
333bigendian="no"
1a17cfdb
AC
334if test "$cross_compile" = "no" ; then
335 cat > $TMPC <<EOF
0dcebdf4
JA
336#include <inttypes.h>
337int main(void)
338{
339 volatile uint32_t i=0x01234567;
340 return (*((uint8_t*)(&i))) == 0x67;
341}
342EOF
1a17cfdb
AC
343 if compile_prog "" "" "endian"; then
344 $TMPE && bigendian="yes"
345 fi
346else
347 # If we're cross compiling, try our best to work it out and rely on the
348 # run-time check to fail if we get it wrong.
349 cat > $TMPC <<EOF
350#include <endian.h>
351int main(void)
352{
353#if __BYTE_ORDER != __BIG_ENDIAN
354# error "Unknown endianness"
355#endif
356}
357EOF
358 compile_prog "" "" "endian" && bigendian="yes"
359 check_define "__ARMEB__" && bigendian="yes"
360 check_define "__MIPSEB__" && bigendian="yes"
0dcebdf4
JA
361fi
362
363
67bf9823
JA
364echo "Operating system $targetos"
365echo "CPU $cpu"
0dcebdf4 366echo "Big endian $bigendian"
67bf9823 367echo "Compiler $cc"
1a17cfdb 368echo "Cross compile $cross_compile"
67bf9823
JA
369echo
370
371##########################################
372# check for wordsize
373wordsize="0"
374cat > $TMPC <<EOF
142429e5
AC
375#include <limits.h>
376#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
67bf9823
JA
377int main(void)
378{
142429e5 379 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
67bf9823
JA
380 return 0;
381}
382EOF
142429e5
AC
383if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
384 wordsize="32"
385elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
386 wordsize="64"
387else
388 fatal "Unknown wordsize"
67bf9823
JA
389fi
390echo "Wordsize $wordsize"
391
392##########################################
393# linux-aio probe
394libaio="no"
395cat > $TMPC <<EOF
396#include <libaio.h>
397#include <stddef.h>
398int main(void)
399{
400 io_setup(0, NULL);
401 return 0;
402}
403EOF
404if compile_prog "" "-laio" "libaio" ; then
405 libaio=yes
406 LIBS="-laio $LIBS"
407else
408 if test "$libaio" = "yes" ; then
409 feature_not_found "linux AIO"
410 fi
411 libaio=no
412fi
413echo "Linux AIO support $libaio"
414
415##########################################
416# posix aio probe
417posix_aio="no"
418posix_aio_lrt="no"
419cat > $TMPC <<EOF
420#include <aio.h>
421int main(void)
422{
423 struct aiocb cb;
424 aio_read(&cb);
425 return 0;
426}
427EOF
428if compile_prog "" "" "posixaio" ; then
429 posix_aio="yes"
430elif compile_prog "" "-lrt" "posixaio"; then
431 posix_aio="yes"
432 posix_aio_lrt="yes"
433 LIBS="-lrt $LIBS"
434fi
435echo "POSIX AIO support $posix_aio"
436echo "POSIX AIO support needs -lrt $posix_aio_lrt"
437
438##########################################
439# posix aio fsync probe
440posix_aio_fsync="no"
441if test "$posix_aio" = "yes" ; then
442 cat > $TMPC <<EOF
443#include <fcntl.h>
444#include <aio.h>
445int main(void)
446{
447 struct aiocb cb;
448 return aio_fsync(O_SYNC, &cb);
449 return 0;
450}
451EOF
452 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
453 posix_aio_fsync=yes
454 fi
455fi
456echo "POSIX AIO fsync $posix_aio_fsync"
457
458##########################################
459# solaris aio probe
460solaris_aio="no"
461cat > $TMPC <<EOF
462#include <sys/types.h>
463#include <sys/asynch.h>
464#include <unistd.h>
465int main(void)
466{
467 aio_result_t res;
468 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
469 return 0;
470}
471EOF
472if compile_prog "" "-laio" "solarisaio" ; then
473 solaris_aio=yes
474 LIBS="-laio $LIBS"
475fi
476echo "Solaris AIO support $solaris_aio"
477
478##########################################
479# __sync_fetch_and_and test
480sfaa="no"
481cat > $TMPC << EOF
482static int sfaa(int *ptr)
483{
9c639a76 484 return __sync_fetch_and_add(ptr, 0);
67bf9823
JA
485}
486
487int main(int argc, char **argv)
488{
489 int val = 42;
490 sfaa(&val);
491 return val;
492}
493EOF
494if compile_prog "" "" "__sync_fetch_and_add()" ; then
495 sfaa="yes"
496fi
9c639a76 497echo "__sync_fetch_and_add $sfaa"
67bf9823
JA
498
499##########################################
500# libverbs probe
501libverbs="no"
502cat > $TMPC << EOF
503#include <stdio.h>
504#include <infiniband/arch.h>
505int main(int argc, char **argv)
506{
507 struct ibv_pd *pd = ibv_alloc_pd(NULL);
508 return 0;
509}
510EOF
511if compile_prog "" "-libverbs" "libverbs" ; then
512 libverbs="yes"
513 LIBS="-libverbs $LIBS"
514fi
515echo "libverbs $libverbs"
516
517##########################################
518# rdmacm probe
519rdmacm="no"
520cat > $TMPC << EOF
521#include <stdio.h>
522#include <rdma/rdma_cma.h>
523int main(int argc, char **argv)
524{
525 rdma_destroy_qp(NULL);
526 return 0;
527}
528EOF
529if compile_prog "" "-lrdmacm" "rdma"; then
530 rdmacm="yes"
531 LIBS="-lrdmacm $LIBS"
532fi
533echo "rdmacm $rdmacm"
534
535##########################################
536# Linux fallocate probe
537linux_fallocate="no"
538cat > $TMPC << EOF
539#include <stdio.h>
540#include <linux/falloc.h>
541int main(int argc, char **argv)
542{
543 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
544 return r;
545}
546EOF
547if compile_prog "" "" "linux_fallocate"; then
548 linux_fallocate="yes"
549fi
550echo "Linux fallocate $linux_fallocate"
551
552##########################################
553# POSIX fadvise probe
554posix_fadvise="no"
555cat > $TMPC << EOF
556#include <stdio.h>
557#include <fcntl.h>
558int main(int argc, char **argv)
559{
560 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
561 return r;
562}
563EOF
564if compile_prog "" "" "posix_fadvise"; then
565 posix_fadvise="yes"
566fi
567echo "POSIX fadvise $posix_fadvise"
568
569##########################################
570# POSIX fallocate probe
571posix_fallocate="no"
572cat > $TMPC << EOF
573#include <stdio.h>
574#include <fcntl.h>
575int main(int argc, char **argv)
576{
577 int r = posix_fallocate(0, 0, 1024);
578 return r;
579}
580EOF
581if compile_prog "" "" "posix_fallocate"; then
582 posix_fallocate="yes"
583fi
584echo "POSIX fallocate $posix_fallocate"
585
586##########################################
587# sched_set/getaffinity 2 or 3 argument test
588linux_2arg_affinity="no"
589linux_3arg_affinity="no"
590cat > $TMPC << EOF
67bf9823
JA
591#include <sched.h>
592int main(int argc, char **argv)
593{
594 cpu_set_t mask;
595 return sched_setaffinity(0, sizeof(mask), &mask);
596}
597EOF
598if compile_prog "" "" "sched_setaffinity(,,)"; then
599 linux_3arg_affinity="yes"
600else
601 cat > $TMPC << EOF
67bf9823
JA
602#include <sched.h>
603int main(int argc, char **argv)
604{
605 cpu_set_t mask;
606 return sched_setaffinity(0, &mask);
607}
608EOF
609 if compile_prog "" "" "sched_setaffinity(,)"; then
610 linux_2arg_affinity="yes"
611 fi
612fi
613echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
614echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
615
616##########################################
617# clock_gettime probe
618clock_gettime="no"
619cat > $TMPC << EOF
620#include <stdio.h>
621#include <time.h>
622int main(int argc, char **argv)
623{
624 return clock_gettime(0, NULL);
625}
626EOF
627if compile_prog "" "" "clock_gettime"; then
628 clock_gettime="yes"
629elif compile_prog "" "-lrt" "clock_gettime"; then
630 clock_gettime="yes"
631 LIBS="-lrt $LIBS"
632fi
633echo "clock_gettime $clock_gettime"
634
635##########################################
636# CLOCK_MONOTONIC probe
637clock_monotonic="no"
638if test "$clock_gettime" = "yes" ; then
639 cat > $TMPC << EOF
640#include <stdio.h>
641#include <time.h>
642int main(int argc, char **argv)
643{
644 return clock_gettime(CLOCK_MONOTONIC, NULL);
645}
646EOF
647 if compile_prog "" "$LIBS" "clock monotonic"; then
648 clock_monotonic="yes"
649 fi
650fi
651echo "CLOCK_MONOTONIC $clock_monotonic"
652
653##########################################
654# CLOCK_MONOTONIC_PRECISE probe
655clock_monotonic_precise="no"
656if test "$clock_gettime" = "yes" ; then
657 cat > $TMPC << EOF
658#include <stdio.h>
659#include <time.h>
660int main(int argc, char **argv)
661{
662 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
663}
664EOF
665 if compile_prog "" "$LIBS" "clock monotonic precise"; then
666 clock_monotonic_precise="yes"
667 fi
668fi
669echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
670
671##########################################
672# gettimeofday() probe
673gettimeofday="no"
674cat > $TMPC << EOF
675#include <sys/time.h>
676#include <stdio.h>
677int main(int argc, char **argv)
678{
679 struct timeval tv;
680 return gettimeofday(&tv, NULL);
681}
682EOF
683if compile_prog "" "" "gettimeofday"; then
684 gettimeofday="yes"
685fi
686echo "gettimeofday $gettimeofday"
687
688##########################################
689# fdatasync() probe
690fdatasync="no"
691cat > $TMPC << EOF
692#include <stdio.h>
693#include <unistd.h>
694int main(int argc, char **argv)
695{
696 return fdatasync(0);
697}
698EOF
699if compile_prog "" "" "fdatasync"; then
700 fdatasync="yes"
701fi
702echo "fdatasync $fdatasync"
703
704##########################################
705# sync_file_range() probe
706sync_file_range="no"
707cat > $TMPC << EOF
708#include <stdio.h>
709#include <unistd.h>
67bf9823
JA
710#include <fcntl.h>
711#include <linux/fs.h>
712int main(int argc, char **argv)
713{
714 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
715 SYNC_FILE_RANGE_WAIT_AFTER;
716 return sync_file_range(0, 0, 0, flags);
717}
718EOF
719if compile_prog "" "" "sync_file_range"; then
720 sync_file_range="yes"
721fi
722echo "sync_file_range $sync_file_range"
723
724##########################################
725# ext4 move extent probe
726ext4_me="no"
727cat > $TMPC << EOF
728#include <fcntl.h>
729#include <sys/ioctl.h>
730int main(int argc, char **argv)
731{
732 struct move_extent me;
733 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
734}
735EOF
c7165b8d
JA
736if compile_prog "" "" "ext4 move extent" ; then
737 ext4_me="yes"
738elif test $targetos = "Linux" ; then
739 # On Linux, just default to it on and let it error at runtime if we really
740 # don't have it. None of my updated systems have it defined, but it does
741 # work. Takes a while to bubble back.
67bf9823
JA
742 ext4_me="yes"
743fi
744echo "EXT4 move extent $ext4_me"
745
746##########################################
747# splice probe
748linux_splice="no"
749cat > $TMPC << EOF
67bf9823
JA
750#include <stdio.h>
751#include <fcntl.h>
752int main(int argc, char **argv)
753{
754 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
755}
756EOF
757if compile_prog "" "" "linux splice"; then
758 linux_splice="yes"
759fi
760echo "Linux splice(2) $linux_splice"
761
762##########################################
763# GUASI probe
764guasi="no"
765cat > $TMPC << EOF
766#include <guasi.h>
767#include <guasi_syscalls.h>
768int main(int argc, char **argv)
769{
770 guasi_t ctx = guasi_create(0, 0, 0);
771 return 0;
772}
773EOF
774if compile_prog "" "" "guasi"; then
775 guasi="yes"
776fi
777echo "GUASI $guasi"
778
779##########################################
780# fusion-aw probe
781fusion_aw="no"
782cat > $TMPC << EOF
99db6564 783#include <nvm/vectored_write.h>
67bf9823
JA
784int main(int argc, char **argv)
785{
786 struct vsl_iovec iov;
787 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
788}
789EOF
99db6564
JA
790if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
791 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
67bf9823
JA
792 fusion_aw="yes"
793fi
794echo "Fusion-io atomic engine $fusion_aw"
795
796##########################################
797# libnuma probe
798libnuma="no"
799cat > $TMPC << EOF
800#include <numa.h>
801int main(int argc, char **argv)
802{
803 return numa_available();
804}
805EOF
806if compile_prog "" "-lnuma" "libnuma"; then
807 libnuma="yes"
808 LIBS="-lnuma $LIBS"
809fi
810echo "libnuma $libnuma"
811
50206d9b
JA
812##########################################
813# libnuma 2.x version API
814if test "$libnuma" = "yes" ; then
815libnuma_v2="no"
816cat > $TMPC << EOF
817#include <numa.h>
818int main(int argc, char **argv)
819{
820 struct bitmask *mask = numa_parse_nodestring(NULL);
821 return 0;
822}
823EOF
824if compile_prog "" "" "libnuma api"; then
825 libnuma_v2="yes"
826fi
827echo "libnuma v2 $libnuma_v2"
828fi
829
67bf9823
JA
830##########################################
831# strsep() probe
832strsep="no"
833cat > $TMPC << EOF
834#include <string.h>
835int main(int argc, char **argv)
836{
837 strsep(NULL, NULL);
838 return 0;
839}
840EOF
841if compile_prog "" "" "strsep"; then
842 strsep="yes"
843fi
844echo "strsep $strsep"
845
9ad8da82
JA
846##########################################
847# strcasestr() probe
848strcasestr="no"
849cat > $TMPC << EOF
850#include <string.h>
851int main(int argc, char **argv)
852{
853 strcasestr(NULL, NULL);
854 return 0;
855}
856EOF
857if compile_prog "" "" "strcasestr"; then
858 strcasestr="yes"
859fi
860echo "strcasestr $strcasestr"
861
67bf9823
JA
862##########################################
863# getopt_long_only() probe
864getopt_long_only="no"
865cat > $TMPC << EOF
866#include <unistd.h>
867#include <stdio.h>
868int main(int argc, char **argv)
869{
870 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
871 return c;
872}
873EOF
874if compile_prog "" "" "getopt_long_only"; then
875 getopt_long_only="yes"
876fi
877echo "getopt_long_only() $getopt_long_only"
878
879##########################################
880# inet_aton() probe
881inet_aton="no"
882cat > $TMPC << EOF
883#include <sys/socket.h>
884#include <arpa/inet.h>
885#include <stdio.h>
886int main(int argc, char **argv)
887{
888 struct in_addr in;
889 return inet_aton(NULL, &in);
890}
891EOF
892if compile_prog "" "" "inet_aton"; then
893 inet_aton="yes"
894fi
895echo "inet_aton $inet_aton"
896
897##########################################
898# socklen_t probe
899socklen_t="no"
900cat > $TMPC << EOF
f6482613 901#include <sys/socket.h>
67bf9823
JA
902int main(int argc, char **argv)
903{
904 socklen_t len = 0;
905 return len;
906}
907EOF
908if compile_prog "" "" "socklen_t"; then
909 socklen_t="yes"
910fi
911echo "socklen_t $socklen_t"
912
913##########################################
914# Whether or not __thread is supported for TLS
915tls_thread="no"
916cat > $TMPC << EOF
917#include <stdio.h>
918static int __thread ret;
919int main(int argc, char **argv)
920{
921 return ret;
922}
923EOF
924if compile_prog "" "" "__thread"; then
925 tls_thread="yes"
926fi
927echo "__thread $tls_thread"
928
44404c5a
JA
929##########################################
930# Check whether we have getrusage(RUSAGE_THREAD)
931rusage_thread="no"
932cat > $TMPC << EOF
933#include <sys/time.h>
934#include <sys/resource.h>
935int main(int argc, char **argv)
936{
937 struct rusage ru;
938 getrusage(RUSAGE_THREAD, &ru);
939 return 0;
940}
941EOF
942if compile_prog "" "" "RUSAGE_THREAD"; then
943 rusage_thread="yes"
944fi
945echo "RUSAGE_THREAD $rusage_thread"
946
7e09a9f1
JA
947##########################################
948# Check whether we have SCHED_IDLE
949sched_idle="no"
950cat > $TMPC << EOF
951#include <sched.h>
952int main(int argc, char **argv)
953{
954 struct sched_param p;
955 return sched_setscheduler(0, SCHED_IDLE, &p);
956}
957EOF
958if compile_prog "" "" "SCHED_IDLE"; then
959 sched_idle="yes"
960fi
961echo "SCHED_IDLE $sched_idle"
962
1eafa37a
JA
963##########################################
964# Check whether we have TCP_NODELAY
965tcp_nodelay="no"
966cat > $TMPC << EOF
967#include <stdio.h>
968#include <sys/types.h>
969#include <sys/socket.h>
970#include <netinet/tcp.h>
971int main(int argc, char **argv)
972{
973 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
974}
975EOF
976if compile_prog "" "" "TCP_NODELAY"; then
977 tcp_nodelay="yes"
978fi
979echo "TCP_NODELAY $tcp_nodelay"
980
38b9354a
JA
981##########################################
982# Check whether we have RLIMIT_MEMLOCK
983rlimit_memlock="no"
984cat > $TMPC << EOF
985#include <sys/time.h>
986#include <sys/resource.h>
987int main(int argc, char **argv)
988{
989 struct rlimit rl;
990 return getrlimit(RLIMIT_MEMLOCK, &rl);
991}
992EOF
993if compile_prog "" "" "RLIMIT_MEMLOCK"; then
994 rlimit_memlock="yes"
995fi
996echo "RLIMIT_MEMLOCK $rlimit_memlock"
997
67bf9823
JA
998#############################################################################
999
67bf9823 1000if test "$wordsize" = "64" ; then
4feafb1e 1001 output_sym "CONFIG_64BIT"
67bf9823 1002elif test "$wordsize" = "32" ; then
4feafb1e 1003 output_sym "CONFIG_32BIT"
67bf9823 1004else
d7145a78 1005 fatal "Unknown wordsize!"
67bf9823 1006fi
0dcebdf4 1007if test "$bigendian" = "yes" ; then
4feafb1e 1008 output_sym "CONFIG_BIG_ENDIAN"
0dcebdf4 1009else
4feafb1e 1010 output_sym "CONFIG_LITTLE_ENDIAN"
0dcebdf4 1011fi
67bf9823 1012if test "$libaio" = "yes" ; then
4feafb1e 1013 output_sym "CONFIG_LIBAIO"
67bf9823
JA
1014fi
1015if test "$posix_aio" = "yes" ; then
4feafb1e 1016 output_sym "CONFIG_POSIXAIO"
67bf9823
JA
1017fi
1018if test "$posix_aio_fsync" = "yes" ; then
4feafb1e 1019 output_sym "CONFIG_POSIXAIO_FSYNC"
67bf9823
JA
1020fi
1021if test "$linux_fallocate" = "yes" ; then
4feafb1e 1022 output_sym "CONFIG_LINUX_FALLOCATE"
67bf9823
JA
1023fi
1024if test "$posix_fallocate" = "yes" ; then
4feafb1e 1025 output_sym "CONFIG_POSIX_FALLOCATE"
67bf9823
JA
1026fi
1027if test "$fdatasync" = "yes" ; then
4feafb1e 1028 output_sym "CONFIG_FDATASYNC"
67bf9823
JA
1029fi
1030if test "$sync_file_range" = "yes" ; then
4feafb1e 1031 output_sym "CONFIG_SYNC_FILE_RANGE"
67bf9823
JA
1032fi
1033if test "$sfaa" = "yes" ; then
4feafb1e 1034 output_sym "CONFIG_SFAA"
67bf9823 1035fi
d9d9db0f 1036if test "$libverbs" = "yes" -a "rdmacm" = "yes" ; then
4feafb1e 1037 output_sym "CONFIG_RDMA"
67bf9823
JA
1038fi
1039if test "$clock_gettime" = "yes" ; then
4feafb1e 1040 output_sym "CONFIG_CLOCK_GETTIME"
67bf9823
JA
1041fi
1042if test "$clock_monotonic" = "yes" ; then
4feafb1e 1043 output_sym "CONFIG_CLOCK_MONOTONIC"
67bf9823
JA
1044fi
1045if test "$clock_monotonic_precise" = "yes" ; then
4feafb1e 1046 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
67bf9823
JA
1047fi
1048if test "$gettimeofday" = "yes" ; then
4feafb1e 1049 output_sym "CONFIG_GETTIMEOFDAY"
67bf9823
JA
1050fi
1051if test "$posix_fadvise" = "yes" ; then
4feafb1e 1052 output_sym "CONFIG_POSIX_FADVISE"
67bf9823
JA
1053fi
1054if test "$linux_3arg_affinity" = "yes" ; then
4feafb1e 1055 output_sym "CONFIG_3ARG_AFFINITY"
67bf9823 1056elif test "$linux_2arg_affinity" = "yes" ; then
4feafb1e 1057 output_sym "CONFIG_2ARG_AFFINITY"
67bf9823
JA
1058fi
1059if test "$strsep" = "yes" ; then
4feafb1e 1060 output_sym "CONFIG_STRSEP"
67bf9823 1061fi
9ad8da82
JA
1062if test "$strcasestr" = "yes" ; then
1063 output_sym "CONFIG_STRCASESTR"
1064fi
67bf9823 1065if test "$getopt_long_only" = "yes" ; then
4feafb1e 1066 output_sym "CONFIG_GETOPT_LONG_ONLY"
67bf9823
JA
1067fi
1068if test "$inet_aton" = "yes" ; then
4feafb1e 1069 output_sym "CONFIG_INET_ATON"
67bf9823
JA
1070fi
1071if test "$socklen_t" = "yes" ; then
4feafb1e 1072 output_sym "CONFIG_SOCKLEN_T"
67bf9823
JA
1073fi
1074if test "$ext4_me" = "yes" ; then
4feafb1e 1075 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
67bf9823
JA
1076fi
1077if test "$linux_splice" = "yes" ; then
4feafb1e 1078 output_sym "CONFIG_LINUX_SPLICE"
67bf9823
JA
1079fi
1080if test "$guasi" = "yes" ; then
4feafb1e 1081 output_sym "CONFIG_GUASI"
67bf9823
JA
1082fi
1083if test "$fusion_aw" = "yes" ; then
4feafb1e 1084 output_sym "CONFIG_FUSION_AW"
67bf9823 1085fi
50206d9b 1086if test "$libnuma_v2" = "yes" ; then
4feafb1e 1087 output_sym "CONFIG_LIBNUMA"
67bf9823
JA
1088fi
1089if test "$solaris_aio" = "yes" ; then
4feafb1e 1090 output_sym "CONFIG_SOLARISAIO"
67bf9823
JA
1091fi
1092if test "$tls_thread" = "yes" ; then
4feafb1e 1093 output_sym "CONFIG_TLS_THREAD"
67bf9823 1094fi
44404c5a 1095if test "$rusage_thread" = "yes" ; then
4feafb1e 1096 output_sym "CONFIG_RUSAGE_THREAD"
44404c5a 1097fi
7e09a9f1
JA
1098if test "$sched_idle" = "yes" ; then
1099 output_sym "CONFIG_SCHED_IDLE"
1100fi
44583e02
JA
1101if test "$tcp_nodelay" = "yes" ; then
1102 output_sym "CONFIG_TCP_NODELAY"
1103fi
38b9354a
JA
1104if test "$rlimit_memlock" = "yes" ; then
1105 output_sym "CONFIG_RLIMIT_MEMLOCK"
1106fi
67bf9823
JA
1107
1108echo "LIBS+=$LIBS" >> $config_host_mak
1109echo "CC=$cc" >> $config_host_mak
af4862b3 1110echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak