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