Jens Axboe | f16b83b | 2019-01-15 11:14:43 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # set temporary file name |
| 4 | if test ! -z "$TMPDIR" ; then |
| 5 | TMPDIR1="${TMPDIR}" |
| 6 | elif test ! -z "$TEMPDIR" ; then |
| 7 | TMPDIR1="${TEMPDIR}" |
| 8 | else |
| 9 | TMPDIR1="/tmp" |
| 10 | fi |
| 11 | |
| 12 | cc=gcc |
| 13 | |
| 14 | TMPC="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.c" |
| 15 | TMPC2="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}-2.c" |
| 16 | TMPO="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.o" |
| 17 | TMPE="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.exe" |
| 18 | |
| 19 | # NB: do not call "exit" in the trap handler; this is buggy with some shells; |
| 20 | # see <1285349658-3122-1-git-send-email-loic.minier@linaro.org> |
| 21 | trap "rm -f $TMPC $TMPC2 $TMPO $TMPE" EXIT INT QUIT TERM |
| 22 | |
| 23 | rm -rf config.log |
| 24 | |
| 25 | config_host_mak="config-host.mak" |
| 26 | config_host_h="config-host.h" |
| 27 | |
| 28 | rm -rf $config_host_mak |
| 29 | rm -rf $config_host_h |
| 30 | |
| 31 | fatal() { |
| 32 | echo $@ |
| 33 | echo "Configure failed, check config.log and/or the above output" |
| 34 | rm -rf $config_host_mak |
| 35 | rm -rf $config_host_h |
| 36 | exit 1 |
| 37 | } |
| 38 | |
| 39 | # Print result for each configuration test |
| 40 | print_config() { |
| 41 | printf "%-30s%s\n" "$1" "$2" |
| 42 | } |
| 43 | |
| 44 | # Default CFLAGS |
| 45 | CFLAGS="-D_GNU_SOURCE -include config-host.h" |
| 46 | BUILD_CFLAGS="" |
| 47 | |
| 48 | # Print configure header at the top of $config_host_h |
| 49 | echo "/*" > $config_host_h |
| 50 | echo " * Automatically generated by configure - do not modify" >> $config_host_h |
| 51 | printf " * Configured with:" >> $config_host_h |
| 52 | printf " * '%s'" "$0" "$@" >> $config_host_h |
| 53 | echo "" >> $config_host_h |
| 54 | echo " */" >> $config_host_h |
| 55 | |
| 56 | echo "# Automatically generated by configure - do not modify" > $config_host_mak |
| 57 | printf "# Configured with:" >> $config_host_mak |
| 58 | printf " '%s'" "$0" "$@" >> $config_host_mak |
| 59 | echo >> $config_host_mak |
| 60 | |
| 61 | do_cc() { |
| 62 | # Run the compiler, capturing its output to the log. |
| 63 | echo $cc "$@" >> config.log |
| 64 | $cc "$@" >> config.log 2>&1 || return $? |
| 65 | # Test passed. If this is an --enable-werror build, rerun |
| 66 | # the test with -Werror and bail out if it fails. This |
| 67 | # makes warning-generating-errors in configure test code |
| 68 | # obvious to developers. |
| 69 | if test "$werror" != "yes"; then |
| 70 | return 0 |
| 71 | fi |
| 72 | # Don't bother rerunning the compile if we were already using -Werror |
| 73 | case "$*" in |
| 74 | *-Werror*) |
| 75 | return 0 |
| 76 | ;; |
| 77 | esac |
| 78 | echo $cc -Werror "$@" >> config.log |
| 79 | $cc -Werror "$@" >> config.log 2>&1 && return $? |
| 80 | echo "ERROR: configure test passed without -Werror but failed with -Werror." |
| 81 | echo "This is probably a bug in the configure script. The failing command" |
| 82 | echo "will be at the bottom of config.log." |
| 83 | fatal "You can run configure with --disable-werror to bypass this check." |
| 84 | } |
| 85 | |
| 86 | compile_object() { |
| 87 | do_cc $CFLAGS -c -o $TMPO $TMPC |
| 88 | } |
| 89 | |
| 90 | compile_prog() { |
| 91 | local_cflags="$1" |
| 92 | local_ldflags="$2 $LIBS" |
| 93 | echo "Compiling test case $3" >> config.log |
| 94 | do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags |
| 95 | } |
| 96 | |
| 97 | has() { |
| 98 | type "$1" >/dev/null 2>&1 |
| 99 | } |
| 100 | |
| 101 | output_sym() { |
| 102 | echo "$1=y" >> $config_host_mak |
| 103 | echo "#define $1" >> $config_host_h |
| 104 | } |
| 105 | |
| 106 | ########################################## |
| 107 | # check for __kernel_rwf_t |
| 108 | __kernel_rwf_t="no" |
| 109 | cat > $TMPC << EOF |
| 110 | #include <linux/fs.h> |
| 111 | int main(int argc, char **argv) |
| 112 | { |
| 113 | __kernel_rwf_t x; |
| 114 | x = 0; |
| 115 | return x; |
| 116 | } |
| 117 | EOF |
| 118 | if compile_prog "" "" "__kernel_rwf_t"; then |
| 119 | __kernel_rwf_t="yes" |
| 120 | fi |
| 121 | print_config "__kernel_rwf_t" "$__kernel_rwf_t" |
| 122 | |
| 123 | ############################################################################# |
| 124 | |
| 125 | if test "$__kernel_rwf_t" = "yes"; then |
| 126 | output_sym "CONFIG_HAVE_KERNEL_RWF_T" |
| 127 | fi |