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