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