-
Notifications
You must be signed in to change notification settings - Fork 11
/
configure
executable file
·481 lines (398 loc) · 10.9 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
#!/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 " --tsbuffer=<opt> [32] Change default TS buffer size (in MB)."
echo " Use like --tsbuffer=64"
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 " --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 " --optimize=<opt> [yes] Perform FFDecsa optimization auto-detection"
echo " for all mmx and sse types optimizations,"
echo " with -O2 and -O3 optimization levels"
echo " O2: same, but only test with -O2"
echo " O3: same, but only test with -O3"
echo " long: Try all known optimizations"
echo " no: use default optimization (-O3 PARALLEL_128_SSE2)"
echo " Option is disabled by --ffdecsa_mode option"
echo " "
echo " --cxx=<opt> [g++] Define C++ and CC version to use"
echo " Use like --cxx=4.7"
echo " "
echo " --update=<opt> [yes] no: don't clean local clone and"
echo " don't pull in any updates."
echo " --replace=<opt> [no] yes: recompile the binary and replace the old one"
echo " "
exit 0
}
compiletype_opt="release"
update_opt="yes"
optimize_opt="yes"
ffdecsa_opt="yes"
replace_opt="no"
for opt do
optval="${opt#*=}"
case "$opt" in
--cxx=*) CXX="g++-$optval"; CC="gcc-$optval"
;;
--ffdecsa_flags=*) ffdecsa_flags="$optval"
;;
--tsbuffer=*) tsbuffer="$optval"
;;
--compiletype=*) compiletype_opt="$optval"
;;
--update=*) update_opt="$optval"
;;
--optimize=*) optimize_opt="$optval"
;;
--ffdecsa_mode=*) optimize_opt="defined"; MAX_MODE="$optval"
;;
--replace=*) replace_opt="$optval"
;;
--help) show_help
;;
*)
die_unknown $opt
;;
esac
done
# Get kernel version
FIRST_DIGIT=$( echo `uname -r` | grep -o '[[:digit:]]\+' | head -n1 )
# 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 git status
if [ "x$update_opt" = "xyes" ]; then
git clean -xfd > /dev/null
git reset --hard HEAD > /dev/null
git remote update > /dev/null 2>&1
if ! [ "$?" -eq 0 ]; then
echo -en "
\E[1;33;44m
###################################
Error(s) encountered while updating
the status from remote git repo.
Aborting...
####################################
\E[0m
"
exit 1
fi
LOCAL=$(git rev-parse @{0})
REMOTE=$(git rev-parse @{u})
BASE=$(git merge-base @{0} @{u})
if [ $LOCAL = $REMOTE ]; then
GITSTATUS="0" # "Up-to-date"
elif [ $LOCAL = $BASE ]; then
GITSTATUS="1" # "Need to pull"
elif [ $REMOTE = $BASE ]; then
GITSTATUS="2" # "Need to push"
else
GITSTATUS="3" # "Diverged"
fi
if [ "$GITSTATUS" -eq "0" ]; then
echo "
Your local clone is clean and up-to-date
"
sleep 3
elif [ "$GITSTATUS" -eq "1" ]; then
echo "
Going to sync your local clone with updated remote repo.
"
sleep 3
git pull > /dev/null
if ! [ "$?" -eq 0 ]; then
echo -en "
\E[1;33;44m
###################################
Error(s) encountered while syncing
local with remote git repo
Aborting...
####################################
\E[0m
"
exit 1
else
echo -en "
######################################################
Synced with remote repo successfully! Please rerun
./configure to complete installation of FFdecsawrapper
Arrow up and enter will get you there.
######################################################
"
exit 0
fi
elif [ "$GITSTATUS" -eq "2" -o "$GITSTATUS" -eq "3" ]; then
echo -en "
\E[1;33;44m
#####################################
Your local clone cannot be synced
with remote repo due to local changes
Aborting...
######################################
\E[0m
"
exit 1
fi
fi
echo "# Automatically generated by configure - do not modify" > config.mak
# Check optimize_opt
if [ "x$optimize_opt" = "xno" ];then
ffdecsa_opt="no"
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
# Check for installed binary
if [ -f /usr/bin/ffdecsawrapper ]; then
if [ "x$replace_opt" = "xno" ]; then
echo "
/usr/bin/ffdecsawrapper exists.
Do you want to recompile it?
"
confirmno "Recompile ffdecsawrapper binary [N/y]"
if ! [ "$?" -eq 0 ]; then
echo "
Nothing to do. Aborting...
"
exit 0
fi
fi
fi
# Make sure that we are running as root
if ! echo "$(whoami)" | grep "root" > /dev/null 2>&1; then
echo -en "
\E[1;33;44m
You should run as root.
Aborting...
\E[0m
"
exit 0
fi
# Fix disapearing headers declarations in newer kernels
if ! cat /usr/include/linux/dvb/dmx.h | grep DMX_KERNEL_CLIENT > /dev/null 2>&1; then
patch -d/ -p0 < dmx.patch
fi
if [ "$OS" = "Debian" -o "$OS" = "Ubuntu" -o "$OS" = "Devuan" ] ; then
# 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
fi
#
# End Debian Section
#
# Set compiler version,
# if not done allready
if [ "x$CXX" = "x" ]; then
CXX=g++
CC=gcc
fi
# Set TsBufferSize
if [ "x$tsbuffer" != "x" ]; then
sed -i "s/DeCsaTsBuffSize=32/DeCsaTsBuffSize=$tsbuffer/" sc/PLUGINS/src/sc.c
fi
# If set, use user defined FFdecsa flags
if [ "x$ffdecsa_flags" != "x" ]; then
echo $ffdecsa_flags >> config.mak
fi
# If set, run optimizer
if [ "x$ffdecsa_flags" = "x" ]; then
if [ "x$ffdecsa_opt" = "xyes" ]; then
CCC=$CXX
export CCC
if [ "x$optimize_opt" = "xyes" ]; then
./FFdecsa_optimizer
if ! [ "$?" -eq 0 ]; then
optimizer
fi
elif [ "x$optimize_opt" = "xlong" ]; then
./FFdecsa_optimizer -e
if ! [ "$?" -eq 0 ]; then
optimizer
fi
elif [ "x$optimize_opt" = "xO2" ]; then
./FFdecsa_optimizer -O 2
if ! [ "$?" -eq 0 ]; then
optimizer
fi
elif [ "x$optimize_opt" = "xO3" ]; then
./FFdecsa_optimizer -O 3
if ! [ "$?" -eq 0 ]; then
optimizer
fi
elif [ "x$optimize_opt" = "xdefined" ]; then
./FFdecsa_optimizer -P $MAX_MODE
if ! [ "$?" -eq 0 ]; then
optimizer
fi
elif [ "x$optimize_opt" != "xno" ]; then
echo "
Bad option to --optimize '$optimize_opt'. Should be 'yes, long, no, O2 or O3'
"
exit 1
fi
else
echo "FFDECSA_OPTS = \"FLAGS=-O3 -march=native -fno-stack-check -fPIC -fexpensive-optimizations -fomit-frame-pointer -funroll-loops\" PARALLEL_MODE=PARALLEL_128_SSE2 COMPILER=g++" >> config.mak
echo "
Using default optimization:
-O3 PARALLEL_128_SSE2
"
fi
fi
# Set compiletype
if [ "x$compiletype_opt" = "xrelease" ]; then
echo "RELEASE=1" >> config.mak
elif [ "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 "
Using C++ compiler: $CXX"
if [ "x$compiletype_opt" = "xrelease" ]; then
echo "Using compile type: release
"
elif [ "x$compiletype_opt" = "xdebug" ]; then
echo "
Using compile type: debug
"
fi
# Set wrapper compiler options
if [ "x$compiletype_opt" = "xrelease" ]; then
echo "SC_FLAGS = \"-O2 -fno-stack-check -fPIC -Wall -Woverloaded-virtual -fno-strict-aliasing\"" >> config.mak
elif [ "x$compiletype_opt" = "xdebug" ]; then
echo "SC_FLAGS = \"-O2 -g -fno-stack-check -fPIC -Wall -Woverloaded-virtual -fno-strict-aliasing\"" >> config.mak
fi
echo "CXX=$CXX" >> config.mak
echo "CC=$CC" >> config.mak
# Compile and finish by installing ffdecsawrapper
sleep 5
make
if ! [ "$?" -eq 0 ]; then
echo -en "
\E[1;33;44m
###################################################
Error(s) encountered while compiling ffdecsawrapper
####################################################
\E[0m
"
exit 1
else
if [ -f /usr/bin/ffdecsawrapper ]; then
rm -f /usr/bin/ffdecsawrapper
fi
cp -f ffdecsawrapper /usr/bin
echo -en "
\E[1;33;44m
####################################
Installed ffdecsawrapper to /usr/bin
####################################
\E[0m
"
fi