configure: fix check_min_lib_version() eval
[fio.git] / configure
CommitLineData
67bf9823
JA
1#!/bin/sh
2#
3# Fio configure script. Heavily influenced by the manual qemu configure
c922e0b0 4# script. Sad this is easier than autoconf and enemies.
67bf9823
JA
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"
9ee669fa 17TMPC2="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}-2.c"
67bf9823
JA
18TMPO="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.o"
19TMPE="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.exe"
20
21# NB: do not call "exit" in the trap handler; this is buggy with some shells;
22# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
9ee669fa 23trap "rm -f $TMPC $TMPC2 $TMPO $TMPE" EXIT INT QUIT TERM
67bf9823
JA
24
25rm -rf config.log
26
27config_host_mak="config-host.mak"
4feafb1e
JA
28config_host_h="config-host.h"
29
30rm -rf $config_host_mak
31rm -rf $config_host_h
67bf9823 32
d7145a78
JA
33fatal() {
34 echo $@
35 echo "Configure failed, check config.log and/or the above output"
36 rm -rf $config_host_mak
37 rm -rf $config_host_h
38 exit 1
39}
40
484b0b65
TK
41# Print result for each configuration test
42print_config() {
43 printf "%-30s%s\n" "$1" "$2"
44}
45
44404c5a 46# Default CFLAGS
4c0b3d98 47CFLAGS="-D_GNU_SOURCE -include config-host.h $CFLAGS"
b6a1e63a 48CONFIGURE_CFLAGS="-Werror-implicit-function-declaration"
af4862b3 49BUILD_CFLAGS=""
67bf9823
JA
50
51# Print a helpful header at the top of config.log
52echo "# FIO configure log $(date)" >> config.log
53printf "# Configured with:" >> config.log
54printf " '%s'" "$0" "$@" >> config.log
55echo >> config.log
56echo "#" >> config.log
57
7560fe7c
JA
58# Print configure header at the top of $config_host_h
59echo "/*" > $config_host_h
60echo " * Automatically generated by configure - do not modify" >> $config_host_h
61printf " * Configured with:" >> $config_host_h
62printf " * '%s'" "$0" "$@" >> $config_host_h
63echo "" >> $config_host_h
64echo " */" >> $config_host_h
65
67bf9823
JA
66do_cc() {
67 # Run the compiler, capturing its output to the log.
68 echo $cc "$@" >> config.log
69 $cc "$@" >> config.log 2>&1 || return $?
70 # Test passed. If this is an --enable-werror build, rerun
71 # the test with -Werror and bail out if it fails. This
72 # makes warning-generating-errors in configure test code
73 # obvious to developers.
74 if test "$werror" != "yes"; then
75 return 0
76 fi
77 # Don't bother rerunning the compile if we were already using -Werror
78 case "$*" in
79 *-Werror*)
80 return 0
81 ;;
82 esac
83 echo $cc -Werror "$@" >> config.log
84 $cc -Werror "$@" >> config.log 2>&1 && return $?
85 echo "ERROR: configure test passed without -Werror but failed with -Werror."
86 echo "This is probably a bug in the configure script. The failing command"
87 echo "will be at the bottom of config.log."
d7145a78 88 fatal "You can run configure with --disable-werror to bypass this check."
67bf9823
JA
89}
90
91compile_object() {
b6a1e63a 92 do_cc $CFLAGS $CONFIGURE_CFLAGS -c -o $TMPO $TMPC
67bf9823
JA
93}
94
95compile_prog() {
96 local_cflags="$1"
adaa46d8 97 local_ldflags="$2 $LIBS"
67bf9823 98 echo "Compiling test case $3" >> config.log
b6a1e63a 99 do_cc $CFLAGS $CONFIGURE_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
67bf9823
JA
100}
101
102feature_not_found() {
103 feature=$1
c55d728b 104 packages=$2
67bf9823
JA
105
106 echo "ERROR"
107 echo "ERROR: User requested feature $feature"
c55d728b
JA
108 if test ! -z "$packages" ; then
109 echo "ERROR: That feature needs $packages installed"
110 fi
67bf9823 111 echo "ERROR: configure was not able to find it"
d7145a78 112 fatal "ERROR"
67bf9823
JA
113}
114
115has() {
116 type "$1" >/dev/null 2>&1
117}
118
119check_define() {
120 cat > $TMPC <<EOF
121#if !defined($1)
122#error $1 not defined
123#endif
124int main(void)
125{
126 return 0;
127}
128EOF
129 compile_object
130}
131
4feafb1e
JA
132output_sym() {
133 echo "$1=y" >> $config_host_mak
134 echo "#define $1" >> $config_host_h
135}
136
162f8c2a 137check_min_lib_version() {
3e48f7c9 138 _feature=$3
162f8c2a 139
3e48f7c9 140 if "${cross_prefix}"pkg-config --atleast-version="$2" "$1" > /dev/null 2>&1; then
162f8c2a
DF
141 return 0
142 fi
3e48f7c9
DF
143 : "${_feature:=${1}}"
144 if "${cross_prefix}"pkg-config --version > /dev/null 2>&1; then
cffe80a4 145 if test "$(eval echo \"\$$_feature\")" = "yes" ; then
3e48f7c9 146 feature_not_found "$_feature" "$1 >= $2"
162f8c2a
DF
147 fi
148 else
3e48f7c9 149 print_config "$1" "missing pkg-config, can't check $_feature version"
162f8c2a
DF
150 fi
151 return 1
152}
153
67bf9823
JA
154targetos=""
155cpu=""
156
91f94d5b 157# default options
47f44635
JA
158show_help="no"
159exit_val=0
ebec2094 160gfio_check="no"
1b10477b 161libhdfs="no"
43f3cec2 162pmemblk="no"
cbb15e42 163devdax="no"
ae0db592 164pmem="no"
d490af7f 165cuda="no"
10756b2c 166libcufile="no"
de26b824 167disable_lex=""
3ee2a3c1 168disable_pmem="no"
a817dc3b 169disable_native="no"
9f75af77 170march_set="no"
247ef2aa 171libiscsi="no"
d643a1e2 172libnbd="no"
38551c04 173libzbc=""
c363fdd7 174dfs=""
5a8a6a03 175dynamic_engines="no"
020d54bd 176prefix=/usr/local
91f94d5b 177
cb1125b0
JA
178# parse options
179for opt do
180 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
181 case "$opt" in
020d54bd
JA
182 --prefix=*) prefix="$optarg"
183 ;;
8b156d8e
JA
184 --cpu=*) cpu="$optarg"
185 ;;
c8931876
JA
186 # esx is cross compiled and cannot be detect through simple uname calls
187 --esx)
188 esx="yes"
189 ;;
cb1125b0
JA
190 --cc=*) CC="$optarg"
191 ;;
208e4c8b
JA
192 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
193 ;;
b7c12794 194 --build-32bit-win) build_32bit_win="yes"
7409711b 195 ;;
a6ab5391
SW
196 --target-win-ver=*) target_win_ver="$optarg"
197 ;;
76bc30ca
SW
198 --enable-pdb) pdb="yes"
199 ;;
d2aeedb9
JA
200 --build-static) build_static="yes"
201 ;;
bad7e42c 202 --enable-gfio) gfio_check="yes"
899fab33 203 ;;
44462517
CF
204 --disable-numa) disable_numa="yes"
205 ;;
f678f8d2
MF
206 --disable-rdma) disable_rdma="yes"
207 ;;
d5f9b0ea
IF
208 --disable-rados) disable_rados="yes"
209 ;;
ce18290e
TM
210 --disable-rbd) disable_rbd="yes"
211 ;;
c2f6a13d
LMB
212 --disable-http) disable_http="yes"
213 ;;
ce18290e
TM
214 --disable-gfapi) disable_gfapi="yes"
215 ;;
1b10477b
MM
216 --enable-libhdfs) libhdfs="yes"
217 ;;
a655bbc4
JA
218 --disable-lex) disable_lex="yes"
219 ;;
de26b824
JA
220 --enable-lex) disable_lex="no"
221 ;;
61054f0d
JA
222 --disable-shm) no_shm="yes"
223 ;;
224 --disable-optimizations) disable_opt="yes"
ba40757e 225 ;;
3ee2a3c1
DJ
226 --disable-pmem) disable_pmem="yes"
227 ;;
d490af7f 228 --enable-cuda) cuda="yes"
03553853 229 ;;
10756b2c
BS
230 --enable-libcufile) libcufile="yes"
231 ;;
a817dc3b
JA
232 --disable-native) disable_native="yes"
233 ;;
a40e7a59
GB
234 --with-ime=*) ime_path="$optarg"
235 ;;
247ef2aa
KZ
236 --enable-libiscsi) libiscsi="yes"
237 ;;
d643a1e2
RJ
238 --enable-libnbd) libnbd="yes"
239 ;;
38551c04
DF
240 --disable-libzbc) libzbc="no"
241 ;;
01fe773d
JD
242 --disable-tcmalloc) disable_tcmalloc="yes"
243 ;;
5a8a6a03
YK
244 --dynamic-libengines) dynamic_engines="yes"
245 ;;
c363fdd7
JL
246 --disable-dfs) dfs="no"
247 ;;
827da4f5 248 --help)
47f44635 249 show_help="yes"
827da4f5 250 ;;
cb1125b0
JA
251 *)
252 echo "Bad option $opt"
47f44635
JA
253 show_help="yes"
254 exit_val=1
cb1125b0
JA
255 esac
256done
257
47f44635 258if test "$show_help" = "yes" ; then
05cef7a0
TK
259 echo "--prefix= Use this directory as installation prefix"
260 echo "--cpu= Specify target CPU if auto-detect fails"
261 echo "--cc= Specify compiler to use"
262 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
263 echo "--build-32bit-win Enable 32-bit build on Windows"
26dcc084 264 echo "--target-win-ver= Minimum version of Windows to target (only accepts 7)"
76bc30ca 265 echo "--enable-pdb Enable Windows PDB symbols generation (needs clang/lld)"
05cef7a0
TK
266 echo "--build-static Build a static fio"
267 echo "--esx Configure build options for esx"
268 echo "--enable-gfio Enable building of gtk gfio"
269 echo "--disable-numa Disable libnuma even if found"
03553853 270 echo "--disable-rdma Disable RDMA support even if found"
e75a6fac
JH
271 echo "--disable-rados Disable Rados support even if found"
272 echo "--disable-rbd Disable Rados Block Device even if found"
273 echo "--disable-http Disable HTTP support even if found"
05cef7a0
TK
274 echo "--disable-gfapi Disable gfapi"
275 echo "--enable-libhdfs Enable hdfs support"
276 echo "--disable-lex Disable use of lex/yacc for math"
277 echo "--disable-pmem Disable pmem based engines even if found"
278 echo "--enable-lex Enable use of lex/yacc for math"
279 echo "--disable-shm Disable SHM support"
61054f0d 280 echo "--disable-optimizations Don't enable compiler optimizations"
03553853 281 echo "--enable-cuda Enable GPUDirect RDMA support"
10756b2c 282 echo "--enable-libcufile Enable GPUDirect Storage cuFile support"
a817dc3b 283 echo "--disable-native Don't build for native host"
a40e7a59 284 echo "--with-ime= Install path for DDN's Infinite Memory Engine"
247ef2aa 285 echo "--enable-libiscsi Enable iscsi support"
d643a1e2 286 echo "--enable-libnbd Enable libnbd (NBD engine) support"
38551c04 287 echo "--disable-libzbc Disable libzbc even if found"
01fe773d 288 echo "--disable-tcmalloc Disable tcmalloc support"
5a8a6a03 289 echo "--dynamic-libengines Lib-based ioengines as dynamic libraries"
c363fdd7 290 echo "--disable-dfs Disable DAOS File System support even if found"
b7a99316 291 exit $exit_val
47f44635
JA
292fi
293
47986339 294cross_prefix=${cross_prefix-${CROSS_COMPILE}}
b73af738
SW
295# Preferred compiler (can be overriden later after we know the platform):
296# ${CC} (if set)
297# ${cross_prefix}gcc (if cross-prefix specified)
298# gcc if available
299# clang if available
300if test -z "${CC}${cross_prefix}"; then
301 if has gcc; then
302 cc=gcc
303 elif has clang; then
304 cc=clang
305 fi
306else
307 cc="${CC-${cross_prefix}gcc}"
308fi
47986339 309
6d0e9f83
AC
310if check_define __ANDROID__ ; then
311 targetos="Android"
312elif check_define __linux__ ; then
67bf9823 313 targetos="Linux"
67bf9823
JA
314elif check_define __OpenBSD__ ; then
315 targetos='OpenBSD'
89556808
BVA
316elif check_define __NetBSD__ ; then
317 targetos='NetBSD'
67bf9823
JA
318elif check_define __sun__ ; then
319 targetos='SunOS'
7cb024f8 320 CFLAGS="$CFLAGS -D_REENTRANT"
b24f59ab
SH
321elif check_define _WIN32 ; then
322 targetos='CYGWIN'
67bf9823
JA
323else
324 targetos=`uname -s`
325fi
326
53cd4eee
AC
327echo "# Automatically generated by configure - do not modify" > $config_host_mak
328printf "# Configured with:" >> $config_host_mak
329printf " '%s'" "$0" "$@" >> $config_host_mak
330echo >> $config_host_mak
331echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
332
61054f0d
JA
333if test "$no_shm" = "yes" ; then
334 output_sym "CONFIG_NO_SHM"
335fi
336
337if test "$disable_opt" = "yes" ; then
338 output_sym "CONFIG_FIO_NO_OPT"
339fi
340
67bf9823
JA
341# Some host OSes need non-standard checks for which CPU to use.
342# Note that these checks are broken for cross-compilation: if you're
343# cross-compiling to one of these OSes then you'll need to specify
344# the correct CPU with the --cpu option.
345case $targetos in
26532556 346AIX|OpenBSD|NetBSD)
de26b824 347 # Unless explicitly enabled, turn off lex.
baa78fdc 348 # OpenBSD will hit syntax error when enabled.
de26b824
JA
349 if test -z "$disable_lex" ; then
350 disable_lex="yes"
daf705b5
JA
351 else
352 force_no_lex_o="yes"
de26b824
JA
353 fi
354 ;;
f22dd97a
RC
355FreeBSD)
356 CFLAGS="$CFLAGS -I/usr/local/include"
357 LDFLAGS="$LDFLAGS -L/usr/local/lib"
358 ;;
67bf9823
JA
359Darwin)
360 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
361 # we can run 64-bit userspace code.
362 # If the user didn't specify a CPU explicitly and the kernel says this is
363 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
364 # detection code.
365 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
366 cpu="x86_64"
367 fi
b6a1e63a 368 # Avoid configure feature detection of features provided by weak symbols
ccf2d89d
SW
369cat > $TMPC <<EOF
370int main(void)
371{
372 return 0;
373}
374EOF
b6a1e63a
SW
375 if compile_prog "" "-Werror=partial-availability" "error on weak symbols"; then
376 CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Werror=partial-availability"
ccf2d89d 377 fi
67bf9823
JA
378 ;;
379SunOS)
380 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
381 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
382 cpu="x86_64"
383 fi
adaa46d8 384 LIBS="-lnsl -lsocket"
cfd94f79
JA
385 ;;
386CYGWIN*)
ca205a75
TK
387 # We still force some options, so keep this message here.
388 echo "Forcing some known good options on Windows"
b73af738 389 if test -z "${CC}${cross_prefix}"; then
7409711b 390 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
b73af738 391 cc="i686-w64-mingw32-gcc"
7409711b 392 else
b73af738 393 cc="x86_64-w64-mingw32-gcc"
7409711b 394 fi
4578d01f 395 fi
a6ab5391
SW
396
397 target_win_ver=$(echo "$target_win_ver" | tr '[:lower:]' '[:upper:]')
398 if test -z "$target_win_ver"; then
399 # Default Windows API target
400 target_win_ver="7"
401 fi
26dcc084 402 if test "$target_win_ver" = "7"; then
a6ab5391
SW
403 output_sym "CONFIG_WINDOWS_7"
404 CFLAGS="$CFLAGS -D_WIN32_WINNT=0x0601"
7409711b 405 else
a6ab5391 406 fatal "Unknown target Windows version"
7409711b 407 fi
a6ab5391 408
ca205a75
TK
409 # We need this to be output_sym'd here because this is Windows specific.
410 # The regular configure path never sets this config.
4feafb1e 411 output_sym "CONFIG_WINDOWSAIO"
ca205a75
TK
412 # We now take the regular configuration path without having exit 0 here.
413 # Flags below are still necessary mostly for MinGW.
12ed4fc8 414 build_static="yes"
ca205a75
TK
415 rusage_thread="yes"
416 fdatasync="yes"
417 clock_gettime="yes" # clock_monotonic probe has dependency on this
418 clock_monotonic="yes"
ca205a75 419 sched_idle="yes"
ea8c20c3 420 pthread_condattr_setclock="no"
deb859d6 421 pthread_affinity="no"
6d0e9f83 422 ;;
67bf9823
JA
423esac
424
b73af738
SW
425# Now we know the target platform we can have another guess at the preferred
426# compiler when it wasn't explictly set
427if test -z "${CC}${cross_prefix}"; then
428 if test "$targetos" = "FreeBSD" || test "$targetos" = "Darwin"; then
429 if has clang; then
430 cc=clang
431 fi
432 fi
433fi
434if test -z "$cc"; then
435 echo "configure: failed to find compiler"
436 exit 1
437fi
438
67bf9823
JA
439if test ! -z "$cpu" ; then
440 # command line argument
441 :
442elif check_define __i386__ ; then
443 cpu="i386"
444elif check_define __x86_64__ ; then
445 cpu="x86_64"
446elif check_define __sparc__ ; then
447 if check_define __arch64__ ; then
448 cpu="sparc64"
449 else
450 cpu="sparc"
451 fi
452elif check_define _ARCH_PPC ; then
453 if check_define _ARCH_PPC64 ; then
454 cpu="ppc64"
455 else
456 cpu="ppc"
457 fi
458elif check_define __mips__ ; then
459 cpu="mips"
460elif check_define __ia64__ ; then
461 cpu="ia64"
462elif check_define __s390__ ; then
463 if check_define __s390x__ ; then
464 cpu="s390x"
465 else
466 cpu="s390"
467 fi
468elif check_define __arm__ ; then
469 cpu="arm"
214e2d56 470elif check_define __aarch64__ ; then
471 cpu="aarch64"
67bf9823
JA
472elif check_define __hppa__ ; then
473 cpu="hppa"
474else
475 cpu=`uname -m`
476fi
477
478# Normalise host CPU name and set ARCH.
479case "$cpu" in
480 ia64|ppc|ppc64|s390|s390x|sparc64)
481 cpu="$cpu"
482 ;;
483 i386|i486|i586|i686|i86pc|BePC)
95ef38ab 484 cpu="x86"
67bf9823
JA
485 ;;
486 x86_64|amd64)
487 cpu="x86_64"
488 ;;
489 armv*b|armv*l|arm)
490 cpu="arm"
491 ;;
214e2d56 492 aarch64)
493 cpu="arm64"
494 ;;
67bf9823
JA
495 hppa|parisc|parisc64)
496 cpu="hppa"
497 ;;
498 mips*)
499 cpu="mips"
500 ;;
501 sparc|sun4[cdmuv])
502 cpu="sparc"
503 ;;
504 *)
8b156d8e 505 echo "Unknown CPU"
67bf9823
JA
506 ;;
507esac
508
1a17cfdb
AC
509##########################################
510# check cross compile
511
ca205a75
TK
512if test "$cross_compile" != "yes" ; then
513 cross_compile="no"
514fi
1a17cfdb
AC
515cat > $TMPC <<EOF
516int main(void)
517{
518 return 0;
519}
520EOF
521if compile_prog "" "" "cross"; then
522 $TMPE 2>/dev/null || cross_compile="yes"
523else
524 fatal "compile test failed"
525fi
526
0dcebdf4
JA
527##########################################
528# check endianness
ca205a75
TK
529if test "$bigendian" != "yes" ; then
530 bigendian="no"
531fi
1a17cfdb
AC
532if test "$cross_compile" = "no" ; then
533 cat > $TMPC <<EOF
0dcebdf4
JA
534#include <inttypes.h>
535int main(void)
536{
537 volatile uint32_t i=0x01234567;
538 return (*((uint8_t*)(&i))) == 0x67;
539}
540EOF
1a17cfdb
AC
541 if compile_prog "" "" "endian"; then
542 $TMPE && bigendian="yes"
543 fi
544else
545 # If we're cross compiling, try our best to work it out and rely on the
546 # run-time check to fail if we get it wrong.
547 cat > $TMPC <<EOF
548#include <endian.h>
549int main(void)
550{
551#if __BYTE_ORDER != __BIG_ENDIAN
552# error "Unknown endianness"
553#endif
554}
555EOF
556 compile_prog "" "" "endian" && bigendian="yes"
557 check_define "__ARMEB__" && bigendian="yes"
558 check_define "__MIPSEB__" && bigendian="yes"
0dcebdf4
JA
559fi
560
561
484b0b65
TK
562print_config "Operating system" "$targetos"
563print_config "CPU" "$cpu"
564print_config "Big endian" "$bigendian"
a6ab5391
SW
565if test ! -z "$target_win_ver"; then
566 print_config "Target Windows version" "$target_win_ver"
567fi
484b0b65
TK
568print_config "Compiler" "$cc"
569print_config "Cross compile" "$cross_compile"
67bf9823
JA
570echo
571
d2aeedb9
JA
572##########################################
573# See if we need to build a static build
574if test "$build_static" = "yes" ; then
575 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
576 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
577else
578 build_static="no"
579fi
484b0b65 580print_config "Static build" "$build_static"
d2aeedb9 581
bb012314
SW
582##########################################
583# check for C11 atomics support
584cat > $TMPC <<EOF
585#include <stdatomic.h>
586int main(void)
587{
588 _Atomic unsigned v;
589 atomic_load(&v);
590 return 0;
591}
592EOF
593if ! compile_prog "" "" "C11 atomics"; then
594 echo
595 echo "Your compiler doesn't support C11 atomics. gcc 4.9/clang 3.6 are the"
596 echo "minimum versions with it - perhaps your compiler is too old?"
597 fatal "C11 atomics support not found"
598fi
599
600
67bf9823
JA
601##########################################
602# check for wordsize
603wordsize="0"
604cat > $TMPC <<EOF
142429e5
AC
605#include <limits.h>
606#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
67bf9823
JA
607int main(void)
608{
142429e5 609 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
67bf9823
JA
610 return 0;
611}
612EOF
142429e5
AC
613if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
614 wordsize="32"
615elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
616 wordsize="64"
617else
618 fatal "Unknown wordsize"
67bf9823 619fi
484b0b65 620print_config "Wordsize" "$wordsize"
67bf9823 621
a9bca4aa
JA
622##########################################
623# zlib probe
ca205a75
TK
624if test "$zlib" != "yes" ; then
625 zlib="no"
626fi
a9bca4aa 627cat > $TMPC <<EOF
804a1e05 628#include <zlib.h>
a9bca4aa
JA
629int main(void)
630{
631 z_stream stream;
632 if (inflateInit(&stream) != Z_OK)
633 return 1;
634 return 0;
635}
636EOF
637if compile_prog "" "-lz" "zlib" ; then
638 zlib=yes
639 LIBS="-lz $LIBS"
a9bca4aa 640fi
484b0b65 641print_config "zlib" "$zlib"
a9bca4aa 642
67bf9823
JA
643##########################################
644# linux-aio probe
ca205a75
TK
645if test "$libaio" != "yes" ; then
646 libaio="no"
647fi
7c77ebef 648if test "$esx" != "yes" ; then
649 cat > $TMPC <<EOF
67bf9823
JA
650#include <libaio.h>
651#include <stddef.h>
652int main(void)
653{
654 io_setup(0, NULL);
655 return 0;
656}
657EOF
d4946e79 658 if compile_prog "" "-laio" "libaio" ; then
7c77ebef 659 libaio=yes
7c77ebef 660 else
661 if test "$libaio" = "yes" ; then
662 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
663 fi
664 libaio=no
67bf9823 665 fi
7d42e66e
KK
666
667 cat > $TMPC <<EOF
668#include <libaio.h>
669#include <stddef.h>
670int main(void)
671{
672 io_prep_preadv2(NULL, 0, NULL, 0, 0, 0);
673 io_prep_pwritev2(NULL, 0, NULL, 0, 0, 0);
674 return 0;
675}
676EOF
677 if compile_prog "" "" "libaio rw flags" ; then
678 libaio_rw_flags=yes
679 else
680 libaio_rw_flags=no
681 fi
67bf9823 682fi
484b0b65 683print_config "Linux AIO support" "$libaio"
7d42e66e 684print_config "Linux AIO support rw flags" "$libaio_rw_flags"
67bf9823
JA
685
686##########################################
687# posix aio probe
ca205a75
TK
688if test "$posix_aio" != "yes" ; then
689 posix_aio="no"
690fi
691if test "$posix_aio_lrt" != "yes" ; then
692 posix_aio_lrt="no"
693fi
67bf9823
JA
694cat > $TMPC <<EOF
695#include <aio.h>
696int main(void)
697{
698 struct aiocb cb;
699 aio_read(&cb);
700 return 0;
701}
702EOF
703if compile_prog "" "" "posixaio" ; then
704 posix_aio="yes"
09c81e13 705elif compile_prog "" "-lrt" "posixaio -lrt"; then
67bf9823
JA
706 posix_aio="yes"
707 posix_aio_lrt="yes"
708 LIBS="-lrt $LIBS"
709fi
484b0b65
TK
710print_config "POSIX AIO support" "$posix_aio"
711print_config "POSIX AIO support needs -lrt" "$posix_aio_lrt"
67bf9823
JA
712
713##########################################
714# posix aio fsync probe
ca205a75
TK
715if test "$posix_aio_fsync" != "yes" ; then
716 posix_aio_fsync="no"
717fi
67bf9823
JA
718if test "$posix_aio" = "yes" ; then
719 cat > $TMPC <<EOF
720#include <fcntl.h>
721#include <aio.h>
722int main(void)
723{
724 struct aiocb cb;
725 return aio_fsync(O_SYNC, &cb);
726 return 0;
727}
728EOF
729 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
730 posix_aio_fsync=yes
731 fi
732fi
484b0b65 733print_config "POSIX AIO fsync" "$posix_aio_fsync"
67bf9823 734
06eac6b2
SW
735##########################################
736# POSIX pshared attribute probe
d418fa90
TK
737if test "$posix_pshared" != "yes" ; then
738 posix_pshared="no"
739fi
06eac6b2
SW
740cat > $TMPC <<EOF
741#include <unistd.h>
742int main(void)
743{
744#if defined(_POSIX_THREAD_PROCESS_SHARED) && ((_POSIX_THREAD_PROCESS_SHARED + 0) > 0)
745# if defined(__CYGWIN__)
746# error "_POSIX_THREAD_PROCESS_SHARED is buggy on Cygwin"
747# elif defined(__APPLE__)
748# include <AvailabilityMacros.h>
749# include <TargetConditionals.h>
750# if TARGET_OS_MAC && MAC_OS_X_VERSION_MIN_REQUIRED < 1070
751# error "_POSIX_THREAD_PROCESS_SHARED is buggy/unsupported prior to OSX 10.7"
752# endif
753# endif
754#else
755# error "_POSIX_THREAD_PROCESS_SHARED is unsupported"
756#endif
757 return 0;
758}
759EOF
760if compile_prog "" "$LIBS" "posix_pshared" ; then
761 posix_pshared=yes
762fi
484b0b65 763print_config "POSIX pshared support" "$posix_pshared"
06eac6b2 764
78b66d32
BVA
765##########################################
766# POSIX pthread_condattr_setclock() probe
ea8c20c3
JL
767if test "$pthread_condattr_setclock" != "no" ; then
768 cat > $TMPC <<EOF
78b66d32
BVA
769#include <pthread.h>
770int main(void)
771{
772 pthread_condattr_t condattr;
773 pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC);
774 return 0;
775}
776EOF
ea8c20c3
JL
777 if compile_prog "" "$LIBS" "pthread_condattr_setclock" ; then
778 pthread_condattr_setclock=yes
779 elif compile_prog "" "$LIBS -lpthread" "pthread_condattr_setclock" ; then
780 pthread_condattr_setclock=yes
781 LIBS="$LIBS -lpthread"
782 fi
78b66d32 783fi
a9bf436e 784print_config "pthread_condattr_setclock()" "$pthread_condattr_setclock"
78b66d32 785
c31092b8
BVA
786##########################################
787# pthread_sigmask() probe
788if test "$pthread_sigmask" != "yes" ; then
789 pthread_sigmask="no"
790fi
791cat > $TMPC <<EOF
792#include <stddef.h> /* NULL */
793#include <signal.h> /* pthread_sigmask() */
794int main(void)
795{
796 return pthread_sigmask(0, NULL, NULL);
797}
798EOF
799if compile_prog "" "$LIBS" "pthread_sigmask" ; then
800 pthread_sigmask=yes
801elif compile_prog "" "$LIBS -lpthread" "pthread_sigmask" ; then
802 pthread_sigmask=yes
803 LIBS="$LIBS -lpthread"
804fi
805print_config "pthread_sigmask()" "$pthread_sigmask"
806
deb859d6
JA
807##########################################
808# pthread_getaffinity_np() probe
809if test "$pthread_getaffinity" != "yes" ; then
810 pthread_getaffinity="no"
811fi
812cat > $TMPC <<EOF
813#include <stddef.h> /* NULL */
814#include <signal.h> /* pthread_sigmask() */
815#include <pthread.h>
816int main(void)
817{
818 cpu_set_t set;
819 return pthread_getaffinity_np(pthread_self(), sizeof(set), &set);
820}
821EOF
822if compile_prog "" "$LIBS" "pthread_getaffinity" ; then
823 pthread_getaffinity="yes"
824elif compile_prog "" "$LIBS -lpthread" "pthread_getaffinity" ; then
825 pthread_getaffinity="yes"
826 LIBS="$LIBS -lpthread"
827fi
828print_config "pthread_getaffinity_np()" "$pthread_getaffinity"
829
67bf9823
JA
830##########################################
831# solaris aio probe
ca205a75
TK
832if test "$solaris_aio" != "yes" ; then
833 solaris_aio="no"
834fi
67bf9823
JA
835cat > $TMPC <<EOF
836#include <sys/types.h>
837#include <sys/asynch.h>
838#include <unistd.h>
839int main(void)
840{
841 aio_result_t res;
842 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
843 return 0;
844}
845EOF
846if compile_prog "" "-laio" "solarisaio" ; then
847 solaris_aio=yes
848 LIBS="-laio $LIBS"
849fi
484b0b65 850print_config "Solaris AIO support" "$solaris_aio"
67bf9823
JA
851
852##########################################
f5cd2907 853# __sync_fetch_and_add test
ca205a75
TK
854if test "$sfaa" != "yes" ; then
855 sfaa="no"
856fi
67bf9823 857cat > $TMPC << EOF
958886d8
JA
858#include <inttypes.h>
859static int sfaa(uint64_t *ptr)
67bf9823 860{
9c639a76 861 return __sync_fetch_and_add(ptr, 0);
67bf9823
JA
862}
863
864int main(int argc, char **argv)
865{
958886d8 866 uint64_t val = 42;
67bf9823
JA
867 sfaa(&val);
868 return val;
869}
870EOF
871if compile_prog "" "" "__sync_fetch_and_add()" ; then
872 sfaa="yes"
873fi
484b0b65 874print_config "__sync_fetch_and_add" "$sfaa"
67bf9823 875
a250edd0
JA
876##########################################
877# __sync_synchronize() test
878if test "$sync_sync" != "yes" ; then
879 sync_sync="no"
880fi
881cat > $TMPC << EOF
882#include <inttypes.h>
883
884int main(int argc, char **argv)
885{
886 __sync_synchronize();
887 return 0;
888}
889EOF
890if compile_prog "" "" "__sync_synchronize()" ; then
891 sync_sync="yes"
892fi
893print_config "__sync_synchronize" "$sync_sync"
894
895##########################################
896# __sync_val_compare_and_swap() test
897if test "$cmp_swap" != "yes" ; then
898 cmp_swap="no"
899fi
900cat > $TMPC << EOF
901#include <inttypes.h>
902
903int main(int argc, char **argv)
904{
905 int x = 0;
906 return __sync_val_compare_and_swap(&x, 1, 2);
907}
908EOF
909if compile_prog "" "" "__sync_val_compare_and_swap()" ; then
910 cmp_swap="yes"
911fi
912print_config "__sync_val_compare_and_swap" "$cmp_swap"
913
67bf9823
JA
914##########################################
915# libverbs probe
ca205a75
TK
916if test "$libverbs" != "yes" ; then
917 libverbs="no"
918fi
67bf9823 919cat > $TMPC << EOF
eb3bfdd8 920#include <infiniband/verbs.h>
67bf9823
JA
921int main(int argc, char **argv)
922{
923 struct ibv_pd *pd = ibv_alloc_pd(NULL);
40dae137 924 return pd != NULL;
67bf9823
JA
925}
926EOF
f678f8d2 927if test "$disable_rdma" != "yes" && compile_prog "" "-libverbs" "libverbs" ; then
67bf9823 928 libverbs="yes"
67bf9823 929fi
484b0b65 930print_config "libverbs" "$libverbs"
67bf9823
JA
931
932##########################################
933# rdmacm probe
ca205a75
TK
934if test "$rdmacm" != "yes" ; then
935 rdmacm="no"
936fi
67bf9823
JA
937cat > $TMPC << EOF
938#include <stdio.h>
939#include <rdma/rdma_cma.h>
940int main(int argc, char **argv)
941{
942 rdma_destroy_qp(NULL);
943 return 0;
944}
945EOF
f678f8d2 946if test "$disable_rdma" != "yes" && compile_prog "" "-lrdmacm" "rdma"; then
67bf9823 947 rdmacm="yes"
67bf9823 948fi
484b0b65 949print_config "rdmacm" "$rdmacm"
67bf9823 950
e4c4625f
JM
951##########################################
952# librpma probe
953if test "$librpma" != "yes" ; then
954 librpma="no"
955fi
956cat > $TMPC << EOF
957#include <stdio.h>
958#include <librpma.h>
959int main(int argc, char **argv)
960{
961 enum rpma_conn_event event = RPMA_CONN_REJECTED;
962 (void) event; /* unused */
963 rpma_log_set_threshold(RPMA_LOG_THRESHOLD, RPMA_LOG_LEVEL_INFO);
964 return 0;
965}
966EOF
967if test "$disable_rdma" != "yes" && compile_prog "" "-lrpma" "rpma"; then
968 librpma="yes"
969fi
970print_config "librpma" "$librpma"
971
972##########################################
973# libprotobuf-c probe
974if test "$libprotobuf_c" != "yes" ; then
975 libprotobuf_c="no"
976fi
977cat > $TMPC << EOF
978#include <stdio.h>
979#include <protobuf-c/protobuf-c.h>
980#if !defined(PROTOBUF_C_VERSION_NUMBER)
981# error PROTOBUF_C_VERSION_NUMBER is not defined!
982#endif
983int main(int argc, char **argv)
984{
985 (void)protobuf_c_message_check(NULL);
986 return 0;
987}
988EOF
989if compile_prog "" "-lprotobuf-c" "protobuf_c"; then
990 libprotobuf_c="yes"
991fi
992print_config "libprotobuf_c" "$libprotobuf_c"
993
44e8e956
BVA
994##########################################
995# asprintf() and vasprintf() probes
996if test "$have_asprintf" != "yes" ; then
997 have_asprintf="no"
998fi
999cat > $TMPC << EOF
1000#include <stdio.h>
1001
1002int main(int argc, char **argv)
1003{
0a702282
SW
1004 char *buf;
1005 return asprintf(&buf, "%s", "str") == 0;
44e8e956
BVA
1006}
1007EOF
1008if compile_prog "" "" "have_asprintf"; then
1009 have_asprintf="yes"
1010fi
1011print_config "asprintf()" "$have_asprintf"
1012
1013if test "$have_vasprintf" != "yes" ; then
1014 have_vasprintf="no"
1015fi
1016cat > $TMPC << EOF
1017#include <stdio.h>
1018
1019int main(int argc, char **argv)
1020{
849ac4b2 1021 va_list ap;
0a702282
SW
1022 char *buf;
1023 return vasprintf(&buf, "%s", ap) == 0;
44e8e956
BVA
1024}
1025EOF
1026if compile_prog "" "" "have_vasprintf"; then
1027 have_vasprintf="yes"
1028fi
1029print_config "vasprintf()" "$have_vasprintf"
1030
67bf9823
JA
1031##########################################
1032# Linux fallocate probe
ca205a75
TK
1033if test "$linux_fallocate" != "yes" ; then
1034 linux_fallocate="no"
1035fi
67bf9823
JA
1036cat > $TMPC << EOF
1037#include <stdio.h>
aa6738a5 1038#include <fcntl.h>
67bf9823
JA
1039#include <linux/falloc.h>
1040int main(int argc, char **argv)
1041{
1042 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
1043 return r;
1044}
1045EOF
1046if compile_prog "" "" "linux_fallocate"; then
1047 linux_fallocate="yes"
1048fi
484b0b65 1049print_config "Linux fallocate" "$linux_fallocate"
67bf9823
JA
1050
1051##########################################
1052# POSIX fadvise probe
ca205a75
TK
1053if test "$posix_fadvise" != "yes" ; then
1054 posix_fadvise="no"
1055fi
67bf9823
JA
1056cat > $TMPC << EOF
1057#include <stdio.h>
1058#include <fcntl.h>
1059int main(int argc, char **argv)
1060{
1061 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
1062 return r;
1063}
1064EOF
1065if compile_prog "" "" "posix_fadvise"; then
1066 posix_fadvise="yes"
1067fi
484b0b65 1068print_config "POSIX fadvise" "$posix_fadvise"
67bf9823
JA
1069
1070##########################################
1071# POSIX fallocate probe
ca205a75
TK
1072if test "$posix_fallocate" != "yes" ; then
1073 posix_fallocate="no"
1074fi
67bf9823
JA
1075cat > $TMPC << EOF
1076#include <stdio.h>
1077#include <fcntl.h>
1078int main(int argc, char **argv)
1079{
1080 int r = posix_fallocate(0, 0, 1024);
1081 return r;
1082}
1083EOF
1084if compile_prog "" "" "posix_fallocate"; then
1085 posix_fallocate="yes"
1086fi
484b0b65 1087print_config "POSIX fallocate" "$posix_fallocate"
67bf9823
JA
1088
1089##########################################
1090# sched_set/getaffinity 2 or 3 argument test
ca205a75
TK
1091if test "$linux_2arg_affinity" != "yes" ; then
1092 linux_2arg_affinity="no"
1093fi
1094if test "$linux_3arg_affinity" != "yes" ; then
1095 linux_3arg_affinity="no"
1096fi
67bf9823 1097cat > $TMPC << EOF
67bf9823
JA
1098#include <sched.h>
1099int main(int argc, char **argv)
1100{
1101 cpu_set_t mask;
1102 return sched_setaffinity(0, sizeof(mask), &mask);
1103}
1104EOF
1105if compile_prog "" "" "sched_setaffinity(,,)"; then
1106 linux_3arg_affinity="yes"
1107else
1108 cat > $TMPC << EOF
67bf9823
JA
1109#include <sched.h>
1110int main(int argc, char **argv)
1111{
1112 cpu_set_t mask;
1113 return sched_setaffinity(0, &mask);
1114}
1115EOF
1116 if compile_prog "" "" "sched_setaffinity(,)"; then
1117 linux_2arg_affinity="yes"
1118 fi
1119fi
484b0b65
TK
1120print_config "sched_setaffinity(3 arg)" "$linux_3arg_affinity"
1121print_config "sched_setaffinity(2 arg)" "$linux_2arg_affinity"
67bf9823
JA
1122
1123##########################################
1124# clock_gettime probe
ca205a75
TK
1125if test "$clock_gettime" != "yes" ; then
1126 clock_gettime="no"
1127fi
67bf9823
JA
1128cat > $TMPC << EOF
1129#include <stdio.h>
1130#include <time.h>
1131int main(int argc, char **argv)
1132{
1133 return clock_gettime(0, NULL);
1134}
1135EOF
1136if compile_prog "" "" "clock_gettime"; then
1137 clock_gettime="yes"
1138elif compile_prog "" "-lrt" "clock_gettime"; then
1139 clock_gettime="yes"
1140 LIBS="-lrt $LIBS"
1141fi
484b0b65 1142print_config "clock_gettime" "$clock_gettime"
67bf9823
JA
1143
1144##########################################
1145# CLOCK_MONOTONIC probe
ca205a75
TK
1146if test "$clock_monotonic" != "yes" ; then
1147 clock_monotonic="no"
1148fi
67bf9823
JA
1149if test "$clock_gettime" = "yes" ; then
1150 cat > $TMPC << EOF
1151#include <stdio.h>
1152#include <time.h>
1153int main(int argc, char **argv)
1154{
1155 return clock_gettime(CLOCK_MONOTONIC, NULL);
1156}
1157EOF
1158 if compile_prog "" "$LIBS" "clock monotonic"; then
1159 clock_monotonic="yes"
1160 fi
1161fi
484b0b65 1162print_config "CLOCK_MONOTONIC" "$clock_monotonic"
67bf9823 1163
25f8227d
JA
1164##########################################
1165# clockid_t probe
ca205a75
TK
1166if test "$clockid_t" != "yes" ; then
1167 clockid_t="no"
1168fi
25f8227d 1169cat > $TMPC << EOF
25f8227d 1170#include <time.h>
209c37b4 1171#include <string.h>
25f8227d
JA
1172int main(int argc, char **argv)
1173{
ccf2d89d 1174 volatile clockid_t cid;
7fcad9e1 1175 memset((void*)&cid, 0, sizeof(cid));
ccf2d89d 1176 return 0;
25f8227d
JA
1177}
1178EOF
1179if compile_prog "" "$LIBS" "clockid_t"; then
1180 clockid_t="yes"
1181fi
484b0b65 1182print_config "clockid_t" "$clockid_t"
25f8227d 1183
67bf9823
JA
1184##########################################
1185# gettimeofday() probe
ca205a75
TK
1186if test "$gettimeofday" != "yes" ; then
1187 gettimeofday="no"
1188fi
67bf9823
JA
1189cat > $TMPC << EOF
1190#include <sys/time.h>
1191#include <stdio.h>
1192int main(int argc, char **argv)
1193{
1194 struct timeval tv;
1195 return gettimeofday(&tv, NULL);
1196}
1197EOF
1198if compile_prog "" "" "gettimeofday"; then
1199 gettimeofday="yes"
1200fi
484b0b65 1201print_config "gettimeofday" "$gettimeofday"
67bf9823
JA
1202
1203##########################################
1204# fdatasync() probe
ca205a75
TK
1205if test "$fdatasync" != "yes" ; then
1206 fdatasync="no"
1207fi
67bf9823
JA
1208cat > $TMPC << EOF
1209#include <stdio.h>
1210#include <unistd.h>
1211int main(int argc, char **argv)
1212{
1213 return fdatasync(0);
1214}
1215EOF
1216if compile_prog "" "" "fdatasync"; then
1217 fdatasync="yes"
1218fi
484b0b65 1219print_config "fdatasync" "$fdatasync"
67bf9823 1220
52a552e2
BVA
1221##########################################
1222# pipe() probe
1223if test "$pipe" != "yes" ; then
1224 pipe="no"
1225fi
1226cat > $TMPC << EOF
1227#include <unistd.h>
1228int main(int argc, char **argv)
1229{
1230 int fd[2];
1231 return pipe(fd);
1232}
1233EOF
1234if compile_prog "" "" "pipe"; then
1235 pipe="yes"
1236fi
1237print_config "pipe()" "$pipe"
1238
1239##########################################
1240# pipe2() probe
1241if test "$pipe2" != "yes" ; then
1242 pipe2="no"
1243fi
1244cat > $TMPC << EOF
1245#include <unistd.h>
1246int main(int argc, char **argv)
1247{
1248 int fd[2];
1249 return pipe2(fd, 0);
1250}
1251EOF
1252if compile_prog "" "" "pipe2"; then
1253 pipe2="yes"
1254fi
1255print_config "pipe2()" "$pipe2"
1256
15eca9aa
BVA
1257##########################################
1258# pread() probe
1259if test "$pread" != "yes" ; then
1260 pread="no"
1261fi
1262cat > $TMPC << EOF
1263#include <unistd.h>
1264int main(int argc, char **argv)
1265{
1266 return pread(0, NULL, 0, 0);
1267}
1268EOF
1269if compile_prog "" "" "pread"; then
1270 pread="yes"
1271fi
1272print_config "pread()" "$pread"
1273
67bf9823
JA
1274##########################################
1275# sync_file_range() probe
ca205a75
TK
1276if test "$sync_file_range" != "yes" ; then
1277 sync_file_range="no"
1278fi
67bf9823
JA
1279cat > $TMPC << EOF
1280#include <stdio.h>
1281#include <unistd.h>
67bf9823
JA
1282#include <fcntl.h>
1283#include <linux/fs.h>
1284int main(int argc, char **argv)
1285{
1286 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
1287 SYNC_FILE_RANGE_WAIT_AFTER;
1288 return sync_file_range(0, 0, 0, flags);
1289}
1290EOF
1291if compile_prog "" "" "sync_file_range"; then
1292 sync_file_range="yes"
1293fi
484b0b65 1294print_config "sync_file_range" "$sync_file_range"
67bf9823
JA
1295
1296##########################################
1297# ext4 move extent probe
ca205a75
TK
1298if test "$ext4_me" != "yes" ; then
1299 ext4_me="no"
1300fi
67bf9823
JA
1301cat > $TMPC << EOF
1302#include <fcntl.h>
1303#include <sys/ioctl.h>
1304int main(int argc, char **argv)
1305{
1306 struct move_extent me;
1307 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
1308}
1309EOF
c7165b8d
JA
1310if compile_prog "" "" "ext4 move extent" ; then
1311 ext4_me="yes"
1312elif test $targetos = "Linux" ; then
1313 # On Linux, just default to it on and let it error at runtime if we really
1314 # don't have it. None of my updated systems have it defined, but it does
1315 # work. Takes a while to bubble back.
67bf9823
JA
1316 ext4_me="yes"
1317fi
484b0b65 1318print_config "EXT4 move extent" "$ext4_me"
67bf9823
JA
1319
1320##########################################
1321# splice probe
ca205a75
TK
1322if test "$linux_splice" != "yes" ; then
1323 linux_splice="no"
1324fi
67bf9823 1325cat > $TMPC << EOF
67bf9823
JA
1326#include <stdio.h>
1327#include <fcntl.h>
1328int main(int argc, char **argv)
1329{
1330 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
1331}
1332EOF
1333if compile_prog "" "" "linux splice"; then
1334 linux_splice="yes"
1335fi
484b0b65 1336print_config "Linux splice(2)" "$linux_splice"
67bf9823 1337
67bf9823
JA
1338##########################################
1339# libnuma probe
ca205a75
TK
1340if test "$libnuma" != "yes" ; then
1341 libnuma="no"
1342fi
67bf9823
JA
1343cat > $TMPC << EOF
1344#include <numa.h>
1345int main(int argc, char **argv)
1346{
1347 return numa_available();
1348}
1349EOF
44462517 1350if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
67bf9823
JA
1351 libnuma="yes"
1352 LIBS="-lnuma $LIBS"
1353fi
484b0b65 1354print_config "libnuma" "$libnuma"
67bf9823 1355
50206d9b 1356##########################################
ca205a75 1357# libnuma 2.x version API, initialize with "no" only if $libnuma is set to "yes"
50206d9b
JA
1358if test "$libnuma" = "yes" ; then
1359libnuma_v2="no"
1360cat > $TMPC << EOF
1361#include <numa.h>
1362int main(int argc, char **argv)
1363{
1364 struct bitmask *mask = numa_parse_nodestring(NULL);
61bde962 1365 return mask->size == 0;
50206d9b
JA
1366}
1367EOF
1368if compile_prog "" "" "libnuma api"; then
1369 libnuma_v2="yes"
1370fi
484b0b65 1371print_config "libnuma v2" "$libnuma_v2"
50206d9b
JA
1372fi
1373
67bf9823
JA
1374##########################################
1375# strsep() probe
ca205a75
TK
1376if test "$strsep" != "yes" ; then
1377 strsep="no"
1378fi
67bf9823
JA
1379cat > $TMPC << EOF
1380#include <string.h>
1381int main(int argc, char **argv)
1382{
ae156be6
JA
1383 static char *string = "This is a string";
1384 strsep(&string, "needle");
67bf9823
JA
1385 return 0;
1386}
1387EOF
1388if compile_prog "" "" "strsep"; then
1389 strsep="yes"
1390fi
484b0b65 1391print_config "strsep" "$strsep"
67bf9823 1392
9ad8da82
JA
1393##########################################
1394# strcasestr() probe
ca205a75
TK
1395if test "$strcasestr" != "yes" ; then
1396 strcasestr="no"
1397fi
9ad8da82
JA
1398cat > $TMPC << EOF
1399#include <string.h>
1400int main(int argc, char **argv)
1401{
aa6738a5 1402 return strcasestr(argv[0], argv[1]) != NULL;
9ad8da82
JA
1403}
1404EOF
1405if compile_prog "" "" "strcasestr"; then
1406 strcasestr="yes"
1407fi
484b0b65 1408print_config "strcasestr" "$strcasestr"
9ad8da82 1409
5ad7be56
KD
1410##########################################
1411# strlcat() probe
ca205a75
TK
1412if test "$strlcat" != "yes" ; then
1413 strlcat="no"
1414fi
5ad7be56
KD
1415cat > $TMPC << EOF
1416#include <string.h>
1417int main(int argc, char **argv)
1418{
1419 static char dst[64];
1420 static char *string = "This is a string";
1421 memset(dst, 0, sizeof(dst));
1422 strlcat(dst, string, sizeof(dst));
1423 return 0;
1424}
1425EOF
1426if compile_prog "" "" "strlcat"; then
1427 strlcat="yes"
1428fi
484b0b65 1429print_config "strlcat" "$strlcat"
5ad7be56 1430
67bf9823
JA
1431##########################################
1432# getopt_long_only() probe
ca205a75
TK
1433if test "$getopt_long_only" != "yes" ; then
1434 getopt_long_only="no"
1435fi
67bf9823
JA
1436cat > $TMPC << EOF
1437#include <unistd.h>
1438#include <stdio.h>
aa6738a5 1439#include <getopt.h>
67bf9823
JA
1440int main(int argc, char **argv)
1441{
d24ff97d 1442 int c = getopt_long_only(argc, argv, "", NULL, NULL);
67bf9823
JA
1443 return c;
1444}
1445EOF
1446if compile_prog "" "" "getopt_long_only"; then
1447 getopt_long_only="yes"
1448fi
484b0b65 1449print_config "getopt_long_only()" "$getopt_long_only"
67bf9823
JA
1450
1451##########################################
1452# inet_aton() probe
ca205a75
TK
1453if test "$inet_aton" != "yes" ; then
1454 inet_aton="no"
1455fi
67bf9823 1456cat > $TMPC << EOF
a932a2cf
BVA
1457#ifdef _WIN32
1458#include <winsock2.h>
1459#else
67bf9823
JA
1460#include <sys/socket.h>
1461#include <arpa/inet.h>
a932a2cf 1462#endif
67bf9823
JA
1463#include <stdio.h>
1464int main(int argc, char **argv)
1465{
1466 struct in_addr in;
1467 return inet_aton(NULL, &in);
1468}
1469EOF
1470if compile_prog "" "" "inet_aton"; then
1471 inet_aton="yes"
1472fi
484b0b65 1473print_config "inet_aton" "$inet_aton"
67bf9823
JA
1474
1475##########################################
1476# socklen_t probe
ca205a75
TK
1477if test "$socklen_t" != "yes" ; then
1478 socklen_t="no"
1479fi
67bf9823 1480cat > $TMPC << EOF
a932a2cf
BVA
1481#ifdef _WIN32
1482#include <winsock2.h>
1483#include <ws2tcpip.h>
1484#else
f6482613 1485#include <sys/socket.h>
a932a2cf 1486#endif
67bf9823
JA
1487int main(int argc, char **argv)
1488{
1489 socklen_t len = 0;
1490 return len;
1491}
1492EOF
1493if compile_prog "" "" "socklen_t"; then
1494 socklen_t="yes"
1495fi
484b0b65 1496print_config "socklen_t" "$socklen_t"
67bf9823
JA
1497
1498##########################################
1499# Whether or not __thread is supported for TLS
ca205a75
TK
1500if test "$tls_thread" != "yes" ; then
1501 tls_thread="no"
1502fi
67bf9823
JA
1503cat > $TMPC << EOF
1504#include <stdio.h>
aa6738a5 1505static __thread int ret;
67bf9823
JA
1506int main(int argc, char **argv)
1507{
1508 return ret;
1509}
1510EOF
1511if compile_prog "" "" "__thread"; then
1512 tls_thread="yes"
1513fi
484b0b65 1514print_config "__thread" "$tls_thread"
67bf9823 1515
91f94d5b 1516##########################################
2639f056 1517# Check if we have required gtk/glib support for gfio
ca205a75
TK
1518if test "$gfio" != "yes" ; then
1519 gfio="no"
1520fi
ebec2094 1521if test "$gfio_check" = "yes" ; then
91f94d5b
JA
1522 cat > $TMPC << EOF
1523#include <glib.h>
1524#include <cairo.h>
1525#include <gtk/gtk.h>
1526int main(void)
1527{
1528 gdk_threads_enter();
91f94d5b 1529 gdk_threads_leave();
b7a99316 1530
ef2b61aa 1531 return GTK_CHECK_VERSION(2, 18, 0) ? 0 : 1; /* 0 on success */
91f94d5b
JA
1532}
1533EOF
4d1bc43e 1534GTK_CFLAGS=$(${cross_prefix}pkg-config --cflags gtk+-2.0 gthread-2.0)
86719845
JA
1535ORG_LDFLAGS=$LDFLAGS
1536LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
91f94d5b
JA
1537if test "$?" != "0" ; then
1538 echo "configure: gtk and gthread not found"
1539 exit 1
1540fi
4d1bc43e 1541GTK_LIBS=$(${cross_prefix}pkg-config --libs gtk+-2.0 gthread-2.0)
91f94d5b
JA
1542if test "$?" != "0" ; then
1543 echo "configure: gtk and gthread not found"
1544 exit 1
1545fi
162f8c2a
DF
1546gfio="yes"
1547if check_min_lib_version gtk+-2.0 2.18.0 "gfio"; then
31ce8438 1548 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
86719845 1549 GFIO_LIBS="$LIBS $GTK_LIBS"
b7a99316
JA
1550 CFLAGS="$CFLAGS $GTK_CFLAGS"
1551 else
31ce8438 1552 echo "Please install gtk and gdk libraries"
b7a99316
JA
1553 gfio="no"
1554 fi
162f8c2a
DF
1555else
1556 gfio="no"
91f94d5b 1557fi
86719845 1558LDFLAGS=$ORG_LDFLAGS
91f94d5b
JA
1559fi
1560
ebec2094 1561if test "$gfio_check" = "yes" ; then
484b0b65 1562 print_config "gtk 2.18 or higher" "$gfio"
ebec2094 1563fi
91f94d5b 1564
bda92394 1565##########################################
44404c5a 1566# Check whether we have getrusage(RUSAGE_THREAD)
ca205a75
TK
1567if test "$rusage_thread" != "yes" ; then
1568 rusage_thread="no"
1569fi
44404c5a
JA
1570cat > $TMPC << EOF
1571#include <sys/time.h>
1572#include <sys/resource.h>
1573int main(int argc, char **argv)
1574{
1575 struct rusage ru;
1576 getrusage(RUSAGE_THREAD, &ru);
1577 return 0;
1578}
1579EOF
1580if compile_prog "" "" "RUSAGE_THREAD"; then
1581 rusage_thread="yes"
1582fi
484b0b65 1583print_config "RUSAGE_THREAD" "$rusage_thread"
44404c5a 1584
7e09a9f1
JA
1585##########################################
1586# Check whether we have SCHED_IDLE
ca205a75
TK
1587if test "$sched_idle" != "yes" ; then
1588 sched_idle="no"
1589fi
7e09a9f1
JA
1590cat > $TMPC << EOF
1591#include <sched.h>
1592int main(int argc, char **argv)
1593{
1594 struct sched_param p;
1595 return sched_setscheduler(0, SCHED_IDLE, &p);
1596}
1597EOF
1598if compile_prog "" "" "SCHED_IDLE"; then
1599 sched_idle="yes"
1600fi
484b0b65 1601print_config "SCHED_IDLE" "$sched_idle"
7e09a9f1 1602
1eafa37a
JA
1603##########################################
1604# Check whether we have TCP_NODELAY
ca205a75
TK
1605if test "$tcp_nodelay" != "yes" ; then
1606 tcp_nodelay="no"
1607fi
1eafa37a 1608cat > $TMPC << EOF
a932a2cf
BVA
1609#ifdef _WIN32
1610#include <winsock2.h>
1611#else
1eafa37a
JA
1612#include <stdio.h>
1613#include <sys/types.h>
1614#include <sys/socket.h>
1615#include <netinet/tcp.h>
a932a2cf 1616#endif
1eafa37a
JA
1617int main(int argc, char **argv)
1618{
1619 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1620}
1621EOF
1622if compile_prog "" "" "TCP_NODELAY"; then
1623 tcp_nodelay="yes"
a932a2cf
BVA
1624elif compile_prog "" "-lws2_32" "TCP_NODELAY"; then
1625 tcp_nodelay="yes"
1626 LIBS="$LIBS -lws2_32"
1eafa37a 1627fi
484b0b65 1628print_config "TCP_NODELAY" "$tcp_nodelay"
1eafa37a 1629
1008602c
JA
1630##########################################
1631# Check whether we have SO_SNDBUF
ca205a75
TK
1632if test "$window_size" != "yes" ; then
1633 window_size="no"
1634fi
1008602c 1635cat > $TMPC << EOF
a932a2cf
BVA
1636#ifdef _WIN32
1637#include <winsock2.h>
1638#else
1008602c
JA
1639#include <stdio.h>
1640#include <sys/types.h>
1641#include <sys/socket.h>
1642#include <netinet/tcp.h>
a932a2cf 1643#endif
1008602c
JA
1644int main(int argc, char **argv)
1645{
1646 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1647 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1648}
1649EOF
1650if compile_prog "" "" "SO_SNDBUF"; then
1651 window_size="yes"
a932a2cf
BVA
1652elif compile_prog "" "-lws2_32" "SO_SNDBUF"; then
1653 window_size="yes"
1654 LIBS="$LIBS -lws2_32"
1008602c 1655fi
484b0b65 1656print_config "Net engine window_size" "$window_size"
1008602c 1657
e5f34d95
JA
1658##########################################
1659# Check whether we have TCP_MAXSEG
ca205a75
TK
1660if test "$mss" != "yes" ; then
1661 mss="no"
1662fi
e5f34d95 1663cat > $TMPC << EOF
a932a2cf
BVA
1664#ifdef _WIN32
1665#include <winsock2.h>
1666#else
e5f34d95
JA
1667#include <stdio.h>
1668#include <sys/types.h>
1669#include <sys/socket.h>
1670#include <netinet/tcp.h>
1671#include <arpa/inet.h>
1672#include <netinet/in.h>
a932a2cf 1673#endif
e5f34d95
JA
1674int main(int argc, char **argv)
1675{
1676 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1677}
1678EOF
1679if compile_prog "" "" "TCP_MAXSEG"; then
1680 mss="yes"
a932a2cf
BVA
1681elif compile_prog "" "-lws2_32" "TCP_MAXSEG"; then
1682 mss="yes"
1683 LIBS="$LIBS -lws2_32"
e5f34d95 1684fi
484b0b65 1685print_config "TCP_MAXSEG" "$mss"
e5f34d95 1686
38b9354a
JA
1687##########################################
1688# Check whether we have RLIMIT_MEMLOCK
ca205a75
TK
1689if test "$rlimit_memlock" != "yes" ; then
1690 rlimit_memlock="no"
1691fi
38b9354a
JA
1692cat > $TMPC << EOF
1693#include <sys/time.h>
1694#include <sys/resource.h>
1695int main(int argc, char **argv)
1696{
1697 struct rlimit rl;
1698 return getrlimit(RLIMIT_MEMLOCK, &rl);
1699}
1700EOF
1701if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1702 rlimit_memlock="yes"
1703fi
484b0b65 1704print_config "RLIMIT_MEMLOCK" "$rlimit_memlock"
38b9354a 1705
07fc0acd
JA
1706##########################################
1707# Check whether we have pwritev/preadv
ca205a75
TK
1708if test "$pwritev" != "yes" ; then
1709 pwritev="no"
1710fi
07fc0acd
JA
1711cat > $TMPC << EOF
1712#include <stdio.h>
1713#include <sys/uio.h>
1714int main(int argc, char **argv)
1715{
1716 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1717}
1718EOF
1719if compile_prog "" "" "pwritev"; then
1720 pwritev="yes"
1721fi
484b0b65 1722print_config "pwritev/preadv" "$pwritev"
07fc0acd 1723
2cafffbe
JA
1724##########################################
1725# Check whether we have pwritev2/preadv2
ca205a75
TK
1726if test "$pwritev2" != "yes" ; then
1727 pwritev2="no"
1728fi
2cafffbe
JA
1729cat > $TMPC << EOF
1730#include <stdio.h>
1731#include <sys/uio.h>
1732int main(int argc, char **argv)
1733{
1734 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1735}
1736EOF
1737if compile_prog "" "" "pwritev2"; then
1738 pwritev2="yes"
1739fi
484b0b65 1740print_config "pwritev2/preadv2" "$pwritev2"
2cafffbe 1741
ecad55e9
JA
1742##########################################
1743# Check whether we have the required functions for ipv6
ca205a75
TK
1744if test "$ipv6" != "yes" ; then
1745 ipv6="no"
1746fi
ecad55e9 1747cat > $TMPC << EOF
a932a2cf
BVA
1748#ifdef _WIN32
1749#include <winsock2.h>
1750#include <ws2tcpip.h>
1751#else
ecad55e9
JA
1752#include <sys/types.h>
1753#include <sys/socket.h>
d219028d 1754#include <netinet/in.h>
ecad55e9 1755#include <netdb.h>
a932a2cf 1756#endif
ecad55e9
JA
1757#include <stdio.h>
1758int main(int argc, char **argv)
1759{
1760 struct addrinfo hints;
1761 struct in6_addr addr;
1762 int ret;
1763
1764 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1765 freeaddrinfo(NULL);
1766 printf("%s\n", gai_strerror(ret));
1767 addr = in6addr_any;
1768 return 0;
1769}
1770EOF
1771if compile_prog "" "" "ipv6"; then
1772 ipv6="yes"
1773fi
484b0b65 1774print_config "IPv6 helpers" "$ipv6"
07fc0acd 1775
c2f6a13d
LMB
1776##########################################
1777# check for http
1778if test "$http" != "yes" ; then
1779 http="no"
1780fi
9ee669fa
DD
1781# check for openssl >= 1.1.0, which uses an opaque HMAC_CTX pointer
1782cat > $TMPC << EOF
1783#include <curl/curl.h>
1784#include <openssl/hmac.h>
1785
1786int main(int argc, char **argv)
1787{
1788 CURL *curl;
1789 HMAC_CTX *ctx;
1790
1791 curl = curl_easy_init();
1792 curl_easy_cleanup(curl);
1793
1794 ctx = HMAC_CTX_new();
1795 HMAC_CTX_reset(ctx);
1796 HMAC_CTX_free(ctx);
1797 return 0;
1798}
1799EOF
1800# openssl < 1.1.0 uses the HMAC_CTX type directly
1801cat > $TMPC2 << EOF
1802#include <curl/curl.h>
1803#include <openssl/hmac.h>
1804
1805int main(int argc, char **argv)
1806{
1807 CURL *curl;
1808 HMAC_CTX ctx;
1809
1810 curl = curl_easy_init();
1811 curl_easy_cleanup(curl);
1812
1813 HMAC_CTX_init(&ctx);
1814 HMAC_CTX_cleanup(&ctx);
1815 return 0;
1816}
1817EOF
1818if test "$disable_http" != "yes"; then
1819 HTTP_LIBS="-lcurl -lssl -lcrypto"
1820 if compile_prog "" "$HTTP_LIBS" "curl-new-ssl"; then
b61a5f46 1821 output_sym "CONFIG_HAVE_OPAQUE_HMAC_CTX"
9ee669fa 1822 http="yes"
9ee669fa
DD
1823 elif mv $TMPC2 $TMPC && compile_prog "" "$HTTP_LIBS" "curl-old-ssl"; then
1824 http="yes"
0290c589 1825 fi
c2f6a13d
LMB
1826fi
1827print_config "http engine" "$http"
1828
d5f9b0ea
IF
1829##########################################
1830# check for rados
1831if test "$rados" != "yes" ; then
1832 rados="no"
1833fi
1834cat > $TMPC << EOF
1835#include <rados/librados.h>
1836
1837int main(int argc, char **argv)
1838{
1839 rados_t cluster;
1840 rados_ioctx_t io_ctx;
1841 const char cluster_name[] = "ceph";
1842 const char user_name[] = "client.admin";
1843 const char pool[] = "rados";
1844
1845 /* The rados_create2 signature required was only introduced in ceph 0.65 */
1846 rados_create2(&cluster, cluster_name, user_name, 0);
1847 rados_ioctx_create(cluster, pool, &io_ctx);
1848
1849 return 0;
1850}
1851EOF
1852if test "$disable_rados" != "yes" && compile_prog "" "-lrados" "rados"; then
d5f9b0ea
IF
1853 rados="yes"
1854fi
1855print_config "Rados engine" "$rados"
1856
fc5c0345
DG
1857##########################################
1858# check for rbd
ca205a75
TK
1859if test "$rbd" != "yes" ; then
1860 rbd="no"
1861fi
fc5c0345
DG
1862cat > $TMPC << EOF
1863#include <rbd/librbd.h>
1864
1865int main(int argc, char **argv)
1866{
fc5c0345
DG
1867 rados_t cluster;
1868 rados_ioctx_t io_ctx;
fb9bc6e3
SW
1869 const char cluster_name[] = "ceph";
1870 const char user_name[] = "client.admin";
fc5c0345 1871 const char pool[] = "rbd";
fc5c0345 1872 int major, minor, extra;
fc5c0345 1873
fb9bc6e3
SW
1874 rbd_version(&major, &minor, &extra);
1875 /* The rados_create2 signature required was only introduced in ceph 0.65 */
1876 rados_create2(&cluster, cluster_name, user_name, 0);
fc5c0345 1877 rados_ioctx_create(cluster, pool, &io_ctx);
fb9bc6e3 1878
fc5c0345
DG
1879 return 0;
1880}
1881EOF
ce18290e 1882if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
fc5c0345
DG
1883 rbd="yes"
1884fi
484b0b65 1885print_config "Rados Block Device engine" "$rbd"
fc5c0345 1886
53b6c979
PL
1887##########################################
1888# check for rbd_poll
ca205a75
TK
1889if test "$rbd_poll" != "yes" ; then
1890 rbd_poll="no"
1891fi
53b6c979
PL
1892if test "$rbd" = "yes"; then
1893cat > $TMPC << EOF
1894#include <rbd/librbd.h>
1895#include <sys/eventfd.h>
1896
1897int main(int argc, char **argv)
1898{
1899 rbd_image_t image;
1900 rbd_completion_t comp;
1901
1902 int fd = eventfd(0, EFD_NONBLOCK);
1903 rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1904 rbd_poll_io_events(image, comp, 1);
1905
1906 return 0;
1907}
1908EOF
1909if compile_prog "" "-lrbd -lrados" "rbd"; then
1910 rbd_poll="yes"
1911fi
484b0b65 1912print_config "rbd_poll" "$rbd_poll"
53b6c979
PL
1913fi
1914
903b2812 1915##########################################
6266dd72 1916# check for rbd_invalidate_cache()
ca205a75
TK
1917if test "$rbd_inval" != "yes" ; then
1918 rbd_inval="no"
1919fi
903b2812
JA
1920if test "$rbd" = "yes"; then
1921cat > $TMPC << EOF
1922#include <rbd/librbd.h>
1923
1924int main(int argc, char **argv)
1925{
1926 rbd_image_t image;
1927
1928 return rbd_invalidate_cache(image);
1929}
1930EOF
1931if compile_prog "" "-lrbd -lrados" "rbd"; then
1932 rbd_inval="yes"
1933fi
484b0b65 1934print_config "rbd_invalidate_cache" "$rbd_inval"
903b2812
JA
1935fi
1936
2e802282
JA
1937##########################################
1938# Check whether we have setvbuf
ca205a75
TK
1939if test "$setvbuf" != "yes" ; then
1940 setvbuf="no"
1941fi
2e802282
JA
1942cat > $TMPC << EOF
1943#include <stdio.h>
1944int main(int argc, char **argv)
1945{
1946 FILE *f = NULL;
1947 char buf[80];
1948 setvbuf(f, buf, _IOFBF, sizeof(buf));
1949 return 0;
1950}
1951EOF
1952if compile_prog "" "" "setvbuf"; then
1953 setvbuf="yes"
1954fi
484b0b65 1955print_config "setvbuf" "$setvbuf"
fc5c0345 1956
bda92394 1957##########################################
6e7d7dfb 1958# check for gfapi
ca205a75
TK
1959if test "$gfapi" != "yes" ; then
1960 gfapi="no"
1961fi
6e7d7dfb 1962cat > $TMPC << EOF
1963#include <glusterfs/api/glfs.h>
1964
1965int main(int argc, char **argv)
1966{
6e7d7dfb 1967 glfs_t *g = glfs_new("foo");
1968
1969 return 0;
1970}
1971EOF
ce18290e 1972if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
6e7d7dfb 1973 gfapi="yes"
1974fi
484b0b65 1975print_config "Gluster API engine" "$gfapi"
6e7d7dfb 1976
6fa14b99 1977##########################################
ca205a75 1978# check for gfapi fadvise support, initialize with "no" only if $gfapi is set to "yes"
6876c98c 1979if test "$gfapi" = "yes" ; then
6fa14b99 1980gf_fadvise="no"
1981cat > $TMPC << EOF
1982#include <glusterfs/api/glfs.h>
1983
1984int main(int argc, char **argv)
1985{
1986 struct glfs_fd *fd;
1987 int ret = glfs_fadvise(fd, 0, 0, 1);
1988
1989 return 0;
1990}
1991EOF
6fa14b99 1992if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1993 gf_fadvise="yes"
1994fi
484b0b65 1995print_config "Gluster API use fadvise" "$gf_fadvise"
6876c98c
JA
1996fi
1997
ce4d13ca
JA
1998##########################################
1999# check for newer gfapi
2000if test "$gfapi" = "yes" ; then
2001gf_new="no"
2002cat > $TMPC << EOF
2003#include <glusterfs/api/glfs.h>
2004
2005int main(int argc, char **argv)
2006{
2007 return glfs_fsync(NULL, NULL, NULL) && glfs_ftruncate(NULL, 0, NULL, NULL);
2008}
2009EOF
2010if compile_prog "" "-lgfapi -lglusterfs" "gf new api"; then
2011 gf_new="yes"
2012fi
2013print_config "Gluster new API" "$gf_new"
2014fi
2015
6876c98c
JA
2016##########################################
2017# check for gfapi trim support
ca205a75
TK
2018if test "$gf_trim" != "yes" ; then
2019 gf_trim="no"
2020fi
6876c98c
JA
2021if test "$gfapi" = "yes" ; then
2022cat > $TMPC << EOF
2023#include <glusterfs/api/glfs.h>
2024
2025int main(int argc, char **argv)
2026{
2027 return glfs_discard_async(NULL, 0, 0);
2028}
2029EOF
2030if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
2031 gf_trim="yes"
2032fi
484b0b65 2033print_config "Gluster API trim support" "$gf_trim"
6876c98c 2034fi
fc5c0345 2035
81795ce3
CE
2036##########################################
2037# Check if we support stckf on s390
ca205a75
TK
2038if test "$s390_z196_facilities" != "yes" ; then
2039 s390_z196_facilities="no"
2040fi
81795ce3
CE
2041cat > $TMPC << EOF
2042#define STFLE_BITS_Z196 45 /* various z196 facilities ... */
2043int main(int argc, char **argv)
2044{
2045 /* We want just 1 double word to be returned. */
2046 register unsigned long reg0 asm("0") = 0;
2047 unsigned long stfle_bits;
2048 asm volatile(".machine push" "\n\t"
2049 ".machine \"z9-109\"" "\n\t"
2050 "stfle %0" "\n\t"
2051 ".machine pop" "\n"
2052 : "=QS" (stfle_bits), "+d" (reg0)
2053 : : "cc");
2054
2055 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
2056 return 0;
2057 else
2058 return -1;
2059}
2060EOF
2061if compile_prog "" "" "s390_z196_facilities"; then
2062 $TMPE
6a2c9363 2063 if [ $? -eq 0 ]; then
81795ce3
CE
2064 s390_z196_facilities="yes"
2065 fi
2066fi
484b0b65 2067print_config "s390_z196_facilities" "$s390_z196_facilities"
1b10477b
MM
2068
2069##########################################
2070# Check if we have required environment variables configured for libhdfs
2071if test "$libhdfs" = "yes" ; then
2072 hdfs_conf_error=0
2073 if test "$JAVA_HOME" = "" ; then
2074 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
2075 hdfs_conf_error=1
2076 fi
2077 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
2078 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
2079 hdfs_conf_error=1
2080 fi
2081 if test "$FIO_LIBHDFS_LIB" = "" ; then
2082 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
2083 hdfs_conf_error=1
2084 fi
2085 if test "$hdfs_conf_error" = "1" ; then
d490af7f 2086 feature_not_found "libhdfs" ""
1b10477b 2087 fi
247e5436
JA
2088 FIO_HDFS_CPU=$cpu
2089 if test "$FIO_HDFS_CPU" = "x86_64" ; then
2090 FIO_HDFS_CPU="amd64"
2091 fi
1b10477b 2092fi
484b0b65 2093print_config "HDFS engine" "$libhdfs"
1b10477b 2094
b8116a87
DE
2095##########################################
2096# Check whether we have MTD
ca205a75
TK
2097if test "$mtd" != "yes" ; then
2098 mtd="no"
2099fi
b8116a87 2100cat > $TMPC << EOF
0e1c454a 2101#include <string.h>
b8116a87
DE
2102#include <mtd/mtd-user.h>
2103#include <sys/ioctl.h>
2104int main(int argc, char **argv)
2105{
0e1c454a 2106 struct mtd_write_req ops;
b8116a87 2107 struct mtd_info_user info;
0e1c454a 2108 memset(&ops, 0, sizeof(ops));
400cd0ff 2109 info.type = MTD_MLCNANDFLASH;
b8116a87
DE
2110 return ioctl(0, MEMGETINFO, &info);
2111}
2112EOF
2113if compile_prog "" "" "mtd"; then
2114 mtd="yes"
2115fi
484b0b65 2116print_config "MTD" "$mtd"
b8116a87 2117
3ee2a3c1
DJ
2118##########################################
2119# Check whether we have libpmem
ca205a75
TK
2120if test "$libpmem" != "yes" ; then
2121 libpmem="no"
2122fi
3ee2a3c1
DJ
2123cat > $TMPC << EOF
2124#include <libpmem.h>
67719e13 2125#include <stdlib.h>
3ee2a3c1
DJ
2126int main(int argc, char **argv)
2127{
2128 int rc;
8ca01e0c 2129 rc = pmem_is_pmem(NULL, 0);
3ee2a3c1
DJ
2130 return 0;
2131}
2132EOF
2133if compile_prog "" "-lpmem" "libpmem"; then
2134 libpmem="yes"
2135fi
484b0b65 2136print_config "libpmem" "$libpmem"
3ee2a3c1 2137
67719e13
ŁS
2138##########################################
2139# Check whether libpmem's version >= 1.5
2140if test "$libpmem1_5" != "yes" ; then
2141 libpmem1_5="no"
2142fi
2143if test "$libpmem" = "yes"; then
2144 cat > $TMPC << EOF
2145#include <libpmem.h>
2146#include <stdlib.h>
2147int main(int argc, char **argv)
2148{
2149 pmem_memcpy(NULL, NULL, NULL, NULL);
2150 return 0;
2151}
2152EOF
2153 if compile_prog "" "-lpmem" "libpmem1_5"; then
2154 libpmem1_5="yes"
2155 fi
2156fi
2157print_config "libpmem1_5" "$libpmem1_5"
2158
3ee2a3c1
DJ
2159##########################################
2160# Check whether we have libpmemblk
cf8775b8 2161# libpmem is a prerequisite
ca205a75
TK
2162if test "$libpmemblk" != "yes" ; then
2163 libpmemblk="no"
2164fi
cf8775b8
RE
2165if test "$libpmem" = "yes"; then
2166 cat > $TMPC << EOF
3ee2a3c1
DJ
2167#include <libpmemblk.h>
2168int main(int argc, char **argv)
2169{
cf8775b8
RE
2170 PMEMblkpool *pbp;
2171 pbp = pmemblk_open("", 0);
3ee2a3c1
DJ
2172 return 0;
2173}
2174EOF
cf8775b8
RE
2175 if compile_prog "" "-lpmemblk" "libpmemblk"; then
2176 libpmemblk="yes"
cf8775b8 2177 fi
3ee2a3c1 2178fi
484b0b65 2179print_config "libpmemblk" "$libpmemblk"
3ee2a3c1 2180
67719e13 2181# Choose libpmem-based ioengines
3ee2a3c1
DJ
2182if test "$libpmem" = "yes" && test "$disable_pmem" = "no"; then
2183 devdax="yes"
67719e13
ŁS
2184 if test "$libpmem1_5" = "yes"; then
2185 pmem="yes"
2186 fi
3ee2a3c1
DJ
2187 if test "$libpmemblk" = "yes"; then
2188 pmemblk="yes"
2189 fi
2190fi
2191
43f3cec2
BB
2192##########################################
2193# Report whether pmemblk engine is enabled
363a5f65 2194print_config "PMDK pmemblk engine" "$pmemblk"
43f3cec2 2195
cbb15e42
DJ
2196##########################################
2197# Report whether dev-dax engine is enabled
363a5f65 2198print_config "PMDK dev-dax engine" "$devdax"
cbb15e42 2199
ae0db592
TI
2200##########################################
2201# Report whether libpmem engine is enabled
363a5f65 2202print_config "PMDK libpmem engine" "$pmem"
ae0db592 2203
a40e7a59
GB
2204##########################################
2205# Check whether we support DDN's IME
2206if test "$libime" != "yes" ; then
2207 libime="no"
2208fi
2209cat > $TMPC << EOF
2210#include <ime_native.h>
2211int main(int argc, char **argv)
2212{
2213 int rc;
2214 ime_native_init();
2215 rc = ime_native_finalize();
2216 return 0;
2217}
2218EOF
2219if compile_prog "-I${ime_path}/include" "-L${ime_path}/lib -lim_client" "libime"; then
2220 libime="yes"
2221 CFLAGS="-I${ime_path}/include $CFLAGS"
2222 LDFLAGS="-Wl,-rpath ${ime_path}/lib -L${ime_path}/lib $LDFLAGS"
2223 LIBS="-lim_client $LIBS"
2224fi
2225print_config "DDN's Infinite Memory Engine" "$libime"
2226
247ef2aa 2227##########################################
d490af7f
SW
2228# Check if we have libiscsi
2229if test "$libiscsi" != "no" ; then
162f8c2a 2230 if check_min_lib_version libiscsi 1.9.0; then
247ef2aa
KZ
2231 libiscsi="yes"
2232 libiscsi_cflags=$(pkg-config --cflags libiscsi)
2233 libiscsi_libs=$(pkg-config --libs libiscsi)
2234 else
247ef2aa
KZ
2235 libiscsi="no"
2236 fi
2237fi
2238print_config "iscsi engine" "$libiscsi"
2239
d643a1e2 2240##########################################
d490af7f
SW
2241# Check if we have libnbd (for NBD support)
2242if test "$libnbd" != "no" ; then
162f8c2a 2243 if check_min_lib_version libnbd 0.9.8; then
d643a1e2
RJ
2244 libnbd="yes"
2245 libnbd_cflags=$(pkg-config --cflags libnbd)
2246 libnbd_libs=$(pkg-config --libs libnbd)
2247 else
d643a1e2
RJ
2248 libnbd="no"
2249 fi
2250fi
2251print_config "NBD engine" "$libnbd"
2252
c363fdd7
JL
2253##########################################
2254# check for dfs (DAOS File System)
2255if test "$dfs" != "no" ; then
2256 cat > $TMPC << EOF
2257#include <fcntl.h>
2258#include <daos.h>
2259#include <daos_fs.h>
2260
2261int main(int argc, char **argv)
2262{
2263 daos_handle_t poh;
2264 daos_handle_t coh;
2265 dfs_t *dfs;
2266
2267 (void) dfs_mount(poh, coh, O_RDWR, &dfs);
2268
2269 return 0;
2270}
2271EOF
2272 if compile_prog "" "-luuid -ldfs -ldaos" "dfs"; then
2273 dfs="yes"
2274 else
2275 dfs="no"
2276 fi
2277fi
2278print_config "DAOS File System (dfs) Engine" "$dfs"
2279
bda92394 2280##########################################
b470a02c
SC
2281# Check if we have lex/yacc available
2282yacc="no"
e7b2c7a3 2283yacc_is_bison="no"
b470a02c
SC
2284lex="no"
2285arith="no"
de26b824 2286if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
cf6dd80e 2287if test "$targetos" != "SunOS" ; then
63c25ff8 2288if has lex; then
b470a02c
SC
2289 lex="yes"
2290fi
63c25ff8 2291if has bison; then
b470a02c 2292 yacc="yes"
7e0049e9 2293 yacc_is_bison="yes"
63c25ff8
SW
2294elif has yacc; then
2295 yacc="yes"
b470a02c
SC
2296fi
2297if test "$yacc" = "yes" && test "$lex" = "yes" ; then
2298 arith="yes"
2299fi
2300
2301if test "$arith" = "yes" ; then
2302cat > $TMPC << EOF
2303extern int yywrap(void);
2304
2305int main(int argc, char **argv)
2306{
2307 yywrap();
2308 return 0;
2309}
2310EOF
63c25ff8
SW
2311if compile_prog "" "-lfl" "flex"; then
2312 LIBS="-lfl $LIBS"
2313elif compile_prog "" "-ll" "lex"; then
719cda03 2314 LIBS="-ll $LIBS"
b470a02c
SC
2315else
2316 arith="no"
2317fi
2318fi
cf6dd80e 2319fi
a655bbc4 2320fi
b470a02c 2321
63bda378
JA
2322# Check if lex fails using -o
2323if test "$arith" = "yes" ; then
daf705b5
JA
2324if test "$force_no_lex_o" = "yes" ; then
2325 lex_use_o="no"
2326else
63c25ff8 2327if lex -o lex.yy.c exp/expression-parser.l 2> /dev/null; then
63bda378
JA
2328 lex_use_o="yes"
2329else
2330 lex_use_o="no"
2331fi
2332fi
daf705b5 2333fi
63bda378 2334
484b0b65 2335print_config "lex/yacc for arithmetic" "$arith"
b470a02c 2336
aae599ba
JA
2337##########################################
2338# Check whether we have setmntent/getmntent
ca205a75
TK
2339if test "$getmntent" != "yes" ; then
2340 getmntent="no"
2341fi
aae599ba
JA
2342cat > $TMPC << EOF
2343#include <stdio.h>
2344#include <mntent.h>
2345int main(int argc, char **argv)
2346{
2347 FILE *mtab = setmntent(NULL, "r");
2348 struct mntent *mnt = getmntent(mtab);
1581b82a 2349 endmntent(mtab);
aae599ba
JA
2350 return 0;
2351}
2352EOF
2353if compile_prog "" "" "getmntent"; then
2354 getmntent="yes"
2355fi
484b0b65 2356print_config "getmntent" "$getmntent"
aae599ba 2357
e7e136da
TK
2358##########################################
2359# Check whether we have getmntinfo
b765bec0
TK
2360# These are originally added for BSDs, but may also work
2361# on other operating systems with getmntinfo(3).
2362
2363# getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
2364# Note that NetBSD needs -Werror to catch warning as error.
ca205a75
TK
2365if test "$getmntinfo" != "yes" ; then
2366 getmntinfo="no"
2367fi
e7e136da
TK
2368cat > $TMPC << EOF
2369#include <stdio.h>
2370#include <sys/param.h>
2371#include <sys/mount.h>
2372int main(int argc, char **argv)
2373{
9ada751d 2374 struct statfs *st;
e7e136da
TK
2375 return getmntinfo(&st, MNT_NOWAIT);
2376}
2377EOF
b765bec0 2378if compile_prog "-Werror" "" "getmntinfo"; then
e7e136da
TK
2379 getmntinfo="yes"
2380fi
484b0b65 2381print_config "getmntinfo" "$getmntinfo"
e7e136da 2382
b765bec0 2383# getmntinfo(3) for NetBSD.
ca205a75
TK
2384if test "$getmntinfo_statvfs" != "yes" ; then
2385 getmntinfo_statvfs="no"
2386fi
b765bec0
TK
2387cat > $TMPC << EOF
2388#include <stdio.h>
2389#include <sys/statvfs.h>
2390int main(int argc, char **argv)
2391{
2392 struct statvfs *st;
2393 return getmntinfo(&st, MNT_NOWAIT);
2394}
2395EOF
2396# Skip the test if the one with statfs arg is detected.
2397if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
2398 getmntinfo_statvfs="yes"
484b0b65 2399 print_config "getmntinfo_statvfs" "$getmntinfo_statvfs"
b765bec0
TK
2400fi
2401
5018f79f
AH
2402##########################################
2403# Check whether we have _Static_assert
ca205a75
TK
2404if test "$static_assert" != "yes" ; then
2405 static_assert="no"
2406fi
5018f79f
AH
2407cat > $TMPC << EOF
2408#include <assert.h>
94815a5c 2409#include <stdlib.h>
51b4c81e 2410#include <stddef.h>
94815a5c
JA
2411
2412struct foo {
2413 int a, b;
2414};
2415
5018f79f
AH
2416int main(int argc, char **argv)
2417{
94815a5c 2418 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
5018f79f
AH
2419 return 0 ;
2420}
2421EOF
2422if compile_prog "" "" "static_assert"; then
2423 static_assert="yes"
2424fi
484b0b65 2425print_config "Static Assert" "$static_assert"
e39c0676
JA
2426
2427##########################################
2428# Check whether we have bool / stdbool.h
ca205a75
TK
2429if test "$have_bool" != "yes" ; then
2430 have_bool="no"
2431fi
e39c0676
JA
2432cat > $TMPC << EOF
2433#include <stdbool.h>
2434int main(int argc, char **argv)
2435{
2436 bool var = true;
2437 return var != false;
2438}
2439EOF
2440if compile_prog "" "" "bool"; then
2441 have_bool="yes"
2442fi
484b0b65 2443print_config "bool" "$have_bool"
e39c0676 2444
b29c71c4
JA
2445##########################################
2446# Check whether we have strndup()
107ad008 2447strndup="no"
b29c71c4
JA
2448cat > $TMPC << EOF
2449#include <string.h>
2450#include <stdlib.h>
2451int main(int argc, char **argv)
2452{
2453 char *res = strndup("test string", 8);
2454
2455 free(res);
2456 return 0;
2457}
2458EOF
2459if compile_prog "" "" "strndup"; then
2460 strndup="yes"
2461fi
2462print_config "strndup" "$strndup"
2463
214e2d56 2464##########################################
0ffccc21
BVA
2465# <valgrind/drd.h> probe
2466# Note: presence of <valgrind/drd.h> implies that <valgrind/valgrind.h> is
2467# also available but not the other way around.
2468if test "$valgrind_dev" != "yes" ; then
2469 valgrind_dev="no"
2470fi
2471cat > $TMPC << EOF
2472#include <valgrind/drd.h>
2473int main(int argc, char **argv)
2474{
2475 return 0;
2476}
2477EOF
2478if compile_prog "" "" "valgrind_dev"; then
2479 valgrind_dev="yes"
2480fi
2481print_config "Valgrind headers" "$valgrind_dev"
2482
236d23a8 2483if test "$targetos" = "Linux" ; then
a76e1995
BVA
2484##########################################
2485# <linux/blkzoned.h> probe
2486if test "$linux_blkzoned" != "yes" ; then
2487 linux_blkzoned="no"
2488fi
2489cat > $TMPC << EOF
2490#include <linux/blkzoned.h>
2491int main(int argc, char **argv)
2492{
2493 return 0;
2494}
2495EOF
2496if compile_prog "" "" "linux_blkzoned"; then
2497 linux_blkzoned="yes"
2498fi
2499print_config "Zoned block device support" "$linux_blkzoned"
2500
236d23a8
SK
2501##########################################
2502# Check BLK_ZONE_REP_CAPACITY
2503cat > $TMPC << EOF
2504#include <linux/blkzoned.h>
2505int main(void)
2506{
2507 return BLK_ZONE_REP_CAPACITY;
2508}
2509EOF
2510if compile_prog "" "" "blkzoned report capacity"; then
2511 output_sym "CONFIG_HAVE_REP_CAPACITY"
2512 rep_capacity="yes"
2513else
2514 rep_capacity="no"
2515fi
2516print_config "Zoned block device capacity" "$rep_capacity"
2517fi
2518
56a19325
DF
2519##########################################
2520# libzbc probe
56a19325
DF
2521cat > $TMPC << EOF
2522#include <libzbc/zbc.h>
2523int main(int argc, char **argv)
2524{
2525 struct zbc_device *dev = NULL;
2526
2527 return zbc_open("foo=bar", O_RDONLY, &dev);
2528}
2529EOF
38551c04
DF
2530if test "$libzbc" != "no" ; then
2531 if compile_prog "" "-lzbc" "libzbc"; then
162f8c2a
DF
2532 libzbc="yes"
2533 if ! check_min_lib_version libzbc 5; then
38551c04
DF
2534 libzbc="no"
2535 fi
56a19325 2536 else
38551c04 2537 if test "$libzbc" = "yes" ; then
56a19325 2538 feature_not_found "libzbc" "libzbc or libzbc/zbc.h"
38551c04
DF
2539 fi
2540 libzbc="no"
56a19325 2541 fi
56a19325
DF
2542fi
2543print_config "libzbc engine" "$libzbc"
2544
a76e1995 2545##########################################
214e2d56 2546# check march=armv8-a+crc+crypto
ca205a75
TK
2547if test "$march_armv8_a_crc_crypto" != "yes" ; then
2548 march_armv8_a_crc_crypto="no"
2549fi
214e2d56 2550if test "$cpu" = "arm64" ; then
2551 cat > $TMPC <<EOF
9b153dc2
TT
2552#include <arm_acle.h>
2553#include <arm_neon.h>
58828d07 2554#include <sys/auxv.h>
9b153dc2 2555
214e2d56 2556int main(void)
2557{
58828d07
SW
2558 /* Can we also do a runtime probe? */
2559#if __linux__
2560 return getauxval(AT_HWCAP);
2561#else
2562# error "Don't know how to do runtime probe for ARM CRC32c"
2563#endif
214e2d56 2564}
2565EOF
58828d07 2566 if compile_prog "-march=armv8-a+crc+crypto" "" "ARM CRC32c"; then
214e2d56 2567 march_armv8_a_crc_crypto="yes"
58828d07 2568 CFLAGS="$CFLAGS -march=armv8-a+crc+crypto"
9f75af77 2569 march_set="yes"
214e2d56 2570 fi
2571fi
484b0b65 2572print_config "march_armv8_a_crc_crypto" "$march_armv8_a_crc_crypto"
214e2d56 2573
03553853
YR
2574##########################################
2575# cuda probe
d490af7f 2576if test "$cuda" != "no" ; then
03553853
YR
2577cat > $TMPC << EOF
2578#include <cuda.h>
2579int main(int argc, char **argv)
2580{
2581 return cuInit(0);
2582}
2583EOF
d490af7f
SW
2584 if compile_prog "" "-lcuda" "cuda"; then
2585 cuda="yes"
2586 LIBS="-lcuda $LIBS"
2587 else
2588 if test "$cuda" = "yes" ; then
2589 feature_not_found "cuda" ""
2590 fi
2591 cuda="no"
2592 fi
03553853 2593fi
484b0b65 2594print_config "cuda" "$cuda"
214e2d56 2595
10756b2c
BS
2596##########################################
2597# libcufile probe
2598if test "$libcufile" != "no" ; then
2599cat > $TMPC << EOF
2600#include <cufile.h>
2601
2602int main(int argc, char* argv[]) {
2603 cuFileDriverOpen();
2604 return 0;
2605}
2606EOF
2607 if compile_prog "" "-lcuda -lcudart -lcufile" "libcufile"; then
2608 libcufile="yes"
2609 LIBS="-lcuda -lcudart -lcufile $LIBS"
2610 else
2611 if test "$libcufile" = "yes" ; then
2612 feature_not_found "libcufile" ""
2613 fi
2614 libcufile="no"
2615 fi
2616fi
2617print_config "libcufile" "$libcufile"
2618
a817dc3b
JA
2619##########################################
2620# check for cc -march=native
2621build_native="no"
2622cat > $TMPC << EOF
2623int main(int argc, char **argv)
2624{
2625 return 0;
2626}
2627EOF
c922e0b0
SW
2628if test "$disable_native" = "no" && test "$disable_opt" != "yes" && \
2629 compile_prog "-march=native" "" "march=native"; then
a817dc3b
JA
2630 build_native="yes"
2631fi
2632print_config "Build march=native" "$build_native"
2633
b8b0e1ee
TK
2634##########################################
2635# check for -lcunit
2636if test "$cunit" != "yes" ; then
2637 cunit="no"
2638fi
2639cat > $TMPC << EOF
2640#include <CUnit/CUnit.h>
2641#include <CUnit/Basic.h>
2642int main(void)
2643{
2644 if (CU_initialize_registry() != CUE_SUCCESS)
2645 return CU_get_error();
2646 CU_basic_set_mode(CU_BRM_VERBOSE);
2647 CU_basic_run_tests();
2648 CU_cleanup_registry();
2649 return CU_get_error();
2650}
2651EOF
2652if compile_prog "" "-lcunit" "CUnit"; then
2653 cunit="yes"
2654fi
2655print_config "CUnit" "$cunit"
2656
57fa61f0
JA
2657##########################################
2658# check for __kernel_rwf_t
2659__kernel_rwf_t="no"
2660cat > $TMPC << EOF
2661#include <linux/fs.h>
2662int main(int argc, char **argv)
2663{
2664 __kernel_rwf_t x;
2665 x = 0;
2666 return x;
2667}
2668EOF
2669if compile_prog "" "" "__kernel_rwf_t"; then
2670 __kernel_rwf_t="yes"
2671fi
2672print_config "__kernel_rwf_t" "$__kernel_rwf_t"
2673
71144e67 2674##########################################
5ad91012 2675# check if gcc has -Wimplicit-fallthrough=2
71144e67
JA
2676fallthrough="no"
2677cat > $TMPC << EOF
2678int main(int argc, char **argv)
2679{
2680 return 0;
2681}
2682EOF
5ad91012 2683if compile_prog "-Wimplicit-fallthrough=2" "" "-Wimplicit-fallthrough=2"; then
71144e67
JA
2684 fallthrough="yes"
2685fi
5ad91012 2686print_config "-Wimplicit-fallthrough=2" "$fallthrough"
71144e67 2687
ff547caa
KB
2688##########################################
2689# check for MADV_HUGEPAGE support
2690if test "$thp" != "yes" ; then
2691 thp="no"
2692fi
2693if test "$esx" != "yes" ; then
2694 cat > $TMPC <<EOF
2695#include <sys/mman.h>
2696int main(void)
2697{
2698 return madvise(0, 0x1000, MADV_HUGEPAGE);
2699}
2700EOF
2701 if compile_prog "" "" "thp" ; then
2702 thp=yes
2703 else
2704 if test "$thp" = "yes" ; then
2705 feature_not_found "Transparent Huge Page" ""
2706 fi
2707 thp=no
2708 fi
2709fi
2710print_config "MADV_HUGEPAGE" "$thp"
2711
de5ed0e4
JA
2712##########################################
2713# check for gettid()
2714gettid="no"
2715cat > $TMPC << EOF
2716#include <unistd.h>
2717int main(int argc, char **argv)
2718{
2719 return gettid();
2720}
2721EOF
2722if compile_prog "" "" "gettid"; then
2723 gettid="yes"
2724fi
2725print_config "gettid" "$gettid"
2726
95f31f7d
TK
2727##########################################
2728# check for statx(2) support by libc
2729statx="no"
2730cat > $TMPC << EOF
2731#include <unistd.h>
2732#include <sys/stat.h>
2733
2734int main(int argc, char **argv)
2735{
2736 struct statx st;
2737 return statx(-1, *argv, 0, 0, &st);
2738}
2739EOF
2740if compile_prog "" "" "statx"; then
2741 statx="yes"
2742fi
2743print_config "statx(2)/libc" "$statx"
2744
2745##########################################
2746# check for statx(2) support by kernel
2747statx_syscall="no"
2748cat > $TMPC << EOF
2749#include <unistd.h>
2750#include <linux/stat.h>
2751#include <sys/stat.h>
2752#include <sys/syscall.h>
2753
2754static int _statx(int dfd, const char *pathname, int flags, unsigned int mask,
2755 struct statx *buffer)
2756{
2757 return syscall(__NR_statx, dfd, pathname, flags, mask, buffer);
2758}
2759
2760int main(int argc, char **argv)
2761{
2762 struct statx st;
2763 return _statx(-1, *argv, 0, 0, &st);
2764}
2765EOF
2766if compile_prog "" "" "statx_syscall"; then
2767 statx_syscall="yes"
2768fi
2769print_config "statx(2)/syscall" "$statx_syscall"
2770
76bc30ca
SW
2771##########################################
2772# check for Windows PDB generation support
2773if test "pdb" != "no" ; then
2774 cat > $TMPC <<EOF
2775int main(void)
2776{
2777 return 0;
2778}
2779EOF
2780 if compile_prog "-g -gcodeview" "-fuse-ld=lld -Wl,-pdb,$TMPO" "pdb"; then
2781 pdb=yes
2782 else
2783 if test "$pdb" = "yes"; then
2784 feature_not_found "PDB" "clang and lld"
2785 fi
2786 pdb=no
2787 fi
2788else
2789 pdb=no
2790fi
2791print_config "Windows PDB generation" "$pdb"
696378af
BVA
2792
2793##########################################
2794# check for timerfd support
2795timerfd_create="no"
ffaaf8ab 2796if test "$esx" != "yes" ; then
696378af
BVA
2797cat > $TMPC << EOF
2798#include <sys/time.h>
2799#include <sys/timerfd.h>
2800
2801int main(int argc, char **argv)
2802{
2803 return timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
2804}
2805EOF
ffaaf8ab
BRH
2806 if compile_prog "" "" "timerfd_create"; then
2807 timerfd_create="yes"
2808 fi
696378af
BVA
2809fi
2810print_config "timerfd_create" "$timerfd_create"
2811
67bf9823
JA
2812#############################################################################
2813
67bf9823 2814if test "$wordsize" = "64" ; then
4feafb1e 2815 output_sym "CONFIG_64BIT"
67bf9823 2816elif test "$wordsize" = "32" ; then
4feafb1e 2817 output_sym "CONFIG_32BIT"
67bf9823 2818else
d7145a78 2819 fatal "Unknown wordsize!"
67bf9823 2820fi
0dcebdf4 2821if test "$bigendian" = "yes" ; then
4feafb1e 2822 output_sym "CONFIG_BIG_ENDIAN"
0dcebdf4 2823else
4feafb1e 2824 output_sym "CONFIG_LITTLE_ENDIAN"
0dcebdf4 2825fi
3989b143
JA
2826if test "$zlib" = "yes" ; then
2827 output_sym "CONFIG_ZLIB"
2828fi
67bf9823 2829if test "$libaio" = "yes" ; then
4feafb1e 2830 output_sym "CONFIG_LIBAIO"
7d42e66e
KK
2831 if test "$libaio_rw_flags" = "yes" ; then
2832 output_sym "CONFIG_LIBAIO_RW_FLAGS"
2833 fi
67bf9823
JA
2834fi
2835if test "$posix_aio" = "yes" ; then
4feafb1e 2836 output_sym "CONFIG_POSIXAIO"
67bf9823
JA
2837fi
2838if test "$posix_aio_fsync" = "yes" ; then
4feafb1e 2839 output_sym "CONFIG_POSIXAIO_FSYNC"
67bf9823 2840fi
06eac6b2
SW
2841if test "$posix_pshared" = "yes" ; then
2842 output_sym "CONFIG_PSHARED"
2843fi
78b66d32
BVA
2844if test "$pthread_condattr_setclock" = "yes" ; then
2845 output_sym "CONFIG_PTHREAD_CONDATTR_SETCLOCK"
2846fi
c31092b8
BVA
2847if test "$pthread_sigmask" = "yes" ; then
2848 output_sym "CONFIG_PTHREAD_SIGMASK"
2849fi
deb859d6
JA
2850if test "$pthread_getaffinity" = "yes" ; then
2851 output_sym "CONFIG_PTHREAD_GETAFFINITY"
2852fi
44e8e956 2853if test "$have_asprintf" = "yes" ; then
cb3b6806 2854 output_sym "CONFIG_HAVE_ASPRINTF"
44e8e956
BVA
2855fi
2856if test "$have_vasprintf" = "yes" ; then
cb3b6806 2857 output_sym "CONFIG_HAVE_VASPRINTF"
44e8e956 2858fi
67bf9823 2859if test "$linux_fallocate" = "yes" ; then
4feafb1e 2860 output_sym "CONFIG_LINUX_FALLOCATE"
67bf9823
JA
2861fi
2862if test "$posix_fallocate" = "yes" ; then
4feafb1e 2863 output_sym "CONFIG_POSIX_FALLOCATE"
67bf9823
JA
2864fi
2865if test "$fdatasync" = "yes" ; then
4feafb1e 2866 output_sym "CONFIG_FDATASYNC"
67bf9823 2867fi
52a552e2
BVA
2868if test "$pipe" = "yes" ; then
2869 output_sym "CONFIG_PIPE"
2870fi
2871if test "$pipe2" = "yes" ; then
2872 output_sym "CONFIG_PIPE2"
2873fi
15eca9aa
BVA
2874if test "$pread" = "yes" ; then
2875 output_sym "CONFIG_PREAD"
2876fi
67bf9823 2877if test "$sync_file_range" = "yes" ; then
4feafb1e 2878 output_sym "CONFIG_SYNC_FILE_RANGE"
67bf9823
JA
2879fi
2880if test "$sfaa" = "yes" ; then
4feafb1e 2881 output_sym "CONFIG_SFAA"
67bf9823 2882fi
a250edd0
JA
2883if test "$sync_sync" = "yes" ; then
2884 output_sym "CONFIG_SYNC_SYNC"
2885fi
2886if test "$cmp_swap" = "yes" ; then
2887 output_sym "CONFIG_CMP_SWAP"
2888fi
954cd73a 2889if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
4feafb1e 2890 output_sym "CONFIG_RDMA"
67bf9823 2891fi
e4c4625f
JM
2892# librpma is supported on the 'x86_64' architecture for now
2893if test "$cpu" = "x86_64" -a "$libverbs" = "yes" -a "$rdmacm" = "yes" \
2894 -a "$librpma" = "yes" -a "$libpmem" = "yes" ; then
2895 output_sym "CONFIG_LIBRPMA_APM"
2896fi
2897if test "$cpu" = "x86_64" -a "$libverbs" = "yes" -a "$rdmacm" = "yes" \
2898 -a "$librpma" = "yes" -a "$libpmem" = "yes" -a "$libprotobuf_c" = "yes" ; then
2899 output_sym "CONFIG_LIBRPMA_GPSPM"
2900fi
67bf9823 2901if test "$clock_gettime" = "yes" ; then
4feafb1e 2902 output_sym "CONFIG_CLOCK_GETTIME"
67bf9823
JA
2903fi
2904if test "$clock_monotonic" = "yes" ; then
4feafb1e 2905 output_sym "CONFIG_CLOCK_MONOTONIC"
67bf9823 2906fi
25f8227d
JA
2907if test "$clockid_t" = "yes"; then
2908 output_sym "CONFIG_CLOCKID_T"
2909fi
67bf9823 2910if test "$gettimeofday" = "yes" ; then
4feafb1e 2911 output_sym "CONFIG_GETTIMEOFDAY"
67bf9823
JA
2912fi
2913if test "$posix_fadvise" = "yes" ; then
4feafb1e 2914 output_sym "CONFIG_POSIX_FADVISE"
67bf9823
JA
2915fi
2916if test "$linux_3arg_affinity" = "yes" ; then
4feafb1e 2917 output_sym "CONFIG_3ARG_AFFINITY"
67bf9823 2918elif test "$linux_2arg_affinity" = "yes" ; then
4feafb1e 2919 output_sym "CONFIG_2ARG_AFFINITY"
67bf9823
JA
2920fi
2921if test "$strsep" = "yes" ; then
4feafb1e 2922 output_sym "CONFIG_STRSEP"
67bf9823 2923fi
9ad8da82
JA
2924if test "$strcasestr" = "yes" ; then
2925 output_sym "CONFIG_STRCASESTR"
2926fi
5ad7be56
KD
2927if test "$strlcat" = "yes" ; then
2928 output_sym "CONFIG_STRLCAT"
2929fi
67bf9823 2930if test "$getopt_long_only" = "yes" ; then
4feafb1e 2931 output_sym "CONFIG_GETOPT_LONG_ONLY"
67bf9823
JA
2932fi
2933if test "$inet_aton" = "yes" ; then
4feafb1e 2934 output_sym "CONFIG_INET_ATON"
67bf9823
JA
2935fi
2936if test "$socklen_t" = "yes" ; then
4feafb1e 2937 output_sym "CONFIG_SOCKLEN_T"
67bf9823
JA
2938fi
2939if test "$ext4_me" = "yes" ; then
4feafb1e 2940 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
67bf9823
JA
2941fi
2942if test "$linux_splice" = "yes" ; then
4feafb1e 2943 output_sym "CONFIG_LINUX_SPLICE"
67bf9823 2944fi
50206d9b 2945if test "$libnuma_v2" = "yes" ; then
4feafb1e 2946 output_sym "CONFIG_LIBNUMA"
67bf9823
JA
2947fi
2948if test "$solaris_aio" = "yes" ; then
4feafb1e 2949 output_sym "CONFIG_SOLARISAIO"
67bf9823
JA
2950fi
2951if test "$tls_thread" = "yes" ; then
4feafb1e 2952 output_sym "CONFIG_TLS_THREAD"
67bf9823 2953fi
44404c5a 2954if test "$rusage_thread" = "yes" ; then
4feafb1e 2955 output_sym "CONFIG_RUSAGE_THREAD"
67bf9823 2956fi
91f94d5b 2957if test "$gfio" = "yes" ; then
bad7e42c 2958 output_sym "CONFIG_GFIO"
91f94d5b 2959fi
c8931876
JA
2960if test "$esx" = "yes" ; then
2961 output_sym "CONFIG_ESX"
2962 output_sym "CONFIG_NO_SHM"
2963fi
7e09a9f1
JA
2964if test "$sched_idle" = "yes" ; then
2965 output_sym "CONFIG_SCHED_IDLE"
2966fi
1eafa37a
JA
2967if test "$tcp_nodelay" = "yes" ; then
2968 output_sym "CONFIG_TCP_NODELAY"
2969fi
1008602c
JA
2970if test "$window_size" = "yes" ; then
2971 output_sym "CONFIG_NET_WINDOWSIZE"
2972fi
e5f34d95
JA
2973if test "$mss" = "yes" ; then
2974 output_sym "CONFIG_NET_MSS"
2975fi
38b9354a
JA
2976if test "$rlimit_memlock" = "yes" ; then
2977 output_sym "CONFIG_RLIMIT_MEMLOCK"
2978fi
07fc0acd
JA
2979if test "$pwritev" = "yes" ; then
2980 output_sym "CONFIG_PWRITEV"
2981fi
2cafffbe
JA
2982if test "$pwritev2" = "yes" ; then
2983 output_sym "CONFIG_PWRITEV2"
2984fi
ecad55e9
JA
2985if test "$ipv6" = "yes" ; then
2986 output_sym "CONFIG_IPV6"
2987fi
c2f6a13d
LMB
2988if test "$http" = "yes" ; then
2989 output_sym "CONFIG_HTTP"
2990fi
d5f9b0ea
IF
2991if test "$rados" = "yes" ; then
2992 output_sym "CONFIG_RADOS"
2993fi
fc5c0345
DG
2994if test "$rbd" = "yes" ; then
2995 output_sym "CONFIG_RBD"
2996fi
53b6c979
PL
2997if test "$rbd_poll" = "yes" ; then
2998 output_sym "CONFIG_RBD_POLL"
2999fi
903b2812
JA
3000if test "$rbd_inval" = "yes" ; then
3001 output_sym "CONFIG_RBD_INVAL"
3002fi
2e802282
JA
3003if test "$setvbuf" = "yes" ; then
3004 output_sym "CONFIG_SETVBUF"
3005fi
81795ce3
CE
3006if test "$s390_z196_facilities" = "yes" ; then
3007 output_sym "CONFIG_S390_Z196_FACILITIES"
3008 CFLAGS="$CFLAGS -march=z9-109"
9f75af77 3009 march_set="yes"
81795ce3 3010fi
6e7d7dfb 3011if test "$gfapi" = "yes" ; then
3012 output_sym "CONFIG_GFAPI"
3013fi
6fa14b99 3014if test "$gf_fadvise" = "yes" ; then
3015 output_sym "CONFIG_GF_FADVISE"
3016fi
6876c98c
JA
3017if test "$gf_trim" = "yes" ; then
3018 output_sym "CONFIG_GF_TRIM"
3019fi
ce4d13ca
JA
3020if test "$gf_new" = "yes" ; then
3021 output_sym "CONFIG_GF_NEW_API"
3022fi
1b10477b
MM
3023if test "$libhdfs" = "yes" ; then
3024 output_sym "CONFIG_LIBHDFS"
247e5436 3025 echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
1527dc50
FB
3026 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
3027 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
3028 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
247ef2aa 3029fi
b8116a87
DE
3030if test "$mtd" = "yes" ; then
3031 output_sym "CONFIG_MTD"
3032fi
43f3cec2
BB
3033if test "$pmemblk" = "yes" ; then
3034 output_sym "CONFIG_PMEMBLK"
3035fi
cbb15e42
DJ
3036if test "$devdax" = "yes" ; then
3037 output_sym "CONFIG_LINUX_DEVDAX"
3038fi
ae0db592
TI
3039if test "$pmem" = "yes" ; then
3040 output_sym "CONFIG_LIBPMEM"
3041fi
a40e7a59
GB
3042if test "$libime" = "yes" ; then
3043 output_sym "CONFIG_IME"
3044fi
b470a02c
SC
3045if test "$arith" = "yes" ; then
3046 output_sym "CONFIG_ARITHMETIC"
e7b2c7a3 3047 if test "$yacc_is_bison" = "yes" ; then
63c25ff8 3048 echo "YACC=bison -y" >> $config_host_mak
e7b2c7a3 3049 else
63c25ff8 3050 echo "YACC=yacc" >> $config_host_mak
e7b2c7a3 3051 fi
63bda378
JA
3052 if test "$lex_use_o" = "yes" ; then
3053 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
3054 fi
b470a02c 3055fi
aae599ba
JA
3056if test "$getmntent" = "yes" ; then
3057 output_sym "CONFIG_GETMNTENT"
3058fi
e7e136da
TK
3059if test "$getmntinfo" = "yes" ; then
3060 output_sym "CONFIG_GETMNTINFO"
3061fi
b765bec0
TK
3062if test "$getmntinfo_statvfs" = "yes" ; then
3063 output_sym "CONFIG_GETMNTINFO_STATVFS"
3064fi
5018f79f
AH
3065if test "$static_assert" = "yes" ; then
3066 output_sym "CONFIG_STATIC_ASSERT"
3067fi
e39c0676
JA
3068if test "$have_bool" = "yes" ; then
3069 output_sym "CONFIG_HAVE_BOOL"
3070fi
b29c71c4
JA
3071if test "$strndup" = "yes" ; then
3072 output_sym "CONFIG_HAVE_STRNDUP"
3073fi
484817a9
JA
3074if test "$disable_opt" = "yes" ; then
3075 output_sym "CONFIG_DISABLE_OPTIMIZATIONS"
3076fi
0ffccc21
BVA
3077if test "$valgrind_dev" = "yes"; then
3078 output_sym "CONFIG_VALGRIND_DEV"
3079fi
a76e1995 3080if test "$linux_blkzoned" = "yes" ; then
b7694961 3081 output_sym "CONFIG_HAS_BLKZONED"
a76e1995 3082fi
56a19325
DF
3083if test "$libzbc" = "yes" ; then
3084 output_sym "CONFIG_LIBZBC"
3085fi
605cf82e 3086if test "$zlib" = "no" ; then
8f909424
JA
3087 echo "Consider installing zlib-dev (zlib-devel, some fio features depend on it."
3088 if test "$build_static" = "yes"; then
3089 echo "Note that some distros have separate packages for static libraries."
3090 fi
605cf82e 3091fi
58828d07
SW
3092if test "$march_armv8_a_crc_crypto" = "yes" ; then
3093 output_sym "ARCH_HAVE_CRC_CRYPTO"
3094fi
03553853
YR
3095if test "$cuda" = "yes" ; then
3096 output_sym "CONFIG_CUDA"
3097fi
10756b2c
BS
3098if test "$libcufile" = "yes" ; then
3099 output_sym "CONFIG_LIBCUFILE"
3100fi
c363fdd7
JL
3101if test "$dfs" = "yes" ; then
3102 output_sym "CONFIG_DFS"
3103fi
9f75af77 3104if test "$march_set" = "no" && test "$build_native" = "yes" ; then
a817dc3b
JA
3105 output_sym "CONFIG_BUILD_NATIVE"
3106fi
b8b0e1ee
TK
3107if test "$cunit" = "yes" ; then
3108 output_sym "CONFIG_HAVE_CUNIT"
3109fi
57fa61f0
JA
3110if test "$__kernel_rwf_t" = "yes"; then
3111 output_sym "CONFIG_HAVE_KERNEL_RWF_T"
3112fi
de5ed0e4
JA
3113if test "$gettid" = "yes"; then
3114 output_sym "CONFIG_HAVE_GETTID"
3115fi
95f31f7d
TK
3116if test "$statx" = "yes"; then
3117 output_sym "CONFIG_HAVE_STATX"
3118fi
3119if test "$statx_syscall" = "yes"; then
3120 output_sym "CONFIG_HAVE_STATX_SYSCALL"
3121fi
696378af
BVA
3122if test "$timerfd_create" = "yes"; then
3123 output_sym "CONFIG_HAVE_TIMERFD_CREATE"
3124fi
71144e67
JA
3125if test "$fallthrough" = "yes"; then
3126 CFLAGS="$CFLAGS -Wimplicit-fallthrough"
3127fi
ff547caa
KB
3128if test "$thp" = "yes" ; then
3129 output_sym "CONFIG_HAVE_THP"
3130fi
247ef2aa
KZ
3131if test "$libiscsi" = "yes" ; then
3132 output_sym "CONFIG_LIBISCSI"
3133 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
3134 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
3135 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
3136fi
d643a1e2
RJ
3137if test "$libnbd" = "yes" ; then
3138 output_sym "CONFIG_LIBNBD"
3139 echo "CONFIG_LIBNBD=m" >> $config_host_mak
3140 echo "LIBNBD_CFLAGS=$libnbd_cflags" >> $config_host_mak
3141 echo "LIBNBD_LIBS=$libnbd_libs" >> $config_host_mak
3142fi
5a8a6a03 3143if test "$dynamic_engines" = "yes" ; then
a504a390 3144 output_sym "CONFIG_DYNAMIC_ENGINES"
5a8a6a03 3145fi
76bc30ca
SW
3146if test "$pdb" = yes; then
3147 output_sym "CONFIG_PDB"
3148fi
3149
5a8a6a03 3150print_config "Lib-based ioengines dynamic" "$dynamic_engines"
01fe773d
JD
3151cat > $TMPC << EOF
3152int main(int argc, char **argv)
3153{
3154 return 0;
3155}
3156EOF
ab6e4714
SW
3157if test "$disable_tcmalloc" != "yes"; then
3158 if compile_prog "" "-ltcmalloc" "tcmalloc"; then
3159 tcmalloc="yes"
3160 LIBS="-ltcmalloc $LIBS"
3161 elif compile_prog "" "-l:libtcmalloc_minimal.so.4" "tcmalloc_minimal4"; then
3162 tcmalloc="yes"
3163 LIBS="-l:libtcmalloc_minimal.so.4 $LIBS"
3164 else
3165 tcmalloc="no"
3166 fi
01fe773d
JD
3167fi
3168print_config "TCMalloc support" "$tcmalloc"
605cf82e 3169
67bf9823 3170echo "LIBS+=$LIBS" >> $config_host_mak
86719845 3171echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
91f94d5b 3172echo "CFLAGS+=$CFLAGS" >> $config_host_mak
d2aeedb9 3173echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
67bf9823 3174echo "CC=$cc" >> $config_host_mak
af4862b3 3175echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
020d54bd 3176echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
c61a3a44 3177
59d8f412 3178if [ `dirname $0` != "." -a ! -e Makefile ]; then
c61a3a44
JF
3179 cat > Makefile <<EOF
3180SRCDIR:=`dirname $0`
3181include \$(SRCDIR)/Makefile
3182EOF
3183fi