blob: 078dab8885002459e71f44a8b98dbe69d230e2cd [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 Axboe44404c52013-01-24 14:20:09 -070032# Default CFLAGS
Jens Axboe208e4c82013-01-29 09:26:07 +010033CFLAGS="-D_GNU_SOURCE"
34EXTFLAGS="-include config-host.h"
Jens Axboe44404c52013-01-24 14:20:09 -070035
Jens Axboe67bf9822013-01-10 11:23:19 +010036# Print a helpful header at the top of config.log
37echo "# FIO configure log $(date)" >> config.log
38printf "# Configured with:" >> config.log
39printf " '%s'" "$0" "$@" >> config.log
40echo >> config.log
41echo "#" >> config.log
42
Jens Axboe7560fe72013-01-25 08:52:28 -070043# Print configure header at the top of $config_host_h
44echo "/*" > $config_host_h
45echo " * Automatically generated by configure - do not modify" >> $config_host_h
46printf " * Configured with:" >> $config_host_h
47printf " * '%s'" "$0" "$@" >> $config_host_h
48echo "" >> $config_host_h
49echo " */" >> $config_host_h
50
Jens Axboe67bf9822013-01-10 11:23:19 +010051do_cc() {
52 # Run the compiler, capturing its output to the log.
53 echo $cc "$@" >> config.log
54 $cc "$@" >> config.log 2>&1 || return $?
55 # Test passed. If this is an --enable-werror build, rerun
56 # the test with -Werror and bail out if it fails. This
57 # makes warning-generating-errors in configure test code
58 # obvious to developers.
59 if test "$werror" != "yes"; then
60 return 0
61 fi
62 # Don't bother rerunning the compile if we were already using -Werror
63 case "$*" in
64 *-Werror*)
65 return 0
66 ;;
67 esac
68 echo $cc -Werror "$@" >> config.log
69 $cc -Werror "$@" >> config.log 2>&1 && return $?
70 echo "ERROR: configure test passed without -Werror but failed with -Werror."
71 echo "This is probably a bug in the configure script. The failing command"
72 echo "will be at the bottom of config.log."
73 echo "You can run configure with --disable-werror to bypass this check."
74 exit 1
75}
76
77compile_object() {
78 do_cc $CFLAGS -c -o $TMPO $TMPC
79}
80
81compile_prog() {
82 local_cflags="$1"
83 local_ldflags="$2"
84 echo "Compiling test case $3" >> config.log
85 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
86}
87
88feature_not_found() {
89 feature=$1
90
91 echo "ERROR"
92 echo "ERROR: User requested feature $feature"
93 echo "ERROR: configure was not able to find it"
94 echo "ERROR"
95 exit 1;
96}
97
98has() {
99 type "$1" >/dev/null 2>&1
100}
101
102check_define() {
103 cat > $TMPC <<EOF
104#if !defined($1)
105#error $1 not defined
106#endif
107int main(void)
108{
109 return 0;
110}
111EOF
112 compile_object
113}
114
Jens Axboe4feafb12013-01-24 23:07:55 -0700115output_sym() {
116 echo "$1=y" >> $config_host_mak
117 echo "#define $1" >> $config_host_h
118}
119
Jens Axboe67bf9822013-01-10 11:23:19 +0100120targetos=""
121cpu=""
122
123cc="${CC-${cross_prefix}gcc}"
124
Jens Axboe899fab32013-01-29 10:06:30 +0100125show_help="no"
126exit_val=0
127
Jens Axboecb1125b2013-01-23 13:47:54 -0700128# parse options
129for opt do
130 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
131 case "$opt" in
132 --cc=*) CC="$optarg"
133 ;;
Jens Axboe208e4c82013-01-29 09:26:07 +0100134 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
135 ;;
Jens Axboe899fab32013-01-29 10:06:30 +0100136 --help)
137 show_help="yes"
138 ;;
Jens Axboecb1125b2013-01-23 13:47:54 -0700139 *)
140 echo "Bad option $opt"
Jens Axboe899fab32013-01-29 10:06:30 +0100141 show_help="yes"
142 exit_val=1
Jens Axboecb1125b2013-01-23 13:47:54 -0700143 esac
144done
145
Jens Axboe899fab32013-01-29 10:06:30 +0100146if test "$show_help" = "yes" ; then
147 echo "--cc= Specify compiler to use"
148 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
149 exit $exit_val
150fi
151
Jens Axboe67bf9822013-01-10 11:23:19 +0100152if check_define __linux__ ; then
153 targetos="Linux"
Jens Axboe67bf9822013-01-10 11:23:19 +0100154elif check_define __OpenBSD__ ; then
155 targetos='OpenBSD'
156elif check_define __sun__ ; then
157 targetos='SunOS'
158else
159 targetos=`uname -s`
160fi
161
162# Some host OSes need non-standard checks for which CPU to use.
163# Note that these checks are broken for cross-compilation: if you're
164# cross-compiling to one of these OSes then you'll need to specify
165# the correct CPU with the --cpu option.
166case $targetos in
167Darwin)
168 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
169 # we can run 64-bit userspace code.
170 # If the user didn't specify a CPU explicitly and the kernel says this is
171 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
172 # detection code.
173 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
174 cpu="x86_64"
175 fi
176 ;;
177SunOS)
178 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
179 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
180 cpu="x86_64"
181 fi
Jens Axboecfd94f72013-01-23 16:23:48 -0700182 ;;
183CYGWIN*)
184 echo "Forcing known good options on Windows"
Jens Axboe4578d012013-01-23 16:26:12 -0700185 if test -z "$CC" ; then
186 CC="x86_64-w64-mingw32-gcc"
187 fi
Jens Axboe4feafb12013-01-24 23:07:55 -0700188 output_sym "CONFIG_LITTLE_ENDIAN"
189 output_sym "CONFIG_64BIT_LLP64"
Jens Axboe4feafb12013-01-24 23:07:55 -0700190 output_sym "CONFIG_FADVISE"
191 output_sym "CONFIG_SOCKLEN_T"
192 output_sym "CONFIG_POSIX_FALLOCATE"
193 output_sym "CONFIG_FADVISE"
194 output_sym "CONFIG_SFAA"
195 output_sym "CONFIG_RUSAGE_THREAD"
196 output_sym "CONFIG_WINDOWSAIO"
197 output_sym "CONFIG_FDATASYNC"
Bruce Cran59308a62013-02-02 20:59:31 +0000198 output_sym "CONFIG_CLOCK_MONOTONIC"
Bruce Crandc0518c2013-01-28 16:07:15 +0000199 output_sym "CONFIG_GETTIMEOFDAY"
200 output_sym "CONFIG_CLOCK_GETTIME"
Jens Axboe7e09a9f2013-01-30 13:58:58 +0100201 output_sym "CONFIG_SCHED_IDLE"
Jens Axboe1eafa372013-01-31 10:19:51 +0100202 output_sym "CONFIG_TCP_NODELAY"
Jens Axboe4feafb12013-01-24 23:07:55 -0700203 echo "CC=$CC" >> $config_host_mak
Jens Axboe899fab32013-01-29 10:06:30 +0100204 echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
Jens Axboecfd94f72013-01-23 16:23:48 -0700205 exit 0
Jens Axboe67bf9822013-01-10 11:23:19 +0100206esac
207
208if test ! -z "$cpu" ; then
209 # command line argument
210 :
211elif check_define __i386__ ; then
212 cpu="i386"
213elif check_define __x86_64__ ; then
214 cpu="x86_64"
215elif check_define __sparc__ ; then
216 if check_define __arch64__ ; then
217 cpu="sparc64"
218 else
219 cpu="sparc"
220 fi
221elif check_define _ARCH_PPC ; then
222 if check_define _ARCH_PPC64 ; then
223 cpu="ppc64"
224 else
225 cpu="ppc"
226 fi
227elif check_define __mips__ ; then
228 cpu="mips"
229elif check_define __ia64__ ; then
230 cpu="ia64"
231elif check_define __s390__ ; then
232 if check_define __s390x__ ; then
233 cpu="s390x"
234 else
235 cpu="s390"
236 fi
237elif check_define __arm__ ; then
238 cpu="arm"
239elif check_define __hppa__ ; then
240 cpu="hppa"
241else
242 cpu=`uname -m`
243fi
244
245# Normalise host CPU name and set ARCH.
246case "$cpu" in
247 ia64|ppc|ppc64|s390|s390x|sparc64)
248 cpu="$cpu"
249 ;;
250 i386|i486|i586|i686|i86pc|BePC)
251 cpu="i386"
252 ;;
253 x86_64|amd64)
254 cpu="x86_64"
255 ;;
256 armv*b|armv*l|arm)
257 cpu="arm"
258 ;;
259 hppa|parisc|parisc64)
260 cpu="hppa"
261 ;;
262 mips*)
263 cpu="mips"
264 ;;
265 sparc|sun4[cdmuv])
266 cpu="sparc"
267 ;;
268 *)
269 echo "Unknown CPU"
270 exit 1;
271 ;;
272esac
273
Jens Axboedcbbf5b2013-01-25 14:35:27 -0700274if test -z "$CC" ; then
Jens Axboe67bf9822013-01-10 11:23:19 +0100275 if test "$targetos" = "FreeBSD"; then
276 if has clang; then
277 CC=clang
278 else
279 CC=gcc
280 fi
Jens Axboe67bf9822013-01-10 11:23:19 +0100281 fi
282fi
283
284cc="${CC-${cross_prefix}gcc}"
285
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700286##########################################
287# check endianness
288bigendian="no"
289cat > $TMPC <<EOF
290#include <inttypes.h>
291int main(void)
292{
293 volatile uint32_t i=0x01234567;
294 return (*((uint8_t*)(&i))) == 0x67;
295}
296EOF
297if compile_prog "" "" "endian"; then
298 $TMPE && bigendian="yes"
299fi
300
301
Jens Axboe67bf9822013-01-10 11:23:19 +0100302echo "Operating system $targetos"
303echo "CPU $cpu"
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700304echo "Big endian $bigendian"
Jens Axboe67bf9822013-01-10 11:23:19 +0100305echo "Compiler $cc"
306echo
307
308##########################################
309# check for wordsize
310wordsize="0"
311cat > $TMPC <<EOF
312#include <stdio.h>
313int main(void)
314{
315 unsigned int wsize = sizeof(long) * 8;
316 printf("%d\n", wsize);
317 return 0;
318}
319EOF
320if compile_prog "" "" "wordsize"; then
321 wordsize=$($TMPE)
322fi
323echo "Wordsize $wordsize"
324
325##########################################
326# linux-aio probe
327libaio="no"
328cat > $TMPC <<EOF
329#include <libaio.h>
330#include <stddef.h>
331int main(void)
332{
333 io_setup(0, NULL);
334 return 0;
335}
336EOF
337if compile_prog "" "-laio" "libaio" ; then
338 libaio=yes
339 LIBS="-laio $LIBS"
340else
341 if test "$libaio" = "yes" ; then
342 feature_not_found "linux AIO"
343 fi
344 libaio=no
345fi
346echo "Linux AIO support $libaio"
347
348##########################################
349# posix aio probe
350posix_aio="no"
351posix_aio_lrt="no"
352cat > $TMPC <<EOF
353#include <aio.h>
354int main(void)
355{
356 struct aiocb cb;
357 aio_read(&cb);
358 return 0;
359}
360EOF
361if compile_prog "" "" "posixaio" ; then
362 posix_aio="yes"
363elif compile_prog "" "-lrt" "posixaio"; then
364 posix_aio="yes"
365 posix_aio_lrt="yes"
366 LIBS="-lrt $LIBS"
367fi
368echo "POSIX AIO support $posix_aio"
369echo "POSIX AIO support needs -lrt $posix_aio_lrt"
370
371##########################################
372# posix aio fsync probe
373posix_aio_fsync="no"
374if test "$posix_aio" = "yes" ; then
375 cat > $TMPC <<EOF
376#include <fcntl.h>
377#include <aio.h>
378int main(void)
379{
380 struct aiocb cb;
381 return aio_fsync(O_SYNC, &cb);
382 return 0;
383}
384EOF
385 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
386 posix_aio_fsync=yes
387 fi
388fi
389echo "POSIX AIO fsync $posix_aio_fsync"
390
391##########################################
392# solaris aio probe
393solaris_aio="no"
394cat > $TMPC <<EOF
395#include <sys/types.h>
396#include <sys/asynch.h>
397#include <unistd.h>
398int main(void)
399{
400 aio_result_t res;
401 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
402 return 0;
403}
404EOF
405if compile_prog "" "-laio" "solarisaio" ; then
406 solaris_aio=yes
407 LIBS="-laio $LIBS"
408fi
409echo "Solaris AIO support $solaris_aio"
410
411##########################################
412# __sync_fetch_and_and test
413sfaa="no"
414cat > $TMPC << EOF
415static int sfaa(int *ptr)
416{
417 return __sync_fetch_and_and(ptr, 0);
418}
419
420int main(int argc, char **argv)
421{
422 int val = 42;
423 sfaa(&val);
424 return val;
425}
426EOF
427if compile_prog "" "" "__sync_fetch_and_add()" ; then
428 sfaa="yes"
429fi
430echo "__sync_fetch_and add $sfaa"
431
432##########################################
433# libverbs probe
434libverbs="no"
435cat > $TMPC << EOF
436#include <stdio.h>
437#include <infiniband/arch.h>
438int main(int argc, char **argv)
439{
440 struct ibv_pd *pd = ibv_alloc_pd(NULL);
441 return 0;
442}
443EOF
444if compile_prog "" "-libverbs" "libverbs" ; then
445 libverbs="yes"
446 LIBS="-libverbs $LIBS"
447fi
448echo "libverbs $libverbs"
449
450##########################################
451# rdmacm probe
452rdmacm="no"
453cat > $TMPC << EOF
454#include <stdio.h>
455#include <rdma/rdma_cma.h>
456int main(int argc, char **argv)
457{
458 rdma_destroy_qp(NULL);
459 return 0;
460}
461EOF
462if compile_prog "" "-lrdmacm" "rdma"; then
463 rdmacm="yes"
464 LIBS="-lrdmacm $LIBS"
465fi
466echo "rdmacm $rdmacm"
467
468##########################################
469# Linux fallocate probe
470linux_fallocate="no"
471cat > $TMPC << EOF
472#include <stdio.h>
473#include <linux/falloc.h>
474int main(int argc, char **argv)
475{
476 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
477 return r;
478}
479EOF
480if compile_prog "" "" "linux_fallocate"; then
481 linux_fallocate="yes"
482fi
483echo "Linux fallocate $linux_fallocate"
484
485##########################################
486# POSIX fadvise probe
487posix_fadvise="no"
488cat > $TMPC << EOF
489#include <stdio.h>
490#include <fcntl.h>
491int main(int argc, char **argv)
492{
493 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
494 return r;
495}
496EOF
497if compile_prog "" "" "posix_fadvise"; then
498 posix_fadvise="yes"
499fi
500echo "POSIX fadvise $posix_fadvise"
501
502##########################################
503# POSIX fallocate probe
504posix_fallocate="no"
505cat > $TMPC << EOF
506#include <stdio.h>
507#include <fcntl.h>
508int main(int argc, char **argv)
509{
510 int r = posix_fallocate(0, 0, 1024);
511 return r;
512}
513EOF
514if compile_prog "" "" "posix_fallocate"; then
515 posix_fallocate="yes"
516fi
517echo "POSIX fallocate $posix_fallocate"
518
519##########################################
520# sched_set/getaffinity 2 or 3 argument test
521linux_2arg_affinity="no"
522linux_3arg_affinity="no"
523cat > $TMPC << EOF
Jens Axboe67bf9822013-01-10 11:23:19 +0100524#include <sched.h>
525int main(int argc, char **argv)
526{
527 cpu_set_t mask;
528 return sched_setaffinity(0, sizeof(mask), &mask);
529}
530EOF
531if compile_prog "" "" "sched_setaffinity(,,)"; then
532 linux_3arg_affinity="yes"
533else
534 cat > $TMPC << EOF
Jens Axboe67bf9822013-01-10 11:23:19 +0100535#include <sched.h>
536int main(int argc, char **argv)
537{
538 cpu_set_t mask;
539 return sched_setaffinity(0, &mask);
540}
541EOF
542 if compile_prog "" "" "sched_setaffinity(,)"; then
543 linux_2arg_affinity="yes"
544 fi
545fi
546echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
547echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
548
549##########################################
550# clock_gettime probe
551clock_gettime="no"
552cat > $TMPC << EOF
553#include <stdio.h>
554#include <time.h>
555int main(int argc, char **argv)
556{
557 return clock_gettime(0, NULL);
558}
559EOF
560if compile_prog "" "" "clock_gettime"; then
561 clock_gettime="yes"
562elif compile_prog "" "-lrt" "clock_gettime"; then
563 clock_gettime="yes"
564 LIBS="-lrt $LIBS"
565fi
566echo "clock_gettime $clock_gettime"
567
568##########################################
569# CLOCK_MONOTONIC probe
570clock_monotonic="no"
571if test "$clock_gettime" = "yes" ; then
572 cat > $TMPC << EOF
573#include <stdio.h>
574#include <time.h>
575int main(int argc, char **argv)
576{
577 return clock_gettime(CLOCK_MONOTONIC, NULL);
578}
579EOF
580 if compile_prog "" "$LIBS" "clock monotonic"; then
581 clock_monotonic="yes"
582 fi
583fi
584echo "CLOCK_MONOTONIC $clock_monotonic"
585
586##########################################
587# CLOCK_MONOTONIC_PRECISE probe
588clock_monotonic_precise="no"
589if test "$clock_gettime" = "yes" ; then
590 cat > $TMPC << EOF
591#include <stdio.h>
592#include <time.h>
593int main(int argc, char **argv)
594{
595 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
596}
597EOF
598 if compile_prog "" "$LIBS" "clock monotonic precise"; then
599 clock_monotonic_precise="yes"
600 fi
601fi
602echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
603
604##########################################
605# gettimeofday() probe
606gettimeofday="no"
607cat > $TMPC << EOF
608#include <sys/time.h>
609#include <stdio.h>
610int main(int argc, char **argv)
611{
612 struct timeval tv;
613 return gettimeofday(&tv, NULL);
614}
615EOF
616if compile_prog "" "" "gettimeofday"; then
617 gettimeofday="yes"
618fi
619echo "gettimeofday $gettimeofday"
620
621##########################################
622# fdatasync() probe
623fdatasync="no"
624cat > $TMPC << EOF
625#include <stdio.h>
626#include <unistd.h>
627int main(int argc, char **argv)
628{
629 return fdatasync(0);
630}
631EOF
632if compile_prog "" "" "fdatasync"; then
633 fdatasync="yes"
634fi
635echo "fdatasync $fdatasync"
636
637##########################################
638# sync_file_range() probe
639sync_file_range="no"
640cat > $TMPC << EOF
641#include <stdio.h>
642#include <unistd.h>
Jens Axboe67bf9822013-01-10 11:23:19 +0100643#include <fcntl.h>
644#include <linux/fs.h>
645int main(int argc, char **argv)
646{
647 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
648 SYNC_FILE_RANGE_WAIT_AFTER;
649 return sync_file_range(0, 0, 0, flags);
650}
651EOF
652if compile_prog "" "" "sync_file_range"; then
653 sync_file_range="yes"
654fi
655echo "sync_file_range $sync_file_range"
656
657##########################################
658# ext4 move extent probe
659ext4_me="no"
660cat > $TMPC << EOF
661#include <fcntl.h>
662#include <sys/ioctl.h>
663int main(int argc, char **argv)
664{
665 struct move_extent me;
666 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
667}
668EOF
Jens Axboec7165b82013-01-12 10:27:53 +0100669if compile_prog "" "" "ext4 move extent" ; then
670 ext4_me="yes"
671elif test $targetos = "Linux" ; then
672 # On Linux, just default to it on and let it error at runtime if we really
673 # don't have it. None of my updated systems have it defined, but it does
674 # work. Takes a while to bubble back.
Jens Axboe67bf9822013-01-10 11:23:19 +0100675 ext4_me="yes"
676fi
677echo "EXT4 move extent $ext4_me"
678
679##########################################
680# splice probe
681linux_splice="no"
682cat > $TMPC << EOF
Jens Axboe67bf9822013-01-10 11:23:19 +0100683#include <stdio.h>
684#include <fcntl.h>
685int main(int argc, char **argv)
686{
687 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
688}
689EOF
690if compile_prog "" "" "linux splice"; then
691 linux_splice="yes"
692fi
693echo "Linux splice(2) $linux_splice"
694
695##########################################
696# GUASI probe
697guasi="no"
698cat > $TMPC << EOF
699#include <guasi.h>
700#include <guasi_syscalls.h>
701int main(int argc, char **argv)
702{
703 guasi_t ctx = guasi_create(0, 0, 0);
704 return 0;
705}
706EOF
707if compile_prog "" "" "guasi"; then
708 guasi="yes"
709fi
710echo "GUASI $guasi"
711
712##########################################
713# fusion-aw probe
714fusion_aw="no"
715cat > $TMPC << EOF
Jens Axboe99db6562013-01-14 19:33:40 +0100716#include <nvm/vectored_write.h>
Jens Axboe67bf9822013-01-10 11:23:19 +0100717int main(int argc, char **argv)
718{
719 struct vsl_iovec iov;
720 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
721}
722EOF
Jens Axboe99db6562013-01-14 19:33:40 +0100723if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
724 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
Jens Axboe67bf9822013-01-10 11:23:19 +0100725 fusion_aw="yes"
726fi
727echo "Fusion-io atomic engine $fusion_aw"
728
729##########################################
730# libnuma probe
731libnuma="no"
732cat > $TMPC << EOF
733#include <numa.h>
734int main(int argc, char **argv)
735{
736 return numa_available();
737}
738EOF
739if compile_prog "" "-lnuma" "libnuma"; then
740 libnuma="yes"
741 LIBS="-lnuma $LIBS"
742fi
743echo "libnuma $libnuma"
744
745##########################################
746# strsep() probe
747strsep="no"
748cat > $TMPC << EOF
749#include <string.h>
750int main(int argc, char **argv)
751{
752 strsep(NULL, NULL);
753 return 0;
754}
755EOF
756if compile_prog "" "" "strsep"; then
757 strsep="yes"
758fi
759echo "strsep $strsep"
760
761##########################################
762# getopt_long_only() probe
763getopt_long_only="no"
764cat > $TMPC << EOF
765#include <unistd.h>
766#include <stdio.h>
767int main(int argc, char **argv)
768{
769 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
770 return c;
771}
772EOF
773if compile_prog "" "" "getopt_long_only"; then
774 getopt_long_only="yes"
775fi
776echo "getopt_long_only() $getopt_long_only"
777
778##########################################
779# inet_aton() probe
780inet_aton="no"
781cat > $TMPC << EOF
782#include <sys/socket.h>
783#include <arpa/inet.h>
784#include <stdio.h>
785int main(int argc, char **argv)
786{
787 struct in_addr in;
788 return inet_aton(NULL, &in);
789}
790EOF
791if compile_prog "" "" "inet_aton"; then
792 inet_aton="yes"
793fi
794echo "inet_aton $inet_aton"
795
796##########################################
797# socklen_t probe
798socklen_t="no"
799cat > $TMPC << EOF
800#include <string.h>
801#include <netinet/in.h>
802int main(int argc, char **argv)
803{
804 socklen_t len = 0;
805 return len;
806}
807EOF
808if compile_prog "" "" "socklen_t"; then
809 socklen_t="yes"
810fi
811echo "socklen_t $socklen_t"
812
813##########################################
814# Whether or not __thread is supported for TLS
815tls_thread="no"
816cat > $TMPC << EOF
817#include <stdio.h>
818static int __thread ret;
819int main(int argc, char **argv)
820{
821 return ret;
822}
823EOF
824if compile_prog "" "" "__thread"; then
825 tls_thread="yes"
826fi
827echo "__thread $tls_thread"
828
Jens Axboe44404c52013-01-24 14:20:09 -0700829##########################################
830# Check whether we have getrusage(RUSAGE_THREAD)
831rusage_thread="no"
832cat > $TMPC << EOF
833#include <sys/time.h>
834#include <sys/resource.h>
835int main(int argc, char **argv)
836{
837 struct rusage ru;
838 getrusage(RUSAGE_THREAD, &ru);
839 return 0;
840}
841EOF
842if compile_prog "" "" "RUSAGE_THREAD"; then
843 rusage_thread="yes"
844fi
845echo "RUSAGE_THREAD $rusage_thread"
846
Jens Axboe7e09a9f2013-01-30 13:58:58 +0100847##########################################
848# Check whether we have SCHED_IDLE
849sched_idle="no"
850cat > $TMPC << EOF
851#include <sched.h>
852int main(int argc, char **argv)
853{
854 struct sched_param p;
855 return sched_setscheduler(0, SCHED_IDLE, &p);
856}
857EOF
858if compile_prog "" "" "SCHED_IDLE"; then
859 sched_idle="yes"
860fi
861echo "SCHED_IDLE $sched_idle"
862
Jens Axboe1eafa372013-01-31 10:19:51 +0100863##########################################
864# Check whether we have TCP_NODELAY
865tcp_nodelay="no"
866cat > $TMPC << EOF
867#include <stdio.h>
868#include <sys/types.h>
869#include <sys/socket.h>
870#include <netinet/tcp.h>
871int main(int argc, char **argv)
872{
873 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
874}
875EOF
876if compile_prog "" "" "TCP_NODELAY"; then
877 tcp_nodelay="yes"
878fi
879echo "TCP_NODELAY $tcp_nodelay"
880
Jens Axboe67bf9822013-01-10 11:23:19 +0100881#############################################################################
882
883echo "# Automatically generated by configure - do not modify" > $config_host_mak
884printf "# Configured with:" >> $config_host_mak
885printf " '%s'" "$0" "$@" >> $config_host_mak
886echo >> $config_host_mak
887
888if test "$wordsize" = "64" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700889 output_sym "CONFIG_64BIT"
Jens Axboe67bf9822013-01-10 11:23:19 +0100890elif test "$wordsize" = "32" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700891 output_sym "CONFIG_32BIT"
Jens Axboe67bf9822013-01-10 11:23:19 +0100892else
893 echo "Unknown wordsize!"
894 exit 1
895fi
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700896if test "$bigendian" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700897 output_sym "CONFIG_BIG_ENDIAN"
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700898else
Jens Axboe4feafb12013-01-24 23:07:55 -0700899 output_sym "CONFIG_LITTLE_ENDIAN"
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700900fi
Jens Axboe67bf9822013-01-10 11:23:19 +0100901if test "$libaio" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700902 output_sym "CONFIG_LIBAIO"
Jens Axboe67bf9822013-01-10 11:23:19 +0100903fi
904if test "$posix_aio" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700905 output_sym "CONFIG_POSIXAIO"
Jens Axboe67bf9822013-01-10 11:23:19 +0100906fi
907if test "$posix_aio_fsync" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700908 output_sym "CONFIG_POSIXAIO_FSYNC"
Jens Axboe67bf9822013-01-10 11:23:19 +0100909fi
910if test "$linux_fallocate" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700911 output_sym "CONFIG_LINUX_FALLOCATE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100912fi
913if test "$posix_fallocate" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700914 output_sym "CONFIG_POSIX_FALLOCATE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100915fi
916if test "$fdatasync" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700917 output_sym "CONFIG_FDATASYNC"
Jens Axboe67bf9822013-01-10 11:23:19 +0100918fi
919if test "$sync_file_range" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700920 output_sym "CONFIG_SYNC_FILE_RANGE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100921fi
922if test "$sfaa" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700923 output_sym "CONFIG_SFAA"
Jens Axboe67bf9822013-01-10 11:23:19 +0100924fi
925if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700926 output_sym "CONFIG_RDMA"
Jens Axboe67bf9822013-01-10 11:23:19 +0100927fi
928if test "$clock_gettime" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700929 output_sym "CONFIG_CLOCK_GETTIME"
Jens Axboe67bf9822013-01-10 11:23:19 +0100930fi
931if test "$clock_monotonic" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700932 output_sym "CONFIG_CLOCK_MONOTONIC"
Jens Axboe67bf9822013-01-10 11:23:19 +0100933fi
934if test "$clock_monotonic_precise" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700935 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100936fi
937if test "$gettimeofday" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700938 output_sym "CONFIG_GETTIMEOFDAY"
Jens Axboe67bf9822013-01-10 11:23:19 +0100939fi
940if test "$posix_fadvise" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700941 output_sym "CONFIG_POSIX_FADVISE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100942fi
943if test "$linux_3arg_affinity" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700944 output_sym "CONFIG_3ARG_AFFINITY"
Jens Axboe67bf9822013-01-10 11:23:19 +0100945elif test "$linux_2arg_affinity" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700946 output_sym "CONFIG_2ARG_AFFINITY"
Jens Axboe67bf9822013-01-10 11:23:19 +0100947fi
948if test "$strsep" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700949 output_sym "CONFIG_STRSEP"
Jens Axboe67bf9822013-01-10 11:23:19 +0100950fi
951if test "$getopt_long_only" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700952 output_sym "CONFIG_GETOPT_LONG_ONLY"
Jens Axboe67bf9822013-01-10 11:23:19 +0100953fi
954if test "$inet_aton" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700955 output_sym "CONFIG_INET_ATON"
Jens Axboe67bf9822013-01-10 11:23:19 +0100956fi
957if test "$socklen_t" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700958 output_sym "CONFIG_SOCKLEN_T"
Jens Axboe67bf9822013-01-10 11:23:19 +0100959fi
960if test "$ext4_me" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700961 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
Jens Axboe67bf9822013-01-10 11:23:19 +0100962fi
963if test "$linux_splice" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700964 output_sym "CONFIG_LINUX_SPLICE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100965fi
966if test "$guasi" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700967 output_sym "CONFIG_GUASI"
Jens Axboe67bf9822013-01-10 11:23:19 +0100968fi
969if test "$fusion_aw" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700970 output_sym "CONFIG_FUSION_AW"
Jens Axboe67bf9822013-01-10 11:23:19 +0100971fi
972if test "$libnuma" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700973 output_sym "CONFIG_LIBNUMA"
Jens Axboe67bf9822013-01-10 11:23:19 +0100974fi
975if test "$solaris_aio" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700976 output_sym "CONFIG_SOLARISAIO"
Jens Axboe67bf9822013-01-10 11:23:19 +0100977fi
978if test "$tls_thread" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700979 output_sym "CONFIG_TLS_THREAD"
Jens Axboe67bf9822013-01-10 11:23:19 +0100980fi
Jens Axboe44404c52013-01-24 14:20:09 -0700981if test "$rusage_thread" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700982 output_sym "CONFIG_RUSAGE_THREAD"
Jens Axboe44404c52013-01-24 14:20:09 -0700983fi
Jens Axboe7e09a9f2013-01-30 13:58:58 +0100984if test "$sched_idle" = "yes" ; then
985 output_sym "CONFIG_SCHED_IDLE"
986fi
Jens Axboe1eafa372013-01-31 10:19:51 +0100987if test "$tcp_nodelay" = "yes" ; then
988 output_sym "CONFIG_TCP_NODELAY"
989fi
Jens Axboe67bf9822013-01-10 11:23:19 +0100990
991echo "LIBS+=$LIBS" >> $config_host_mak
992echo "CC=$cc" >> $config_host_mak
Jens Axboe208e4c82013-01-29 09:26:07 +0100993echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak