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