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