Fix bug with rate and read/write mixed workloads at 100% bias
[fio.git] / configure
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
8 if test ! -z "$TMPDIR" ; then
9     TMPDIR1="${TMPDIR}"
10 elif test ! -z "$TEMPDIR" ; then
11     TMPDIR1="${TEMPDIR}"
12 else
13     TMPDIR1="/tmp"
14 fi
15
16 TMPC="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.c"
17 TMPO="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.o"
18 TMPE="${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>
22 trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
23
24 rm -rf config.log
25
26 config_host_mak="config-host.mak"
27 config_host_h="config-host.h"
28
29 rm -rf $config_host_mak
30 rm -rf $config_host_h
31
32 # Default CFLAGS
33 CFLAGS="-D_GNU_SOURCE"
34 EXTFLAGS="-include config-host.h"
35
36 # Print a helpful header at the top of config.log
37 echo "# FIO configure log $(date)" >> config.log
38 printf "# Configured with:" >> config.log
39 printf " '%s'" "$0" "$@" >> config.log
40 echo >> config.log
41 echo "#" >> config.log
42
43 # Print configure header at the top of $config_host_h
44 echo "/*" > $config_host_h
45 echo " * Automatically generated by configure - do not modify" >> $config_host_h
46 printf " * Configured with:" >> $config_host_h
47 printf " * '%s'" "$0" "$@" >> $config_host_h
48 echo "" >> $config_host_h
49 echo " */" >> $config_host_h
50
51 do_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
77 compile_object() {
78   do_cc $CFLAGS -c -o $TMPO $TMPC
79 }
80
81 compile_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
88 feature_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
98 has() {
99   type "$1" >/dev/null 2>&1
100 }
101
102 check_define() {
103   cat > $TMPC <<EOF
104 #if !defined($1)
105 #error $1 not defined
106 #endif
107 int main(void)
108 {
109   return 0;
110 }
111 EOF
112   compile_object
113 }
114
115 output_sym() {
116   echo "$1=y" >> $config_host_mak
117   echo "#define $1" >> $config_host_h
118 }
119
120 targetos=""
121 cpu=""
122
123 cc="${CC-${cross_prefix}gcc}"
124
125 show_help="no"
126 exit_val=0
127
128 # parse options
129 for opt do
130   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
131   case "$opt" in
132   --cc=*) CC="$optarg"
133   ;;
134   --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
135   ;;
136   --build-32bit-win=*) build_32bit_win="$optarg"
137   ;;
138   --help)
139   show_help="yes"
140   ;;
141   *)
142   echo "Bad option $opt"
143   show_help="yes"
144   exit_val=1
145   esac
146 done
147
148 if test "$show_help" = "yes" ; then
149   echo "--cc=                  Specify compiler to use"
150   echo "--extra-cflags=        Specify extra CFLAGS to pass to compiler"
151   echo "--build-32bit-win=     Specify yes for a 32-bit build on Windows"
152   exit $exit_val
153 fi
154
155 if check_define __linux__ ; then
156   targetos="Linux"
157 elif check_define __OpenBSD__ ; then
158   targetos='OpenBSD'
159 elif check_define __sun__ ; then
160   targetos='SunOS'
161 else
162   targetos=`uname -s`
163 fi
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.
169 case $targetos in
170 Darwin)
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   ;;
180 SunOS)
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
185   ;;
186 CYGWIN*)
187   echo "Forcing known good options on Windows"
188   if test -z "$CC" ; then
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
194   fi
195   output_sym "CONFIG_LITTLE_ENDIAN"
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
201   output_sym "CONFIG_FADVISE"
202   output_sym "CONFIG_SOCKLEN_T"
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"
208   output_sym "CONFIG_CLOCK_MONOTONIC"
209   output_sym "CONFIG_GETTIMEOFDAY"
210   output_sym "CONFIG_CLOCK_GETTIME"
211   output_sym "CONFIG_SCHED_IDLE"
212   output_sym "CONFIG_TCP_NODELAY"
213   echo "CC=$CC" >> $config_host_mak
214   echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
215   exit 0
216 esac
217
218 if test ! -z "$cpu" ; then
219   # command line argument
220   :
221 elif check_define __i386__ ; then
222   cpu="i386"
223 elif check_define __x86_64__ ; then
224   cpu="x86_64"
225 elif check_define __sparc__ ; then
226   if check_define __arch64__ ; then
227     cpu="sparc64"
228   else
229     cpu="sparc"
230   fi
231 elif check_define _ARCH_PPC ; then
232   if check_define _ARCH_PPC64 ; then
233     cpu="ppc64"
234   else
235     cpu="ppc"
236   fi
237 elif check_define __mips__ ; then
238   cpu="mips"
239 elif check_define __ia64__ ; then
240   cpu="ia64"
241 elif check_define __s390__ ; then
242   if check_define __s390x__ ; then
243     cpu="s390x"
244   else
245     cpu="s390"
246   fi
247 elif check_define __arm__ ; then
248   cpu="arm"
249 elif check_define __hppa__ ; then
250   cpu="hppa"
251 else
252   cpu=`uname -m`
253 fi
254
255 # Normalise host CPU name and set ARCH.
256 case "$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   ;;
282 esac
283
284 if test -z "$CC" ; then
285   if test "$targetos" = "FreeBSD"; then
286     if has clang; then
287       CC=clang
288     else
289       CC=gcc
290     fi
291   fi
292 fi
293
294 cc="${CC-${cross_prefix}gcc}"
295
296 ##########################################
297 # check endianness
298 bigendian="no"
299 cat > $TMPC <<EOF
300 #include <inttypes.h>
301 int main(void)
302 {
303   volatile uint32_t i=0x01234567;
304   return (*((uint8_t*)(&i))) == 0x67;
305 }
306 EOF
307 if compile_prog "" "" "endian"; then
308   $TMPE && bigendian="yes"
309 fi
310
311
312 echo "Operating system              $targetos"
313 echo "CPU                           $cpu"
314 echo "Big endian                    $bigendian"
315 echo "Compiler                      $cc"
316 echo
317
318 ##########################################
319 # check for wordsize
320 wordsize="0"
321 cat > $TMPC <<EOF
322 #include <stdio.h>
323 int main(void)
324 {
325   unsigned int wsize = sizeof(long) * 8;
326   printf("%d\n", wsize);
327   return 0;
328 }
329 EOF
330 if compile_prog "" "" "wordsize"; then
331   wordsize=$($TMPE)
332 fi
333 echo "Wordsize                      $wordsize"
334
335 ##########################################
336 # linux-aio probe
337 libaio="no"
338 cat > $TMPC <<EOF
339 #include <libaio.h>
340 #include <stddef.h>
341 int main(void)
342 {
343   io_setup(0, NULL);
344   return 0;
345 }
346 EOF
347 if compile_prog "" "-laio" "libaio" ; then
348   libaio=yes
349   LIBS="-laio $LIBS"
350 else
351   if test "$libaio" = "yes" ; then
352     feature_not_found "linux AIO"
353   fi
354   libaio=no
355 fi
356 echo "Linux AIO support             $libaio"
357
358 ##########################################
359 # posix aio probe
360 posix_aio="no"
361 posix_aio_lrt="no"
362 cat > $TMPC <<EOF
363 #include <aio.h>
364 int main(void)
365 {
366   struct aiocb cb;
367   aio_read(&cb);
368   return 0;
369 }
370 EOF
371 if compile_prog "" "" "posixaio" ; then
372   posix_aio="yes"
373 elif compile_prog "" "-lrt" "posixaio"; then
374   posix_aio="yes"
375   posix_aio_lrt="yes"
376   LIBS="-lrt $LIBS"
377 fi
378 echo "POSIX AIO support             $posix_aio"
379 echo "POSIX AIO support needs -lrt  $posix_aio_lrt"
380
381 ##########################################
382 # posix aio fsync probe
383 posix_aio_fsync="no"
384 if test "$posix_aio" = "yes" ; then
385   cat > $TMPC <<EOF
386 #include <fcntl.h>
387 #include <aio.h>
388 int main(void)
389 {
390   struct aiocb cb;
391   return aio_fsync(O_SYNC, &cb);
392   return 0;
393 }
394 EOF
395   if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
396     posix_aio_fsync=yes
397   fi
398 fi
399 echo "POSIX AIO fsync               $posix_aio_fsync"
400
401 ##########################################
402 # solaris aio probe
403 solaris_aio="no"
404 cat > $TMPC <<EOF
405 #include <sys/types.h>
406 #include <sys/asynch.h>
407 #include <unistd.h>
408 int main(void)
409 {
410   aio_result_t res;
411   return aioread(0, NULL, 0, 0, SEEK_SET, &res);
412   return 0;
413 }
414 EOF
415 if compile_prog "" "-laio" "solarisaio" ; then
416   solaris_aio=yes
417   LIBS="-laio $LIBS"
418 fi
419 echo "Solaris AIO support           $solaris_aio"
420
421 ##########################################
422 # __sync_fetch_and_and test
423 sfaa="no"
424 cat > $TMPC << EOF
425 static int sfaa(int *ptr)
426 {
427   return __sync_fetch_and_and(ptr, 0);
428 }
429
430 int main(int argc, char **argv)
431 {
432   int val = 42;
433   sfaa(&val);
434   return val;
435 }
436 EOF
437 if compile_prog "" "" "__sync_fetch_and_add()" ; then
438     sfaa="yes"
439 fi
440 echo "__sync_fetch_and add          $sfaa"
441
442 ##########################################
443 # libverbs probe
444 libverbs="no"
445 cat > $TMPC << EOF
446 #include <stdio.h>
447 #include <infiniband/arch.h>
448 int main(int argc, char **argv)
449 {
450   struct ibv_pd *pd = ibv_alloc_pd(NULL);
451   return 0;
452 }
453 EOF
454 if compile_prog "" "-libverbs" "libverbs" ; then
455     libverbs="yes"
456     LIBS="-libverbs $LIBS"
457 fi
458 echo "libverbs                      $libverbs"
459
460 ##########################################
461 # rdmacm probe
462 rdmacm="no"
463 cat > $TMPC << EOF
464 #include <stdio.h>
465 #include <rdma/rdma_cma.h>
466 int main(int argc, char **argv)
467 {
468   rdma_destroy_qp(NULL);
469   return 0;
470 }
471 EOF
472 if compile_prog "" "-lrdmacm" "rdma"; then
473     rdmacm="yes"
474     LIBS="-lrdmacm $LIBS"
475 fi
476 echo "rdmacm                        $rdmacm"
477
478 ##########################################
479 # Linux fallocate probe
480 linux_fallocate="no"
481 cat > $TMPC << EOF
482 #include <stdio.h>
483 #include <linux/falloc.h>
484 int main(int argc, char **argv)
485 {
486   int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
487   return r;
488 }
489 EOF
490 if compile_prog "" "" "linux_fallocate"; then
491     linux_fallocate="yes"
492 fi
493 echo "Linux fallocate               $linux_fallocate"
494
495 ##########################################
496 # POSIX fadvise probe
497 posix_fadvise="no"
498 cat > $TMPC << EOF
499 #include <stdio.h>
500 #include <fcntl.h>
501 int main(int argc, char **argv)
502 {
503   int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
504   return r;
505 }
506 EOF
507 if compile_prog "" "" "posix_fadvise"; then
508     posix_fadvise="yes"
509 fi
510 echo "POSIX fadvise                 $posix_fadvise"
511
512 ##########################################
513 # POSIX fallocate probe
514 posix_fallocate="no"
515 cat > $TMPC << EOF
516 #include <stdio.h>
517 #include <fcntl.h>
518 int main(int argc, char **argv)
519 {
520   int r = posix_fallocate(0, 0, 1024);
521   return r;
522 }
523 EOF
524 if compile_prog "" "" "posix_fallocate"; then
525     posix_fallocate="yes"
526 fi
527 echo "POSIX fallocate               $posix_fallocate"
528
529 ##########################################
530 # sched_set/getaffinity 2 or 3 argument test
531 linux_2arg_affinity="no"
532 linux_3arg_affinity="no"
533 cat > $TMPC << EOF
534 #include <sched.h>
535 int main(int argc, char **argv)
536 {
537   cpu_set_t mask;
538   return sched_setaffinity(0, sizeof(mask), &mask);
539 }
540 EOF
541 if compile_prog "" "" "sched_setaffinity(,,)"; then
542   linux_3arg_affinity="yes"
543 else
544   cat > $TMPC << EOF
545 #include <sched.h>
546 int main(int argc, char **argv)
547 {
548   cpu_set_t mask;
549   return sched_setaffinity(0, &mask);
550 }
551 EOF
552   if compile_prog "" "" "sched_setaffinity(,)"; then
553     linux_2arg_affinity="yes"
554   fi
555 fi
556 echo "sched_setaffinity(3 arg)      $linux_3arg_affinity"
557 echo "sched_setaffinity(2 arg)      $linux_2arg_affinity"
558
559 ##########################################
560 # clock_gettime probe
561 clock_gettime="no"
562 cat > $TMPC << EOF
563 #include <stdio.h>
564 #include <time.h>
565 int main(int argc, char **argv)
566 {
567   return clock_gettime(0, NULL);
568 }
569 EOF
570 if compile_prog "" "" "clock_gettime"; then
571     clock_gettime="yes"
572 elif compile_prog "" "-lrt" "clock_gettime"; then
573     clock_gettime="yes"
574     LIBS="-lrt $LIBS"
575 fi
576 echo "clock_gettime                 $clock_gettime"
577
578 ##########################################
579 # CLOCK_MONOTONIC probe
580 clock_monotonic="no"
581 if test "$clock_gettime" = "yes" ; then
582   cat > $TMPC << EOF
583 #include <stdio.h>
584 #include <time.h>
585 int main(int argc, char **argv)
586 {
587   return clock_gettime(CLOCK_MONOTONIC, NULL);
588 }
589 EOF
590   if compile_prog "" "$LIBS" "clock monotonic"; then
591       clock_monotonic="yes"
592   fi
593 fi
594 echo "CLOCK_MONOTONIC               $clock_monotonic"
595
596 ##########################################
597 # CLOCK_MONOTONIC_PRECISE probe
598 clock_monotonic_precise="no"
599 if test "$clock_gettime" = "yes" ; then
600   cat > $TMPC << EOF
601 #include <stdio.h>
602 #include <time.h>
603 int main(int argc, char **argv)
604 {
605   return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
606 }
607 EOF
608   if compile_prog "" "$LIBS" "clock monotonic precise"; then
609       clock_monotonic_precise="yes"
610   fi
611 fi
612 echo "CLOCK_MONOTONIC_PRECISE       $clock_monotonic_precise"
613
614 ##########################################
615 # gettimeofday() probe
616 gettimeofday="no"
617 cat > $TMPC << EOF
618 #include <sys/time.h>
619 #include <stdio.h>
620 int main(int argc, char **argv)
621 {
622   struct timeval tv;
623   return gettimeofday(&tv, NULL);
624 }
625 EOF
626 if compile_prog "" "" "gettimeofday"; then
627     gettimeofday="yes"
628 fi
629 echo "gettimeofday                  $gettimeofday"
630
631 ##########################################
632 # fdatasync() probe
633 fdatasync="no"
634 cat > $TMPC << EOF
635 #include <stdio.h>
636 #include <unistd.h>
637 int main(int argc, char **argv)
638 {
639   return fdatasync(0);
640 }
641 EOF
642 if compile_prog "" "" "fdatasync"; then
643   fdatasync="yes"
644 fi
645 echo "fdatasync                     $fdatasync"
646
647 ##########################################
648 # sync_file_range() probe
649 sync_file_range="no"
650 cat > $TMPC << EOF
651 #include <stdio.h>
652 #include <unistd.h>
653 #include <fcntl.h>
654 #include <linux/fs.h>
655 int 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 }
661 EOF
662 if compile_prog "" "" "sync_file_range"; then
663   sync_file_range="yes"
664 fi
665 echo "sync_file_range               $sync_file_range"
666
667 ##########################################
668 # ext4 move extent probe
669 ext4_me="no"
670 cat > $TMPC << EOF
671 #include <fcntl.h>
672 #include <sys/ioctl.h>
673 int main(int argc, char **argv)
674 {
675   struct move_extent me;
676   return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
677 }
678 EOF
679 if compile_prog "" "" "ext4 move extent" ; then
680   ext4_me="yes"
681 elif 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.
685   ext4_me="yes"
686 fi
687 echo "EXT4 move extent              $ext4_me"
688
689 ##########################################
690 # splice probe
691 linux_splice="no"
692 cat > $TMPC << EOF
693 #include <stdio.h>
694 #include <fcntl.h>
695 int main(int argc, char **argv)
696 {
697   return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
698 }
699 EOF
700 if compile_prog "" "" "linux splice"; then
701   linux_splice="yes"
702 fi
703 echo "Linux splice(2)               $linux_splice"
704
705 ##########################################
706 # GUASI probe
707 guasi="no"
708 cat > $TMPC << EOF
709 #include <guasi.h>
710 #include <guasi_syscalls.h>
711 int main(int argc, char **argv)
712 {
713   guasi_t ctx = guasi_create(0, 0, 0);
714   return 0;
715 }
716 EOF
717 if compile_prog "" "" "guasi"; then
718   guasi="yes"
719 fi
720 echo "GUASI                         $guasi"
721
722 ##########################################
723 # fusion-aw probe
724 fusion_aw="no"
725 cat > $TMPC << EOF
726 #include <nvm/vectored_write.h>
727 int main(int argc, char **argv)
728 {
729   struct vsl_iovec iov;
730   return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
731 }
732 EOF
733 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
734   LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
735   fusion_aw="yes"
736 fi
737 echo "Fusion-io atomic engine       $fusion_aw"
738
739 ##########################################
740 # libnuma probe
741 libnuma="no"
742 cat > $TMPC << EOF
743 #include <numa.h>
744 int main(int argc, char **argv)
745 {
746   return numa_available();
747 }
748 EOF
749 if compile_prog "" "-lnuma" "libnuma"; then
750   libnuma="yes"
751   LIBS="-lnuma $LIBS"
752 fi
753 echo "libnuma                       $libnuma"
754
755 ##########################################
756 # strsep() probe
757 strsep="no"
758 cat > $TMPC << EOF
759 #include <string.h>
760 int main(int argc, char **argv)
761 {
762   strsep(NULL, NULL);
763   return 0;
764 }
765 EOF
766 if compile_prog "" "" "strsep"; then
767   strsep="yes"
768 fi
769 echo "strsep                        $strsep"
770
771 ##########################################
772 # getopt_long_only() probe
773 getopt_long_only="no"
774 cat > $TMPC << EOF
775 #include <unistd.h>
776 #include <stdio.h>
777 int main(int argc, char **argv)
778 {
779   int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
780   return c;
781 }
782 EOF
783 if compile_prog "" "" "getopt_long_only"; then
784   getopt_long_only="yes"
785 fi
786 echo "getopt_long_only()            $getopt_long_only"
787
788 ##########################################
789 # inet_aton() probe
790 inet_aton="no"
791 cat > $TMPC << EOF
792 #include <sys/socket.h>
793 #include <arpa/inet.h>
794 #include <stdio.h>
795 int main(int argc, char **argv)
796 {
797   struct in_addr in;
798   return inet_aton(NULL, &in);
799 }
800 EOF
801 if compile_prog "" "" "inet_aton"; then
802   inet_aton="yes"
803 fi
804 echo "inet_aton                     $inet_aton"
805
806 ##########################################
807 # socklen_t probe
808 socklen_t="no"
809 cat > $TMPC << EOF
810 #include <string.h>
811 #include <netinet/in.h>
812 int main(int argc, char **argv)
813 {
814   socklen_t len = 0;
815   return len;
816 }
817 EOF
818 if compile_prog "" "" "socklen_t"; then
819   socklen_t="yes"
820 fi
821 echo "socklen_t                     $socklen_t"
822
823 ##########################################
824 # Whether or not __thread is supported for TLS
825 tls_thread="no"
826 cat > $TMPC << EOF
827 #include <stdio.h>
828 static int __thread ret;
829 int main(int argc, char **argv)
830 {
831   return ret;
832 }
833 EOF
834 if compile_prog "" "" "__thread"; then
835   tls_thread="yes"
836 fi
837 echo "__thread                      $tls_thread"
838
839 ##########################################
840 # Check whether we have getrusage(RUSAGE_THREAD)
841 rusage_thread="no"
842 cat > $TMPC << EOF
843 #include <sys/time.h>
844 #include <sys/resource.h>
845 int main(int argc, char **argv)
846 {
847   struct rusage ru;
848   getrusage(RUSAGE_THREAD, &ru);
849   return 0;
850 }
851 EOF
852 if compile_prog "" "" "RUSAGE_THREAD"; then
853   rusage_thread="yes"
854 fi
855 echo "RUSAGE_THREAD                 $rusage_thread"
856
857 ##########################################
858 # Check whether we have SCHED_IDLE
859 sched_idle="no"
860 cat > $TMPC << EOF
861 #include <sched.h>
862 int main(int argc, char **argv)
863 {
864   struct sched_param p;
865   return sched_setscheduler(0, SCHED_IDLE, &p);
866 }
867 EOF
868 if compile_prog "" "" "SCHED_IDLE"; then
869   sched_idle="yes"
870 fi
871 echo "SCHED_IDLE                    $sched_idle"
872
873 ##########################################
874 # Check whether we have TCP_NODELAY
875 tcp_nodelay="no"
876 cat > $TMPC << EOF
877 #include <stdio.h>
878 #include <sys/types.h>
879 #include <sys/socket.h>
880 #include <netinet/tcp.h>
881 int main(int argc, char **argv)
882 {
883   return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
884 }
885 EOF
886 if compile_prog "" "" "TCP_NODELAY"; then
887   tcp_nodelay="yes"
888 fi
889 echo "TCP_NODELAY                   $tcp_nodelay"
890
891 #############################################################################
892
893 echo "# Automatically generated by configure - do not modify" > $config_host_mak
894 printf "# Configured with:" >> $config_host_mak
895 printf " '%s'" "$0" "$@" >> $config_host_mak
896 echo >> $config_host_mak
897
898 if test "$wordsize" = "64" ; then
899   output_sym "CONFIG_64BIT"
900 elif test "$wordsize" = "32" ; then
901   output_sym "CONFIG_32BIT"
902 else
903   echo "Unknown wordsize!"
904   exit 1
905 fi
906 if test "$bigendian" = "yes" ; then
907   output_sym "CONFIG_BIG_ENDIAN"
908 else
909   output_sym "CONFIG_LITTLE_ENDIAN"
910 fi
911 if test "$libaio" = "yes" ; then
912   output_sym "CONFIG_LIBAIO"
913 fi
914 if test "$posix_aio" = "yes" ; then
915   output_sym "CONFIG_POSIXAIO"
916 fi
917 if test "$posix_aio_fsync" = "yes" ; then
918   output_sym "CONFIG_POSIXAIO_FSYNC"
919 fi
920 if test "$linux_fallocate" = "yes" ; then
921   output_sym "CONFIG_LINUX_FALLOCATE"
922 fi
923 if test "$posix_fallocate" = "yes" ; then
924   output_sym "CONFIG_POSIX_FALLOCATE"
925 fi
926 if test "$fdatasync" = "yes" ; then
927   output_sym "CONFIG_FDATASYNC"
928 fi
929 if test "$sync_file_range" = "yes" ; then
930   output_sym "CONFIG_SYNC_FILE_RANGE"
931 fi
932 if test "$sfaa" = "yes" ; then
933   output_sym "CONFIG_SFAA"
934 fi
935 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
936   output_sym "CONFIG_RDMA"
937 fi
938 if test "$clock_gettime" = "yes" ; then
939   output_sym "CONFIG_CLOCK_GETTIME"
940 fi
941 if test "$clock_monotonic" = "yes" ; then
942   output_sym "CONFIG_CLOCK_MONOTONIC"
943 fi
944 if test "$clock_monotonic_precise" = "yes" ; then
945   output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
946 fi
947 if test "$gettimeofday" = "yes" ; then
948   output_sym "CONFIG_GETTIMEOFDAY"
949 fi
950 if test "$posix_fadvise" = "yes" ; then
951   output_sym "CONFIG_POSIX_FADVISE"
952 fi
953 if test "$linux_3arg_affinity" = "yes" ; then
954   output_sym "CONFIG_3ARG_AFFINITY"
955 elif test "$linux_2arg_affinity" = "yes" ; then
956   output_sym "CONFIG_2ARG_AFFINITY"
957 fi
958 if test "$strsep" = "yes" ; then
959   output_sym "CONFIG_STRSEP"
960 fi
961 if test "$getopt_long_only" = "yes" ; then
962   output_sym "CONFIG_GETOPT_LONG_ONLY"
963 fi
964 if test "$inet_aton" = "yes" ; then
965   output_sym "CONFIG_INET_ATON"
966 fi
967 if test "$socklen_t" = "yes" ; then
968   output_sym "CONFIG_SOCKLEN_T"
969 fi
970 if test "$ext4_me" = "yes" ; then
971   output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
972 fi
973 if test "$linux_splice" = "yes" ; then
974   output_sym "CONFIG_LINUX_SPLICE"
975 fi
976 if test "$guasi" = "yes" ; then
977   output_sym "CONFIG_GUASI"
978 fi
979 if test "$fusion_aw" = "yes" ; then
980   output_sym "CONFIG_FUSION_AW"
981 fi
982 if test "$libnuma" = "yes" ; then
983   output_sym "CONFIG_LIBNUMA"
984 fi
985 if test "$solaris_aio" = "yes" ; then
986   output_sym "CONFIG_SOLARISAIO"
987 fi
988 if test "$tls_thread" = "yes" ; then
989   output_sym "CONFIG_TLS_THREAD"
990 fi
991 if test "$rusage_thread" = "yes" ; then
992   output_sym "CONFIG_RUSAGE_THREAD"
993 fi
994 if test "$sched_idle" = "yes" ; then
995   output_sym "CONFIG_SCHED_IDLE"
996 fi
997 if test "$tcp_nodelay" = "yes" ; then
998   output_sym "CONFIG_TCP_NODELAY"
999 fi
1000
1001 echo "LIBS+=$LIBS" >> $config_host_mak
1002 echo "CC=$cc" >> $config_host_mak
1003 echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak