-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathconfigure
executable file
·340 lines (292 loc) · 10.2 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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
#!/bin/bash
# - Mellanox Confidential and Proprietary -
#
# Copyright (C) January 2010, Mellanox Technologies Ltd. ALL RIGHTS RESERVED.
#
# Except as specifically permitted herein, no portion of the information,
# including but not limited to object code and source code, may be reproduced,
# modified, distributed, republished or otherwise exploited in any form or by
# any means for any purpose without the prior written permission of Mellanox
# Technologies Ltd. Use of software subject to the terms and conditions
# detailed in the file "LICENSE.txt".
#
#
usage()
{
cat << EOF
\`configure' configures variables for kernel modules compilation
Usage: `basename $0` [options]
--prefix=PREFIX for userspace components []
--build_root=BUILD_ROOT root directory to build RPM packages
--kernel-version=VERSION make for this kernel [$(uname -r)]
--modules-dir=DIR modules directory [/lib/modules/$(uname -r)]
--kernel-sources=DIR make for this kernel [/lib/modules/$(uname -r)/build]
Kernel modules configuration:
--with-memtrack enable momory tracking [no]
--without-memtrack disable memory tracking [yes]
--with-debug-info make CONFIG_DEBUG_INFO=y [yes]
--without-debug-info [no]
--help - print out options
EOF
}
# Execute command w/ echo and exit if it fail
ex()
{
echo "$@"
if ! "$@"; then
printf "\nFailed executing $@\n\n"
exit 1
fi
}
# Compare 2 kernel versions
check_kerver()
{
local kver=$1
local min_kver=$2
shift 2
kver_a=$(echo -n ${kver} | cut -d '.' -f 1)
kver_b=$(echo -n ${kver} | cut -d '.' -f 2)
kver_c=$(echo -n ${kver} | cut -d '.' -f 3 | cut -d '-' -f 1 | tr -d [:alpha:][:punct:])
min_kver_a=$(echo -n ${min_kver} | cut -d '.' -f 1)
min_kver_b=$(echo -n ${min_kver} | cut -d '.' -f 2)
min_kver_c=$(echo -n ${min_kver} | cut -d '.' -f 3 | cut -d '-' -f 1 | tr -d [:alpha:][:punct:])
if [ ${kver_a} -lt ${min_kver_a} ] ||
[[ ${kver_a} -eq ${min_kver_a} && ${kver_b} -lt ${min_kver_b} ]] ||
[[ ${kver_a} -eq ${min_kver_a} && ${kver_b} -eq ${min_kver_b} && ${kver_c} -lt ${min_kver_c} ]]; then
return 1
fi
return 0
}
apply_mlxfw_patches()
{
local patches_folder_name=drivers/net/local_mlxfw/patches/
if ( patch --follow-symlinks < /dev/null 2>&1 1>/dev/null ) ; then
mlxfw_extra_patch_configure_parameters="${mlxfw_extra_patch_configure_parameters} --follow-symlinks"
fi
for patch_file in ${patches_folder_name}/*
do
ex patch ${mlxfw_extra_patch_configure_parameters} -p1 -l -i ${patch_file}
done
}
apply_mlxfw_changes()
{
cp -v drivers/net/local_mlxfw/mlxfw_main.c drivers/net/mlxfw
apply_mlxfw_patches
}
apply_backporting_patches()
{
local patches_folder_name=sx_scripts/kernel_backports/$1
if ( patch --follow-symlinks < /dev/null 2>&1 1>/dev/null ) ; then
mlnx_extra_patch_configure_parameters="${mlnx_extra_patch_configure_parameters} --follow-symlinks"
fi
for patch_file in ${patches_folder_name}/*
do
ex patch ${mlnx_extra_patch_configure_parameters} -p1 -l -i ${patch_file}
done
}
main()
{
# Parsing parameters
while [ ! -z "$1" ]
do
case $1 in
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p | -p)
shift
prefix=$1
PREFIX="--prefix ${prefix}"
;;
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=* | -p=*)
prefix=`expr "x$1" : 'x[^=]*=\(.*\)'`
PREFIX="--prefix ${prefix}"
;;
-modules-dir | --modules-dir | --mod-dir)
shift
MODULES_DIR=$1
;;
-modules-dir=* | --modules-dir=* | --mod-dir=*)
MODULES_DIR=`expr "x$1" : 'x[^=]*=\(.*\)'`
;;
-kernel-sources | --kernel-sources | --kernel-src | --kern-src | --ker-src)
shift
KBLD=$1
;;
-kernel-sources=* | --kernel-sources=* | --kernel-src=* | --kern-src=* | --ker-src=*)
KBLD=`expr "x$1" : 'x[^=]*=\(.*\)'`
;;
-kernel-version | --kernel-version | --kern-ver | --ker-ver)
shift
KVERSION=$1
;;
-kernel-version=* | --kernel-version=* | --kern-ver=* | --ker-ver=*)
KVERSION=`expr "x$1" : 'x[^=]*=\(.*\)'`
;;
--with-memtrack)
CONFIG_MEMTRACK="m"
;;
--without-memtrack)
CONFIG_MEMTRACK=
;;
--with-debug-info)
CONFIG_DEBUG_INFO="y"
;;
--without-debug-info)
CONFIG_DEBUG_INFO=
;;
--with-modprobe|--without-modprobe)
;;
--with-sx-core-debug)
CONFIG_SX_CORE_DEBUG="y"
;;
-h | --help)
usage
exit 0
;;
--with*)
echo
echo "Unsupported or unused parameter: $1"
echo
;;
*)
echo
echo "Wrong parameter $1"
echo
usage
exit 1
;;
esac
shift
done
#Set default values
CONFIG_SX_CORE="m"
CONFIG_SX_NETDEV="m"
CONFIG_SX_EMAD_DUMP="m"
CONFIG_SX_BFD="m"
CONFIG_MLXFW="m"
KVERSION=${KVERSION:-$(uname -r)}
MIN_KVERSION="2.6.27"
MODULES_DIR=${MODULES_DIR:-/lib/modules/${KVERSION}/updates}
KBLD=${KBLD:-/lib/modules/${KVERSION}/build}
if [ -d "/lib/modules/${KVERSION}/source" ]; then
KSRC=${KSRC:-/lib/modules/${KVERSION}/source}
fi
ARCH=${ARCH:-$(uname -m)}
# Additional parameters to be passed to configure command
CWD=$(pwd)
CONFIG="configure.mk.kernel"
mkdir -p ${CWD}/include/linux
AUTOCONF_H="${CWD}/include/linux/autoconf.h"
CONFIG_SX_CORE_DEBUG=${CONFIG_SX_CORE_DEBUG:-''}
CONFIG_MEMTRACK=${CONFIG_MEMTRACK:-''}
CONFIG_DEBUG_INFO=${CONFIG_DEBUG_INFO:-'y'}
kernel_patching_marker_file="config.${KVERSION}"
if [ ! -e ${kernel_patching_marker_file} ]; then
# Check for minimal supported kernel version
if ! check_kerver ${KVERSION} ${MIN_KVERSION}; then
echo "Kernel version ${KVERSION} is less then supported kernel ${MIN_KVERSION}. Exiting..."
exit 1
fi
case ${KVERSION} in
3.10.* | 3.13.* | 3.14.* | 3.16.*)
echo "Kernel version ${KVERSION} - 3.10 kernel - no backporting patches required"
;;
4.9.*)
MODULES_DIR=/lib/modules/${KVERSION}/update
apply_backporting_patches "4.9.0"
;;
4.15.*)
MODULES_DIR=/lib/modules/${KVERSION}/update
apply_backporting_patches "4.9.0"
apply_backporting_patches "4.15.15"
;;
*)
echo "Kernel version ${KVERSION} is not supported, supported versions are 3.10.*, 3.13.*, 3.14.*, 3.16.* and 4.9.0"
exit 1
;;
esac
apply_mlxfw_changes
touch ${kernel_patching_marker_file}
fi
# Create configure.mk
/bin/rm -f ${CWD}/${CONFIG}
cat >> ${CWD}/${CONFIG} << EOFCONFIG
# Current working directory
CWD=${CWD}
# Kernel level
KVERSION=${KVERSION}
ARCH=${ARCH}
MODULES_DIR=${MODULES_DIR}
KBLD=${KBLD}
KSRC=${KSRC}
AUTOCONF_H=${AUTOCONF_H}
WITH_MAKE_PARAMS=${WITH_MAKE_PARAMS}
CONFIG_MEMTRACK=${CONFIG_MEMTRACK}
CONFIG_DEBUG_INFO=${CONFIG_DEBUG_INFO}
CONFIG_SX_CORE=${CONFIG_SX_CORE}
CONFIG_SX_CORE_DEBUG=${CONFIG_SX_CORE_DEBUG}
CONFIG_SX_NETDEV=${CONFIG_SX_NETDEV}
CONFIG_SX_EMAD_DUMP=${CONFIG_SX_EMAD_DUMP}
CONFIG_SX_BFD=${CONFIG_SX_BFD}
CONFIG_MLXFW=${CONFIG_MLXFW}
EOFCONFIG
echo "Created ${CONFIG}:"
cat ${CWD}/${CONFIG}
# Create autoconf.h
if [ "X${CONFIG_MEMTRACK}" == "Xm" ]; then
DEFINE_MEMTRACK="#define CONFIG_MEMTRACK 1"
else
DEFINE_MEMTRACK="#undef CONFIG_MEMTRACK"
fi
if [ "X${CONFIG_DEBUG_INFO}" == "Xy" ]; then
DEFINE_DEBUG_INFO="#define CONFIG_DEBUG_INFO 1"
else
DEFINE_DEBUG_INFO="#undef CONFIG_DEBUG_INFO"
fi
if [ "X${CONFIG_SX_CORE}" == "Xm" ]; then
DEFINE_SX_CORE="#define CONFIG_SX_CORE 1"
else
DEFINE_SX_CORE="#undef CONFIG_SX_CORE"
fi
if [ "X${CONFIG_SX_CORE_DEBUG}" == "Xy" ]; then
DEFINE_SX_CORE_DEBUG="#define SX_CORE_DEBUG 1"
else
DEFINE_SX_CORE_DEBUG="#undef SX_CORE_DEBUG"
fi
if [ "X${CONFIG_SX_NETDEV}" == "Xm" ]; then
DEFINE_SX_NETDEV="#define CONFIG_SX_NETDEV 1"
else
DEFINE_SX_NETDEV="#undef CONFIG_SX_NETDEV"
fi
if [ "X${CONFIG_SX_EMAD_DUMP}" == "Xm" ]; then
DEFINE_SX_EMAD_DUMP="#define CONFIG_SX_EMAD_DUMP 1"
else
DEFINE_SX_EMAD_DUMP="#undef CONFIG_SX_EMAD_DUMP"
fi
if [ "X${CONFIG_SX_BFD}" == "Xm" ]; then
DEFINE_SX_BFD="#define CONFIG_SX_BFD 1"
else
DEFINE_SX_BFD="#undef CONFIG_SX_BFD"
fi
if [ "X${CONFIG_MLXFW}" == "Xm" ]; then
DEFINE_MLXFW="#define CONFIG_MLXFW 1"
else
DEFINE_MLXFW="#undef CONFIG_MLXFW"
fi
cat >> ${AUTOCONF_H} << EOFAUTOCONF
#undef CONFIG_MEMTRACK
#undef CONFIG_DEBUG_INFO
#undef CONFIG_SX_CORE
#undef SX_CORE_DEBUG
#undef CONFIG_SX_NETDEV
#undef CONFIG_SX_EMAD_DUMP
#undef CONFIG_SX_BFD
#undef CONFIG_MLXFW
${DEFINE_SX_CORE}
${DEFINE_SX_CORE_DEBUG}
${DEFINE_SX_NETDEV}
${DEFINE_DEBUG_INFO}
${DEFINE_MEMTRACK}
EOFAUTOCONF
echo "Created ${AUTOCONF_H}:"
cat ${AUTOCONF_H}
}
main $@