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