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