blob: ef71a14b913b61ec61a0c03e2e12a76ed105e4d9 [file] [log] [blame]
Jens Axboef16b83b2019-01-15 11:14:43 -07001#!/bin/sh
2#
3# set temporary file name
4if test ! -z "$TMPDIR" ; then
5 TMPDIR1="${TMPDIR}"
6elif test ! -z "$TEMPDIR" ; then
7 TMPDIR1="${TEMPDIR}"
8else
9 TMPDIR1="/tmp"
10fi
11
12cc=gcc
13
14TMPC="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.c"
15TMPC2="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}-2.c"
16TMPO="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.o"
17TMPE="${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>
21trap "rm -f $TMPC $TMPC2 $TMPO $TMPE" EXIT INT QUIT TERM
22
23rm -rf config.log
24
25config_host_mak="config-host.mak"
26config_host_h="config-host.h"
27
28rm -rf $config_host_mak
29rm -rf $config_host_h
30
31fatal() {
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
40print_config() {
41 printf "%-30s%s\n" "$1" "$2"
42}
43
44# Default CFLAGS
45CFLAGS="-D_GNU_SOURCE -include config-host.h"
46BUILD_CFLAGS=""
47
48# Print configure header at the top of $config_host_h
49echo "/*" > $config_host_h
50echo " * Automatically generated by configure - do not modify" >> $config_host_h
51printf " * Configured with:" >> $config_host_h
52printf " * '%s'" "$0" "$@" >> $config_host_h
53echo "" >> $config_host_h
54echo " */" >> $config_host_h
55
56echo "# Automatically generated by configure - do not modify" > $config_host_mak
57printf "# Configured with:" >> $config_host_mak
58printf " '%s'" "$0" "$@" >> $config_host_mak
59echo >> $config_host_mak
60
61do_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
86compile_object() {
87 do_cc $CFLAGS -c -o $TMPO $TMPC
88}
89
90compile_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
97has() {
98 type "$1" >/dev/null 2>&1
99}
100
101output_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"
109cat > $TMPC << EOF
110#include <linux/fs.h>
111int main(int argc, char **argv)
112{
113 __kernel_rwf_t x;
114 x = 0;
115 return x;
116}
117EOF
118if compile_prog "" "" "__kernel_rwf_t"; then
119 __kernel_rwf_t="yes"
120fi
121print_config "__kernel_rwf_t" "$__kernel_rwf_t"
122
123#############################################################################
124
125if test "$__kernel_rwf_t" = "yes"; then
126 output_sym "CONFIG_HAVE_KERNEL_RWF_T"
127fi