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