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