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