forked from confluentinc/librdkafka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·214 lines (165 loc) · 4.55 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/usr/bin/env bash
#
BASHVER=$(expr ${BASH_VERSINFO[0]} \* 1000 + ${BASH_VERSINFO[1]})
if [ "$BASHVER" -lt 3002 ]; then
echo "ERROR: mklove requires bash version 3.2 or later but you are using $BASH_VERSION ($BASHVER)"
echo " See https://github.com/edenhill/mklove/issues/15"
exit 1
fi
MKL_CONFIGURE_ARGS="$0 $*"
# Load base module
source mklove/modules/configure.base
# Read some special command line options right away that must be known prior to
# sourcing modules.
mkl_in_list "$*" "--no-download" && MKL_NO_DOWNLOAD=1
# Disable downloads when --help is used to avoid blocking calls.
mkl_in_list "$*" "--help" && MKL_NO_DOWNLOAD=1
mkl_in_list "$*" "--debug" && MKL_DEBUG=1
# This is the earliest possible time to check for color support in
# terminal because mkl_check_terminal_color_support uses mkl_dbg which
# needs to know if MKL_DEBUG is set
mkl_check_terminal_color_support
# Delete temporary Makefile and header files on exit.
trap "{ rm -f $MKL_OUTMK $MKL_OUTH; }" EXIT
##
## Load builtin modules
##
# Builtin options, etc.
mkl_require builtin
# Host/target support
mkl_require host
# Compiler detection
mkl_require cc
# Load application provided modules (in current directory), if any.
for fname in configure.* ; do
if [[ $fname = 'configure.*' ]]; then
continue
fi
# Skip temporary files
if [[ $fname = *~ ]]; then
continue
fi
mkl_require $fname
done
##
## Argument parsing (options)
##
##
_SAVE_ARGS="$*"
# Parse arguments
while [[ ! -z $@ ]]; do
if [[ $1 != --* ]]; then
mkl_err "Unknown non-option argument: $1"
mkl_usage
exit 1
fi
opt=${1#--}
shift
if [[ $opt = *=* ]]; then
name="${opt%%=*}"
arg="${opt#*=}"
eqarg=1
else
name="$opt"
arg=""
eqarg=0
fi
safeopt="$(mkl_env_esc $name)"
if ! mkl_func_exists opt_$safeopt ; then
mkl_err "Unknown option $opt"
mkl_usage
exit 1
fi
# Check if this option needs an argument.
reqarg=$(mkl_meta_get "MKL_OPT_ARGS" "$(mkl_env_esc $name)")
if [[ ! -z $reqarg ]]; then
if [[ $eqarg == 0 && -z $arg ]]; then
arg="$1"
shift
if [[ -z $arg && $reqarg != '\*' ]]; then
mkl_err "Missing argument to option --$name $reqarg"
exit 1
fi
fi
else
if [[ ! -z $arg ]]; then
mkl_err "Option --$name expects no argument"
exit 1
fi
arg=y
fi
case $name in
re|reconfigure)
oldcmd=$(head -1 config.log | grep '^# configure exec: ' | \
sed -e 's/^\# configure exec: [^ ]*configure//')
echo "Reconfiguring: $0 $oldcmd"
exec $0 $oldcmd
;;
list-modules)
echo "Modules loaded:"
for mod in $MKL_MODULES ; do
echo " $mod"
done
exit 0
;;
list-checks)
echo "Check functions in calling order:"
for mf in $MKL_CHECKS ; do
mod=${mf%:*}
func=${mf#*:}
echo -e "${MKL_GREEN}From module $mod:$MKL_CLR_RESET"
declare -f $func
echo ""
done
exit 0
;;
update-modules)
fails=0
echo "Updating modules"
for mod in $MKL_MODULES ; do
echo -n "Updating $mod..."
if mkl_module_download "$mod" > /dev/null ; then
echo -e "${MKL_GREEN}ok${MKL_CLR_RESET}"
else
echo -e "${MKL_RED}failed${MKL_CLR_RESET}"
fails=$(expr $fails + 1)
fi
done
exit $fails
;;
help)
mkl_usage
exit 0
;;
*)
opt_$safeopt "$arg" || exit 1
mkl_var_append MKL_OPTS_SET "$safeopt"
;;
esac
done
if [[ ! -z $MKL_CLEAN ]]; then
mkl_clean
exit 0
fi
# Move away previous log file
[[ -f $MKL_OUTDBG ]] && mv $MKL_OUTDBG ${MKL_OUTDBG}.old
# Create output files
echo "# configure exec: $0 $_SAVE_ARGS" >> $MKL_OUTDBG
echo "# On $(date)" >> $MKL_OUTDBG
rm -f $MKL_OUTMK $MKL_OUTH
# Load cache file
mkl_cache_read
# Run checks
mkl_checks_run
# Check accumulated failures, will not return on failure.
mkl_check_fails
# Generate outputs
mkl_generate
# Summarize what happened
mkl_summary
# Write cache file
mkl_cache_write
echo ""
echo "Now type 'make' to build"
trap - EXIT
exit 0