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