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