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