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