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