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