configure revision 142429e5ae9ac82c3e37af759f12d058f8259e23
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
8if test ! -z "$TMPDIR" ; then
9    TMPDIR1="${TMPDIR}"
10elif test ! -z "$TEMPDIR" ; then
11    TMPDIR1="${TEMPDIR}"
12else
13    TMPDIR1="/tmp"
14fi
15
16TMPC="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.c"
17TMPO="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.o"
18TMPE="${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>
22trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
23
24rm -rf config.log
25
26config_host_mak="config-host.mak"
27config_host_h="config-host.h"
28
29rm -rf $config_host_mak
30rm -rf $config_host_h
31
32fatal() {
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
41CFLAGS="-D_GNU_SOURCE"
42EXTFLAGS="-include config-host.h"
43
44# Print a helpful header at the top of config.log
45echo "# FIO configure log $(date)" >> config.log
46printf "# Configured with:" >> config.log
47printf " '%s'" "$0" "$@" >> config.log
48echo >> config.log
49echo "#" >> config.log
50
51# Print configure header at the top of $config_host_h
52echo "/*" > $config_host_h
53echo " * Automatically generated by configure - do not modify" >> $config_host_h
54printf " * Configured with:" >> $config_host_h
55printf " * '%s'" "$0" "$@" >> $config_host_h
56echo "" >> $config_host_h
57echo " */" >> $config_host_h
58
59do_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
84compile_object() {
85  do_cc $CFLAGS -c -o $TMPO $TMPC
86}
87
88compile_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
95feature_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
104has() {
105  type "$1" >/dev/null 2>&1
106}
107
108check_define() {
109  cat > $TMPC <<EOF
110#if !defined($1)
111#error $1 not defined
112#endif
113int main(void)
114{
115  return 0;
116}
117EOF
118  compile_object
119}
120
121output_sym() {
122  echo "$1=y" >> $config_host_mak
123  echo "#define $1" >> $config_host_h
124}
125
126targetos=""
127cpu=""
128
129cross_prefix=${cross_prefix-${CROSS_COMPILE}}
130cc="${CC-${cross_prefix}gcc}"
131
132show_help="no"
133exit_val=0
134
135# parse options
136for 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
155done
156
157if 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
163fi
164
165if check_define __ANDROID__ ; then
166  targetos="Android"
167elif check_define __linux__ ; then
168  targetos="Linux"
169elif check_define __OpenBSD__ ; then
170  targetos='OpenBSD'
171elif check_define __sun__ ; then
172  targetos='SunOS'
173else
174  targetos=`uname -s`
175fi
176
177echo "# Automatically generated by configure - do not modify" > $config_host_mak
178printf "# Configured with:" >> $config_host_mak
179printf " '%s'" "$0" "$@" >> $config_host_mak
180echo >> $config_host_mak
181echo "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.
187case $targetos in
188Darwin)
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  ;;
198SunOS)
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  ;;
205CYGWIN*)
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 "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
234  exit 0
235  ;;
236Android)
237  output_sym "CONFIG_32BIT"
238  output_sym "CONFIG_LITTLE_ENDIAN"
239  output_sym "CONFIG_SOCKLEN_T"
240  output_sym "CONFIG_GETTIMEOFDAY"
241  output_sym "CONFIG_CLOCK_GETTIME"
242  output_sym "CONFIG_CLOCK_MONOTONIC"
243  echo "CC=$cc" >> $config_host_mak
244  echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
245  exit 0
246esac
247
248if test ! -z "$cpu" ; then
249  # command line argument
250  :
251elif check_define __i386__ ; then
252  cpu="i386"
253elif check_define __x86_64__ ; then
254  cpu="x86_64"
255elif check_define __sparc__ ; then
256  if check_define __arch64__ ; then
257    cpu="sparc64"
258  else
259    cpu="sparc"
260  fi
261elif check_define _ARCH_PPC ; then
262  if check_define _ARCH_PPC64 ; then
263    cpu="ppc64"
264  else
265    cpu="ppc"
266  fi
267elif check_define __mips__ ; then
268  cpu="mips"
269elif check_define __ia64__ ; then
270  cpu="ia64"
271elif check_define __s390__ ; then
272  if check_define __s390x__ ; then
273    cpu="s390x"
274  else
275    cpu="s390"
276  fi
277elif check_define __arm__ ; then
278  cpu="arm"
279elif check_define __hppa__ ; then
280  cpu="hppa"
281else
282  cpu=`uname -m`
283fi
284
285# Normalise host CPU name and set ARCH.
286case "$cpu" in
287  ia64|ppc|ppc64|s390|s390x|sparc64)
288    cpu="$cpu"
289  ;;
290  i386|i486|i586|i686|i86pc|BePC)
291    cpu="i386"
292  ;;
293  x86_64|amd64)
294    cpu="x86_64"
295  ;;
296  armv*b|armv*l|arm)
297    cpu="arm"
298  ;;
299  hppa|parisc|parisc64)
300    cpu="hppa"
301  ;;
302  mips*)
303    cpu="mips"
304  ;;
305  sparc|sun4[cdmuv])
306    cpu="sparc"
307  ;;
308  *)
309  echo "Unknown CPU"
310  ;;
311esac
312
313if test -z "$CC" ; then
314  if test "$targetos" = "FreeBSD"; then
315    if has clang; then
316      CC=clang
317    else
318      CC=gcc
319    fi
320  fi
321fi
322
323cc="${CC-${cross_prefix}gcc}"
324
325##########################################
326# check endianness
327bigendian="no"
328cat > $TMPC <<EOF
329#include <inttypes.h>
330int main(void)
331{
332  volatile uint32_t i=0x01234567;
333  return (*((uint8_t*)(&i))) == 0x67;
334}
335EOF
336if compile_prog "" "" "endian"; then
337  $TMPE && bigendian="yes"
338fi
339
340
341echo "Operating system              $targetos"
342echo "CPU                           $cpu"
343echo "Big endian                    $bigendian"
344echo "Compiler                      $cc"
345echo
346
347##########################################
348# check for wordsize
349wordsize="0"
350cat > $TMPC <<EOF
351#include <limits.h>
352#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
353int main(void)
354{
355  BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
356  return 0;
357}
358EOF
359if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
360  wordsize="32"
361elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
362  wordsize="64"
363else
364  fatal "Unknown wordsize"
365fi
366echo "Wordsize                      $wordsize"
367
368##########################################
369# linux-aio probe
370libaio="no"
371cat > $TMPC <<EOF
372#include <libaio.h>
373#include <stddef.h>
374int main(void)
375{
376  io_setup(0, NULL);
377  return 0;
378}
379EOF
380if compile_prog "" "-laio" "libaio" ; then
381  libaio=yes
382  LIBS="-laio $LIBS"
383else
384  if test "$libaio" = "yes" ; then
385    feature_not_found "linux AIO"
386  fi
387  libaio=no
388fi
389echo "Linux AIO support             $libaio"
390
391##########################################
392# posix aio probe
393posix_aio="no"
394posix_aio_lrt="no"
395cat > $TMPC <<EOF
396#include <aio.h>
397int main(void)
398{
399  struct aiocb cb;
400  aio_read(&cb);
401  return 0;
402}
403EOF
404if compile_prog "" "" "posixaio" ; then
405  posix_aio="yes"
406elif compile_prog "" "-lrt" "posixaio"; then
407  posix_aio="yes"
408  posix_aio_lrt="yes"
409  LIBS="-lrt $LIBS"
410fi
411echo "POSIX AIO support             $posix_aio"
412echo "POSIX AIO support needs -lrt  $posix_aio_lrt"
413
414##########################################
415# posix aio fsync probe
416posix_aio_fsync="no"
417if test "$posix_aio" = "yes" ; then
418  cat > $TMPC <<EOF
419#include <fcntl.h>
420#include <aio.h>
421int main(void)
422{
423  struct aiocb cb;
424  return aio_fsync(O_SYNC, &cb);
425  return 0;
426}
427EOF
428  if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
429    posix_aio_fsync=yes
430  fi
431fi
432echo "POSIX AIO fsync               $posix_aio_fsync"
433
434##########################################
435# solaris aio probe
436solaris_aio="no"
437cat > $TMPC <<EOF
438#include <sys/types.h>
439#include <sys/asynch.h>
440#include <unistd.h>
441int main(void)
442{
443  aio_result_t res;
444  return aioread(0, NULL, 0, 0, SEEK_SET, &res);
445  return 0;
446}
447EOF
448if compile_prog "" "-laio" "solarisaio" ; then
449  solaris_aio=yes
450  LIBS="-laio $LIBS"
451fi
452echo "Solaris AIO support           $solaris_aio"
453
454##########################################
455# __sync_fetch_and_and test
456sfaa="no"
457cat > $TMPC << EOF
458static int sfaa(int *ptr)
459{
460  return __sync_fetch_and_add(ptr, 0);
461}
462
463int main(int argc, char **argv)
464{
465  int val = 42;
466  sfaa(&val);
467  return val;
468}
469EOF
470if compile_prog "" "" "__sync_fetch_and_add()" ; then
471    sfaa="yes"
472fi
473echo "__sync_fetch_and_add          $sfaa"
474
475##########################################
476# libverbs probe
477libverbs="no"
478cat > $TMPC << EOF
479#include <stdio.h>
480#include <infiniband/arch.h>
481int main(int argc, char **argv)
482{
483  struct ibv_pd *pd = ibv_alloc_pd(NULL);
484  return 0;
485}
486EOF
487if compile_prog "" "-libverbs" "libverbs" ; then
488    libverbs="yes"
489    LIBS="-libverbs $LIBS"
490fi
491echo "libverbs                      $libverbs"
492
493##########################################
494# rdmacm probe
495rdmacm="no"
496cat > $TMPC << EOF
497#include <stdio.h>
498#include <rdma/rdma_cma.h>
499int main(int argc, char **argv)
500{
501  rdma_destroy_qp(NULL);
502  return 0;
503}
504EOF
505if compile_prog "" "-lrdmacm" "rdma"; then
506    rdmacm="yes"
507    LIBS="-lrdmacm $LIBS"
508fi
509echo "rdmacm                        $rdmacm"
510
511##########################################
512# Linux fallocate probe
513linux_fallocate="no"
514cat > $TMPC << EOF
515#include <stdio.h>
516#include <linux/falloc.h>
517int main(int argc, char **argv)
518{
519  int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
520  return r;
521}
522EOF
523if compile_prog "" "" "linux_fallocate"; then
524    linux_fallocate="yes"
525fi
526echo "Linux fallocate               $linux_fallocate"
527
528##########################################
529# POSIX fadvise probe
530posix_fadvise="no"
531cat > $TMPC << EOF
532#include <stdio.h>
533#include <fcntl.h>
534int main(int argc, char **argv)
535{
536  int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
537  return r;
538}
539EOF
540if compile_prog "" "" "posix_fadvise"; then
541    posix_fadvise="yes"
542fi
543echo "POSIX fadvise                 $posix_fadvise"
544
545##########################################
546# POSIX fallocate probe
547posix_fallocate="no"
548cat > $TMPC << EOF
549#include <stdio.h>
550#include <fcntl.h>
551int main(int argc, char **argv)
552{
553  int r = posix_fallocate(0, 0, 1024);
554  return r;
555}
556EOF
557if compile_prog "" "" "posix_fallocate"; then
558    posix_fallocate="yes"
559fi
560echo "POSIX fallocate               $posix_fallocate"
561
562##########################################
563# sched_set/getaffinity 2 or 3 argument test
564linux_2arg_affinity="no"
565linux_3arg_affinity="no"
566cat > $TMPC << EOF
567#include <sched.h>
568int main(int argc, char **argv)
569{
570  cpu_set_t mask;
571  return sched_setaffinity(0, sizeof(mask), &mask);
572}
573EOF
574if compile_prog "" "" "sched_setaffinity(,,)"; then
575  linux_3arg_affinity="yes"
576else
577  cat > $TMPC << EOF
578#include <sched.h>
579int main(int argc, char **argv)
580{
581  cpu_set_t mask;
582  return sched_setaffinity(0, &mask);
583}
584EOF
585  if compile_prog "" "" "sched_setaffinity(,)"; then
586    linux_2arg_affinity="yes"
587  fi
588fi
589echo "sched_setaffinity(3 arg)      $linux_3arg_affinity"
590echo "sched_setaffinity(2 arg)      $linux_2arg_affinity"
591
592##########################################
593# clock_gettime probe
594clock_gettime="no"
595cat > $TMPC << EOF
596#include <stdio.h>
597#include <time.h>
598int main(int argc, char **argv)
599{
600  return clock_gettime(0, NULL);
601}
602EOF
603if compile_prog "" "" "clock_gettime"; then
604    clock_gettime="yes"
605elif compile_prog "" "-lrt" "clock_gettime"; then
606    clock_gettime="yes"
607    LIBS="-lrt $LIBS"
608fi
609echo "clock_gettime                 $clock_gettime"
610
611##########################################
612# CLOCK_MONOTONIC probe
613clock_monotonic="no"
614if test "$clock_gettime" = "yes" ; then
615  cat > $TMPC << EOF
616#include <stdio.h>
617#include <time.h>
618int main(int argc, char **argv)
619{
620  return clock_gettime(CLOCK_MONOTONIC, NULL);
621}
622EOF
623  if compile_prog "" "$LIBS" "clock monotonic"; then
624      clock_monotonic="yes"
625  fi
626fi
627echo "CLOCK_MONOTONIC               $clock_monotonic"
628
629##########################################
630# CLOCK_MONOTONIC_PRECISE probe
631clock_monotonic_precise="no"
632if test "$clock_gettime" = "yes" ; then
633  cat > $TMPC << EOF
634#include <stdio.h>
635#include <time.h>
636int main(int argc, char **argv)
637{
638  return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
639}
640EOF
641  if compile_prog "" "$LIBS" "clock monotonic precise"; then
642      clock_monotonic_precise="yes"
643  fi
644fi
645echo "CLOCK_MONOTONIC_PRECISE       $clock_monotonic_precise"
646
647##########################################
648# gettimeofday() probe
649gettimeofday="no"
650cat > $TMPC << EOF
651#include <sys/time.h>
652#include <stdio.h>
653int main(int argc, char **argv)
654{
655  struct timeval tv;
656  return gettimeofday(&tv, NULL);
657}
658EOF
659if compile_prog "" "" "gettimeofday"; then
660    gettimeofday="yes"
661fi
662echo "gettimeofday                  $gettimeofday"
663
664##########################################
665# fdatasync() probe
666fdatasync="no"
667cat > $TMPC << EOF
668#include <stdio.h>
669#include <unistd.h>
670int main(int argc, char **argv)
671{
672  return fdatasync(0);
673}
674EOF
675if compile_prog "" "" "fdatasync"; then
676  fdatasync="yes"
677fi
678echo "fdatasync                     $fdatasync"
679
680##########################################
681# sync_file_range() probe
682sync_file_range="no"
683cat > $TMPC << EOF
684#include <stdio.h>
685#include <unistd.h>
686#include <fcntl.h>
687#include <linux/fs.h>
688int main(int argc, char **argv)
689{
690  unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
691			SYNC_FILE_RANGE_WAIT_AFTER;
692  return sync_file_range(0, 0, 0, flags);
693}
694EOF
695if compile_prog "" "" "sync_file_range"; then
696  sync_file_range="yes"
697fi
698echo "sync_file_range               $sync_file_range"
699
700##########################################
701# ext4 move extent probe
702ext4_me="no"
703cat > $TMPC << EOF
704#include <fcntl.h>
705#include <sys/ioctl.h>
706int main(int argc, char **argv)
707{
708  struct move_extent me;
709  return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
710}
711EOF
712if compile_prog "" "" "ext4 move extent" ; then
713  ext4_me="yes"
714elif test $targetos = "Linux" ; then
715  # On Linux, just default to it on and let it error at runtime if we really
716  # don't have it. None of my updated systems have it defined, but it does
717  # work. Takes a while to bubble back.
718  ext4_me="yes"
719fi
720echo "EXT4 move extent              $ext4_me"
721
722##########################################
723# splice probe
724linux_splice="no"
725cat > $TMPC << EOF
726#include <stdio.h>
727#include <fcntl.h>
728int main(int argc, char **argv)
729{
730  return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
731}
732EOF
733if compile_prog "" "" "linux splice"; then
734  linux_splice="yes"
735fi
736echo "Linux splice(2)               $linux_splice"
737
738##########################################
739# GUASI probe
740guasi="no"
741cat > $TMPC << EOF
742#include <guasi.h>
743#include <guasi_syscalls.h>
744int main(int argc, char **argv)
745{
746  guasi_t ctx = guasi_create(0, 0, 0);
747  return 0;
748}
749EOF
750if compile_prog "" "" "guasi"; then
751  guasi="yes"
752fi
753echo "GUASI                         $guasi"
754
755##########################################
756# fusion-aw probe
757fusion_aw="no"
758cat > $TMPC << EOF
759#include <nvm/vectored_write.h>
760int main(int argc, char **argv)
761{
762  struct vsl_iovec iov;
763  return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
764}
765EOF
766if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
767  LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
768  fusion_aw="yes"
769fi
770echo "Fusion-io atomic engine       $fusion_aw"
771
772##########################################
773# libnuma probe
774libnuma="no"
775cat > $TMPC << EOF
776#include <numa.h>
777int main(int argc, char **argv)
778{
779  return numa_available();
780}
781EOF
782if compile_prog "" "-lnuma" "libnuma"; then
783  libnuma="yes"
784  LIBS="-lnuma $LIBS"
785fi
786echo "libnuma                       $libnuma"
787
788##########################################
789# strsep() probe
790strsep="no"
791cat > $TMPC << EOF
792#include <string.h>
793int main(int argc, char **argv)
794{
795  strsep(NULL, NULL);
796  return 0;
797}
798EOF
799if compile_prog "" "" "strsep"; then
800  strsep="yes"
801fi
802echo "strsep                        $strsep"
803
804##########################################
805# getopt_long_only() probe
806getopt_long_only="no"
807cat > $TMPC << EOF
808#include <unistd.h>
809#include <stdio.h>
810int main(int argc, char **argv)
811{
812  int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
813  return c;
814}
815EOF
816if compile_prog "" "" "getopt_long_only"; then
817  getopt_long_only="yes"
818fi
819echo "getopt_long_only()            $getopt_long_only"
820
821##########################################
822# inet_aton() probe
823inet_aton="no"
824cat > $TMPC << EOF
825#include <sys/socket.h>
826#include <arpa/inet.h>
827#include <stdio.h>
828int main(int argc, char **argv)
829{
830  struct in_addr in;
831  return inet_aton(NULL, &in);
832}
833EOF
834if compile_prog "" "" "inet_aton"; then
835  inet_aton="yes"
836fi
837echo "inet_aton                     $inet_aton"
838
839##########################################
840# socklen_t probe
841socklen_t="no"
842cat > $TMPC << EOF
843#include <string.h>
844#include <netinet/in.h>
845int main(int argc, char **argv)
846{
847  socklen_t len = 0;
848  return len;
849}
850EOF
851if compile_prog "" "" "socklen_t"; then
852  socklen_t="yes"
853fi
854echo "socklen_t                     $socklen_t"
855
856##########################################
857# Whether or not __thread is supported for TLS
858tls_thread="no"
859cat > $TMPC << EOF
860#include <stdio.h>
861static int __thread ret;
862int main(int argc, char **argv)
863{
864  return ret;
865}
866EOF
867if compile_prog "" "" "__thread"; then
868  tls_thread="yes"
869fi
870echo "__thread                      $tls_thread"
871
872##########################################
873# Check whether we have getrusage(RUSAGE_THREAD)
874rusage_thread="no"
875cat > $TMPC << EOF
876#include <sys/time.h>
877#include <sys/resource.h>
878int main(int argc, char **argv)
879{
880  struct rusage ru;
881  getrusage(RUSAGE_THREAD, &ru);
882  return 0;
883}
884EOF
885if compile_prog "" "" "RUSAGE_THREAD"; then
886  rusage_thread="yes"
887fi
888echo "RUSAGE_THREAD                 $rusage_thread"
889
890##########################################
891# Check whether we have SCHED_IDLE
892sched_idle="no"
893cat > $TMPC << EOF
894#include <sched.h>
895int main(int argc, char **argv)
896{
897  struct sched_param p;
898  return sched_setscheduler(0, SCHED_IDLE, &p);
899}
900EOF
901if compile_prog "" "" "SCHED_IDLE"; then
902  sched_idle="yes"
903fi
904echo "SCHED_IDLE                    $sched_idle"
905
906##########################################
907# Check whether we have TCP_NODELAY
908tcp_nodelay="no"
909cat > $TMPC << EOF
910#include <stdio.h>
911#include <sys/types.h>
912#include <sys/socket.h>
913#include <netinet/tcp.h>
914int main(int argc, char **argv)
915{
916  return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
917}
918EOF
919if compile_prog "" "" "TCP_NODELAY"; then
920  tcp_nodelay="yes"
921fi
922echo "TCP_NODELAY                   $tcp_nodelay"
923
924##########################################
925# Check whether we have RLIMIT_MEMLOCK
926rlimit_memlock="no"
927cat > $TMPC << EOF
928#include <sys/time.h>
929#include <sys/resource.h>
930int main(int argc, char **argv)
931{
932  struct rlimit rl;
933  return getrlimit(RLIMIT_MEMLOCK, &rl);
934}
935EOF
936if compile_prog "" "" "RLIMIT_MEMLOCK"; then
937  rlimit_memlock="yes"
938fi
939echo "RLIMIT_MEMLOCK                $rlimit_memlock"
940
941#############################################################################
942
943if test "$wordsize" = "64" ; then
944  output_sym "CONFIG_64BIT"
945elif test "$wordsize" = "32" ; then
946  output_sym "CONFIG_32BIT"
947else
948  fatal "Unknown wordsize!"
949fi
950if test "$bigendian" = "yes" ; then
951  output_sym "CONFIG_BIG_ENDIAN"
952else
953  output_sym "CONFIG_LITTLE_ENDIAN"
954fi
955if test "$libaio" = "yes" ; then
956  output_sym "CONFIG_LIBAIO"
957fi
958if test "$posix_aio" = "yes" ; then
959  output_sym "CONFIG_POSIXAIO"
960fi
961if test "$posix_aio_fsync" = "yes" ; then
962  output_sym "CONFIG_POSIXAIO_FSYNC"
963fi
964if test "$linux_fallocate" = "yes" ; then
965  output_sym "CONFIG_LINUX_FALLOCATE"
966fi
967if test "$posix_fallocate" = "yes" ; then
968  output_sym "CONFIG_POSIX_FALLOCATE"
969fi
970if test "$fdatasync" = "yes" ; then
971  output_sym "CONFIG_FDATASYNC"
972fi
973if test "$sync_file_range" = "yes" ; then
974  output_sym "CONFIG_SYNC_FILE_RANGE"
975fi
976if test "$sfaa" = "yes" ; then
977  output_sym "CONFIG_SFAA"
978fi
979if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
980  output_sym "CONFIG_RDMA"
981fi
982if test "$clock_gettime" = "yes" ; then
983  output_sym "CONFIG_CLOCK_GETTIME"
984fi
985if test "$clock_monotonic" = "yes" ; then
986  output_sym "CONFIG_CLOCK_MONOTONIC"
987fi
988if test "$clock_monotonic_precise" = "yes" ; then
989  output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
990fi
991if test "$gettimeofday" = "yes" ; then
992  output_sym "CONFIG_GETTIMEOFDAY"
993fi
994if test "$posix_fadvise" = "yes" ; then
995  output_sym "CONFIG_POSIX_FADVISE"
996fi
997if test "$linux_3arg_affinity" = "yes" ; then
998  output_sym "CONFIG_3ARG_AFFINITY"
999elif test "$linux_2arg_affinity" = "yes" ; then
1000  output_sym "CONFIG_2ARG_AFFINITY"
1001fi
1002if test "$strsep" = "yes" ; then
1003  output_sym "CONFIG_STRSEP"
1004fi
1005if test "$getopt_long_only" = "yes" ; then
1006  output_sym "CONFIG_GETOPT_LONG_ONLY"
1007fi
1008if test "$inet_aton" = "yes" ; then
1009  output_sym "CONFIG_INET_ATON"
1010fi
1011if test "$socklen_t" = "yes" ; then
1012  output_sym "CONFIG_SOCKLEN_T"
1013fi
1014if test "$ext4_me" = "yes" ; then
1015  output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
1016fi
1017if test "$linux_splice" = "yes" ; then
1018  output_sym "CONFIG_LINUX_SPLICE"
1019fi
1020if test "$guasi" = "yes" ; then
1021  output_sym "CONFIG_GUASI"
1022fi
1023if test "$fusion_aw" = "yes" ; then
1024  output_sym "CONFIG_FUSION_AW"
1025fi
1026if test "$libnuma" = "yes" ; then
1027  output_sym "CONFIG_LIBNUMA"
1028fi
1029if test "$solaris_aio" = "yes" ; then
1030  output_sym "CONFIG_SOLARISAIO"
1031fi
1032if test "$tls_thread" = "yes" ; then
1033  output_sym "CONFIG_TLS_THREAD"
1034fi
1035if test "$rusage_thread" = "yes" ; then
1036  output_sym "CONFIG_RUSAGE_THREAD"
1037fi
1038if test "$sched_idle" = "yes" ; then
1039  output_sym "CONFIG_SCHED_IDLE"
1040fi
1041#if test "$tcp_nodelay" = "yes" ; then
1042  #output_sym "CONFIG_TCP_NODELAY"
1043#fi
1044if test "$rlimit_memlock" = "yes" ; then
1045  output_sym "CONFIG_RLIMIT_MEMLOCK"
1046fi
1047
1048echo "LIBS+=$LIBS" >> $config_host_mak
1049echo "CC=$cc" >> $config_host_mak
1050echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak
1051