configure: remember to initialize 'strndup' to "no"
[fio.git] / configure
... / ...
CommitLineData
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# Print result for each configuration test
41print_config() {
42 printf "%-30s%s\n" "$1" "$2"
43}
44
45# Default CFLAGS
46CFLAGS="-D_GNU_SOURCE -include config-host.h"
47BUILD_CFLAGS=""
48
49# Print a helpful header at the top of config.log
50echo "# FIO configure log $(date)" >> config.log
51printf "# Configured with:" >> config.log
52printf " '%s'" "$0" "$@" >> config.log
53echo >> config.log
54echo "#" >> config.log
55
56# Print configure header at the top of $config_host_h
57echo "/*" > $config_host_h
58echo " * Automatically generated by configure - do not modify" >> $config_host_h
59printf " * Configured with:" >> $config_host_h
60printf " * '%s'" "$0" "$@" >> $config_host_h
61echo "" >> $config_host_h
62echo " */" >> $config_host_h
63
64do_cc() {
65 # Run the compiler, capturing its output to the log.
66 echo $cc "$@" >> config.log
67 $cc "$@" >> config.log 2>&1 || return $?
68 # Test passed. If this is an --enable-werror build, rerun
69 # the test with -Werror and bail out if it fails. This
70 # makes warning-generating-errors in configure test code
71 # obvious to developers.
72 if test "$werror" != "yes"; then
73 return 0
74 fi
75 # Don't bother rerunning the compile if we were already using -Werror
76 case "$*" in
77 *-Werror*)
78 return 0
79 ;;
80 esac
81 echo $cc -Werror "$@" >> config.log
82 $cc -Werror "$@" >> config.log 2>&1 && return $?
83 echo "ERROR: configure test passed without -Werror but failed with -Werror."
84 echo "This is probably a bug in the configure script. The failing command"
85 echo "will be at the bottom of config.log."
86 fatal "You can run configure with --disable-werror to bypass this check."
87}
88
89compile_object() {
90 do_cc $CFLAGS -c -o $TMPO $TMPC
91}
92
93compile_prog() {
94 local_cflags="$1"
95 local_ldflags="$2 $LIBS"
96 echo "Compiling test case $3" >> config.log
97 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
98}
99
100feature_not_found() {
101 feature=$1
102 packages=$2
103
104 echo "ERROR"
105 echo "ERROR: User requested feature $feature"
106 if test ! -z "$packages" ; then
107 echo "ERROR: That feature needs $packages installed"
108 fi
109 echo "ERROR: configure was not able to find it"
110 fatal "ERROR"
111}
112
113has() {
114 type "$1" >/dev/null 2>&1
115}
116
117check_define() {
118 cat > $TMPC <<EOF
119#if !defined($1)
120#error $1 not defined
121#endif
122int main(void)
123{
124 return 0;
125}
126EOF
127 compile_object
128}
129
130output_sym() {
131 echo "$1=y" >> $config_host_mak
132 echo "#define $1" >> $config_host_h
133}
134
135targetos=""
136cpu=""
137
138# default options
139show_help="no"
140exit_val=0
141gfio_check="no"
142libhdfs="no"
143pmemblk="no"
144devdax="no"
145disable_lex=""
146disable_pmem="no"
147prefix=/usr/local
148
149# parse options
150for opt do
151 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
152 case "$opt" in
153 --prefix=*) prefix="$optarg"
154 ;;
155 --cpu=*) cpu="$optarg"
156 ;;
157 # esx is cross compiled and cannot be detect through simple uname calls
158 --esx)
159 esx="yes"
160 ;;
161 --cc=*) CC="$optarg"
162 ;;
163 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
164 ;;
165 --build-32bit-win) build_32bit_win="yes"
166 ;;
167 --build-static) build_static="yes"
168 ;;
169 --enable-gfio) gfio_check="yes"
170 ;;
171 --disable-numa) disable_numa="yes"
172 ;;
173 --disable-rdma) disable_rdma="yes"
174 ;;
175 --disable-rbd) disable_rbd="yes"
176 ;;
177 --disable-rbd-blkin) disable_rbd_blkin="yes"
178 ;;
179 --disable-gfapi) disable_gfapi="yes"
180 ;;
181 --enable-libhdfs) libhdfs="yes"
182 ;;
183 --disable-lex) disable_lex="yes"
184 ;;
185 --enable-lex) disable_lex="no"
186 ;;
187 --disable-shm) no_shm="yes"
188 ;;
189 --disable-optimizations) disable_opt="yes"
190 ;;
191 --disable-pmem) disable_pmem="yes"
192 ;;
193 --enable-cuda) enable_cuda="yes"
194 ;;
195 --help)
196 show_help="yes"
197 ;;
198 *)
199 echo "Bad option $opt"
200 show_help="yes"
201 exit_val=1
202 esac
203done
204
205if test "$show_help" = "yes" ; then
206 echo "--prefix= Use this directory as installation prefix"
207 echo "--cpu= Specify target CPU if auto-detect fails"
208 echo "--cc= Specify compiler to use"
209 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
210 echo "--build-32bit-win Enable 32-bit build on Windows"
211 echo "--build-static Build a static fio"
212 echo "--esx Configure build options for esx"
213 echo "--enable-gfio Enable building of gtk gfio"
214 echo "--disable-numa Disable libnuma even if found"
215 echo "--disable-rdma Disable RDMA support even if found"
216 echo "--disable-gfapi Disable gfapi"
217 echo "--enable-libhdfs Enable hdfs support"
218 echo "--disable-lex Disable use of lex/yacc for math"
219 echo "--disable-pmem Disable pmem based engines even if found"
220 echo "--enable-lex Enable use of lex/yacc for math"
221 echo "--disable-shm Disable SHM support"
222 echo "--disable-optimizations Don't enable compiler optimizations"
223 echo "--enable-cuda Enable GPUDirect RDMA support"
224 exit $exit_val
225fi
226
227cross_prefix=${cross_prefix-${CROSS_COMPILE}}
228cc="${CC-${cross_prefix}gcc}"
229
230if check_define __ANDROID__ ; then
231 targetos="Android"
232elif check_define __linux__ ; then
233 targetos="Linux"
234elif check_define __OpenBSD__ ; then
235 targetos='OpenBSD'
236elif check_define __sun__ ; then
237 targetos='SunOS'
238 CFLAGS="$CFLAGS -D_REENTRANT"
239elif check_define _WIN32 ; then
240 targetos='CYGWIN'
241else
242 targetos=`uname -s`
243fi
244
245echo "# Automatically generated by configure - do not modify" > $config_host_mak
246printf "# Configured with:" >> $config_host_mak
247printf " '%s'" "$0" "$@" >> $config_host_mak
248echo >> $config_host_mak
249echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
250
251if test "$no_shm" = "yes" ; then
252 output_sym "CONFIG_NO_SHM"
253fi
254
255if test "$disable_opt" = "yes" ; then
256 output_sym "CONFIG_FIO_NO_OPT"
257fi
258
259# Some host OSes need non-standard checks for which CPU to use.
260# Note that these checks are broken for cross-compilation: if you're
261# cross-compiling to one of these OSes then you'll need to specify
262# the correct CPU with the --cpu option.
263case $targetos in
264AIX|OpenBSD)
265 # Unless explicitly enabled, turn off lex.
266 # OpenBSD will hit syntax error when enabled.
267 if test -z "$disable_lex" ; then
268 disable_lex="yes"
269 else
270 force_no_lex_o="yes"
271 fi
272 ;;
273Darwin)
274 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
275 # we can run 64-bit userspace code.
276 # If the user didn't specify a CPU explicitly and the kernel says this is
277 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
278 # detection code.
279 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
280 cpu="x86_64"
281 fi
282 # Error at compile time linking of weak/partial symbols if possible...
283cat > $TMPC <<EOF
284int main(void)
285{
286 return 0;
287}
288EOF
289 if compile_prog "" "-Wl,-no_weak_imports" "disable weak symbols"; then
290 echo "Disabling weak symbols"
291 LDFLAGS="$LDFLAGS -Wl,-no_weak_imports"
292 fi
293 ;;
294SunOS)
295 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
296 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
297 cpu="x86_64"
298 fi
299 LIBS="-lnsl -lsocket"
300 ;;
301CYGWIN*)
302 # We still force some options, so keep this message here.
303 echo "Forcing some known good options on Windows"
304 if test -z "$CC" ; then
305 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
306 CC="i686-w64-mingw32-gcc"
307 if test -e "../zlib/contrib/vstudio/vc14/x86/ZlibStatReleaseWithoutAsm/zlibstat.lib"; then
308 echo "Building with zlib support"
309 output_sym "CONFIG_ZLIB"
310 echo "LIBS=../zlib/contrib/vstudio/vc14/x86/ZlibStatReleaseWithoutAsm/zlibstat.lib" >> $config_host_mak
311 fi
312 else
313 CC="x86_64-w64-mingw32-gcc"
314 if test -e "../zlib/contrib/vstudio/vc14/x64/ZlibStatReleaseWithoutAsm/zlibstat.lib"; then
315 echo "Building with zlib support"
316 output_sym "CONFIG_ZLIB"
317 echo "LIBS=../zlib/contrib/vstudio/vc14/x64/ZlibStatReleaseWithoutAsm/zlibstat.lib" >> $config_host_mak
318 fi
319 fi
320 fi
321 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
322 output_sym "CONFIG_32BIT"
323 else
324 output_sym "CONFIG_64BIT_LLP64"
325 fi
326 # We need this to be output_sym'd here because this is Windows specific.
327 # The regular configure path never sets this config.
328 output_sym "CONFIG_WINDOWSAIO"
329 # We now take the regular configuration path without having exit 0 here.
330 # Flags below are still necessary mostly for MinGW.
331 socklen_t="yes"
332 sfaa="yes"
333 rusage_thread="yes"
334 fdatasync="yes"
335 clock_gettime="yes" # clock_monotonic probe has dependency on this
336 clock_monotonic="yes"
337 gettimeofday="yes"
338 sched_idle="yes"
339 tcp_nodelay="yes"
340 tls_thread="yes"
341 static_assert="yes"
342 ipv6="yes"
343 echo "CC=$CC" >> $config_host_mak
344 echo "BUILD_CFLAGS=$CFLAGS -I../zlib -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
345 ;;
346esac
347
348if test ! -z "$cpu" ; then
349 # command line argument
350 :
351elif check_define __i386__ ; then
352 cpu="i386"
353elif check_define __x86_64__ ; then
354 cpu="x86_64"
355elif check_define __sparc__ ; then
356 if check_define __arch64__ ; then
357 cpu="sparc64"
358 else
359 cpu="sparc"
360 fi
361elif check_define _ARCH_PPC ; then
362 if check_define _ARCH_PPC64 ; then
363 cpu="ppc64"
364 else
365 cpu="ppc"
366 fi
367elif check_define __mips__ ; then
368 cpu="mips"
369elif check_define __ia64__ ; then
370 cpu="ia64"
371elif check_define __s390__ ; then
372 if check_define __s390x__ ; then
373 cpu="s390x"
374 else
375 cpu="s390"
376 fi
377elif check_define __arm__ ; then
378 cpu="arm"
379elif check_define __aarch64__ ; then
380 cpu="aarch64"
381elif check_define __hppa__ ; then
382 cpu="hppa"
383else
384 cpu=`uname -m`
385fi
386
387# Normalise host CPU name and set ARCH.
388case "$cpu" in
389 ia64|ppc|ppc64|s390|s390x|sparc64)
390 cpu="$cpu"
391 ;;
392 i386|i486|i586|i686|i86pc|BePC)
393 cpu="x86"
394 ;;
395 x86_64|amd64)
396 cpu="x86_64"
397 ;;
398 armv*b|armv*l|arm)
399 cpu="arm"
400 ;;
401 aarch64)
402 cpu="arm64"
403 ;;
404 hppa|parisc|parisc64)
405 cpu="hppa"
406 ;;
407 mips*)
408 cpu="mips"
409 ;;
410 sparc|sun4[cdmuv])
411 cpu="sparc"
412 ;;
413 *)
414 echo "Unknown CPU"
415 ;;
416esac
417
418if test -z "$CC" ; then
419 if test "$targetos" = "FreeBSD"; then
420 if has clang; then
421 CC=clang
422 else
423 CC=gcc
424 fi
425 fi
426fi
427
428cc="${CC-${cross_prefix}gcc}"
429
430##########################################
431# check cross compile
432
433if test "$cross_compile" != "yes" ; then
434 cross_compile="no"
435fi
436cat > $TMPC <<EOF
437int main(void)
438{
439 return 0;
440}
441EOF
442if compile_prog "" "" "cross"; then
443 $TMPE 2>/dev/null || cross_compile="yes"
444else
445 fatal "compile test failed"
446fi
447
448##########################################
449# check endianness
450if test "$bigendian" != "yes" ; then
451 bigendian="no"
452fi
453if test "$cross_compile" = "no" ; then
454 cat > $TMPC <<EOF
455#include <inttypes.h>
456int main(void)
457{
458 volatile uint32_t i=0x01234567;
459 return (*((uint8_t*)(&i))) == 0x67;
460}
461EOF
462 if compile_prog "" "" "endian"; then
463 $TMPE && bigendian="yes"
464 fi
465else
466 # If we're cross compiling, try our best to work it out and rely on the
467 # run-time check to fail if we get it wrong.
468 cat > $TMPC <<EOF
469#include <endian.h>
470int main(void)
471{
472#if __BYTE_ORDER != __BIG_ENDIAN
473# error "Unknown endianness"
474#endif
475}
476EOF
477 compile_prog "" "" "endian" && bigendian="yes"
478 check_define "__ARMEB__" && bigendian="yes"
479 check_define "__MIPSEB__" && bigendian="yes"
480fi
481
482
483print_config "Operating system" "$targetos"
484print_config "CPU" "$cpu"
485print_config "Big endian" "$bigendian"
486print_config "Compiler" "$cc"
487print_config "Cross compile" "$cross_compile"
488echo
489
490##########################################
491# See if we need to build a static build
492if test "$build_static" = "yes" ; then
493 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
494 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
495else
496 build_static="no"
497fi
498print_config "Static build" "$build_static"
499
500##########################################
501# check for wordsize
502wordsize="0"
503cat > $TMPC <<EOF
504#include <limits.h>
505#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
506int main(void)
507{
508 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
509 return 0;
510}
511EOF
512if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
513 wordsize="32"
514elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
515 wordsize="64"
516else
517 fatal "Unknown wordsize"
518fi
519print_config "Wordsize" "$wordsize"
520
521##########################################
522# zlib probe
523if test "$zlib" != "yes" ; then
524 zlib="no"
525fi
526cat > $TMPC <<EOF
527#include <zlib.h>
528int main(void)
529{
530 z_stream stream;
531 if (inflateInit(&stream) != Z_OK)
532 return 1;
533 return 0;
534}
535EOF
536if compile_prog "" "-lz" "zlib" ; then
537 zlib=yes
538 LIBS="-lz $LIBS"
539fi
540print_config "zlib" "$zlib"
541
542##########################################
543# linux-aio probe
544if test "$libaio" != "yes" ; then
545 libaio="no"
546fi
547if test "$esx" != "yes" ; then
548 cat > $TMPC <<EOF
549#include <libaio.h>
550#include <stddef.h>
551int main(void)
552{
553 io_setup(0, NULL);
554 return 0;
555}
556EOF
557 if compile_prog "" "-laio" "libaio" ; then
558 libaio=yes
559 LIBS="-laio $LIBS"
560 else
561 if test "$libaio" = "yes" ; then
562 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
563 fi
564 libaio=no
565 fi
566fi
567print_config "Linux AIO support" "$libaio"
568
569##########################################
570# posix aio probe
571if test "$posix_aio" != "yes" ; then
572 posix_aio="no"
573fi
574if test "$posix_aio_lrt" != "yes" ; then
575 posix_aio_lrt="no"
576fi
577cat > $TMPC <<EOF
578#include <aio.h>
579int main(void)
580{
581 struct aiocb cb;
582 aio_read(&cb);
583 return 0;
584}
585EOF
586if compile_prog "" "" "posixaio" ; then
587 posix_aio="yes"
588elif compile_prog "" "-lrt" "posixaio"; then
589 posix_aio="yes"
590 posix_aio_lrt="yes"
591 LIBS="-lrt $LIBS"
592fi
593print_config "POSIX AIO support" "$posix_aio"
594print_config "POSIX AIO support needs -lrt" "$posix_aio_lrt"
595
596##########################################
597# posix aio fsync probe
598if test "$posix_aio_fsync" != "yes" ; then
599 posix_aio_fsync="no"
600fi
601if test "$posix_aio" = "yes" ; then
602 cat > $TMPC <<EOF
603#include <fcntl.h>
604#include <aio.h>
605int main(void)
606{
607 struct aiocb cb;
608 return aio_fsync(O_SYNC, &cb);
609 return 0;
610}
611EOF
612 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
613 posix_aio_fsync=yes
614 fi
615fi
616print_config "POSIX AIO fsync" "$posix_aio_fsync"
617
618##########################################
619# POSIX pshared attribute probe
620if test "$posix_pshared" != "yes" ; then
621 posix_pshared="no"
622fi
623cat > $TMPC <<EOF
624#include <unistd.h>
625int main(void)
626{
627#if defined(_POSIX_THREAD_PROCESS_SHARED) && ((_POSIX_THREAD_PROCESS_SHARED + 0) > 0)
628# if defined(__CYGWIN__)
629# error "_POSIX_THREAD_PROCESS_SHARED is buggy on Cygwin"
630# elif defined(__APPLE__)
631# include <AvailabilityMacros.h>
632# include <TargetConditionals.h>
633# if TARGET_OS_MAC && MAC_OS_X_VERSION_MIN_REQUIRED < 1070
634# error "_POSIX_THREAD_PROCESS_SHARED is buggy/unsupported prior to OSX 10.7"
635# endif
636# endif
637#else
638# error "_POSIX_THREAD_PROCESS_SHARED is unsupported"
639#endif
640 return 0;
641}
642EOF
643if compile_prog "" "$LIBS" "posix_pshared" ; then
644 posix_pshared=yes
645fi
646print_config "POSIX pshared support" "$posix_pshared"
647
648##########################################
649# solaris aio probe
650if test "$solaris_aio" != "yes" ; then
651 solaris_aio="no"
652fi
653cat > $TMPC <<EOF
654#include <sys/types.h>
655#include <sys/asynch.h>
656#include <unistd.h>
657int main(void)
658{
659 aio_result_t res;
660 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
661 return 0;
662}
663EOF
664if compile_prog "" "-laio" "solarisaio" ; then
665 solaris_aio=yes
666 LIBS="-laio $LIBS"
667fi
668print_config "Solaris AIO support" "$solaris_aio"
669
670##########################################
671# __sync_fetch_and_add test
672if test "$sfaa" != "yes" ; then
673 sfaa="no"
674fi
675cat > $TMPC << EOF
676#include <inttypes.h>
677static int sfaa(uint64_t *ptr)
678{
679 return __sync_fetch_and_add(ptr, 0);
680}
681
682int main(int argc, char **argv)
683{
684 uint64_t val = 42;
685 sfaa(&val);
686 return val;
687}
688EOF
689if compile_prog "" "" "__sync_fetch_and_add()" ; then
690 sfaa="yes"
691fi
692print_config "__sync_fetch_and_add" "$sfaa"
693
694##########################################
695# libverbs probe
696if test "$libverbs" != "yes" ; then
697 libverbs="no"
698fi
699cat > $TMPC << EOF
700#include <stdio.h>
701#include <infiniband/arch.h>
702int main(int argc, char **argv)
703{
704 struct ibv_pd *pd = ibv_alloc_pd(NULL);
705 return 0;
706}
707EOF
708if test "$disable_rdma" != "yes" && compile_prog "" "-libverbs" "libverbs" ; then
709 libverbs="yes"
710 LIBS="-libverbs $LIBS"
711fi
712print_config "libverbs" "$libverbs"
713
714##########################################
715# rdmacm probe
716if test "$rdmacm" != "yes" ; then
717 rdmacm="no"
718fi
719cat > $TMPC << EOF
720#include <stdio.h>
721#include <rdma/rdma_cma.h>
722int main(int argc, char **argv)
723{
724 rdma_destroy_qp(NULL);
725 return 0;
726}
727EOF
728if test "$disable_rdma" != "yes" && compile_prog "" "-lrdmacm" "rdma"; then
729 rdmacm="yes"
730 LIBS="-lrdmacm $LIBS"
731fi
732print_config "rdmacm" "$rdmacm"
733
734##########################################
735# Linux fallocate probe
736if test "$linux_fallocate" != "yes" ; then
737 linux_fallocate="no"
738fi
739cat > $TMPC << EOF
740#include <stdio.h>
741#include <fcntl.h>
742#include <linux/falloc.h>
743int main(int argc, char **argv)
744{
745 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
746 return r;
747}
748EOF
749if compile_prog "" "" "linux_fallocate"; then
750 linux_fallocate="yes"
751fi
752print_config "Linux fallocate" "$linux_fallocate"
753
754##########################################
755# POSIX fadvise probe
756if test "$posix_fadvise" != "yes" ; then
757 posix_fadvise="no"
758fi
759cat > $TMPC << EOF
760#include <stdio.h>
761#include <fcntl.h>
762int main(int argc, char **argv)
763{
764 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
765 return r;
766}
767EOF
768if compile_prog "" "" "posix_fadvise"; then
769 posix_fadvise="yes"
770fi
771print_config "POSIX fadvise" "$posix_fadvise"
772
773##########################################
774# POSIX fallocate probe
775if test "$posix_fallocate" != "yes" ; then
776 posix_fallocate="no"
777fi
778cat > $TMPC << EOF
779#include <stdio.h>
780#include <fcntl.h>
781int main(int argc, char **argv)
782{
783 int r = posix_fallocate(0, 0, 1024);
784 return r;
785}
786EOF
787if compile_prog "" "" "posix_fallocate"; then
788 posix_fallocate="yes"
789fi
790print_config "POSIX fallocate" "$posix_fallocate"
791
792##########################################
793# sched_set/getaffinity 2 or 3 argument test
794if test "$linux_2arg_affinity" != "yes" ; then
795 linux_2arg_affinity="no"
796fi
797if test "$linux_3arg_affinity" != "yes" ; then
798 linux_3arg_affinity="no"
799fi
800cat > $TMPC << EOF
801#include <sched.h>
802int main(int argc, char **argv)
803{
804 cpu_set_t mask;
805 return sched_setaffinity(0, sizeof(mask), &mask);
806}
807EOF
808if compile_prog "" "" "sched_setaffinity(,,)"; then
809 linux_3arg_affinity="yes"
810else
811 cat > $TMPC << EOF
812#include <sched.h>
813int main(int argc, char **argv)
814{
815 cpu_set_t mask;
816 return sched_setaffinity(0, &mask);
817}
818EOF
819 if compile_prog "" "" "sched_setaffinity(,)"; then
820 linux_2arg_affinity="yes"
821 fi
822fi
823print_config "sched_setaffinity(3 arg)" "$linux_3arg_affinity"
824print_config "sched_setaffinity(2 arg)" "$linux_2arg_affinity"
825
826##########################################
827# clock_gettime probe
828if test "$clock_gettime" != "yes" ; then
829 clock_gettime="no"
830fi
831cat > $TMPC << EOF
832#include <stdio.h>
833#include <time.h>
834int main(int argc, char **argv)
835{
836 return clock_gettime(0, NULL);
837}
838EOF
839if compile_prog "" "" "clock_gettime"; then
840 clock_gettime="yes"
841elif compile_prog "" "-lrt" "clock_gettime"; then
842 clock_gettime="yes"
843 LIBS="-lrt $LIBS"
844fi
845print_config "clock_gettime" "$clock_gettime"
846
847##########################################
848# CLOCK_MONOTONIC probe
849if test "$clock_monotonic" != "yes" ; then
850 clock_monotonic="no"
851fi
852if test "$clock_gettime" = "yes" ; then
853 cat > $TMPC << EOF
854#include <stdio.h>
855#include <time.h>
856int main(int argc, char **argv)
857{
858 return clock_gettime(CLOCK_MONOTONIC, NULL);
859}
860EOF
861 if compile_prog "" "$LIBS" "clock monotonic"; then
862 clock_monotonic="yes"
863 fi
864fi
865print_config "CLOCK_MONOTONIC" "$clock_monotonic"
866
867##########################################
868# CLOCK_MONOTONIC_RAW probe
869if test "$clock_monotonic_raw" != "yes" ; then
870 clock_monotonic_raw="no"
871fi
872if test "$clock_gettime" = "yes" ; then
873 cat > $TMPC << EOF
874#include <stdio.h>
875#include <time.h>
876int main(int argc, char **argv)
877{
878 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
879}
880EOF
881 if compile_prog "" "$LIBS" "clock monotonic"; then
882 clock_monotonic_raw="yes"
883 fi
884fi
885print_config "CLOCK_MONOTONIC_RAW" "$clock_monotonic_raw"
886
887##########################################
888# CLOCK_MONOTONIC_PRECISE probe
889if test "$clock_monotonic_precise" != "yes" ; then
890 clock_monotonic_precise="no"
891fi
892if test "$clock_gettime" = "yes" ; then
893 cat > $TMPC << EOF
894#include <stdio.h>
895#include <time.h>
896int main(int argc, char **argv)
897{
898 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
899}
900EOF
901 if compile_prog "" "$LIBS" "clock monotonic precise"; then
902 clock_monotonic_precise="yes"
903 fi
904fi
905print_config "CLOCK_MONOTONIC_PRECISE" "$clock_monotonic_precise"
906
907##########################################
908# clockid_t probe
909if test "$clockid_t" != "yes" ; then
910 clockid_t="no"
911fi
912cat > $TMPC << EOF
913#include <time.h>
914#include <string.h>
915int main(int argc, char **argv)
916{
917 volatile clockid_t cid;
918 memset((void*)&cid, 0, sizeof(cid));
919 return 0;
920}
921EOF
922if compile_prog "" "$LIBS" "clockid_t"; then
923 clockid_t="yes"
924fi
925print_config "clockid_t" "$clockid_t"
926
927##########################################
928# gettimeofday() probe
929if test "$gettimeofday" != "yes" ; then
930 gettimeofday="no"
931fi
932cat > $TMPC << EOF
933#include <sys/time.h>
934#include <stdio.h>
935int main(int argc, char **argv)
936{
937 struct timeval tv;
938 return gettimeofday(&tv, NULL);
939}
940EOF
941if compile_prog "" "" "gettimeofday"; then
942 gettimeofday="yes"
943fi
944print_config "gettimeofday" "$gettimeofday"
945
946##########################################
947# fdatasync() probe
948if test "$fdatasync" != "yes" ; then
949 fdatasync="no"
950fi
951cat > $TMPC << EOF
952#include <stdio.h>
953#include <unistd.h>
954int main(int argc, char **argv)
955{
956 return fdatasync(0);
957}
958EOF
959if compile_prog "" "" "fdatasync"; then
960 fdatasync="yes"
961fi
962print_config "fdatasync" "$fdatasync"
963
964##########################################
965# sync_file_range() probe
966if test "$sync_file_range" != "yes" ; then
967 sync_file_range="no"
968fi
969cat > $TMPC << EOF
970#include <stdio.h>
971#include <unistd.h>
972#include <fcntl.h>
973#include <linux/fs.h>
974int main(int argc, char **argv)
975{
976 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
977 SYNC_FILE_RANGE_WAIT_AFTER;
978 return sync_file_range(0, 0, 0, flags);
979}
980EOF
981if compile_prog "" "" "sync_file_range"; then
982 sync_file_range="yes"
983fi
984print_config "sync_file_range" "$sync_file_range"
985
986##########################################
987# ext4 move extent probe
988if test "$ext4_me" != "yes" ; then
989 ext4_me="no"
990fi
991cat > $TMPC << EOF
992#include <fcntl.h>
993#include <sys/ioctl.h>
994int main(int argc, char **argv)
995{
996 struct move_extent me;
997 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
998}
999EOF
1000if compile_prog "" "" "ext4 move extent" ; then
1001 ext4_me="yes"
1002elif test $targetos = "Linux" ; then
1003 # On Linux, just default to it on and let it error at runtime if we really
1004 # don't have it. None of my updated systems have it defined, but it does
1005 # work. Takes a while to bubble back.
1006 ext4_me="yes"
1007fi
1008print_config "EXT4 move extent" "$ext4_me"
1009
1010##########################################
1011# splice probe
1012if test "$linux_splice" != "yes" ; then
1013 linux_splice="no"
1014fi
1015cat > $TMPC << EOF
1016#include <stdio.h>
1017#include <fcntl.h>
1018int main(int argc, char **argv)
1019{
1020 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
1021}
1022EOF
1023if compile_prog "" "" "linux splice"; then
1024 linux_splice="yes"
1025fi
1026print_config "Linux splice(2)" "$linux_splice"
1027
1028##########################################
1029# GUASI probe
1030if test "$guasi" != "yes" ; then
1031 guasi="no"
1032fi
1033cat > $TMPC << EOF
1034#include <guasi.h>
1035#include <guasi_syscalls.h>
1036int main(int argc, char **argv)
1037{
1038 guasi_t ctx = guasi_create(0, 0, 0);
1039 return 0;
1040}
1041EOF
1042if compile_prog "" "" "guasi"; then
1043 guasi="yes"
1044fi
1045print_config "GUASI" "$guasi"
1046
1047##########################################
1048# fusion-aw probe
1049if test "$fusion_aw" != "yes" ; then
1050 fusion_aw="no"
1051fi
1052cat > $TMPC << EOF
1053#include <nvm/nvm_primitives.h>
1054int main(int argc, char **argv)
1055{
1056 nvm_version_t ver_info;
1057 nvm_handle_t handle;
1058
1059 handle = nvm_get_handle(0, &ver_info);
1060 return nvm_atomic_write(handle, 0, 0, 0);
1061}
1062EOF
1063if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
1064 LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
1065 fusion_aw="yes"
1066fi
1067print_config "Fusion-io atomic engine" "$fusion_aw"
1068
1069##########################################
1070# libnuma probe
1071if test "$libnuma" != "yes" ; then
1072 libnuma="no"
1073fi
1074cat > $TMPC << EOF
1075#include <numa.h>
1076int main(int argc, char **argv)
1077{
1078 return numa_available();
1079}
1080EOF
1081if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
1082 libnuma="yes"
1083 LIBS="-lnuma $LIBS"
1084fi
1085print_config "libnuma" "$libnuma"
1086
1087##########################################
1088# libnuma 2.x version API, initialize with "no" only if $libnuma is set to "yes"
1089if test "$libnuma" = "yes" ; then
1090libnuma_v2="no"
1091cat > $TMPC << EOF
1092#include <numa.h>
1093int main(int argc, char **argv)
1094{
1095 struct bitmask *mask = numa_parse_nodestring(NULL);
1096 return mask->size == 0;
1097}
1098EOF
1099if compile_prog "" "" "libnuma api"; then
1100 libnuma_v2="yes"
1101fi
1102print_config "libnuma v2" "$libnuma_v2"
1103fi
1104
1105##########################################
1106# strsep() probe
1107if test "$strsep" != "yes" ; then
1108 strsep="no"
1109fi
1110cat > $TMPC << EOF
1111#include <string.h>
1112int main(int argc, char **argv)
1113{
1114 static char *string = "This is a string";
1115 strsep(&string, "needle");
1116 return 0;
1117}
1118EOF
1119if compile_prog "" "" "strsep"; then
1120 strsep="yes"
1121fi
1122print_config "strsep" "$strsep"
1123
1124##########################################
1125# strcasestr() probe
1126if test "$strcasestr" != "yes" ; then
1127 strcasestr="no"
1128fi
1129cat > $TMPC << EOF
1130#include <string.h>
1131int main(int argc, char **argv)
1132{
1133 return strcasestr(argv[0], argv[1]) != NULL;
1134}
1135EOF
1136if compile_prog "" "" "strcasestr"; then
1137 strcasestr="yes"
1138fi
1139print_config "strcasestr" "$strcasestr"
1140
1141##########################################
1142# strlcat() probe
1143if test "$strlcat" != "yes" ; then
1144 strlcat="no"
1145fi
1146cat > $TMPC << EOF
1147#include <string.h>
1148int main(int argc, char **argv)
1149{
1150 static char dst[64];
1151 static char *string = "This is a string";
1152 memset(dst, 0, sizeof(dst));
1153 strlcat(dst, string, sizeof(dst));
1154 return 0;
1155}
1156EOF
1157if compile_prog "" "" "strlcat"; then
1158 strlcat="yes"
1159fi
1160print_config "strlcat" "$strlcat"
1161
1162##########################################
1163# getopt_long_only() probe
1164if test "$getopt_long_only" != "yes" ; then
1165 getopt_long_only="no"
1166fi
1167cat > $TMPC << EOF
1168#include <unistd.h>
1169#include <stdio.h>
1170#include <getopt.h>
1171int main(int argc, char **argv)
1172{
1173 int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
1174 return c;
1175}
1176EOF
1177if compile_prog "" "" "getopt_long_only"; then
1178 getopt_long_only="yes"
1179fi
1180print_config "getopt_long_only()" "$getopt_long_only"
1181
1182##########################################
1183# inet_aton() probe
1184if test "$inet_aton" != "yes" ; then
1185 inet_aton="no"
1186fi
1187cat > $TMPC << EOF
1188#include <sys/socket.h>
1189#include <arpa/inet.h>
1190#include <stdio.h>
1191int main(int argc, char **argv)
1192{
1193 struct in_addr in;
1194 return inet_aton(NULL, &in);
1195}
1196EOF
1197if compile_prog "" "" "inet_aton"; then
1198 inet_aton="yes"
1199fi
1200print_config "inet_aton" "$inet_aton"
1201
1202##########################################
1203# socklen_t probe
1204if test "$socklen_t" != "yes" ; then
1205 socklen_t="no"
1206fi
1207cat > $TMPC << EOF
1208#include <sys/socket.h>
1209int main(int argc, char **argv)
1210{
1211 socklen_t len = 0;
1212 return len;
1213}
1214EOF
1215if compile_prog "" "" "socklen_t"; then
1216 socklen_t="yes"
1217fi
1218print_config "socklen_t" "$socklen_t"
1219
1220##########################################
1221# Whether or not __thread is supported for TLS
1222if test "$tls_thread" != "yes" ; then
1223 tls_thread="no"
1224fi
1225cat > $TMPC << EOF
1226#include <stdio.h>
1227static __thread int ret;
1228int main(int argc, char **argv)
1229{
1230 return ret;
1231}
1232EOF
1233if compile_prog "" "" "__thread"; then
1234 tls_thread="yes"
1235fi
1236print_config "__thread" "$tls_thread"
1237
1238##########################################
1239# Check if we have required gtk/glib support for gfio
1240if test "$gfio" != "yes" ; then
1241 gfio="no"
1242fi
1243if test "$gfio_check" = "yes" ; then
1244 cat > $TMPC << EOF
1245#include <glib.h>
1246#include <cairo.h>
1247#include <gtk/gtk.h>
1248int main(void)
1249{
1250 gdk_threads_enter();
1251 gdk_threads_leave();
1252
1253 return GTK_CHECK_VERSION(2, 18, 0) ? 0 : 1; /* 0 on success */
1254}
1255EOF
1256GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
1257ORG_LDFLAGS=$LDFLAGS
1258LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
1259if test "$?" != "0" ; then
1260 echo "configure: gtk and gthread not found"
1261 exit 1
1262fi
1263GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
1264if test "$?" != "0" ; then
1265 echo "configure: gtk and gthread not found"
1266 exit 1
1267fi
1268if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
1269 $TMPE
1270 if test "$?" = "0" ; then
1271 gfio="yes"
1272 GFIO_LIBS="$LIBS $GTK_LIBS"
1273 CFLAGS="$CFLAGS $GTK_CFLAGS"
1274 else
1275 echo "GTK found, but need version 2.18 or higher"
1276 gfio="no"
1277 fi
1278else
1279 echo "Please install gtk and gdk libraries"
1280 gfio="no"
1281fi
1282LDFLAGS=$ORG_LDFLAGS
1283fi
1284
1285if test "$gfio_check" = "yes" ; then
1286 print_config "gtk 2.18 or higher" "$gfio"
1287fi
1288
1289##########################################
1290# Check whether we have getrusage(RUSAGE_THREAD)
1291if test "$rusage_thread" != "yes" ; then
1292 rusage_thread="no"
1293fi
1294cat > $TMPC << EOF
1295#include <sys/time.h>
1296#include <sys/resource.h>
1297int main(int argc, char **argv)
1298{
1299 struct rusage ru;
1300 getrusage(RUSAGE_THREAD, &ru);
1301 return 0;
1302}
1303EOF
1304if compile_prog "" "" "RUSAGE_THREAD"; then
1305 rusage_thread="yes"
1306fi
1307print_config "RUSAGE_THREAD" "$rusage_thread"
1308
1309##########################################
1310# Check whether we have SCHED_IDLE
1311if test "$sched_idle" != "yes" ; then
1312 sched_idle="no"
1313fi
1314cat > $TMPC << EOF
1315#include <sched.h>
1316int main(int argc, char **argv)
1317{
1318 struct sched_param p;
1319 return sched_setscheduler(0, SCHED_IDLE, &p);
1320}
1321EOF
1322if compile_prog "" "" "SCHED_IDLE"; then
1323 sched_idle="yes"
1324fi
1325print_config "SCHED_IDLE" "$sched_idle"
1326
1327##########################################
1328# Check whether we have TCP_NODELAY
1329if test "$tcp_nodelay" != "yes" ; then
1330 tcp_nodelay="no"
1331fi
1332cat > $TMPC << EOF
1333#include <stdio.h>
1334#include <sys/types.h>
1335#include <sys/socket.h>
1336#include <netinet/tcp.h>
1337int main(int argc, char **argv)
1338{
1339 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1340}
1341EOF
1342if compile_prog "" "" "TCP_NODELAY"; then
1343 tcp_nodelay="yes"
1344fi
1345print_config "TCP_NODELAY" "$tcp_nodelay"
1346
1347##########################################
1348# Check whether we have SO_SNDBUF
1349if test "$window_size" != "yes" ; then
1350 window_size="no"
1351fi
1352cat > $TMPC << EOF
1353#include <stdio.h>
1354#include <sys/types.h>
1355#include <sys/socket.h>
1356#include <netinet/tcp.h>
1357int main(int argc, char **argv)
1358{
1359 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1360 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1361}
1362EOF
1363if compile_prog "" "" "SO_SNDBUF"; then
1364 window_size="yes"
1365fi
1366print_config "Net engine window_size" "$window_size"
1367
1368##########################################
1369# Check whether we have TCP_MAXSEG
1370if test "$mss" != "yes" ; then
1371 mss="no"
1372fi
1373cat > $TMPC << EOF
1374#include <stdio.h>
1375#include <sys/types.h>
1376#include <sys/socket.h>
1377#include <netinet/tcp.h>
1378#include <arpa/inet.h>
1379#include <netinet/in.h>
1380int main(int argc, char **argv)
1381{
1382 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1383}
1384EOF
1385if compile_prog "" "" "TCP_MAXSEG"; then
1386 mss="yes"
1387fi
1388print_config "TCP_MAXSEG" "$mss"
1389
1390##########################################
1391# Check whether we have RLIMIT_MEMLOCK
1392if test "$rlimit_memlock" != "yes" ; then
1393 rlimit_memlock="no"
1394fi
1395cat > $TMPC << EOF
1396#include <sys/time.h>
1397#include <sys/resource.h>
1398int main(int argc, char **argv)
1399{
1400 struct rlimit rl;
1401 return getrlimit(RLIMIT_MEMLOCK, &rl);
1402}
1403EOF
1404if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1405 rlimit_memlock="yes"
1406fi
1407print_config "RLIMIT_MEMLOCK" "$rlimit_memlock"
1408
1409##########################################
1410# Check whether we have pwritev/preadv
1411if test "$pwritev" != "yes" ; then
1412 pwritev="no"
1413fi
1414cat > $TMPC << EOF
1415#include <stdio.h>
1416#include <sys/uio.h>
1417int main(int argc, char **argv)
1418{
1419 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1420}
1421EOF
1422if compile_prog "" "" "pwritev"; then
1423 pwritev="yes"
1424fi
1425print_config "pwritev/preadv" "$pwritev"
1426
1427##########################################
1428# Check whether we have pwritev2/preadv2
1429if test "$pwritev2" != "yes" ; then
1430 pwritev2="no"
1431fi
1432cat > $TMPC << EOF
1433#include <stdio.h>
1434#include <sys/uio.h>
1435int main(int argc, char **argv)
1436{
1437 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1438}
1439EOF
1440if compile_prog "" "" "pwritev2"; then
1441 pwritev2="yes"
1442fi
1443print_config "pwritev2/preadv2" "$pwritev2"
1444
1445##########################################
1446# Check whether we have the required functions for ipv6
1447if test "$ipv6" != "yes" ; then
1448 ipv6="no"
1449fi
1450cat > $TMPC << EOF
1451#include <sys/types.h>
1452#include <sys/socket.h>
1453#include <netinet/in.h>
1454#include <netdb.h>
1455#include <stdio.h>
1456int main(int argc, char **argv)
1457{
1458 struct addrinfo hints;
1459 struct in6_addr addr;
1460 int ret;
1461
1462 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1463 freeaddrinfo(NULL);
1464 printf("%s\n", gai_strerror(ret));
1465 addr = in6addr_any;
1466 return 0;
1467}
1468EOF
1469if compile_prog "" "" "ipv6"; then
1470 ipv6="yes"
1471fi
1472print_config "IPv6 helpers" "$ipv6"
1473
1474##########################################
1475# check for rbd
1476if test "$rbd" != "yes" ; then
1477 rbd="no"
1478fi
1479cat > $TMPC << EOF
1480#include <rbd/librbd.h>
1481
1482int main(int argc, char **argv)
1483{
1484 rados_t cluster;
1485 rados_ioctx_t io_ctx;
1486 const char pool[] = "rbd";
1487
1488 int major, minor, extra;
1489 rbd_version(&major, &minor, &extra);
1490
1491 rados_ioctx_create(cluster, pool, &io_ctx);
1492 return 0;
1493}
1494EOF
1495if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
1496 LIBS="-lrbd -lrados $LIBS"
1497 rbd="yes"
1498fi
1499print_config "Rados Block Device engine" "$rbd"
1500
1501##########################################
1502# check for rbd_poll
1503if test "$rbd_poll" != "yes" ; then
1504 rbd_poll="no"
1505fi
1506if test "$rbd" = "yes"; then
1507cat > $TMPC << EOF
1508#include <rbd/librbd.h>
1509#include <sys/eventfd.h>
1510
1511int main(int argc, char **argv)
1512{
1513 rbd_image_t image;
1514 rbd_completion_t comp;
1515
1516 int fd = eventfd(0, EFD_NONBLOCK);
1517 rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1518 rbd_poll_io_events(image, comp, 1);
1519
1520 return 0;
1521}
1522EOF
1523if compile_prog "" "-lrbd -lrados" "rbd"; then
1524 rbd_poll="yes"
1525fi
1526print_config "rbd_poll" "$rbd_poll"
1527fi
1528
1529##########################################
1530# check for rbd_invaidate_cache()
1531if test "$rbd_inval" != "yes" ; then
1532 rbd_inval="no"
1533fi
1534if test "$rbd" = "yes"; then
1535cat > $TMPC << EOF
1536#include <rbd/librbd.h>
1537
1538int main(int argc, char **argv)
1539{
1540 rbd_image_t image;
1541
1542 return rbd_invalidate_cache(image);
1543}
1544EOF
1545if compile_prog "" "-lrbd -lrados" "rbd"; then
1546 rbd_inval="yes"
1547fi
1548print_config "rbd_invalidate_cache" "$rbd_inval"
1549fi
1550
1551##########################################
1552# check for blkin
1553if test "$rbd_blkin" != "yes" ; then
1554 rbd_blkin="no"
1555fi
1556cat > $TMPC << EOF
1557#include <rbd/librbd.h>
1558#include <zipkin_c.h>
1559
1560int main(int argc, char **argv)
1561{
1562 int r;
1563 struct blkin_trace_info t_info;
1564 blkin_init_trace_info(&t_info);
1565 rbd_completion_t completion;
1566 rbd_image_t image;
1567 uint64_t off;
1568 size_t len;
1569 const char *buf;
1570 r = rbd_aio_write_traced(image, off, len, buf, completion, &t_info);
1571 return 0;
1572}
1573EOF
1574if test "$disable_rbd" != "yes" && test "$disable_rbd_blkin" != "yes" \
1575 && compile_prog "" "-lrbd -lrados -lblkin" "rbd_blkin"; then
1576 LIBS="-lblkin $LIBS"
1577 rbd_blkin="yes"
1578fi
1579print_config "rbd blkin tracing" "$rbd_blkin"
1580
1581##########################################
1582# Check whether we have setvbuf
1583if test "$setvbuf" != "yes" ; then
1584 setvbuf="no"
1585fi
1586cat > $TMPC << EOF
1587#include <stdio.h>
1588int main(int argc, char **argv)
1589{
1590 FILE *f = NULL;
1591 char buf[80];
1592 setvbuf(f, buf, _IOFBF, sizeof(buf));
1593 return 0;
1594}
1595EOF
1596if compile_prog "" "" "setvbuf"; then
1597 setvbuf="yes"
1598fi
1599print_config "setvbuf" "$setvbuf"
1600
1601##########################################
1602# check for gfapi
1603if test "$gfapi" != "yes" ; then
1604 gfapi="no"
1605fi
1606cat > $TMPC << EOF
1607#include <glusterfs/api/glfs.h>
1608
1609int main(int argc, char **argv)
1610{
1611 glfs_t *g = glfs_new("foo");
1612
1613 return 0;
1614}
1615EOF
1616if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1617 LIBS="-lgfapi -lglusterfs $LIBS"
1618 gfapi="yes"
1619fi
1620print_config "Gluster API engine" "$gfapi"
1621
1622##########################################
1623# check for gfapi fadvise support, initialize with "no" only if $gfapi is set to "yes"
1624if test "$gfapi" = "yes" ; then
1625gf_fadvise="no"
1626cat > $TMPC << EOF
1627#include <glusterfs/api/glfs.h>
1628
1629int main(int argc, char **argv)
1630{
1631 struct glfs_fd *fd;
1632 int ret = glfs_fadvise(fd, 0, 0, 1);
1633
1634 return 0;
1635}
1636EOF
1637if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1638 gf_fadvise="yes"
1639fi
1640print_config "Gluster API use fadvise" "$gf_fadvise"
1641fi
1642
1643##########################################
1644# check for gfapi trim support
1645if test "$gf_trim" != "yes" ; then
1646 gf_trim="no"
1647fi
1648if test "$gfapi" = "yes" ; then
1649cat > $TMPC << EOF
1650#include <glusterfs/api/glfs.h>
1651
1652int main(int argc, char **argv)
1653{
1654 return glfs_discard_async(NULL, 0, 0);
1655}
1656EOF
1657if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
1658 gf_trim="yes"
1659fi
1660print_config "Gluster API trim support" "$gf_trim"
1661fi
1662
1663##########################################
1664# Check if we support stckf on s390
1665if test "$s390_z196_facilities" != "yes" ; then
1666 s390_z196_facilities="no"
1667fi
1668cat > $TMPC << EOF
1669#define STFLE_BITS_Z196 45 /* various z196 facilities ... */
1670int main(int argc, char **argv)
1671{
1672 /* We want just 1 double word to be returned. */
1673 register unsigned long reg0 asm("0") = 0;
1674 unsigned long stfle_bits;
1675 asm volatile(".machine push" "\n\t"
1676 ".machine \"z9-109\"" "\n\t"
1677 "stfle %0" "\n\t"
1678 ".machine pop" "\n"
1679 : "=QS" (stfle_bits), "+d" (reg0)
1680 : : "cc");
1681
1682 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
1683 return 0;
1684 else
1685 return -1;
1686}
1687EOF
1688if compile_prog "" "" "s390_z196_facilities"; then
1689 $TMPE
1690 if [ $? -eq 0 ]; then
1691 s390_z196_facilities="yes"
1692 fi
1693fi
1694print_config "s390_z196_facilities" "$s390_z196_facilities"
1695
1696##########################################
1697# Check if we have required environment variables configured for libhdfs
1698if test "$libhdfs" = "yes" ; then
1699 hdfs_conf_error=0
1700 if test "$JAVA_HOME" = "" ; then
1701 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
1702 hdfs_conf_error=1
1703 fi
1704 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
1705 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
1706 hdfs_conf_error=1
1707 fi
1708 if test "$FIO_LIBHDFS_LIB" = "" ; then
1709 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
1710 hdfs_conf_error=1
1711 fi
1712 if test "$hdfs_conf_error" = "1" ; then
1713 exit 1
1714 fi
1715 FIO_HDFS_CPU=$cpu
1716 if test "$FIO_HDFS_CPU" = "x86_64" ; then
1717 FIO_HDFS_CPU="amd64"
1718 fi
1719fi
1720print_config "HDFS engine" "$libhdfs"
1721
1722##########################################
1723# Check whether we have MTD
1724if test "$mtd" != "yes" ; then
1725 mtd="no"
1726fi
1727cat > $TMPC << EOF
1728#include <string.h>
1729#include <mtd/mtd-user.h>
1730#include <sys/ioctl.h>
1731int main(int argc, char **argv)
1732{
1733 struct mtd_write_req ops;
1734 struct mtd_info_user info;
1735 memset(&ops, 0, sizeof(ops));
1736 info.type = MTD_MLCNANDFLASH;
1737 return ioctl(0, MEMGETINFO, &info);
1738}
1739EOF
1740if compile_prog "" "" "mtd"; then
1741 mtd="yes"
1742fi
1743print_config "MTD" "$mtd"
1744
1745##########################################
1746# Check whether we have libpmem
1747if test "$libpmem" != "yes" ; then
1748 libpmem="no"
1749fi
1750cat > $TMPC << EOF
1751#include <libpmem.h>
1752int main(int argc, char **argv)
1753{
1754 int rc;
1755 rc = pmem_is_pmem(0, 0);
1756 return 0;
1757}
1758EOF
1759if compile_prog "" "-lpmem" "libpmem"; then
1760 libpmem="yes"
1761 LIBS="-lpmem $LIBS"
1762fi
1763print_config "libpmem" "$libpmem"
1764
1765##########################################
1766# Check whether we have libpmemblk
1767# libpmem is a prerequisite
1768if test "$libpmemblk" != "yes" ; then
1769 libpmemblk="no"
1770fi
1771if test "$libpmem" = "yes"; then
1772 cat > $TMPC << EOF
1773#include <libpmemblk.h>
1774int main(int argc, char **argv)
1775{
1776 PMEMblkpool *pbp;
1777 pbp = pmemblk_open("", 0);
1778 return 0;
1779}
1780EOF
1781 if compile_prog "" "-lpmemblk" "libpmemblk"; then
1782 libpmemblk="yes"
1783 LIBS="-lpmemblk $LIBS"
1784 fi
1785fi
1786print_config "libpmemblk" "$libpmemblk"
1787
1788# Choose the ioengines
1789if test "$libpmem" = "yes" && test "$disable_pmem" = "no"; then
1790 devdax="yes"
1791 if test "$libpmemblk" = "yes"; then
1792 pmemblk="yes"
1793 fi
1794fi
1795
1796##########################################
1797# Report whether pmemblk engine is enabled
1798print_config "NVML pmemblk engine" "$pmemblk"
1799
1800##########################################
1801# Report whether dev-dax engine is enabled
1802print_config "NVML dev-dax engine" "$devdax"
1803
1804##########################################
1805# Check if we have lex/yacc available
1806yacc="no"
1807yacc_is_bison="no"
1808lex="no"
1809arith="no"
1810if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
1811if test "$targetos" != "SunOS" ; then
1812LEX=$(which lex 2> /dev/null)
1813if test -x "$LEX" ; then
1814 lex="yes"
1815fi
1816YACC=$(which bison 2> /dev/null)
1817if test -x "$YACC" ; then
1818 yacc="yes"
1819 yacc_is_bison="yes"
1820else
1821 YACC=$(which yacc 2> /dev/null)
1822 if test -x "$YACC" ; then
1823 yacc="yes"
1824 fi
1825fi
1826if test "$yacc" = "yes" && test "$lex" = "yes" ; then
1827 arith="yes"
1828fi
1829
1830if test "$arith" = "yes" ; then
1831cat > $TMPC << EOF
1832extern int yywrap(void);
1833
1834int main(int argc, char **argv)
1835{
1836 yywrap();
1837 return 0;
1838}
1839EOF
1840if compile_prog "" "-ll" "lex"; then
1841 LIBS="-ll $LIBS"
1842else
1843 arith="no"
1844fi
1845fi
1846fi
1847fi
1848
1849# Check if lex fails using -o
1850if test "$arith" = "yes" ; then
1851if test "$force_no_lex_o" = "yes" ; then
1852 lex_use_o="no"
1853else
1854$LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
1855if test "$?" = "0" ; then
1856 lex_use_o="yes"
1857else
1858 lex_use_o="no"
1859fi
1860fi
1861fi
1862
1863print_config "lex/yacc for arithmetic" "$arith"
1864
1865##########################################
1866# Check whether we have setmntent/getmntent
1867if test "$getmntent" != "yes" ; then
1868 getmntent="no"
1869fi
1870cat > $TMPC << EOF
1871#include <stdio.h>
1872#include <mntent.h>
1873int main(int argc, char **argv)
1874{
1875 FILE *mtab = setmntent(NULL, "r");
1876 struct mntent *mnt = getmntent(mtab);
1877 endmntent(mtab);
1878 return 0;
1879}
1880EOF
1881if compile_prog "" "" "getmntent"; then
1882 getmntent="yes"
1883fi
1884print_config "getmntent" "$getmntent"
1885
1886##########################################
1887# Check whether we have getmntinfo
1888# These are originally added for BSDs, but may also work
1889# on other operating systems with getmntinfo(3).
1890
1891# getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
1892# Note that NetBSD needs -Werror to catch warning as error.
1893if test "$getmntinfo" != "yes" ; then
1894 getmntinfo="no"
1895fi
1896cat > $TMPC << EOF
1897#include <stdio.h>
1898#include <sys/param.h>
1899#include <sys/mount.h>
1900int main(int argc, char **argv)
1901{
1902 struct statfs *st;
1903 return getmntinfo(&st, MNT_NOWAIT);
1904}
1905EOF
1906if compile_prog "-Werror" "" "getmntinfo"; then
1907 getmntinfo="yes"
1908fi
1909print_config "getmntinfo" "$getmntinfo"
1910
1911# getmntinfo(3) for NetBSD.
1912if test "$getmntinfo_statvfs" != "yes" ; then
1913 getmntinfo_statvfs="no"
1914fi
1915cat > $TMPC << EOF
1916#include <stdio.h>
1917#include <sys/statvfs.h>
1918int main(int argc, char **argv)
1919{
1920 struct statvfs *st;
1921 return getmntinfo(&st, MNT_NOWAIT);
1922}
1923EOF
1924# Skip the test if the one with statfs arg is detected.
1925if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
1926 getmntinfo_statvfs="yes"
1927 print_config "getmntinfo_statvfs" "$getmntinfo_statvfs"
1928fi
1929
1930##########################################
1931# Check whether we have _Static_assert
1932if test "$static_assert" != "yes" ; then
1933 static_assert="no"
1934fi
1935cat > $TMPC << EOF
1936#include <assert.h>
1937#include <stdlib.h>
1938#include <stddef.h>
1939
1940struct foo {
1941 int a, b;
1942};
1943
1944int main(int argc, char **argv)
1945{
1946 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
1947 return 0 ;
1948}
1949EOF
1950if compile_prog "" "" "static_assert"; then
1951 static_assert="yes"
1952fi
1953print_config "Static Assert" "$static_assert"
1954
1955##########################################
1956# Check whether we have bool / stdbool.h
1957if test "$have_bool" != "yes" ; then
1958 have_bool="no"
1959fi
1960cat > $TMPC << EOF
1961#include <stdbool.h>
1962int main(int argc, char **argv)
1963{
1964 bool var = true;
1965 return var != false;
1966}
1967EOF
1968if compile_prog "" "" "bool"; then
1969 have_bool="yes"
1970fi
1971print_config "bool" "$have_bool"
1972
1973##########################################
1974# Check whether we have strndup()
1975strndup="no"
1976cat > $TMPC << EOF
1977#include <string.h>
1978#include <stdlib.h>
1979int main(int argc, char **argv)
1980{
1981 char *res = strndup("test string", 8);
1982
1983 free(res);
1984 return 0;
1985}
1986EOF
1987if compile_prog "" "" "strndup"; then
1988 strndup="yes"
1989fi
1990print_config "strndup" "$strndup"
1991
1992##########################################
1993# check march=armv8-a+crc+crypto
1994if test "$march_armv8_a_crc_crypto" != "yes" ; then
1995 march_armv8_a_crc_crypto="no"
1996fi
1997if test "$cpu" = "arm64" ; then
1998 cat > $TMPC <<EOF
1999#include <sys/auxv.h>
2000#include <arm_acle.h>
2001#include <arm_neon.h>
2002
2003int main(void)
2004{
2005 return 0;
2006}
2007EOF
2008 if compile_prog "-march=armv8-a+crc+crypto" "" ""; then
2009 march_armv8_a_crc_crypto="yes"
2010 CFLAGS="$CFLAGS -march=armv8-a+crc+crypto -DARCH_HAVE_CRC_CRYPTO"
2011 fi
2012fi
2013print_config "march_armv8_a_crc_crypto" "$march_armv8_a_crc_crypto"
2014
2015##########################################
2016# cuda probe
2017if test "$cuda" != "yes" ; then
2018 cuda="no"
2019fi
2020cat > $TMPC << EOF
2021#include <cuda.h>
2022int main(int argc, char **argv)
2023{
2024 return cuInit(0);
2025}
2026EOF
2027if test "$enable_cuda" = "yes" && compile_prog "" "-lcuda" "cuda"; then
2028 cuda="yes"
2029 LIBS="-lcuda $LIBS"
2030fi
2031print_config "cuda" "$cuda"
2032
2033#############################################################################
2034
2035if test "$wordsize" = "64" ; then
2036 output_sym "CONFIG_64BIT"
2037elif test "$wordsize" = "32" ; then
2038 output_sym "CONFIG_32BIT"
2039else
2040 fatal "Unknown wordsize!"
2041fi
2042if test "$bigendian" = "yes" ; then
2043 output_sym "CONFIG_BIG_ENDIAN"
2044else
2045 output_sym "CONFIG_LITTLE_ENDIAN"
2046fi
2047if test "$zlib" = "yes" ; then
2048 output_sym "CONFIG_ZLIB"
2049fi
2050if test "$libaio" = "yes" ; then
2051 output_sym "CONFIG_LIBAIO"
2052fi
2053if test "$posix_aio" = "yes" ; then
2054 output_sym "CONFIG_POSIXAIO"
2055fi
2056if test "$posix_aio_fsync" = "yes" ; then
2057 output_sym "CONFIG_POSIXAIO_FSYNC"
2058fi
2059if test "$posix_pshared" = "yes" ; then
2060 output_sym "CONFIG_PSHARED"
2061fi
2062if test "$linux_fallocate" = "yes" ; then
2063 output_sym "CONFIG_LINUX_FALLOCATE"
2064fi
2065if test "$posix_fallocate" = "yes" ; then
2066 output_sym "CONFIG_POSIX_FALLOCATE"
2067fi
2068if test "$fdatasync" = "yes" ; then
2069 output_sym "CONFIG_FDATASYNC"
2070fi
2071if test "$sync_file_range" = "yes" ; then
2072 output_sym "CONFIG_SYNC_FILE_RANGE"
2073fi
2074if test "$sfaa" = "yes" ; then
2075 output_sym "CONFIG_SFAA"
2076fi
2077if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
2078 output_sym "CONFIG_RDMA"
2079fi
2080if test "$clock_gettime" = "yes" ; then
2081 output_sym "CONFIG_CLOCK_GETTIME"
2082fi
2083if test "$clock_monotonic" = "yes" ; then
2084 output_sym "CONFIG_CLOCK_MONOTONIC"
2085fi
2086if test "$clock_monotonic_raw" = "yes" ; then
2087 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
2088fi
2089if test "$clock_monotonic_precise" = "yes" ; then
2090 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
2091fi
2092if test "$clockid_t" = "yes"; then
2093 output_sym "CONFIG_CLOCKID_T"
2094fi
2095if test "$gettimeofday" = "yes" ; then
2096 output_sym "CONFIG_GETTIMEOFDAY"
2097fi
2098if test "$posix_fadvise" = "yes" ; then
2099 output_sym "CONFIG_POSIX_FADVISE"
2100fi
2101if test "$linux_3arg_affinity" = "yes" ; then
2102 output_sym "CONFIG_3ARG_AFFINITY"
2103elif test "$linux_2arg_affinity" = "yes" ; then
2104 output_sym "CONFIG_2ARG_AFFINITY"
2105fi
2106if test "$strsep" = "yes" ; then
2107 output_sym "CONFIG_STRSEP"
2108fi
2109if test "$strcasestr" = "yes" ; then
2110 output_sym "CONFIG_STRCASESTR"
2111fi
2112if test "$strlcat" = "yes" ; then
2113 output_sym "CONFIG_STRLCAT"
2114fi
2115if test "$getopt_long_only" = "yes" ; then
2116 output_sym "CONFIG_GETOPT_LONG_ONLY"
2117fi
2118if test "$inet_aton" = "yes" ; then
2119 output_sym "CONFIG_INET_ATON"
2120fi
2121if test "$socklen_t" = "yes" ; then
2122 output_sym "CONFIG_SOCKLEN_T"
2123fi
2124if test "$ext4_me" = "yes" ; then
2125 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
2126fi
2127if test "$linux_splice" = "yes" ; then
2128 output_sym "CONFIG_LINUX_SPLICE"
2129fi
2130if test "$guasi" = "yes" ; then
2131 output_sym "CONFIG_GUASI"
2132fi
2133if test "$fusion_aw" = "yes" ; then
2134 output_sym "CONFIG_FUSION_AW"
2135fi
2136if test "$libnuma_v2" = "yes" ; then
2137 output_sym "CONFIG_LIBNUMA"
2138fi
2139if test "$solaris_aio" = "yes" ; then
2140 output_sym "CONFIG_SOLARISAIO"
2141fi
2142if test "$tls_thread" = "yes" ; then
2143 output_sym "CONFIG_TLS_THREAD"
2144fi
2145if test "$rusage_thread" = "yes" ; then
2146 output_sym "CONFIG_RUSAGE_THREAD"
2147fi
2148if test "$gfio" = "yes" ; then
2149 output_sym "CONFIG_GFIO"
2150fi
2151if test "$esx" = "yes" ; then
2152 output_sym "CONFIG_ESX"
2153 output_sym "CONFIG_NO_SHM"
2154fi
2155if test "$sched_idle" = "yes" ; then
2156 output_sym "CONFIG_SCHED_IDLE"
2157fi
2158if test "$tcp_nodelay" = "yes" ; then
2159 output_sym "CONFIG_TCP_NODELAY"
2160fi
2161if test "$window_size" = "yes" ; then
2162 output_sym "CONFIG_NET_WINDOWSIZE"
2163fi
2164if test "$mss" = "yes" ; then
2165 output_sym "CONFIG_NET_MSS"
2166fi
2167if test "$rlimit_memlock" = "yes" ; then
2168 output_sym "CONFIG_RLIMIT_MEMLOCK"
2169fi
2170if test "$pwritev" = "yes" ; then
2171 output_sym "CONFIG_PWRITEV"
2172fi
2173if test "$pwritev2" = "yes" ; then
2174 output_sym "CONFIG_PWRITEV2"
2175fi
2176if test "$ipv6" = "yes" ; then
2177 output_sym "CONFIG_IPV6"
2178fi
2179if test "$rbd" = "yes" ; then
2180 output_sym "CONFIG_RBD"
2181fi
2182if test "$rbd_poll" = "yes" ; then
2183 output_sym "CONFIG_RBD_POLL"
2184fi
2185if test "$rbd_inval" = "yes" ; then
2186 output_sym "CONFIG_RBD_INVAL"
2187fi
2188if test "$rbd_blkin" = "yes" ; then
2189 output_sym "CONFIG_RBD_BLKIN"
2190fi
2191if test "$setvbuf" = "yes" ; then
2192 output_sym "CONFIG_SETVBUF"
2193fi
2194if test "$s390_z196_facilities" = "yes" ; then
2195 output_sym "CONFIG_S390_Z196_FACILITIES"
2196 CFLAGS="$CFLAGS -march=z9-109"
2197fi
2198if test "$gfapi" = "yes" ; then
2199 output_sym "CONFIG_GFAPI"
2200fi
2201if test "$gf_fadvise" = "yes" ; then
2202 output_sym "CONFIG_GF_FADVISE"
2203fi
2204if test "$gf_trim" = "yes" ; then
2205 output_sym "CONFIG_GF_TRIM"
2206fi
2207if test "$libhdfs" = "yes" ; then
2208 output_sym "CONFIG_LIBHDFS"
2209 echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
2210 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
2211 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
2212 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
2213 fi
2214if test "$mtd" = "yes" ; then
2215 output_sym "CONFIG_MTD"
2216fi
2217if test "$pmemblk" = "yes" ; then
2218 output_sym "CONFIG_PMEMBLK"
2219fi
2220if test "$devdax" = "yes" ; then
2221 output_sym "CONFIG_LINUX_DEVDAX"
2222fi
2223if test "$arith" = "yes" ; then
2224 output_sym "CONFIG_ARITHMETIC"
2225 if test "$yacc_is_bison" = "yes" ; then
2226 echo "YACC=$YACC -y" >> $config_host_mak
2227 else
2228 echo "YACC=$YACC" >> $config_host_mak
2229 fi
2230 if test "$lex_use_o" = "yes" ; then
2231 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
2232 fi
2233fi
2234if test "$getmntent" = "yes" ; then
2235 output_sym "CONFIG_GETMNTENT"
2236fi
2237if test "$getmntinfo" = "yes" ; then
2238 output_sym "CONFIG_GETMNTINFO"
2239fi
2240if test "$getmntinfo_statvfs" = "yes" ; then
2241 output_sym "CONFIG_GETMNTINFO_STATVFS"
2242fi
2243if test "$static_assert" = "yes" ; then
2244 output_sym "CONFIG_STATIC_ASSERT"
2245fi
2246if test "$have_bool" = "yes" ; then
2247 output_sym "CONFIG_HAVE_BOOL"
2248fi
2249if test "$strndup" = "yes" ; then
2250 output_sym "CONFIG_HAVE_STRNDUP"
2251fi
2252if test "$disable_opt" = "yes" ; then
2253 output_sym "CONFIG_DISABLE_OPTIMIZATIONS"
2254fi
2255if test "$zlib" = "no" ; then
2256 echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it."
2257fi
2258if test "$cuda" = "yes" ; then
2259 output_sym "CONFIG_CUDA"
2260fi
2261
2262echo "LIBS+=$LIBS" >> $config_host_mak
2263echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
2264echo "CFLAGS+=$CFLAGS" >> $config_host_mak
2265echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
2266echo "CC=$cc" >> $config_host_mak
2267echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
2268echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
2269
2270if [ `dirname $0` != "." -a ! -e Makefile ]; then
2271 cat > Makefile <<EOF
2272SRCDIR:=`dirname $0`
2273include \$(SRCDIR)/Makefile
2274EOF
2275fi