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