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