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