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