blob: 1fa9b635ade84b3fe8f9eedfd0789176ab7bb795 [file] [log] [blame]
Jens Axboe67bf9822013-01-10 11:23:19 +01001#!/bin/sh
2#
3# Fio configure script. Heavily influenced by the manual qemu configure
4# script. Sad this this is easier than autoconf and enemies.
5#
6
7# set temporary file name
8if test ! -z "$TMPDIR" ; then
9 TMPDIR1="${TMPDIR}"
10elif test ! -z "$TEMPDIR" ; then
11 TMPDIR1="${TEMPDIR}"
12else
13 TMPDIR1="/tmp"
14fi
15
16TMPC="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.c"
17TMPO="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.o"
18TMPE="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.exe"
19
20# NB: do not call "exit" in the trap handler; this is buggy with some shells;
21# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
22trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
23
24rm -rf config.log
25
26config_host_mak="config-host.mak"
Jens Axboe4feafb12013-01-24 23:07:55 -070027config_host_h="config-host.h"
28
29rm -rf $config_host_mak
30rm -rf $config_host_h
Jens Axboe67bf9822013-01-10 11:23:19 +010031
Jens Axboed7145a72013-02-11 13:21:54 +010032fatal() {
33 echo $@
34 echo "Configure failed, check config.log and/or the above output"
35 rm -rf $config_host_mak
36 rm -rf $config_host_h
37 exit 1
38}
39
Jens Axboe44404c52013-01-24 14:20:09 -070040# Default CFLAGS
Jens Axboe208e4c82013-01-29 09:26:07 +010041CFLAGS="-D_GNU_SOURCE"
42EXTFLAGS="-include config-host.h"
Jens Axboe44404c52013-01-24 14:20:09 -070043
Jens Axboe67bf9822013-01-10 11:23:19 +010044# Print a helpful header at the top of config.log
45echo "# FIO configure log $(date)" >> config.log
46printf "# Configured with:" >> config.log
47printf " '%s'" "$0" "$@" >> config.log
48echo >> config.log
49echo "#" >> config.log
50
Jens Axboe7560fe72013-01-25 08:52:28 -070051# Print configure header at the top of $config_host_h
52echo "/*" > $config_host_h
53echo " * Automatically generated by configure - do not modify" >> $config_host_h
54printf " * Configured with:" >> $config_host_h
55printf " * '%s'" "$0" "$@" >> $config_host_h
56echo "" >> $config_host_h
57echo " */" >> $config_host_h
58
Jens Axboe67bf9822013-01-10 11:23:19 +010059do_cc() {
60 # Run the compiler, capturing its output to the log.
61 echo $cc "$@" >> config.log
62 $cc "$@" >> config.log 2>&1 || return $?
63 # Test passed. If this is an --enable-werror build, rerun
64 # the test with -Werror and bail out if it fails. This
65 # makes warning-generating-errors in configure test code
66 # obvious to developers.
67 if test "$werror" != "yes"; then
68 return 0
69 fi
70 # Don't bother rerunning the compile if we were already using -Werror
71 case "$*" in
72 *-Werror*)
73 return 0
74 ;;
75 esac
76 echo $cc -Werror "$@" >> config.log
77 $cc -Werror "$@" >> config.log 2>&1 && return $?
78 echo "ERROR: configure test passed without -Werror but failed with -Werror."
79 echo "This is probably a bug in the configure script. The failing command"
80 echo "will be at the bottom of config.log."
Jens Axboed7145a72013-02-11 13:21:54 +010081 fatal "You can run configure with --disable-werror to bypass this check."
Jens Axboe67bf9822013-01-10 11:23:19 +010082}
83
84compile_object() {
85 do_cc $CFLAGS -c -o $TMPO $TMPC
86}
87
88compile_prog() {
89 local_cflags="$1"
Jens Axboeadaa46d2013-02-28 22:10:22 +010090 local_ldflags="$2 $LIBS"
Jens Axboe67bf9822013-01-10 11:23:19 +010091 echo "Compiling test case $3" >> config.log
92 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
93}
94
95feature_not_found() {
96 feature=$1
97
98 echo "ERROR"
99 echo "ERROR: User requested feature $feature"
100 echo "ERROR: configure was not able to find it"
Jens Axboed7145a72013-02-11 13:21:54 +0100101 fatal "ERROR"
Jens Axboe67bf9822013-01-10 11:23:19 +0100102}
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
Jens Axboe4feafb12013-01-24 23:07:55 -0700121output_sym() {
122 echo "$1=y" >> $config_host_mak
123 echo "#define $1" >> $config_host_h
124}
125
Jens Axboe67bf9822013-01-10 11:23:19 +0100126targetos=""
127cpu=""
128
Aaron Carroll53cd4ee2013-03-14 16:57:38 +1100129cross_prefix=${cross_prefix-${CROSS_COMPILE}}
Jens Axboe67bf9822013-01-10 11:23:19 +0100130cc="${CC-${cross_prefix}gcc}"
131
Jens Axboe899fab32013-01-29 10:06:30 +0100132show_help="no"
133exit_val=0
134
Jens Axboecb1125b2013-01-23 13:47:54 -0700135# parse options
136for opt do
137 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
138 case "$opt" in
Jens Axboe8b156d82013-02-10 15:48:34 +0100139 --cpu=*) cpu="$optarg"
140 ;;
Jens Axboecb1125b2013-01-23 13:47:54 -0700141 --cc=*) CC="$optarg"
142 ;;
Jens Axboe208e4c82013-01-29 09:26:07 +0100143 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
144 ;;
Huadong Liu74097112013-02-05 08:43:14 +0100145 --build-32bit-win=*) build_32bit_win="$optarg"
146 ;;
Jens Axboe899fab32013-01-29 10:06:30 +0100147 --help)
148 show_help="yes"
149 ;;
Jens Axboecb1125b2013-01-23 13:47:54 -0700150 *)
151 echo "Bad option $opt"
Jens Axboe899fab32013-01-29 10:06:30 +0100152 show_help="yes"
153 exit_val=1
Jens Axboecb1125b2013-01-23 13:47:54 -0700154 esac
155done
156
Jens Axboe899fab32013-01-29 10:06:30 +0100157if test "$show_help" = "yes" ; then
Jens Axboe8b156d82013-02-10 15:48:34 +0100158 echo "--cpu= Specify target CPU if auto-detect fails"
Jens Axboe899fab32013-01-29 10:06:30 +0100159 echo "--cc= Specify compiler to use"
160 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
Bruce Cran723d7b32013-02-05 17:44:19 +0000161 echo "--build-32bit-win= Specify yes for a 32-bit build on Windows"
Jens Axboe899fab32013-01-29 10:06:30 +0100162 exit $exit_val
163fi
164
Aaron Carroll6d0e9f82013-02-12 09:58:14 +0100165if check_define __ANDROID__ ; then
166 targetos="Android"
167elif check_define __linux__ ; then
Jens Axboe67bf9822013-01-10 11:23:19 +0100168 targetos="Linux"
Jens Axboe67bf9822013-01-10 11:23:19 +0100169elif check_define __OpenBSD__ ; then
170 targetos='OpenBSD'
171elif check_define __sun__ ; then
172 targetos='SunOS'
173else
174 targetos=`uname -s`
175fi
176
Aaron Carroll53cd4ee2013-03-14 16:57:38 +1100177echo "# 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
Jens Axboe67bf9822013-01-10 11:23:19 +0100183# 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
Jens Axboeadaa46d2013-02-28 22:10:22 +0100203 LIBS="-lnsl -lsocket"
Jens Axboecfd94f72013-01-23 16:23:48 -0700204 ;;
205CYGWIN*)
206 echo "Forcing known good options on Windows"
Jens Axboe4578d012013-01-23 16:26:12 -0700207 if test -z "$CC" ; then
Huadong Liu74097112013-02-05 08:43:14 +0100208 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
Jens Axboe4578d012013-01-23 16:26:12 -0700213 fi
Jens Axboe4feafb12013-01-24 23:07:55 -0700214 output_sym "CONFIG_LITTLE_ENDIAN"
Huadong Liu74097112013-02-05 08:43:14 +0100215 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
Jens Axboe4feafb12013-01-24 23:07:55 -0700220 output_sym "CONFIG_FADVISE"
221 output_sym "CONFIG_SOCKLEN_T"
Jens Axboe4feafb12013-01-24 23:07:55 -0700222 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"
Bruce Cran59308a62013-02-02 20:59:31 +0000227 output_sym "CONFIG_CLOCK_MONOTONIC"
Bruce Crandc0518c2013-01-28 16:07:15 +0000228 output_sym "CONFIG_GETTIMEOFDAY"
229 output_sym "CONFIG_CLOCK_GETTIME"
Jens Axboe7e09a9f2013-01-30 13:58:58 +0100230 output_sym "CONFIG_SCHED_IDLE"
Jens Axboe1eafa372013-01-31 10:19:51 +0100231 output_sym "CONFIG_TCP_NODELAY"
Jens Axboe4feafb12013-01-24 23:07:55 -0700232 echo "CC=$CC" >> $config_host_mak
Jens Axboe899fab32013-01-29 10:06:30 +0100233 echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
Jens Axboecfd94f72013-01-23 16:23:48 -0700234 exit 0
Aaron Carroll6d0e9f82013-02-12 09:58:14 +0100235 ;;
236Android)
237 output_sym "CONFIG_32BIT"
Aaron Carroll1e72a882013-02-18 08:52:18 +0100238 output_sym "CONFIG_LITTLE_ENDIAN"
Aaron Carroll6d0e9f82013-02-12 09:58:14 +0100239 output_sym "CONFIG_SOCKLEN_T"
240 output_sym "CONFIG_GETTIMEOFDAY"
241 output_sym "CONFIG_CLOCK_GETTIME"
Aaron Carroll1e72a882013-02-18 08:52:18 +0100242 output_sym "CONFIG_CLOCK_MONOTONIC"
Aaron Carroll6d0e9f82013-02-12 09:58:14 +0100243 echo "CC=$cc" >> $config_host_mak
Aaron Carroll56c79602013-03-13 10:09:10 +0100244 echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
Aaron Carroll6d0e9f82013-02-12 09:58:14 +0100245 exit 0
Jens Axboe67bf9822013-01-10 11:23:19 +0100246esac
247
248if test ! -z "$cpu" ; then
249 # command line argument
250 :
251elif check_define __i386__ ; then
252 cpu="i386"
253elif check_define __x86_64__ ; then
254 cpu="x86_64"
255elif check_define __sparc__ ; then
256 if check_define __arch64__ ; then
257 cpu="sparc64"
258 else
259 cpu="sparc"
260 fi
261elif check_define _ARCH_PPC ; then
262 if check_define _ARCH_PPC64 ; then
263 cpu="ppc64"
264 else
265 cpu="ppc"
266 fi
267elif check_define __mips__ ; then
268 cpu="mips"
269elif check_define __ia64__ ; then
270 cpu="ia64"
271elif check_define __s390__ ; then
272 if check_define __s390x__ ; then
273 cpu="s390x"
274 else
275 cpu="s390"
276 fi
277elif check_define __arm__ ; then
278 cpu="arm"
279elif check_define __hppa__ ; then
280 cpu="hppa"
281else
282 cpu=`uname -m`
283fi
284
285# Normalise host CPU name and set ARCH.
286case "$cpu" in
287 ia64|ppc|ppc64|s390|s390x|sparc64)
288 cpu="$cpu"
289 ;;
290 i386|i486|i586|i686|i86pc|BePC)
291 cpu="i386"
292 ;;
293 x86_64|amd64)
294 cpu="x86_64"
295 ;;
296 armv*b|armv*l|arm)
297 cpu="arm"
298 ;;
299 hppa|parisc|parisc64)
300 cpu="hppa"
301 ;;
302 mips*)
303 cpu="mips"
304 ;;
305 sparc|sun4[cdmuv])
306 cpu="sparc"
307 ;;
308 *)
Jens Axboe8b156d82013-02-10 15:48:34 +0100309 echo "Unknown CPU"
Jens Axboe67bf9822013-01-10 11:23:19 +0100310 ;;
311esac
312
Jens Axboedcbbf5b2013-01-25 14:35:27 -0700313if test -z "$CC" ; then
Jens Axboe67bf9822013-01-10 11:23:19 +0100314 if test "$targetos" = "FreeBSD"; then
315 if has clang; then
316 CC=clang
317 else
318 CC=gcc
319 fi
Jens Axboe67bf9822013-01-10 11:23:19 +0100320 fi
321fi
322
323cc="${CC-${cross_prefix}gcc}"
324
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700325##########################################
326# check endianness
327bigendian="no"
328cat > $TMPC <<EOF
329#include <inttypes.h>
330int main(void)
331{
332 volatile uint32_t i=0x01234567;
333 return (*((uint8_t*)(&i))) == 0x67;
334}
335EOF
336if compile_prog "" "" "endian"; then
337 $TMPE && bigendian="yes"
338fi
339
340
Jens Axboe67bf9822013-01-10 11:23:19 +0100341echo "Operating system $targetos"
342echo "CPU $cpu"
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700343echo "Big endian $bigendian"
Jens Axboe67bf9822013-01-10 11:23:19 +0100344echo "Compiler $cc"
345echo
346
347##########################################
348# check for wordsize
349wordsize="0"
350cat > $TMPC <<EOF
351#include <stdio.h>
352int main(void)
353{
354 unsigned int wsize = sizeof(long) * 8;
355 printf("%d\n", wsize);
356 return 0;
357}
358EOF
359if compile_prog "" "" "wordsize"; then
Jens Axboeb65588b2013-02-26 21:55:08 +0100360 wordsize=`$TMPE`
Jens Axboe67bf9822013-01-10 11:23:19 +0100361fi
362echo "Wordsize $wordsize"
363
364##########################################
365# linux-aio probe
366libaio="no"
367cat > $TMPC <<EOF
368#include <libaio.h>
369#include <stddef.h>
370int main(void)
371{
372 io_setup(0, NULL);
373 return 0;
374}
375EOF
376if compile_prog "" "-laio" "libaio" ; then
377 libaio=yes
378 LIBS="-laio $LIBS"
379else
380 if test "$libaio" = "yes" ; then
381 feature_not_found "linux AIO"
382 fi
383 libaio=no
384fi
385echo "Linux AIO support $libaio"
386
387##########################################
388# posix aio probe
389posix_aio="no"
390posix_aio_lrt="no"
391cat > $TMPC <<EOF
392#include <aio.h>
393int main(void)
394{
395 struct aiocb cb;
396 aio_read(&cb);
397 return 0;
398}
399EOF
400if compile_prog "" "" "posixaio" ; then
401 posix_aio="yes"
402elif compile_prog "" "-lrt" "posixaio"; then
403 posix_aio="yes"
404 posix_aio_lrt="yes"
405 LIBS="-lrt $LIBS"
406fi
407echo "POSIX AIO support $posix_aio"
408echo "POSIX AIO support needs -lrt $posix_aio_lrt"
409
410##########################################
411# posix aio fsync probe
412posix_aio_fsync="no"
413if test "$posix_aio" = "yes" ; then
414 cat > $TMPC <<EOF
415#include <fcntl.h>
416#include <aio.h>
417int main(void)
418{
419 struct aiocb cb;
420 return aio_fsync(O_SYNC, &cb);
421 return 0;
422}
423EOF
424 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
425 posix_aio_fsync=yes
426 fi
427fi
428echo "POSIX AIO fsync $posix_aio_fsync"
429
430##########################################
431# solaris aio probe
432solaris_aio="no"
433cat > $TMPC <<EOF
434#include <sys/types.h>
435#include <sys/asynch.h>
436#include <unistd.h>
437int main(void)
438{
439 aio_result_t res;
440 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
441 return 0;
442}
443EOF
444if compile_prog "" "-laio" "solarisaio" ; then
445 solaris_aio=yes
446 LIBS="-laio $LIBS"
447fi
448echo "Solaris AIO support $solaris_aio"
449
450##########################################
451# __sync_fetch_and_and test
452sfaa="no"
453cat > $TMPC << EOF
454static int sfaa(int *ptr)
455{
Jens Axboe9c639a72013-02-28 22:13:29 +0100456 return __sync_fetch_and_add(ptr, 0);
Jens Axboe67bf9822013-01-10 11:23:19 +0100457}
458
459int main(int argc, char **argv)
460{
461 int val = 42;
462 sfaa(&val);
463 return val;
464}
465EOF
466if compile_prog "" "" "__sync_fetch_and_add()" ; then
467 sfaa="yes"
468fi
Jens Axboe9c639a72013-02-28 22:13:29 +0100469echo "__sync_fetch_and_add $sfaa"
Jens Axboe67bf9822013-01-10 11:23:19 +0100470
471##########################################
472# libverbs probe
473libverbs="no"
474cat > $TMPC << EOF
475#include <stdio.h>
476#include <infiniband/arch.h>
477int main(int argc, char **argv)
478{
479 struct ibv_pd *pd = ibv_alloc_pd(NULL);
480 return 0;
481}
482EOF
483if compile_prog "" "-libverbs" "libverbs" ; then
484 libverbs="yes"
485 LIBS="-libverbs $LIBS"
486fi
487echo "libverbs $libverbs"
488
489##########################################
490# rdmacm probe
491rdmacm="no"
492cat > $TMPC << EOF
493#include <stdio.h>
494#include <rdma/rdma_cma.h>
495int main(int argc, char **argv)
496{
497 rdma_destroy_qp(NULL);
498 return 0;
499}
500EOF
501if compile_prog "" "-lrdmacm" "rdma"; then
502 rdmacm="yes"
503 LIBS="-lrdmacm $LIBS"
504fi
505echo "rdmacm $rdmacm"
506
507##########################################
508# Linux fallocate probe
509linux_fallocate="no"
510cat > $TMPC << EOF
511#include <stdio.h>
512#include <linux/falloc.h>
513int main(int argc, char **argv)
514{
515 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
516 return r;
517}
518EOF
519if compile_prog "" "" "linux_fallocate"; then
520 linux_fallocate="yes"
521fi
522echo "Linux fallocate $linux_fallocate"
523
524##########################################
525# POSIX fadvise probe
526posix_fadvise="no"
527cat > $TMPC << EOF
528#include <stdio.h>
529#include <fcntl.h>
530int main(int argc, char **argv)
531{
532 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
533 return r;
534}
535EOF
536if compile_prog "" "" "posix_fadvise"; then
537 posix_fadvise="yes"
538fi
539echo "POSIX fadvise $posix_fadvise"
540
541##########################################
542# POSIX fallocate probe
543posix_fallocate="no"
544cat > $TMPC << EOF
545#include <stdio.h>
546#include <fcntl.h>
547int main(int argc, char **argv)
548{
549 int r = posix_fallocate(0, 0, 1024);
550 return r;
551}
552EOF
553if compile_prog "" "" "posix_fallocate"; then
554 posix_fallocate="yes"
555fi
556echo "POSIX fallocate $posix_fallocate"
557
558##########################################
559# sched_set/getaffinity 2 or 3 argument test
560linux_2arg_affinity="no"
561linux_3arg_affinity="no"
562cat > $TMPC << EOF
Jens Axboe67bf9822013-01-10 11:23:19 +0100563#include <sched.h>
564int main(int argc, char **argv)
565{
566 cpu_set_t mask;
567 return sched_setaffinity(0, sizeof(mask), &mask);
568}
569EOF
570if compile_prog "" "" "sched_setaffinity(,,)"; then
571 linux_3arg_affinity="yes"
572else
573 cat > $TMPC << EOF
Jens Axboe67bf9822013-01-10 11:23:19 +0100574#include <sched.h>
575int main(int argc, char **argv)
576{
577 cpu_set_t mask;
578 return sched_setaffinity(0, &mask);
579}
580EOF
581 if compile_prog "" "" "sched_setaffinity(,)"; then
582 linux_2arg_affinity="yes"
583 fi
584fi
585echo "sched_setaffinity(3 arg) $linux_3arg_affinity"
586echo "sched_setaffinity(2 arg) $linux_2arg_affinity"
587
588##########################################
589# clock_gettime probe
590clock_gettime="no"
591cat > $TMPC << EOF
592#include <stdio.h>
593#include <time.h>
594int main(int argc, char **argv)
595{
596 return clock_gettime(0, NULL);
597}
598EOF
599if compile_prog "" "" "clock_gettime"; then
600 clock_gettime="yes"
601elif compile_prog "" "-lrt" "clock_gettime"; then
602 clock_gettime="yes"
603 LIBS="-lrt $LIBS"
604fi
605echo "clock_gettime $clock_gettime"
606
607##########################################
608# CLOCK_MONOTONIC probe
609clock_monotonic="no"
610if test "$clock_gettime" = "yes" ; then
611 cat > $TMPC << EOF
612#include <stdio.h>
613#include <time.h>
614int main(int argc, char **argv)
615{
616 return clock_gettime(CLOCK_MONOTONIC, NULL);
617}
618EOF
619 if compile_prog "" "$LIBS" "clock monotonic"; then
620 clock_monotonic="yes"
621 fi
622fi
623echo "CLOCK_MONOTONIC $clock_monotonic"
624
625##########################################
626# CLOCK_MONOTONIC_PRECISE probe
627clock_monotonic_precise="no"
628if test "$clock_gettime" = "yes" ; then
629 cat > $TMPC << EOF
630#include <stdio.h>
631#include <time.h>
632int main(int argc, char **argv)
633{
634 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
635}
636EOF
637 if compile_prog "" "$LIBS" "clock monotonic precise"; then
638 clock_monotonic_precise="yes"
639 fi
640fi
641echo "CLOCK_MONOTONIC_PRECISE $clock_monotonic_precise"
642
643##########################################
644# gettimeofday() probe
645gettimeofday="no"
646cat > $TMPC << EOF
647#include <sys/time.h>
648#include <stdio.h>
649int main(int argc, char **argv)
650{
651 struct timeval tv;
652 return gettimeofday(&tv, NULL);
653}
654EOF
655if compile_prog "" "" "gettimeofday"; then
656 gettimeofday="yes"
657fi
658echo "gettimeofday $gettimeofday"
659
660##########################################
661# fdatasync() probe
662fdatasync="no"
663cat > $TMPC << EOF
664#include <stdio.h>
665#include <unistd.h>
666int main(int argc, char **argv)
667{
668 return fdatasync(0);
669}
670EOF
671if compile_prog "" "" "fdatasync"; then
672 fdatasync="yes"
673fi
674echo "fdatasync $fdatasync"
675
676##########################################
677# sync_file_range() probe
678sync_file_range="no"
679cat > $TMPC << EOF
680#include <stdio.h>
681#include <unistd.h>
Jens Axboe67bf9822013-01-10 11:23:19 +0100682#include <fcntl.h>
683#include <linux/fs.h>
684int main(int argc, char **argv)
685{
686 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
687 SYNC_FILE_RANGE_WAIT_AFTER;
688 return sync_file_range(0, 0, 0, flags);
689}
690EOF
691if compile_prog "" "" "sync_file_range"; then
692 sync_file_range="yes"
693fi
694echo "sync_file_range $sync_file_range"
695
696##########################################
697# ext4 move extent probe
698ext4_me="no"
699cat > $TMPC << EOF
700#include <fcntl.h>
701#include <sys/ioctl.h>
702int main(int argc, char **argv)
703{
704 struct move_extent me;
705 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
706}
707EOF
Jens Axboec7165b82013-01-12 10:27:53 +0100708if compile_prog "" "" "ext4 move extent" ; then
709 ext4_me="yes"
710elif test $targetos = "Linux" ; then
711 # On Linux, just default to it on and let it error at runtime if we really
712 # don't have it. None of my updated systems have it defined, but it does
713 # work. Takes a while to bubble back.
Jens Axboe67bf9822013-01-10 11:23:19 +0100714 ext4_me="yes"
715fi
716echo "EXT4 move extent $ext4_me"
717
718##########################################
719# splice probe
720linux_splice="no"
721cat > $TMPC << EOF
Jens Axboe67bf9822013-01-10 11:23:19 +0100722#include <stdio.h>
723#include <fcntl.h>
724int main(int argc, char **argv)
725{
726 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
727}
728EOF
729if compile_prog "" "" "linux splice"; then
730 linux_splice="yes"
731fi
732echo "Linux splice(2) $linux_splice"
733
734##########################################
735# GUASI probe
736guasi="no"
737cat > $TMPC << EOF
738#include <guasi.h>
739#include <guasi_syscalls.h>
740int main(int argc, char **argv)
741{
742 guasi_t ctx = guasi_create(0, 0, 0);
743 return 0;
744}
745EOF
746if compile_prog "" "" "guasi"; then
747 guasi="yes"
748fi
749echo "GUASI $guasi"
750
751##########################################
752# fusion-aw probe
753fusion_aw="no"
754cat > $TMPC << EOF
Jens Axboe99db6562013-01-14 19:33:40 +0100755#include <nvm/vectored_write.h>
Jens Axboe67bf9822013-01-10 11:23:19 +0100756int main(int argc, char **argv)
757{
758 struct vsl_iovec iov;
759 return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
760}
761EOF
Jens Axboe99db6562013-01-14 19:33:40 +0100762if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
763 LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
Jens Axboe67bf9822013-01-10 11:23:19 +0100764 fusion_aw="yes"
765fi
766echo "Fusion-io atomic engine $fusion_aw"
767
768##########################################
769# libnuma probe
770libnuma="no"
771cat > $TMPC << EOF
772#include <numa.h>
773int main(int argc, char **argv)
774{
775 return numa_available();
776}
777EOF
778if compile_prog "" "-lnuma" "libnuma"; then
779 libnuma="yes"
780 LIBS="-lnuma $LIBS"
781fi
782echo "libnuma $libnuma"
783
784##########################################
785# strsep() probe
786strsep="no"
787cat > $TMPC << EOF
788#include <string.h>
789int main(int argc, char **argv)
790{
791 strsep(NULL, NULL);
792 return 0;
793}
794EOF
795if compile_prog "" "" "strsep"; then
796 strsep="yes"
797fi
798echo "strsep $strsep"
799
800##########################################
801# getopt_long_only() probe
802getopt_long_only="no"
803cat > $TMPC << EOF
804#include <unistd.h>
805#include <stdio.h>
806int main(int argc, char **argv)
807{
808 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
809 return c;
810}
811EOF
812if compile_prog "" "" "getopt_long_only"; then
813 getopt_long_only="yes"
814fi
815echo "getopt_long_only() $getopt_long_only"
816
817##########################################
818# inet_aton() probe
819inet_aton="no"
820cat > $TMPC << EOF
821#include <sys/socket.h>
822#include <arpa/inet.h>
823#include <stdio.h>
824int main(int argc, char **argv)
825{
826 struct in_addr in;
827 return inet_aton(NULL, &in);
828}
829EOF
830if compile_prog "" "" "inet_aton"; then
831 inet_aton="yes"
832fi
833echo "inet_aton $inet_aton"
834
835##########################################
836# socklen_t probe
837socklen_t="no"
838cat > $TMPC << EOF
839#include <string.h>
840#include <netinet/in.h>
841int main(int argc, char **argv)
842{
843 socklen_t len = 0;
844 return len;
845}
846EOF
847if compile_prog "" "" "socklen_t"; then
848 socklen_t="yes"
849fi
850echo "socklen_t $socklen_t"
851
852##########################################
853# Whether or not __thread is supported for TLS
854tls_thread="no"
855cat > $TMPC << EOF
856#include <stdio.h>
857static int __thread ret;
858int main(int argc, char **argv)
859{
860 return ret;
861}
862EOF
863if compile_prog "" "" "__thread"; then
864 tls_thread="yes"
865fi
866echo "__thread $tls_thread"
867
Jens Axboe44404c52013-01-24 14:20:09 -0700868##########################################
869# Check whether we have getrusage(RUSAGE_THREAD)
870rusage_thread="no"
871cat > $TMPC << EOF
872#include <sys/time.h>
873#include <sys/resource.h>
874int main(int argc, char **argv)
875{
876 struct rusage ru;
877 getrusage(RUSAGE_THREAD, &ru);
878 return 0;
879}
880EOF
881if compile_prog "" "" "RUSAGE_THREAD"; then
882 rusage_thread="yes"
883fi
884echo "RUSAGE_THREAD $rusage_thread"
885
Jens Axboe7e09a9f2013-01-30 13:58:58 +0100886##########################################
887# Check whether we have SCHED_IDLE
888sched_idle="no"
889cat > $TMPC << EOF
890#include <sched.h>
891int main(int argc, char **argv)
892{
893 struct sched_param p;
894 return sched_setscheduler(0, SCHED_IDLE, &p);
895}
896EOF
897if compile_prog "" "" "SCHED_IDLE"; then
898 sched_idle="yes"
899fi
900echo "SCHED_IDLE $sched_idle"
901
Jens Axboe1eafa372013-01-31 10:19:51 +0100902##########################################
903# Check whether we have TCP_NODELAY
904tcp_nodelay="no"
905cat > $TMPC << EOF
906#include <stdio.h>
907#include <sys/types.h>
908#include <sys/socket.h>
909#include <netinet/tcp.h>
910int main(int argc, char **argv)
911{
912 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
913}
914EOF
915if compile_prog "" "" "TCP_NODELAY"; then
916 tcp_nodelay="yes"
917fi
918echo "TCP_NODELAY $tcp_nodelay"
919
Jens Axboe38b93542013-02-28 08:28:05 +0100920##########################################
921# Check whether we have RLIMIT_MEMLOCK
922rlimit_memlock="no"
923cat > $TMPC << EOF
924#include <sys/time.h>
925#include <sys/resource.h>
926int main(int argc, char **argv)
927{
928 struct rlimit rl;
929 return getrlimit(RLIMIT_MEMLOCK, &rl);
930}
931EOF
932if compile_prog "" "" "RLIMIT_MEMLOCK"; then
933 rlimit_memlock="yes"
934fi
935echo "RLIMIT_MEMLOCK $rlimit_memlock"
936
Jens Axboe67bf9822013-01-10 11:23:19 +0100937#############################################################################
938
Jens Axboe67bf9822013-01-10 11:23:19 +0100939if test "$wordsize" = "64" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700940 output_sym "CONFIG_64BIT"
Jens Axboe67bf9822013-01-10 11:23:19 +0100941elif test "$wordsize" = "32" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700942 output_sym "CONFIG_32BIT"
Jens Axboe67bf9822013-01-10 11:23:19 +0100943else
Jens Axboed7145a72013-02-11 13:21:54 +0100944 fatal "Unknown wordsize!"
Jens Axboe67bf9822013-01-10 11:23:19 +0100945fi
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700946if test "$bigendian" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700947 output_sym "CONFIG_BIG_ENDIAN"
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700948else
Jens Axboe4feafb12013-01-24 23:07:55 -0700949 output_sym "CONFIG_LITTLE_ENDIAN"
Jens Axboe0dcebdf2013-01-23 15:42:16 -0700950fi
Jens Axboe67bf9822013-01-10 11:23:19 +0100951if test "$libaio" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700952 output_sym "CONFIG_LIBAIO"
Jens Axboe67bf9822013-01-10 11:23:19 +0100953fi
954if test "$posix_aio" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700955 output_sym "CONFIG_POSIXAIO"
Jens Axboe67bf9822013-01-10 11:23:19 +0100956fi
957if test "$posix_aio_fsync" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700958 output_sym "CONFIG_POSIXAIO_FSYNC"
Jens Axboe67bf9822013-01-10 11:23:19 +0100959fi
960if test "$linux_fallocate" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700961 output_sym "CONFIG_LINUX_FALLOCATE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100962fi
963if test "$posix_fallocate" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700964 output_sym "CONFIG_POSIX_FALLOCATE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100965fi
966if test "$fdatasync" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700967 output_sym "CONFIG_FDATASYNC"
Jens Axboe67bf9822013-01-10 11:23:19 +0100968fi
969if test "$sync_file_range" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700970 output_sym "CONFIG_SYNC_FILE_RANGE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100971fi
972if test "$sfaa" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700973 output_sym "CONFIG_SFAA"
Jens Axboe67bf9822013-01-10 11:23:19 +0100974fi
975if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700976 output_sym "CONFIG_RDMA"
Jens Axboe67bf9822013-01-10 11:23:19 +0100977fi
978if test "$clock_gettime" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700979 output_sym "CONFIG_CLOCK_GETTIME"
Jens Axboe67bf9822013-01-10 11:23:19 +0100980fi
981if test "$clock_monotonic" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700982 output_sym "CONFIG_CLOCK_MONOTONIC"
Jens Axboe67bf9822013-01-10 11:23:19 +0100983fi
984if test "$clock_monotonic_precise" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700985 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100986fi
987if test "$gettimeofday" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700988 output_sym "CONFIG_GETTIMEOFDAY"
Jens Axboe67bf9822013-01-10 11:23:19 +0100989fi
990if test "$posix_fadvise" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700991 output_sym "CONFIG_POSIX_FADVISE"
Jens Axboe67bf9822013-01-10 11:23:19 +0100992fi
993if test "$linux_3arg_affinity" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700994 output_sym "CONFIG_3ARG_AFFINITY"
Jens Axboe67bf9822013-01-10 11:23:19 +0100995elif test "$linux_2arg_affinity" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700996 output_sym "CONFIG_2ARG_AFFINITY"
Jens Axboe67bf9822013-01-10 11:23:19 +0100997fi
998if test "$strsep" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -0700999 output_sym "CONFIG_STRSEP"
Jens Axboe67bf9822013-01-10 11:23:19 +01001000fi
1001if test "$getopt_long_only" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001002 output_sym "CONFIG_GETOPT_LONG_ONLY"
Jens Axboe67bf9822013-01-10 11:23:19 +01001003fi
1004if test "$inet_aton" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001005 output_sym "CONFIG_INET_ATON"
Jens Axboe67bf9822013-01-10 11:23:19 +01001006fi
1007if test "$socklen_t" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001008 output_sym "CONFIG_SOCKLEN_T"
Jens Axboe67bf9822013-01-10 11:23:19 +01001009fi
1010if test "$ext4_me" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001011 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
Jens Axboe67bf9822013-01-10 11:23:19 +01001012fi
1013if test "$linux_splice" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001014 output_sym "CONFIG_LINUX_SPLICE"
Jens Axboe67bf9822013-01-10 11:23:19 +01001015fi
1016if test "$guasi" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001017 output_sym "CONFIG_GUASI"
Jens Axboe67bf9822013-01-10 11:23:19 +01001018fi
1019if test "$fusion_aw" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001020 output_sym "CONFIG_FUSION_AW"
Jens Axboe67bf9822013-01-10 11:23:19 +01001021fi
1022if test "$libnuma" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001023 output_sym "CONFIG_LIBNUMA"
Jens Axboe67bf9822013-01-10 11:23:19 +01001024fi
1025if test "$solaris_aio" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001026 output_sym "CONFIG_SOLARISAIO"
Jens Axboe67bf9822013-01-10 11:23:19 +01001027fi
1028if test "$tls_thread" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001029 output_sym "CONFIG_TLS_THREAD"
Jens Axboe67bf9822013-01-10 11:23:19 +01001030fi
Jens Axboe44404c52013-01-24 14:20:09 -07001031if test "$rusage_thread" = "yes" ; then
Jens Axboe4feafb12013-01-24 23:07:55 -07001032 output_sym "CONFIG_RUSAGE_THREAD"
Jens Axboe44404c52013-01-24 14:20:09 -07001033fi
Jens Axboe7e09a9f2013-01-30 13:58:58 +01001034if test "$sched_idle" = "yes" ; then
1035 output_sym "CONFIG_SCHED_IDLE"
1036fi
Aaron Carroll56c79602013-03-13 10:09:10 +01001037#if test "$tcp_nodelay" = "yes" ; then
1038 #output_sym "CONFIG_TCP_NODELAY"
1039#fi
Jens Axboe38b93542013-02-28 08:28:05 +01001040if test "$rlimit_memlock" = "yes" ; then
1041 output_sym "CONFIG_RLIMIT_MEMLOCK"
1042fi
Jens Axboe67bf9822013-01-10 11:23:19 +01001043
1044echo "LIBS+=$LIBS" >> $config_host_mak
1045echo "CC=$cc" >> $config_host_mak
Jens Axboe208e4c82013-01-29 09:26:07 +01001046echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak