-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure
executable file
·369 lines (335 loc) · 10.4 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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
#!/bin/sh
PATH=$PATH:/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/sbin
case "$1" in
--from-dkms-conf*)
KDKMS=`echo "$1" | sed 's/[^=]*.//'`
# restore options from existing Makefile, if present
if [ -e Makefile ]; then
set -- `sed -n 's/^CARGS = \(.*\)/\1/p' Makefile`
FROMDKMSCONF=1
fi
;;
esac
error() {
printf "! Error: $*\n"
exit 1
}
compiler_presence_test() {
echo -n "Check for working gcc: "
$CC -v >/dev/null 2>&1
if [ $? = 0 ]; then
echo Yes "($CC)"
else
echo No
echo "! You need gcc to install module from source"
if [ -s /etc/debian_version ]; then
NAME=Debian
if [ -e /etc/os-release ]; then
. /etc/os-release >/dev/null 2>&1
fi
echo "! "
echo "! Under $NAME try to run this:"
echo "! root# apt-get install gcc"
echo "! "
elif [ -s /etc/redhat-release ]; then
echo "! "
echo "! Under Centos try to run this:"
echo "! root# yum install gcc"
echo "! "
fi
exit 1
fi
}
show_help() {
echo "Possible options:"
echo " --kver=.. kernel version (ex.: 2.6.30-std-def-alt15)"
echo " --kdir=.. directory for kernel source (ex.: /usr/src/kernel)"
echo " --enable-snmp-rules enables SNMP-index conversion rules"
echo " --enable-macaddress enables MAC address for v9/IPFIX"
echo " --enable-vlan enables VLAN Ids for v9/IPFIX"
echo " --enable-direction enables flowDirection(61) Element"
echo " --enable-sampler enables Flow Sampling"
echo " --enable-sampler=hash enables Hash sampler"
echo " --enable-aggregation enables aggregation rules"
echo " --promisc-mpls decapsulate MPLS in promisc mode"
echo " --promisc-mpls=N -- and record N labels (default 3)"
echo " --enable-physdev enables physdev reporting"
echo " --enable-physdev-override to override interfaces"
echo " --disable-snmp-agent disables net-snmp agent"
echo " --disable-dkms disables DKMS support completely"
echo " --disable-dkms-install no DKMS install but still create dkms.conf"
exit 0
}
CARGS="$@"
for ac_option
do
case "$ac_option" in
-*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) ac_optarg= ;;
esac
case "$ac_option" in
--kver=*) KVERSION="$ac_optarg" ;;
--kdir=*) KDIR="$ac_optarg" ;;
--enable-mac*) KOPTS="$KOPTS -DENABLE_MAC" ;;
--enable-vlan*) KOPTS="$KOPTS -DENABLE_VLAN" ;;
--enable-direc*) KOPTS="$KOPTS -DENABLE_DIRECTION" ;;
--enable-sampl*hash) KOPTS="$KOPTS -DENABLE_SAMPLER -DSAMPLING_HASH" ;;
--enable-sampl*) KOPTS="$KOPTS -DENABLE_SAMPLER" ;;
--enable-aggr*) KOPTS="$KOPTS -DENABLE_AGGR" ;;
--promisc-mpls*) ENABLE_PROMISC=1; PROMISC_MPLS=1; MPLS_DEPTH=${ac_optarg:-3} ;;
--enable-snmp-r*) KOPTS="$KOPTS -DSNMP_RULES" ;;
--enable-physdev) KOPTS="$KOPTS -DENABLE_PHYSDEV" ;;
--enable-physdev-over*) KOPTS="$KOPTS -DENABLE_PHYSDEV_OVER" ;;
--disable-snmp-a*) SKIPSNMP=1 ;;
--disable-net-snmp*) SKIPSNMP=1 ;;
--disable-dkms*) SKIPDKMS=1 ;;
--from-dkms-conf*) ;;
--make) echo called from make; CARGS=`echo $CARGS | sed s/--make//g` ;;
-Werror) KOPTS="$KOPTS -Werror" ;;
--help|-h) show_help ;;
-*) echo Invalid option: $ac_option; exit 1 ;;
# *) ni="$ni $ac_option" ;;
esac
done
ENABLE_PROMISC=1
if [ "$PROMISC_MPLS" = 1 ]; then
KOPTS="$KOPTS -DPROMISC_MPLS"
case "$MPLS_DEPTH" in (*[!0-9]*|"") MPLS_DEPTH=1 ;; esac
if [ "$MPLS_DEPTH" -lt 1 ]; then
echo "! Requested MPLS stack depth is too small, limiting to 1."
elif [ "$MPLS_DEPTH" -gt 10 ]; then
echo "! Requested MPLS stack depth is too big, limiting to 10."
MPLS_DEPTH=10;
fi
if [ "$MPLS_DEPTH" -ge 1 ]; then KOPTS="$KOPTS -DMPLS_DEPTH=$MPLS_DEPTH"; fi
fi
kernel_find_version() {
KHOW=requested
test "$KVERSION" && return 0
if grep -q '#.*Debian' /proc/version; then
KHOW=proc
KVERSION=`sed -n 's/.*#.*Debian \([0-9\.]\+\)-.*/\1/p' /proc/version`
KLIBMOD=`uname -r`
else
KHOW=uname
KVERSION=`uname -r`
fi
test "$KDIR" || return 0
test -s $KDIR/Makefile || return 1
test -s $KDIR/include/config/kernel.release || return 1
KVERSION=`cat $KDIR/include/config/kernel.release`
KHOW=sources
}
kernel_check_src() {
if [ -s "$1/Makefile" ]; then
KDIR="$1"
return 0
fi
return 1
}
kernel_check_src2() {
if kernel_check_src $1/source; then
KSRC=$KDIR
fi
kernel_check_src $1/build
}
kernel_find_source() {
if [ "$KDKMS" ]; then
# dkms args is highest priority
KDIR=$KDKMS
KSHOW=dkms
return 0
fi
KSHOW=requested
test "$KDIR" && return 0
KSHOW=found
kernel_check_src2 /lib/modules/$KLIBMOD && return 0
kernel_check_src2 /lib/modules/$KVERSION && return 0
kernel_check_src /usr/src/kernels/$KVERSION && return 0
kernel_check_src /usr/src/linux-$KVERSION && return 0
echo "! Linux source not found. Don't panic. You may specify kernel source"
echo "! directory with --kdir=..., or try to install kernel-devel package,"
echo "! or just raw sources for linux-$KVERSION from kernel.org."
if grep -q -i centos /proc/version 2>/dev/null; then
echo "! "
arch=.`uname -m`
echo "! Under Centos simply run this:"
echo "! root# yum install kernel-devel"
fi
if grep -q -i debian /proc/version 2>/dev/null; then
echo "! "
echo "! Under Debian simply run this:"
echo "! root# apt-get install module-assistant"
echo "! root# m-a prepare"
fi
exit 1
}
kernel_check_consistency() {
if [ -s $KDIR/include/config/kernel.release ]; then
SRCVER=`cat $KDIR/include/config/kernel.release`
if [ "$KVERSION" != "$SRCVER" ]; then
echo "! Warning: $KHOW kernel version ($KVERSION) and $KSHOW version of kernel source ($SRCVER) doesn't match!"
echo "! You may try to specify only kernel source tree with --kdir=$KDIR"
echo "! and configure will pick up version properly."
echo "! Assuming you want to build for $SRCVER"
KVERSION=$SRCVER
fi
fi
test -e "$KDIR/.config" || error ".config in kernel source not found, run make menuconfig in $KDIR"
test -d "$KDIR/include/config" || error "kernel is not prepared, run make prepare modules_prepare in $KDIR"
}
kconfig() {
KCONFIG=$KDIR/.config
if ! grep -q "^$1=" $KCONFIG 2>/dev/null; then
if [ "$KCONFIGREPORTED" != true ]; then
KCONFIGREPORTED=true
echo Kernel config file checked: $KCONFIG
echo
fi
echo "! Attention: $1 is undefined in your kernel configuration"
echo "! Without this option enabled $2 will not work."
echo
return 1
fi
return 0
}
kernel_check_config() {
kconfig CONFIG_SYSCTL "sysctl interface"
kconfig CONFIG_PROC_FS "proc interface"
kconfig CONFIG_IPV6 "IPv6"
}
kernel_check_include() {
echo -n "Checking for presence of $1... "
if [ "$KSRC" -a -e $KSRC/$1 ]; then
echo Yes
KOPTS="$KOPTS $2"
elif [ -e $KDIR/$1 ]; then
echo Yes
KOPTS="$KOPTS $2"
else
echo No
fi
}
kernel_check_features() {
kernel_check_include include/linux/llist.h -DHAVE_LLIST
kernel_check_include include/linux/grsecurity.h -DHAVE_GRSECURITY_H
}
snmp_check() {
SNMPTARGET=
SNMPINSTALL=
test "$SKIPSNMP" && return
echo -n "Searching for net-snmp-config... "
if which net-snmp-config >/dev/null 2>&1; then
echo Yes `which net-snmp-config`
else
echo No.
SNMPCONFIG=no
fi
echo -n "Searching for net-snmp agent... "
if [ -s /etc/redhat-release ]; then
if ! rpm --quiet -q net-snmp; then
echo No.
SNMPADD="do: yum install net-snmp"
if [ "$SNMPCONFIG" ]; then
SNMPADD="$SNMPADD net-snmp-devel"
fi
else
echo Yes.
fi
if [ "$SNMPCONFIG" ]; then
SNMPCONFIG="run: yum install net-snmp-devel"
fi
elif [ -s /etc/debian_version ]; then
if ! dpkg -s snmpd >/dev/null 2>&1; then
echo No.
SNMPADD="do: apt-get install snmpd"
if [ "$SNMPCONFIG" ]; then
SNMPADD="$SNMPADD libsnmp-dev"
fi
else
echo Yes.
fi
if [ "$SNMPCONFIG" ]; then
SNMPCONFIG="run: apt-get install libsnmp-dev"
fi
elif [ -s /etc/snmp/snmpd.conf ]; then
echo Yes.
else
echo No.
SNMPADD="install net-snmp (www.net-snmp.org)"
SNMPCONFIG="reinstall net-snmp with agent support."
fi
if [ "$SNMPADD" ]; then
echo " Assuming you don't want net-snmp agent support".
echo " Otherwise $SNMPADD"
return
elif [ "$SNMPCONFIG" ]; then
echo "! You have net-snmp agent but not development package."
echo "! net-snmp agent will not be built, to fix:"
echo "! $SNMPCONFIG"
return
fi
SNMPTARGET=snmp_netflow.so
SNMPINSTALL=sinstall
}
dkms_check() {
DKMSINSTALL=
test "$SKIPDKMS" && return
echo -n "Checking for DKMS... "
if ! which dkms >/dev/null 2>&1; then
echo "No. (It may be useful to install it.)"
echo "! "
echo "! DKMS is method of installing kernel modules, that will"
echo "! automatically recompile module after kernel upgrade."
if [ -s /etc/debian_version ]; then
echo "! "
echo "! To install it under Debian simply run this:"
echo "! root# apt-get install dkms"
echo "! "
elif [ -s /etc/redhat-release ]; then
echo "! "
echo "! To install it under Centos enable EPEL or RPMforge repository,"
echo "! then run this:"
echo "! root# yum install dkms"
echo "! "
fi
return
fi
echo Yes.
DKMSINSTALL=dinstall
test "$FROMDKMSCONF" && return
if dkms status | grep ^pkt-netflow, >/dev/null; then
echo "! You are already have module installed via DKMS"
echo "! it will be uninstalled on 'make install' and"
echo "! current version of module installed afterwards."
echo "! Use --disable-dkms option if don't want this."
fi
}
kernel_find_version #KVERSION
test "$KLIBMOD" || KLIBMOD=$KVERSION
echo "Kernel version: $KVERSION ($KHOW)"
kernel_find_source #KDIR
echo "Kernel sources: $KDIR ($KSHOW)"
kernel_check_consistency
kernel_check_config
kernel_check_features
CC=${CC:-gcc}
compiler_presence_test
snmp_check
dkms_check
rm -f compat_def.h
REPLACE="\
s!@CARGS@!$CARGS!;\
s!@KVERSION@!$KVERSION!;\
s!@KDIR@!$KDIR!;\
s!@KOPTS@!$KOPTS!;\
s!@SNMPTARGET@!$SNMPTARGET!;\
s!@SNMPINSTALL@!$SNMPINSTALL!;\
s!@DKMSINSTALL@!$DKMSINSTALL!"
echo -n "Creating Makefile.. "
sed "$REPLACE" Makefile.in > Makefile
echo done.
echo
echo " If you need some options enabled run ./configure --help"
echo " Now run: make all install"
echo