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