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