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