forked from bas-t/ffdecsawrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·594 lines (494 loc) · 14.8 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
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
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
#!/bin/bash
die(){
echo -en "
\E[1;33;44m$1, aborting...\E[0m
"
exit 1
}
die_unknown(){
echo -en "
\E[1;33;44mUnknown option \"$1\".\E[0m
"
./configure --help
exit 1
}
confirmno(){
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [y/N]} " response
case $response in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
confirmyes(){
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [Y/n]} " response
case $response in
[yY][eE][sS]|[yY])
true
;;
[nN][oO]|[nN])
false
;;
*)
true
;;
esac
}
optimizer(){
echo -en "
\E[1;33;44m
Fatal error(s) encoutered during optimization tests.
Aborting...
\E[0m
"
exit 1
}
show_help(){
echo " Usage: ./configure --opt1=<opt> --opt2=<opt>"
echo " "
echo " Options: [default], if any, in brackets after option."
echo " "
echo " --help Print this message"
echo " "
echo " --compiletype=<opt> [release] Specify compile type: release or debug."
echo " "
echo " --dvb_dir=<path> Use <path> for DVB headers. It is mandatory if you"
echo " compiled v4l (based) drivers."
echo " If you did not, don't use this option!"
echo " Use like --dvb_dir=/usr/src/media_build/linux"
echo " Info: www.lursen.org/wiki/V4l_and_ffdecsawrapper"
echo " "
echo " --optimize=<opt> [yes] Perform FFDecsa optimization auto-detection"
echo " for all mmx and sse types optimizations"
echo " with both -O2 and -O3 levels"
echo " long: Try all known optimizations"
echo " no: Don't do any optimizations"
echo " Option is disabled by --ffdecsa_mode option"
echo " "
echo " --tsbuffer=<opt> [4] Change default TS buffer size (in MB)."
echo " Use like --tsbuffer=8"
echo " "
echo " --ffdecsa_mode=<opt> Test single <opt> optimization mode"
echo " with both -O2 and -O3 level"
echo " Use like --ffdecsa_mode=PARALLEL_128_SSE"
echo " Option disables --optimize option"
echo " "
echo " --ffdecsa_flags=<opt> Use <opt> ffdecsa compiler flags."
echo " Don't use this option unless you"
echo " exactly know what you are doing."
echo " "
echo " --cxx=<opt> [g++] Define C++ and CC version to use"
echo " Use like --cxx=4.7"
echo " "
exit 0
}
ffdecsa_opt="yes"
compiletype_opt="release"
for opt do
optval="${opt#*=}"
case "$opt" in
--dvb_dir=*) dvb_path=`eval echo $optval`
;;
--cxx=*) CXX="g++-$optval"; CC="gcc-$optval"
;;
--ffdecsa_mode=*) ffdecsa_opt="defined"; MAX_MODE="$optval"
;;
--ffdecsa_flags=*) ffdecsa_flags="$optval"
;;
--tsbuffer=*) tsbuffer="$optval"
;;
--optimize=*) ffdecsa_opt="$optval"
;;
--compiletype=*) compiletype_opt="$optval"
;;
--help) show_help
;;
*)
die_unknown $opt
;;
esac
done
echo "# Automatically generated by configure - do not modify" > config.mak
# Get kernel version numbers
SHORT_KERNEL=$( echo `uname -r` | grep -o '[[:digit:]]\+\.[[:digit:]]\+' )
FIRST_DIGIT=$( echo `uname -r` | grep -o '[[:digit:]]\+' | head -n1 )
SECOND_DIGIT=$( echo `uname -r` | grep -o '[[:digit:]]\+' | head -n2 | awk 'NR==2' )
PATCHLEVEL=$( echo `uname -r` | grep -o '[[:digit:]]\+' | head -n3 | awk 'NR==3' )
# Abort if running kernel is < 3.x
if [ "$FIRST_DIGIT" -lt 3 ]; then
echo -en "
\E[1;33;44m
The kernel you are running is not supported anymore.
Minimum supported version is 3.x
\E[0m
Aborting...
"
exit 1
fi
# Check for use of v4l drivers
if test "x$dvb_path" != "x"; then
if ! [ -f "/etc/arch-release" ] > /dev/null 2>&1; then
echo -en "
\E[1;33;44m
! ATTENTION !
\E[0m
You have set the --dvb_dir= option, indicating that you compiled
and installed newest dvb drivers from v4l.This should mean that
you patched the v4l sources with the apropriate dvb-mutex patch.
If you are not sure, you probably did not.
In that case answer no to the question and first have a look at:
http://www.lursen.org/wiki/V4l_and_ffdecsawrapper
"
confirmyes "Proceed?[Y/n]"
if [ "$?" -eq 1 ]; then
echo "
You have chosen not to proceed.
Aborting...
"
exit 0
fi
fi
fi
#
# Begin Debian Section
#
# First get some info on what we are running
if [ -f /usr/bin/lsb_release ]; then
OS=$( lsb_release -si )
RELEASE=$( lsb_release -sc )
fi
# The rest of the Debian section
# depends on the outcome of next line
if [ "$OS" == Debian ] || [ "$OS" == Ubuntu ] ; then
# Make sure that we are running as root
if ! echo "$(whoami)" | grep "root" > /dev/null 2>&1; then
if [ "$OS" == Debian ]; then
echo -en "
\E[1;33;44m
You should run as root.
Aborting...
\E[0m
"
exit 0
else
echo -en "
\E[1;33;44m
You should run as root.
Do \"sudo su\" and run me again.
Aborting...
\E[0m
"
exit 0
fi
fi
# Check if FFdecsawrapper is running
# If it is, offer to stop it
if ps -C ffdecsawrapper > /dev/null 2>&1; then
echo "
It seems that FFdecsawrapper is running.
It should be stopped before proceeding.
"
confirmyes "Do you want to stop FFdecsawrapper now? [Y/n]"
if [ "$?" -eq 0 ]; then
if test -e /etc/init.d/ffdecsawrapper; then
/etc/init.d/ffdecsawrapper stop
sleep 3
rmmod dvbloopback > /dev/null 2>&1
else
killall -9 ffdecsawrapper
sleep 3
rmmod dvbloopback > /dev/null 2>&1
fi
fi
fi
# Install build dependencies for FFdecsawrapper
if ! dpkg-query -l gettext | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency gettext, marking for installation.
"
apt-get install gettext -y || die "Error installing dependency gettext"
fi
if ! dpkg-query -l libv4l-dev | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency libv4l-dev, marking for installation.
"
apt-get install libv4l-dev -y || die "Error installing dependency libv4l-dev"
fi
if ! dpkg-query -l libproc-processtable-perl | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency libproc-processtable-perl, marking for installation.
"
apt-get install libproc-processtable-perl -y || die "Error installing dependency libproc-processtable-perl"
fi
if ! dpkg-query -l libssl-dev | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency libssl-dev, marking for installation.
"
apt-get install libssl-dev -y || die "Error installing dependency libssl-dev"
fi
if ! dpkg-query -l build-essential | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency build-essential, marking for installation.
"
apt-get install build-essential -y || die "Error installing dependency build-essential"
fi
# If we are running a Debian kernel
# we need the headers installed.
# But don't install headers if we are running
# a vanilla kernel
# uname -a does not return Debian
# when we are running a vannila kernel
if uname -a | egrep 'Debian|Ubuntu' > /dev/null 2>&1; then
if ! dpkg-query -l linux-headers-`uname -r` | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency linux-headers-`uname -r`, marking for installation.
"
apt-get install linux-headers-`uname -r` -y || die "Error installing dependency linux-headers-`uname -r`"
fi
fi
# Compare system default g++ (major) version with the
# g++ (major) version the kernel was built with
# If they differ, choose the version the kernel was built with
# and install any missing packages, unless we defined
# a specific version using --cxx= option on command line
if test "x$CXX" != "x"; then
if ! dpkg-query -l $CXX | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency $CXX, marking for installation.
"
apt-get install $CXX -y || die "Error installing dependency $CXX"
fi
fi
CCSYSTEM=$( g++ -v 2>&1 | grep -i "gcc version" | awk '{ print $3 }' | cut -d'.' -f1,2 )
CCKERNEL=$( cat /proc/version | awk '{ print $7 }' | cut -d'.' -f1,2 )
if ! [ "$CCSYSTEM" == "$CCKERNEL" ] ; then
if test "x$CXX" = "x"; then
CXX=g++-$CCKERNEL
CC=gcc-$CCKERNEL
fi
if ! dpkg-query -l g++-$CCKERNEL | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency g++-$CCKERNEL, marking for installation.
"
apt-get install g++-$CCKERNEL -y || die "Error installing dependency g++-$CCKERNEL"
fi
fi
fi
#
# End Debian Section
#
# Get the right dvbdev.h in place
# If --dvb_dir= is set, use supplied header, else
# distinguish between '3.6 or lower' and '3.7 or higher' kernels,
# they use different versions of dvbdev.h
if test "x$dvb_path" != "x"; then
if test -f $dvb_path/drivers/media/dvb-core/dvbdev.h; then
cp -f $dvb_path/drivers/media/dvb-core/dvbdev.h dvbloopback/module/dvbdev.h
elif test -f $dvb_path/drivers/media/dvb/dvb-core/dvbdev.h; then
cp -f $dvb_path/drivers/media/dvb/dvb-core/dvbdev.h dvbloopback/module/dvbdev.h
else echo -en "
\E[1;33;44m
ERROR!!!
Could not locate any of the following:
$dvb_path/drivers/media/dvb-core/dvbdev.h
$dvb_path/drivers/media/dvb/dvb-core/dvbdev.h
Aborting...
\E[0m
"
make clean > /dev/null 2>&1
exit 0
fi
else
if [ "$SECOND_DIGIT" -lt 7 ]; then
cp -f dvbloopback/module/dvbdev-2.6.38.h dvbloopback/module/dvbdev.h
else
cp -f dvbloopback/module/dvbdev-3.7.x.h dvbloopback/module/dvbdev.h
fi
fi
# Get the right Module.symvers in place
# Abort when it is not found
if test "x$dvb_path" = "x"; then
if test -f /lib/modules/`uname -r`/build/Module.symvers; then
cp -f /lib/modules/`uname -r`/build/Module.symvers dvbloopback/module/Module.symvers
else echo -en "
\E[1;33;44m
ERROR!!!
could not locate /lib/modules/`uname -r`/build/Module.symvers
Aborting...
\E[0m
"
make clean > /dev/null 2>&1
exit 0
fi
else
if test -f $dvb_path/../v4l/Module.symvers; then
cp -f $dvb_path/../v4l/Module.symvers dvbloopback/module/Module.symvers
fi
fi
# Set compiler version,
# if not done allready
if test "x$CXX" = "x"; then
CXX=g++
CC=gcc
fi
# Define what optimization tests we want
if test "x$ffdecsa_flags" = "x"; then
CCC=$CXX
export CCC
if test "x$ffdecsa_opt" = "xyes"; then
./FFdecsa_optimizer
if ! [ "$?" -eq 0 ]; then
optimizer
fi
elif test "x$ffdecsa_opt" = "xlong"; then
./FFdecsa_optimizer -e
if ! [ "$?" -eq 0 ]; then
optimizer
fi
elif test "x$ffdecsa_opt" = "xdefined"; then
./FFdecsa_optimizer -P $MAX_MODE
if ! [ "$?" -eq 0 ]; then
optimizer
fi
elif test "x$ffdecsa_opt" != "xno"; then
echo "
Bad option to --optimize '$ffdecsa_opt'. Should be 'yes, long, no'"
exit 1
fi
fi
# Play with TsBufferSize, w.i.p
if test "x$tsbuffer" != "x"; then
sed -i "s/DeCsaTsBuffSize=4/DeCsaTsBuffSize=$tsbuffer/" sc/PLUGINS/src/sc.c
fi
# If set, use user defined FFdecsa flags
if test "x$ffdecsa_flags" != "x"; then
echo $ffdecsa_flags >> config.mak
fi
# Set compiletype
if test "x$compiletype_opt" = "xrelease"; then
echo "RELEASE=1" >> config.mak
elif test "x$compiletype_opt" = "xdebug"; then
echo "RELEASE=0" >> config.mak
else
echo "
Bad option to --compiletype '$compiletype_opt' Should be 'release, debug'"
exit 1
fi
echo "
`uname -r` kernel detected.
Using C++ compiler: $CXX"
if test "x$compiletype_opt" = "xrelease"; then
echo "Using compile type: release
"
elif test "x$compiletype_opt" = "xdebug"; then
echo "
Using compile type: debug
"
fi
# Set wrapper compiler options
if test "x$compiletype_opt" = "xrelease"; then
echo "SC_FLAGS = \"-O2 -fPIC -Wall -Woverloaded-virtual -fno-strict-aliasing\"" >> config.mak
elif test "x$compiletype_opt" = "xdebug"; then
echo "SC_FLAGS = \"-O2 -g -fPIC -Wall -Woverloaded-virtual -fno-strict-aliasing\"" >> config.mak
fi
echo "CXX=$CXX" >> config.mak
echo "CC=$CC" >> config.mak
# Compile and, if running Debian/Ubuntu,
# finish by installing the lot.
if [ "$OS" == Debian ] || [ "$OS" == Ubuntu ] ; then
echo "
Everything looks ok!
Just hit 'enter' to run
make && make module
"
confirmyes "Start compiling now?[Y/n]"
if [ "$?" -eq 0 ]; then
make && make module
if [ "$?" -eq 0 ]; then
echo "
Do you want to install ffdecsawrapper binary and dvbloopback kernel module?
Binary's location: /usr/bin/ffdecsawrapper
dvbloopback module: /lib/modules/`uname -r`/updates/ffdecsawrapper/dvbloopback.ko
If you hit Y and your kernel needs to be patched, that will be done too.
"
confirmyes "Yes, install them now![Y/n]"
if [ "$?" -eq 0 ]; then
rm -f /lib/modules/`uname -r`/updates/ffdecsawrapper/dvbloopback.ko
rm -f /usr/bin/ffdecsawrapper
cp -f ffdecsawrapper /usr/bin
mkdir -p /lib/modules/`uname -r`/updates/ffdecsawrapper
/usr/bin/install dvbloopback.ko /lib/modules/`uname -r`/updates/ffdecsawrapper
if [ "$?" -eq 0 ]; then
depmod -a
# The kernel needs to be patched if we don't
# use newest v4l drivers, but don't offer
# to do so if it allready has been done.
if test "x$dvb_path" = "x"; then
if ! find /lib/modules/`uname -r`/updates -name dvb-core.ko -print | grep "dvb-core.ko" > /dev/null 2>&1; then
if uname -a | egrep 'Debian|Ubuntu' > /dev/null 2>&1; then
echo -en "
#########################
\E[1;33;44mInstalled without errors!\E[0m
#########################
"
./kernelpatch
else
echo -en "
##########################
\E[1;33;44mInstalled without errors!!\E[0m
\E[1;33;44mKernelpatch not needed, or\E[0m
\E[1;33;44mnon stock kernel detected.\E[0m
##########################
"
fi
else
echo -en "
###############################
\E[1;33;44mInstalled without errors!\E[0m
\E[1;33;44mExisting kernel patch detected.\E[0m
###############################
"
fi
fi
else
echo -en "
\E[1;33;44m
#############################################################
Error(s) encoutered installing the dvbloopback kernel module.
#############################################################
\E[0m
"
exit 1
fi
fi
fi
else
echo "
NOT starting compilation
"
fi
else
if ! [ -f "/etc/arch-release" ] > /dev/null 2>&1; then
echo "
Everything looks ok!
Just hit 'enter' to run
make && make module
"
confirmyes "Start compiling now?[Y/n]"
if [ "$?" -eq 0 ]; then
make && make module
else
echo "
NOT starting compilation
"
fi
else
sleep 2
make && make module
fi
fi