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