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