forked from lucab/ntop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautogen.sh
executable file
·463 lines (380 loc) · 10.7 KB
/
autogen.sh
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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
#!/bin/sh
#
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Run this to generate all the initial makefiles for ntop
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#
# Copyright (C) 2004-06 Rocco Carbone <[email protected]>
# 2006-12 Luca Deri <[email protected]>
#
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#
# $Log$
#
######################################
#
# This is mostly a fix for FreeBSD hosts that have the
# bad behaviour of calling programs as <program name><version>
#
find_command()
{
for P in "$1"; do
IFS=:
for D in $PATH; do
for F in $D/$P; do
[ -x "$F" ] && echo $F && return 0
done
done
done
}
#######################################
AUTOMAKE=`find_command 'automake-*'`
version="0.2.3"
echo ""
echo "Starting ntop automatic configuration system v.$version"
echo ""
echo " Please be patient, there is a lot to do..."
echo ""
# Defaults
LIBTOOL=libtool
LIBTOOLIZE=libtoolize
config="y"
NAME=ntop
# OSx
(uname -a|grep -v Darwin) < /dev/null > /dev/null 2>&1 ||
{
echo "....Adding fix for OSX"
LIBTOOL=glibtool
LIBTOOLIZE=glibtoolize
}
# The name of this program.
progname=`echo "$0" | sed 's%^.*/%%'`
GNU_OR_DIE=1
help="Try \`$progname --help' for more information"
for arg
do
case "$arg" in
-h | --help)
cat <<EOF
This script should help you to configure 'ntop'
Usage: $progname [OPTION]...
-h, --help display this message and exit
-v, --version print version information and exit
-d, --debug enable verbose shell tracing
-p, --purge purge all files which are not part of the source package
--noconfig skip the ./configure execution
Any unrecognized options will be passed to ./configure, e.g.:
./autogen.sh --prefix=/usr
becomes
./configure --prefix=/usr
EOF
exit 0
;;
--noconfig)
config="n"
;;
-v | --version)
echo "$progname $version"
exit 0
;;
-d | --debug)
echo "....Enabling shell trace mode"
set -x
;;
-p | --purge)
echo "....Cleanup of file system of locally generated files..."
if [ -f Makefile ]; then
make -k clean > /dev/null 2>&1
fi
rm -rf .deps
rm -f libtool.m4.in
rm -f config.guess
rm -f config.sub
rm -f install-sh
rm -f ltconfig
rm -f ltmain.sh
rm -f missing
# rm -f mkinstalldirs
rm -f INSTALL
rm -f COPYING
rm -f texinfo.tex
rm -f acinclude.m4
rm -f aclocal.m4
rm -f config.h.in
rm -f stamp-h.in
rm -f Makefile.in
rm -f configure
rm -f config.h
rm -f depcomp
rm -f stamp.h
rm -f libtool
rm -f Makefile
rm -f stamp-h.in
rm -f stamp-h
rm -f stamp-h1
rm -f config.cache
rm -f config.status
rm -f config.log
rm -fr autom4te.cache
rm -f Makefile
rm -f Makefile.in
rm -f compile
rm -f plugins/Makefile
rm -f plugins/Makefile.in
rm -rf nDPI
rm -f *~
exit 0
;;
esac
done
echo "1. Testing gnu tools...."
($LIBTOOL --version) < /dev/null > /dev/null 2>&1 ||
{
echo
echo "You must have libtool installed to compile $NAME."
echo "Download the appropriate package for your distribution, or get the"
echo "source tarball from ftp://ftp.gnu.org/pub/gnu/libtool"
echo " We require version 1.4 or higher"
echo " We recommend version 1.5 or higher"
GNU_OR_DIE=0
}
AUTOMAKE=`find_command 'automake*'`
($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 ||
{
echo
echo "You must have automake installed to compile $NAME."
echo "Download the appropriate package for your distribution, or get the"
echo "source tarball from ftp://ftp.gnu.org/pub/gnu/automake"
echo " We recommend version 1.6.3 or higher"
GNU_OR_DIE=0
}
AUTOCONF=`find_command 'autoconf*'`
($AUTOCONF --version) < /dev/null > /dev/null 2>&1 ||
{
echo
echo "You must have autoconf installed to compile $progname."
echo "Download the appropriate package for your distribution, or get the"
echo "source tarball from ftp://ftp.gnu.org/pub/gnu/autoconf"
echo " We recommend version 2.53 or higher"
GNU_OR_DIE=0
}
WGET=`find_command 'wget*'`
($WGET --version) < /dev/null > /dev/null 2>&1 ||
{
echo
echo "You must have wget installed to compile $progname."
echo "Download the appropriate package for your distribution, or get the"
echo "source tarball from ftp://ftp.gnu.org/pub/gnu/wget"
GNU_OR_DIE=0
}
if test "$GNU_OR_DIE" -eq 0; then
exit 1
fi
SVN=`find_command 'svn'`
($SVN --version) < /dev/null > /dev/null 2>&1 ||
{
echo
echo "You must have svn/subversion installed to compile $progname."
echo "Download the appropriate package for your distribution, or get the"
echo "source from http://subversion.tigris.org"
GNU_OR_DIE=0
}
if test "$GNU_OR_DIE" -eq 0; then
exit 1
fi
# Check versions...
libtoolversion=`$LIBTOOL --version < /dev/null 2>&1 | grep libtool | cut -d " " -f 4`
echo " libtool ..... ${libtoolversion}"
case "${libtoolversion}" in
*1\.3\.[[45]]\-freebsd\-ports*)
echo ""
echo "*******************************************************************"
echo "*"
echo "*ERROR: ntop requires libtool version 1.4 or newer..."
echo "*"
echo "* FreeBSD ports 1.3.4 seems to work, so we will let it slide..."
echo "*"
echo "* Fasten your seat belt and good luck! If you are injured, the"
echo "* development team will disavow any knowledge of your intentions."
echo "*"
echo "*******************************************************************"
;;
*1\.[[0-3]]*)
echo ""
echo "*******************************************************************"
echo "*"
echo "*ERROR: ntop requires libtool version 1.4 or newer..."
echo "*"
echo "*"
echo "*>>> Unable to proceed with your request, aborting!"
echo "*"
echo "*******************************************************************"
exit 1
;;
esac
echo " .... ok"
automakeversion=`$AUTOMAKE --version < /dev/null 2>&1 | grep '^automake' | cut -d " " -f 4`
echo " automake .... ${automakeversion}"
if test `echo ${automakeversion}| cut -c 4` = "."; then
automakeversion=`echo ${automakeversion}| cut -c 3`
else
automakeversion=`echo ${automakeversion}| cut -c 3-4`
fi
if test ${automakeversion} -lt 6; then
echo ""
echo "******************************************************************"
echo "*"
echo "*ERROR: ntop requires automake version 1.6 or newer..."
echo "*"
echo "*>>> Unable to proceed with your request, aborting!"
echo "*"
echo "*******************************************************************"
exit 1
fi
echo " .... ok"
autoconfversion=`$AUTOCONF --version < /dev/null 2>&1 | grep '^autoconf' | cut -d " " -f 4`
echo " autoconf .... ${autoconfversion}"
case "${autoconfversion}" in
*2\.[[0-4]]*)
echo ""
echo "******************************************************************"
echo "*"
echo "*ERROR: ntop requires autoconf version 2.53 or newer..."
echo "*"
echo "*>>> Unable to proceed with your request, aborting!"
echo "*"
echo "*******************************************************************"
exit 1
;;
*2\.5\[[0-2]]*)
echo ""
echo "******************************************************************"
echo "*"
echo "*ERROR: ntop requires autoconf version 2.53 or newer..."
echo "*"
echo "*>>> Unable to proceed with your request, aborting!"
echo "*"
echo "*******************************************************************"
exit 1
;;
esac
echo " .... ok"
echo ""
#
# 2. prepare the package to use libtool
#
echo "2. Preparing for libtool ...."
$LIBTOOLIZE --copy --force
if [ ! -f libtool.m4.in ]; then
echo " Finding libtool.m4.in"
if [ -f /usr/local/share/aclocal/libtool.m4 ]; then
echo " .... found /usr/local/share/aclocal/libtool.m4"
cp /usr/local/share/aclocal/libtool.m4 libtool.m4.in
else
if [ -f /usr/share/aclocal/libtool.m4 ]; then
echo " .... found /usr/share/aclocal/libtool.m4"
cp /usr/share/aclocal/libtool.m4 libtool.m4.in
else
echo " .... not found - aborting!"
fi
fi
fi
echo " .... done"
echo ""
#
# 3. create local definitions for automake
#
echo "3. Create acinclude.m4, local definitions for automake ..."
cat acinclude.m4.in libtool.m4.in acinclude.m4.ntop > acinclude.m4
echo " .... done"
echo ""
#
# 4. run 'aclocal' to create aclocal.m4 from configure.in (optionally acinclude.m4)
#
echo "4. Running aclocal to create aclocal.m4 ..."
ACLOCAL=`find_command 'aclocal*'`
$ACLOCAL $ACLOCAL_FLAGS
echo " .... done"
echo ""
#
# 5. run 'autoheader' to create config.h.in from configure.in
#
echo "5. Running autoheader to create config.h.in ..."
AUTOHEADER=`find_command 'autoheader*'`
$AUTOHEADER
echo " .... done"
echo ""
echo "timestamp" > stamp-h.in
#
# 6.
# run 'automake' to create Makefile.in from configure.in and Makefile.am
# (optionally aclocal.m4)
# the generated Makefile.in is compliant to GNU Makefile standard
#
echo "6. Running automake to create Makefile.in ..."
touch NEWS AUTHORS ChangeLog
$AUTOMAKE --add-missing --copy
echo " .... done"
echo ""
#
# 7.
# run 'autoconf' to create configure from configure.in
#
echo "7. Running autoconf to create configure ..."
$AUTOCONF
echo " .... done"
echo ""
chmod gou+x ./config.guess
# Needed on some distro as CentOS
\mkdir m4
# Link 3rd party files
\cp 3rd_party/* .
#
# 8.
# run './configure' for real fun!
#
if [ ".${config}" = ".y" ]; then
echo "8. Running ./configure ..."
if [ -x config.status -a -z "$*" ]; then
./config.status --recheck
else
if test -z "$*"; then
echo "I am going to run ./configure with no arguments"
echo "if you wish to pass any to it, please specify them on the $0 command line."
fi
./configure "$@" || exit 1
fi
echo " .... autogen.sh done"
echo "just type make to compile ntop"
else
echo "8. Skipping ./configure"
echo "Run ./configure and then make to compile ntop"
fi
echo ""
#
# cleanup to handle programs garbage
#
rm -f /tmp/acin* /tmp/acout*
rm -f autoha*
rm -f confdefs.h
# Get nDPI
echo "9. Downloading nDPI..."
NDPI_URL=https://svn.ntop.org/svn/ntop/trunk/nDPI/
if test -d nDPI; then
echo "nDPI already available"
else
svn co $NDPI_URL
fi
dnl> nDPI compilation
if test -f NDPI_LIB; then
echo "nDPI already compiled"
else
echo "10. Compiling nDPI..."
cd nDPI; ./configure --with-pic; make; cd ..
fi
echo
echo "Now we're ready to compile ntop"
# Local Variables:
# mode:shell-script
# sh-indentation:2
# End: