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