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