blob: d22696021c4c947f132c476296493d35fce8a616 [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 Axboe67bf9822013-01-10 11:23:19 +010035
36# 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 Axboe91f94d52013-01-24 10:25:42 -0700125# default options
Jens Axboe47f44632013-01-24 10:34:14 -0700126show_help="no"
127exit_val=0
Jens Axboe135be492013-01-29 10:09:55 +0100128gfio="no"
Jens Axboe91f94d52013-01-24 10:25:42 -0700129
Jens Axboecb1125b2013-01-23 13:47:54 -0700130# parse options
131for opt do
132 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
133 case "$opt" in
Jens Axboe91f94d52013-01-24 10:25:42 -0700134 --cc=*)
135 CC="$optarg"
136 ;;
Jens Axboe135be492013-01-29 10:09:55 +0100137 --extra-cflags=*)
138 CFLAGS="$CFLAGS $optarg"
Jens Axboecb1125b2013-01-23 13:47:54 -0700139 ;;
Jens Axboe91f94d52013-01-24 10:25:42 -0700140 --enable-gfio)
141 gfio="yes"
142 ;;
Jens Axboe827da4f2013-01-24 10:27:26 -0700143 --help)
Jens Axboe47f44632013-01-24 10:34:14 -0700144 show_help="yes"
Jens Axboe827da4f2013-01-24 10:27:26 -0700145 ;;
Jens Axboecb1125b2013-01-23 13:47:54 -0700146 *)
147 echo "Bad option $opt"
Jens Axboe47f44632013-01-24 10:34:14 -0700148 show_help="yes"
149 exit_val=1
Jens Axboecb1125b2013-01-23 13:47:54 -0700150 esac
151done
152
Jens Axboe47f44632013-01-24 10:34:14 -0700153if test "$show_help" = "yes" ; then
Jens Axboeb7a99312013-02-04 12:46:54 +0100154 echo "--cc= Specify compiler to use"
Jens Axboe899fab32013-01-29 10:06:30 +0100155 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
Jens Axboeb7a99312013-02-04 12:46:54 +0100156 echo "--enable-gfio Enable building of gtk gfio"
157 exit $exit_val
Jens Axboe47f44632013-01-24 10:34:14 -0700158fi
159
Jens Axboe67bf9822013-01-10 11:23:19 +0100160if check_define __linux__ ; then
161 targetos="Linux"
Jens Axboe67bf9822013-01-10 11:23:19 +0100162elif check_define __OpenBSD__ ; then
163 targetos='OpenBSD'
164elif check_define __sun__ ; then
165 targetos='SunOS'
166else
167 targetos=`uname -s`
168fi
169
170# Some host OSes need non-standard checks for which CPU to use.
171# Note that these checks are broken for cross-compilation: if you're
172# cross-compiling to one of these OSes then you'll need to specify
173# the correct CPU with the --cpu option.
174case $targetos in
175Darwin)
176 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
177 # we can run 64-bit userspace code.
178 # If the user didn't specify a CPU explicitly and the kernel says this is
179 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
180 # detection code.
181 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
182 cpu="x86_64"
183 fi
184 ;;
185SunOS)
186 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
187 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
188 cpu="x86_64"
189 fi
Jens Axboecfd94f72013-01-23 16:23:48 -0700190 ;;
191CYGWIN*)
192 echo "Forcing known good options on Windows"
Jens Axboe4578d012013-01-23 16:26:12 -0700193 if test -z "$CC" ; then
194 CC="x86_64-w64-mingw32-gcc"
195 fi
Jens Axboe4feafb12013-01-24 23:07:55 -0700196 output_sym "CONFIG_LITTLE_ENDIAN"
197 output_sym "CONFIG_64BIT_LLP64"
198 output_sym "CONFIG_CLOCK_GETTIME"
199 output_sym "CONFIG_CLOCK_MONOTONIC"
200 output_sym "CONFIG_GETTIMEOFDAY"
201 output_sym "CONFIG_FADVISE"
202 output_sym "CONFIG_SOCKLEN_T"
203 output_sym "CONFIG_POSIX_FALLOCATE"
204 output_sym "CONFIG_FADVISE"
205 output_sym "CONFIG_SFAA"
206 output_sym "CONFIG_RUSAGE_THREAD"
207 output_sym "CONFIG_WINDOWSAIO"
208 output_sym "CONFIG_FDATASYNC"
Bruce Crandc0518c2013-01-28 16:07:15 +0000209 output_sym "CONFIG_GETTIMEOFDAY"
210 output_sym "CONFIG_CLOCK_GETTIME"
Jens Axboe7e09a9f2013-01-30 13:58:58 +0100211 output_sym "CONFIG_SCHED_IDLE"
Jens Axboe1eafa372013-01-31 10:19:51 +0100212 output_sym "CONFIG_TCP_NODELAY"
Jens Axboe4feafb12013-01-24 23:07:55 -0700213 echo "CC=$CC" >> $config_host_mak
Jens Axboe899fab32013-01-29 10:06:30 +0100214 echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
Jens Axboecfd94f72013-01-23 16:23:48 -0700215 exit 0
Jens Axboe67bf9822013-01-10 11:23:19 +0100216esac
217
218if test ! -z "$cpu" ; then
219 # command line argument
220 :
221elif check_define __i386__ ; then
222 cpu="i386"
223elif check_define __x86_64__ ; then
224 cpu="x86_64"
225elif check_define __sparc__ ; then
226 if check_define __arch64__ ; then
227 cpu="sparc64"
228 else
229 cpu="sparc"
230 fi
231elif check_define _ARCH_PPC ; then
232 if check_define _ARCH_PPC64 ; then
233 cpu="ppc64"
234 else
235 cpu="ppc"
236 fi
237elif check_define __mips__ ; then
238 cpu="mips"
239elif check_define __ia64__ ; then
240 cpu="ia64"
241elif check_define __s390__ ; then
242 if check_define __s390x__ ; then
243 cpu="s390x"
244 else
245 cpu="s390"
246 fi
247elif check_define __arm__ ; then
248 cpu="arm"
249elif check_define __hppa__ ; then
250 cpu="hppa"
251else
252 cpu=`uname -m`
253fi
254
255# Normalise host CPU name and set ARCH.
256case "$cpu" in
257 ia64|ppc|ppc64|s390|s390x|sparc64)
258 cpu="$cpu"
259 ;;
260 i386|i486|i586|i686|i86pc|BePC)
261 cpu="i386"
262 ;;
263 x86_64|amd64)
264 cpu="x86_64"
265 ;;
266 armv*b|armv*l|arm)
267 cpu="arm"
268 ;;
269 hppa|parisc|parisc64)
270 cpu="hppa"
271 ;;
272 mips*)
273 cpu="mips"
274 ;;
275 sparc|sun4[cdmuv])
276 cpu="sparc"
277 ;;
278 *)
279 echo "Unknown CPU"
280 exit 1;
281 ;;
282esac
283
Jens Axboedcbbf5b2013-01-25 14:35:27 -0700284if test -z "$CC" ; then
Jens Axboe67bf9822013-01-10 11:23:19 +0100285 if test "$targetos" = "FreeBSD"; then
286 if has clang; then
287 CC=clang
288 else
289 CC=gcc
290 fi
Jens Axboe67bf9822013-01-10 11:23:19 +0100291 fi
292fi
293
294cc="${CC-${cross_prefix}gcc}"
295
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700296##########################################
297# check endianness
298bigendian="no"
299cat > $TMPC <<EOF
300#include <inttypes.h>
301int main(void)
302{
303 volatile uint32_t i=0x01234567;
304 return (*((uint8_t*)(&i))) == 0x67;
305}
306EOF
307if compile_prog "" "" "endian"; then
308 $TMPE && bigendian="yes"
309fi
310
311
Jens Axboe67bf9822013-01-10 11:23:19 +0100312echo "Operating system $targetos"
313echo "CPU $cpu"
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700314echo "Big endian $bigendian"
Jens Axboe67bf9822013-01-10 11:23:19 +0100315echo "Compiler $cc"
316echo
317
318##########################################
319# check for wordsize
320wordsize="0"
321cat > $TMPC <<EOF
322#include <stdio.h>
323int main(void)
324{
325 unsigned int wsize = sizeof(long) * 8;
326 printf("%d\n", wsize);
327 return 0;
328}
329EOF
330if compile_prog "" "" "wordsize"; then
331 wordsize=$($TMPE)
332fi
333echo "Wordsize $wordsize"
334
335##########################################
336# linux-aio probe
337libaio="no"
338cat > $TMPC <<EOF
339#include <libaio.h>
340#include <stddef.h>
341int main(void)
342{
343 io_setup(0, NULL);
344 return 0;
345}
346EOF
347if compile_prog "" "-laio" "libaio" ; then
348 libaio=yes
349 LIBS="-laio $LIBS"
350else
351 if test "$libaio" = "yes" ; then
352 feature_not_found "linux AIO"
353 fi
354 libaio=no
355fi
356echo "Linux AIO support $libaio"
357
358##########################################
359# posix aio probe
360posix_aio="no"
361posix_aio_lrt="no"
362cat > $TMPC <<EOF
363#include <aio.h>
364int main(void)
365{
366 struct aiocb cb;
367 aio_read(&cb);
368 return 0;
369}
370EOF
371if compile_prog "" "" "posixaio" ; then
372 posix_aio="yes"
373elif compile_prog "" "-lrt" "posixaio"; then
374 posix_aio="yes"
375 posix_aio_lrt="yes"
376 LIBS="-lrt $LIBS"
377fi
378echo "POSIX AIO support $posix_aio"
379echo "POSIX AIO support needs -lrt $posix_aio_lrt"
380
381##########################################
382# posix aio fsync probe
383posix_aio_fsync="no"
384if test "$posix_aio" = "yes" ; then
385 cat > $TMPC <<EOF
386#include <fcntl.h>
387#include <aio.h>
388int main(void)
389{
390 struct aiocb cb;
391 return aio_fsync(O_SYNC, &cb);
392 return 0;
393}
394EOF
395 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
396 posix_aio_fsync=yes
397 fi
398fi
399echo "POSIX AIO fsync $posix_aio_fsync"
400
401##########################################
402# solaris aio probe
403solaris_aio="no"
404cat > $TMPC <<EOF
405#include <sys/types.h>
406#include <sys/asynch.h>
407#include <unistd.h>
408int main(void)
409{
410 aio_result_t res;
411 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
412 return 0;
413}
414EOF
415if compile_prog "" "-laio" "solarisaio" ; then
416 solaris_aio=yes
417 LIBS="-laio $LIBS"
418fi
419echo "Solaris AIO support $solaris_aio"
420
421##########################################
422# __sync_fetch_and_and test
423sfaa="no"
424cat > $TMPC << EOF
425static int sfaa(int *ptr)
426{
427 return __sync_fetch_and_and(ptr, 0);
428}
429
430int main(int argc, char **argv)
431{
432 int val = 42;
433 sfaa(&val);
434 return val;
435}
436EOF
437if compile_prog "" "" "__sync_fetch_and_add()" ; then
438 sfaa="yes"
439fi
440echo "__sync_fetch_and add $sfaa"
441
442##########################################
443# libverbs probe
444libverbs="no"
445cat > $TMPC << EOF
446#include <stdio.h>
447#include <infiniband/arch.h>
448int main(int argc, char **argv)
449{
450 struct ibv_pd *pd = ibv_alloc_pd(NULL);
451 return 0;
452}
453EOF
454if compile_prog "" "-libverbs" "libverbs" ; then
455 libverbs="yes"
456 LIBS="-libverbs $LIBS"
457fi
458echo "libverbs $libverbs"
459
460##########################################
461# rdmacm probe
462rdmacm="no"
463cat > $TMPC << EOF
464#include <stdio.h>
465#include <rdma/rdma_cma.h>
466int main(int argc, char **argv)
467{
468 rdma_destroy_qp(NULL);
469 return 0;
470}
471EOF
472if compile_prog "" "-lrdmacm" "rdma"; then
473 rdmacm="yes"
474 LIBS="-lrdmacm $LIBS"
475fi
476echo "rdmacm $rdmacm"
477
478##########################################
479# Linux fallocate probe
480linux_fallocate="no"
481cat > $TMPC << EOF
482#include <stdio.h>
483#include <linux/falloc.h>
484int main(int argc, char **argv)
485{
486 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
487 return r;
488}
489EOF
490if compile_prog "" "" "linux_fallocate"; then
491 linux_fallocate="yes"
492fi
493echo "Linux fallocate $linux_fallocate"
494
495##########################################
496# POSIX fadvise probe
497posix_fadvise="no"
498cat > $TMPC << EOF
499#include <stdio.h>
500#include <fcntl.h>
501int main(int argc, char **argv)
502{
503 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
504 return r;
505}
506EOF
507if compile_prog "" "" "posix_fadvise"; then
508 posix_fadvise="yes"
509fi
510echo "POSIX fadvise $posix_fadvise"
511
512##########################################
513# POSIX fallocate probe
514posix_fallocate="no"
515cat > $TMPC << EOF
516#include <stdio.h>
517#include <fcntl.h>
518int main(int argc, char **argv)
519{
520 int r = posix_fallocate(0, 0, 1024);
521 return r;
522}
523EOF
524if compile_prog "" "" "posix_fallocate"; then
525 posix_fallocate="yes"
526fi
527echo "POSIX fallocate $posix_fallocate"
528
529##########################################
530# sched_set/getaffinity 2 or 3 argument test
531linux_2arg_affinity="no"
532linux_3arg_affinity="no"
533cat > $TMPC << EOF
Jens Axboe67bf9822013-01-10 11:23:19 +0100534#include <sched.h>
535int main(int argc, char **argv)
536{
537 cpu_set_t mask;
538 return sched_setaffinity(0, sizeof(mask), &mask);
539}
540EOF
541if compile_prog "" "" "sched_setaffinity(,,)"; then
542 linux_3arg_affinity="yes"
543else
544 cat > $TMPC << EOF
Jens Axboe67bf9822013-01-10 11:23:19 +0100545#include <sched.h>
546int main(int argc, char **argv)
547{
548 cpu_set_t mask;
549 return sched_setaffinity(0, &mask);
550}
551EOF
552 if compile_prog "" "" "sched_setaffinity(,)"; then
553 linux_2arg_affinity="yes"
554 fi
555fi
556echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
557echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
558
559##########################################
560# clock_gettime probe
561clock_gettime="no"
562cat > $TMPC << EOF
563#include <stdio.h>
564#include <time.h>
565int main(int argc, char **argv)
566{
567 return clock_gettime(0, NULL);
568}
569EOF
570if compile_prog "" "" "clock_gettime"; then
571 clock_gettime="yes"
572elif compile_prog "" "-lrt" "clock_gettime"; then
573 clock_gettime="yes"
574 LIBS="-lrt $LIBS"
575fi
576echo "clock_gettime $clock_gettime"
577
578##########################################
579# CLOCK_MONOTONIC probe
580clock_monotonic="no"
581if test "$clock_gettime" = "yes" ; then
582 cat > $TMPC << EOF
583#include <stdio.h>
584#include <time.h>
585int main(int argc, char **argv)
586{
587 return clock_gettime(CLOCK_MONOTONIC, NULL);
588}
589EOF
590 if compile_prog "" "$LIBS" "clock monotonic"; then
591 clock_monotonic="yes"
592 fi
593fi
594echo "CLOCK_MONOTONIC $clock_monotonic"
595
596##########################################
597# CLOCK_MONOTONIC_PRECISE probe
598clock_monotonic_precise="no"
599if test "$clock_gettime" = "yes" ; then
600 cat > $TMPC << EOF
601#include <stdio.h>
602#include <time.h>
603int main(int argc, char **argv)
604{
605 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
606}
607EOF
608 if compile_prog "" "$LIBS" "clock monotonic precise"; then
609 clock_monotonic_precise="yes"
610 fi
611fi
612echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
613
614##########################################
615# gettimeofday() probe
616gettimeofday="no"
617cat > $TMPC << EOF
618#include <sys/time.h>
619#include <stdio.h>
620int main(int argc, char **argv)
621{
622 struct timeval tv;
623 return gettimeofday(&tv, NULL);
624}
625EOF
626if compile_prog "" "" "gettimeofday"; then
627 gettimeofday="yes"
628fi
629echo "gettimeofday $gettimeofday"
630
631##########################################
632# fdatasync() probe
633fdatasync="no"
634cat > $TMPC << EOF
635#include <stdio.h>
636#include <unistd.h>
637int main(int argc, char **argv)
638{
639 return fdatasync(0);
640}
641EOF
642if compile_prog "" "" "fdatasync"; then
643 fdatasync="yes"
644fi
645echo "fdatasync $fdatasync"
646
647##########################################
648# sync_file_range() probe
649sync_file_range="no"
650cat > $TMPC << EOF
651#include <stdio.h>
652#include <unistd.h>
Jens Axboe67bf9822013-01-10 11:23:19 +0100653#include <fcntl.h>
654#include <linux/fs.h>
655int main(int argc, char **argv)
656{
657 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
658 SYNC_FILE_RANGE_WAIT_AFTER;
659 return sync_file_range(0, 0, 0, flags);
660}
661EOF
662if compile_prog "" "" "sync_file_range"; then
663 sync_file_range="yes"
664fi
665echo "sync_file_range $sync_file_range"
666
667##########################################
668# ext4 move extent probe
669ext4_me="no"
670cat > $TMPC << EOF
671#include <fcntl.h>
672#include <sys/ioctl.h>
673int main(int argc, char **argv)
674{
675 struct move_extent me;
676 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
677}
678EOF
Jens Axboec7165b82013-01-12 10:27:53 +0100679if compile_prog "" "" "ext4 move extent" ; then
680 ext4_me="yes"
681elif test $targetos = "Linux" ; then
682 # On Linux, just default to it on and let it error at runtime if we really
683 # don't have it. None of my updated systems have it defined, but it does
684 # work. Takes a while to bubble back.
Jens Axboe67bf9822013-01-10 11:23:19 +0100685 ext4_me="yes"
686fi
687echo "EXT4 move extent $ext4_me"
688
689##########################################
690# splice probe
691linux_splice="no"
692cat > $TMPC << EOF
Jens Axboe67bf9822013-01-10 11:23:19 +0100693#include <stdio.h>
694#include <fcntl.h>
695int main(int argc, char **argv)
696{
697 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
698}
699EOF
700if compile_prog "" "" "linux splice"; then
701 linux_splice="yes"
702fi
703echo "Linux splice(2) $linux_splice"
704
705##########################################
706# GUASI probe
707guasi="no"
708cat > $TMPC << EOF
709#include <guasi.h>
710#include <guasi_syscalls.h>
711int main(int argc, char **argv)
712{
713 guasi_t ctx = guasi_create(0, 0, 0);
714 return 0;
715}
716EOF
717if compile_prog "" "" "guasi"; then
718 guasi="yes"
719fi
720echo "GUASI $guasi"
721
722##########################################
723# fusion-aw probe
724fusion_aw="no"
725cat > $TMPC << EOF
Jens Axboe99db6562013-01-14 19:33:40 +0100726#include <nvm/vectored_write.h>
Jens Axboe67bf9822013-01-10 11:23:19 +0100727int main(int argc, char **argv)
728{
729 struct vsl_iovec iov;
730 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
731}
732EOF
Jens Axboe99db6562013-01-14 19:33:40 +0100733if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
734 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
Jens Axboe67bf9822013-01-10 11:23:19 +0100735 fusion_aw="yes"
736fi
737echo "Fusion-io atomic engine $fusion_aw"
738
739##########################################
740# libnuma probe
741libnuma="no"
742cat > $TMPC << EOF
743#include <numa.h>
744int main(int argc, char **argv)
745{
746 return numa_available();
747}
748EOF
749if compile_prog "" "-lnuma" "libnuma"; then
750 libnuma="yes"
751 LIBS="-lnuma $LIBS"
752fi
753echo "libnuma $libnuma"
754
755##########################################
756# strsep() probe
757strsep="no"
758cat > $TMPC << EOF
759#include <string.h>
760int main(int argc, char **argv)
761{
762 strsep(NULL, NULL);
763 return 0;
764}
765EOF
766if compile_prog "" "" "strsep"; then
767 strsep="yes"
768fi
769echo "strsep $strsep"
770
771##########################################
772# getopt_long_only() probe
773getopt_long_only="no"
774cat > $TMPC << EOF
775#include <unistd.h>
776#include <stdio.h>
777int main(int argc, char **argv)
778{
779 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
780 return c;
781}
782EOF
783if compile_prog "" "" "getopt_long_only"; then
784 getopt_long_only="yes"
785fi
786echo "getopt_long_only() $getopt_long_only"
787
788##########################################
789# inet_aton() probe
790inet_aton="no"
791cat > $TMPC << EOF
792#include <sys/socket.h>
793#include <arpa/inet.h>
794#include <stdio.h>
795int main(int argc, char **argv)
796{
797 struct in_addr in;
798 return inet_aton(NULL, &in);
799}
800EOF
801if compile_prog "" "" "inet_aton"; then
802 inet_aton="yes"
803fi
804echo "inet_aton $inet_aton"
805
806##########################################
807# socklen_t probe
808socklen_t="no"
809cat > $TMPC << EOF
810#include <string.h>
811#include <netinet/in.h>
812int main(int argc, char **argv)
813{
814 socklen_t len = 0;
815 return len;
816}
817EOF
818if compile_prog "" "" "socklen_t"; then
819 socklen_t="yes"
820fi
821echo "socklen_t $socklen_t"
822
823##########################################
824# Whether or not __thread is supported for TLS
825tls_thread="no"
826cat > $TMPC << EOF
827#include <stdio.h>
828static int __thread ret;
829int main(int argc, char **argv)
830{
831 return ret;
832}
833EOF
834if compile_prog "" "" "__thread"; then
835 tls_thread="yes"
836fi
837echo "__thread $tls_thread"
838
Jens Axboe91f94d52013-01-24 10:25:42 -0700839##########################################
840# Whether or not __thread is supported for TLS
841if test "$gfio" = "yes" ; then
842 cat > $TMPC << EOF
843#include <glib.h>
844#include <cairo.h>
845#include <gtk/gtk.h>
846int main(void)
847{
848 gdk_threads_enter();
Jens Axboe91f94d52013-01-24 10:25:42 -0700849 gdk_threads_leave();
Jens Axboeb7a99312013-02-04 12:46:54 +0100850
851 printf("%d", GTK_CHECK_VERSION(2, 18, 0));
Jens Axboe91f94d52013-01-24 10:25:42 -0700852}
853EOF
854GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
855if test "$?" != "0" ; then
856 echo "configure: gtk and gthread not found"
857 exit 1
858fi
859GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
860if test "$?" != "0" ; then
861 echo "configure: gtk and gthread not found"
862 exit 1
863fi
Jens Axboeb7a99312013-02-04 12:46:54 +0100864if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
865 r=$($TMPE)
866 if test "$r" != "0" ; then
867 gfio="yes"
868 LIBS="$LIBS $GTK_LIBS"
869 CFLAGS="$CFLAGS $GTK_CFLAGS"
870 else
871 echo "GTK found, but need version 2.18 or higher"
872 gfio="no"
873 fi
Jens Axboe91f94d52013-01-24 10:25:42 -0700874else
875 echo "Please install gtk and gdk libraries"
876 gfio="no"
877fi
878fi
879
880echo "gfio $gfio"
881
Jens Axboe44404c52013-01-24 14:20:09 -0700882# Check whether we have getrusage(RUSAGE_THREAD)
883rusage_thread="no"
884cat > $TMPC << EOF
885#include <sys/time.h>
886#include <sys/resource.h>
887int main(int argc, char **argv)
888{
889 struct rusage ru;
890 getrusage(RUSAGE_THREAD, &ru);
891 return 0;
892}
893EOF
894if compile_prog "" "" "RUSAGE_THREAD"; then
895 rusage_thread="yes"
896fi
897echo "RUSAGE_THREAD $rusage_thread"
898
Jens Axboe7e09a9f2013-01-30 13:58:58 +0100899##########################################
900# Check whether we have SCHED_IDLE
901sched_idle="no"
902cat > $TMPC << EOF
903#include <sched.h>
904int main(int argc, char **argv)
905{
906 struct sched_param p;
907 return sched_setscheduler(0, SCHED_IDLE, &p);
908}
909EOF
910if compile_prog "" "" "SCHED_IDLE"; then
911 sched_idle="yes"
912fi
913echo "SCHED_IDLE $sched_idle"
914
Jens Axboe1eafa372013-01-31 10:19:51 +0100915##########################################
916# Check whether we have TCP_NODELAY
917tcp_nodelay="no"
918cat > $TMPC << EOF
919#include <stdio.h>
920#include <sys/types.h>
921#include <sys/socket.h>
922#include <netinet/tcp.h>
923int main(int argc, char **argv)
924{
925 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
926}
927EOF
928if compile_prog "" "" "TCP_NODELAY"; then
929 tcp_nodelay="yes"
930fi
931echo "TCP_NODELAY $tcp_nodelay"
932
Jens Axboe67bf9822013-01-10 11:23:19 +0100933#############################################################################
934
935echo "# Automatically generated by configure - do not modify" > $config_host_mak
936printf "# Configured with:" >> $config_host_mak
937printf " '%s'" "$0" "$@" >> $config_host_mak
938echo >> $config_host_mak
939
940if test "$wordsize" = "64" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700941 output_sym "CONFIG_64BIT"
Jens Axboe67bf9822013-01-10 11:23:19 +0100942elif test "$wordsize" = "32" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700943 output_sym "CONFIG_32BIT"
Jens Axboe67bf9822013-01-10 11:23:19 +0100944else
945 echo "Unknown wordsize!"
946 exit 1
947fi
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700948if test "$bigendian" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700949 output_sym "CONFIG_BIG_ENDIAN"
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700950else
Jens Axboe4feafb12013-01-24 23:07:55 -0700951 output_sym "CONFIG_LITTLE_ENDIAN"
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700952fi
Jens Axboe67bf9822013-01-10 11:23:19 +0100953if test "$libaio" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700954 output_sym "CONFIG_LIBAIO"
Jens Axboe67bf9822013-01-10 11:23:19 +0100955fi
956if test "$posix_aio" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700957 output_sym "CONFIG_POSIXAIO"
Jens Axboe67bf9822013-01-10 11:23:19 +0100958fi
959if test "$posix_aio_fsync" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700960 output_sym "CONFIG_POSIXAIO_FSYNC"
Jens Axboe67bf9822013-01-10 11:23:19 +0100961fi
962if test "$linux_fallocate" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700963 output_sym "CONFIG_LINUX_FALLOCATE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100964fi
965if test "$posix_fallocate" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700966 output_sym "CONFIG_POSIX_FALLOCATE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100967fi
968if test "$fdatasync" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700969 output_sym "CONFIG_FDATASYNC"
Jens Axboe67bf9822013-01-10 11:23:19 +0100970fi
971if test "$sync_file_range" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700972 output_sym "CONFIG_SYNC_FILE_RANGE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100973fi
974if test "$sfaa" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700975 output_sym "CONFIG_SFAA"
Jens Axboe67bf9822013-01-10 11:23:19 +0100976fi
977if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700978 output_sym "CONFIG_RDMA"
Jens Axboe67bf9822013-01-10 11:23:19 +0100979fi
980if test "$clock_gettime" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700981 output_sym "CONFIG_CLOCK_GETTIME"
Jens Axboe67bf9822013-01-10 11:23:19 +0100982fi
983if test "$clock_monotonic" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700984 output_sym "CONFIG_CLOCK_MONOTONIC"
Jens Axboe67bf9822013-01-10 11:23:19 +0100985fi
986if test "$clock_monotonic_precise" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700987 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100988fi
989if test "$gettimeofday" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700990 output_sym "CONFIG_GETTIMEOFDAY"
Jens Axboe67bf9822013-01-10 11:23:19 +0100991fi
992if test "$posix_fadvise" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700993 output_sym "CONFIG_POSIX_FADVISE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100994fi
995if test "$linux_3arg_affinity" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700996 output_sym "CONFIG_3ARG_AFFINITY"
Jens Axboe67bf9822013-01-10 11:23:19 +0100997elif test "$linux_2arg_affinity" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700998 output_sym "CONFIG_2ARG_AFFINITY"
Jens Axboe67bf9822013-01-10 11:23:19 +0100999fi
1000if test "$strsep" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001001 output_sym "CONFIG_STRSEP"
Jens Axboe67bf9822013-01-10 11:23:19 +01001002fi
1003if test "$getopt_long_only" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001004 output_sym "CONFIG_GETOPT_LONG_ONLY"
Jens Axboe67bf9822013-01-10 11:23:19 +01001005fi
1006if test "$inet_aton" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001007 output_sym "CONFIG_INET_ATON"
Jens Axboe67bf9822013-01-10 11:23:19 +01001008fi
1009if test "$socklen_t" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001010 output_sym "CONFIG_SOCKLEN_T"
Jens Axboe67bf9822013-01-10 11:23:19 +01001011fi
1012if test "$ext4_me" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001013 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
Jens Axboe67bf9822013-01-10 11:23:19 +01001014fi
1015if test "$linux_splice" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001016 output_sym "CONFIG_LINUX_SPLICE"
Jens Axboe67bf9822013-01-10 11:23:19 +01001017fi
1018if test "$guasi" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001019 output_sym "CONFIG_GUASI"
Jens Axboe67bf9822013-01-10 11:23:19 +01001020fi
1021if test "$fusion_aw" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001022 output_sym "CONFIG_FUSION_AW"
Jens Axboe67bf9822013-01-10 11:23:19 +01001023fi
1024if test "$libnuma" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001025 output_sym "CONFIG_LIBNUMA"
Jens Axboe67bf9822013-01-10 11:23:19 +01001026fi
1027if test "$solaris_aio" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001028 output_sym "CONFIG_SOLARISAIO"
Jens Axboe67bf9822013-01-10 11:23:19 +01001029fi
1030if test "$tls_thread" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001031 output_sym "CONFIG_TLS_THREAD"
Jens Axboe67bf9822013-01-10 11:23:19 +01001032fi
Jens Axboe44404c52013-01-24 14:20:09 -07001033if test "$rusage_thread" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001034 output_sym "CONFIG_RUSAGE_THREAD"
Jens Axboe67bf9822013-01-10 11:23:19 +01001035fi
Jens Axboe91f94d52013-01-24 10:25:42 -07001036if test "$gfio" = "yes" ; then
1037 echo "CONFIG_GFIO=y" >> $config_host_mak
1038fi
Jens Axboe7e09a9f2013-01-30 13:58:58 +01001039if test "$sched_idle" = "yes" ; then
1040 output_sym "CONFIG_SCHED_IDLE"
1041fi
Jens Axboe1eafa372013-01-31 10:19:51 +01001042if test "$tcp_nodelay" = "yes" ; then
1043 output_sym "CONFIG_TCP_NODELAY"
1044fi
Jens Axboe67bf9822013-01-10 11:23:19 +01001045
1046echo "LIBS+=$LIBS" >> $config_host_mak
Jens Axboe91f94d52013-01-24 10:25:42 -07001047echo "CFLAGS+=$CFLAGS" >> $config_host_mak
Jens Axboe67bf9822013-01-10 11:23:19 +01001048echo "CC=$cc" >> $config_host_mak
Jens Axboe208e4c82013-01-29 09:26:07 +01001049echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak