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