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