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