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