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