forked from tvheadend/tvheadend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·665 lines (592 loc) · 13 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
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
#!/bin/bash
#
# Tvheadend configure script
#
# Copyright (c) 2012 Adam Sutton <[email protected]>
#
# ###########################################################################
# Setup
# ###########################################################################
ROOTDIR=$(cd "$(dirname "$0")"; pwd)
test -z "$PKG_CONFIG" && PKG_CONFIG=pkg-config
#
# Options
#
OPTIONS=(
"pie:yes"
"cwc:yes"
"capmt:yes"
"constcw:yes"
"linuxdvb:yes"
"satip_server:yes"
"satip_client:yes"
"hdhomerun_client:no"
"hdhomerun_static:yes"
"iptv:yes"
"tsfile:yes"
"dvbscan:yes"
"timeshift:yes"
"trace:yes"
"imagecache:auto"
"avahi:auto"
"zlib:auto"
"libav:auto"
"ffmpeg_static:yes"
"libx264:yes"
"libx264_static:yes"
"libx265:yes"
"libx265_static:yes"
"libvpx:yes"
"libvpx_static:yes"
"libtheora:yes"
"libtheora_static:yes"
"libvorbis:yes"
"libvorbis_static:yes"
"libfdkaac:yes"
"libfdkaac_static:yes"
"nvenc:auto"
"qsv:no"
"libmfx_static:yes"
"inotify:auto"
"epoll:auto"
"uriparser:auto"
"ccache:auto"
"tvhcsa:auto"
"bundle:no"
"dvbcsa:no"
"dvben50221:auto"
"kqueue:no"
"dbus_1:auto"
"android:no"
"tsdebug:no"
"gtimer_check:no"
"slow_memoryinfo:no"
"libsystemd_daemon:no"
"bintray_cache:yes"
)
#
# Begin
#
. "$ROOTDIR/support/configure.inc"
case "$ROOTDIR" in
*\ * ) die "The source directory contains a space. It is not supported."
esac
# ###########################################################################
# Parse arguments
# ###########################################################################
opt=
val=
for opt do
val=${opt#*=}
opt=${opt%=*}
opt=${opt#*--}
case "$opt" in
help)
show_help
;;
*dir|prefix)
eval "$opt=$val"
;;
gzip)
eval "$(toupper ${opt}CMD)=\"$val\""
;;
cc|cflags|ldflags|arch|cpu|platform|python|bzip2|nowerror)
eval "$(toupper $opt)=\"$val\""
;;
enable-*)
opt=${opt#*-}
enable $opt 1
;;
disable-*)
opt=${opt#*-}
disable $opt 1
;;
esac
done
# ###########################################################################
# Checks
# ###########################################################################
echo "Checking support/features"
#
# Compiler
#
# Use ccache
if enabled_or_auto ccache; then
which ccache &> /dev/null
if [ $? -eq 0 ]; then
echo "$CC" | grep -q ccache || CC="ccache $CC"
enable ccache
elif enabled ccache; then
die "ccache not found, try --disable-ccache"
fi
fi
# Valiate compiler
check_cc || die 'No C compiler found'
check_cc_header execinfo
check_cc_option mmx
check_cc_option sse2
check_cc_optionW unused-result
if check_cc '
#if !defined(__clang__)
#error this is not clang
#endif
'; then
COMPILER=clang
else
COMPILER=gcc
fi
check_cc_snippet getloadavg '#include <stdlib.h>
void test() { getloadavg(NULL,0); }'
check_cc_snippet atomic64 '#include <stdint.h>
uint64_t test(uint64_t *ptr){
return __sync_fetch_and_add(ptr, 1);
}'
check_cc_snippet atomic_time_t '#include <stdint.h>
#include <time.h>
uint64_t test(time_t *ptr){
return __sync_fetch_and_add(ptr, 1);
}'
check_cc_snippet lockowner '
#include <sys/syscall.h>
#include <unistd.h>
#include <pthread.h>
#define TEST test
int ok = 1;
void *lockowner ( void *p)
{
pthread_mutex_t lock;
pthread_mutex_init(&lock, NULL);
pthread_mutex_lock(&lock);
if (lock.__data.__owner == syscall(SYS_gettid))
ok = 0;
return NULL;
}
int test ( void )
{
pthread_t tid;
pthread_create(&tid, NULL, lockowner, NULL);
pthread_join(tid, NULL);
return ok;
}' -lpthread
check_cc_snippet qsort_r '
#include <stdlib.h>
#define TEST test
int test(void)
{
qsort_r(NULL, 0, 0, NULL, NULL);
return 0;
}
'
check_cc_snippet stime '
#include <time.h>
#define TEST test
int test(void)
{
time_t t = 1;
stime(&t);
return 0;
}
'
check_cc_snippet gmtoff '
#include <time.h>
#define TEST test
int test(void)
{
struct tm x;
x.tm_gmtoff = 0;
return 0;
}
' -DHAS_GMTOFF
check_cc_snippet recvmmsg '
#define _GNU_SOURCE
#include <stdlib.h>
#include <sys/socket.h>
#define TEST test
int test(void)
{
recvmmsg(0, NULL, 0, 0, NULL);
return 0;
}
'
check_cc_snippet sendmmsg '
#define _GNU_SOURCE
#include <stdlib.h>
#include <sys/socket.h>
#define TEST test
int test(void)
{
sendmmsg(0, NULL, 0, 0);
return 0;
}
'
check_cc_snippet libiconv '
#include <iconv.h>
int test(void)
{
iconv_t ic = iconv_open("ASCII", "ASCII");
return 0;
}
' -liconv
if enabled_or_auto dvben50221; then
check_cc_snippet libdvben50221 '
#include <libdvben50221/en50221_session.h>
#define TEST test
int test(void)
{
struct en50221_transport_layer *tl = en50221_tl_create(5, 32);
return 0;
}
' '-ldvben50221 -ldvbapi -lucsi'
if enabled libdvben50221; then
enable dvben50221
else
disable dvben50221
fi
fi
check_cc_snippet ifnames '
#include <net/if.h>
int test(void)
{
struct if_nameindex *ifnames = if_nameindex();
if_freenameindex(ifnames);
return 0;
}
'
#
# Python
#
check_py || echo 'WARN: no python binary found'
check_py_import gzip
#
# Binaries
#
check_bin ${PKG_CONFIG} bin_pkg_config || die 'no pkg-config binaries found'
check_bin ${XGETTEXT} || die 'no gettext binaries found'
check_bin ${MSGMERGE} || die 'no gettext binaries found'
check_bin ${GZIPCMD} || die 'no gzip binary found'
check_bin ${BZIP2} || echo 'WARN: no bzip2 binary found'
#
# SSL
#
if [ ${PLATFORM} = "freebsd" ]; then
# FreeBSD has libssl in base
enable ssl
elif check_pkg openssl || check_pkg libssl; then
enable ssl
elif check_cc_header 'openssl/ssl' ssl; then
enable ssl
else
die "SSL development support not found"
fi
#
# OS X
#
if [ ${PLATFORM} = "darwin" ]; then
disable linuxdvb
disable avahi
enable bonjour
fi
#
# DVB API
#
check_cc_header 'linux/dvb/version' linuxdvbapi
if enabled_or_auto linuxdvb; then
if enabled linuxdvbapi; then
enable linuxdvb
elif enabled linuxdvb; then
die "Linux DVB API not found (use --disable-linuxdvb)"
fi
fi
#
# HDHomeRun - libhdhomerun
#
if enabled hdhomerun_static; then
enable hdhomerun_client
else
if enabled_or_auto hdhomerun_client; then
if check_cc_header 'libhdhomerun/hdhomerun' libhdhomerun; then
enable hdhomerun_client
LDFLAGS="$LDFLAGS -lhdhomerun"
fi
fi
fi
#
# Gzip
#
if enabled_or_auto zlib; then
if check_pkg zlib; then
enable zlib
elif enabled zlib; then
die "Zlib development support not found (use --disable-zlib)"
fi
fi
#
# SAT>IP server
#
if enabled_or_auto satip_server; then
enable upnp
fi
#
# SAT>IP client
#
if enabled_or_auto satip_client; then
enable upnp
fi
#
# uriparser
#
if enabled_or_auto uriparser; then
if check_pkg liburiparser; then
enable uriparser
elif enabled uriparser; then
die "liburiparser development support not found (use --disable-uriparser)"
fi
fi
#
# Bundling
#
if enabled bundle; then
if enabled zlib && ! enabled py_gzip; then
die "Python gzip module not found (use --disable-zlib or --disable-bundle)"
fi
fi
#
# Avahi
#
if enabled_or_auto avahi; then
if check_pkg avahi-client; then
enable avahi
elif enabled avahi; then
die "Avahi development support not found (use --disable-avahi)"
fi
fi
#
# ffmpeg
#
if enabled ffmpeg_static; then
enable libav
has_libav=true
# libx264
if enabled libx264; then
if disabled libx264_static; then
check_pkg x264 ">=0.142" || die "x264 package not found"
fi
else
disable libx264_static
fi
# libx265
if enabled libx265; then
if disabled libx265_static; then
check_pkg x265 ">=1.5" || die "x265 package not found"
else
check_bin cmake || die "cmake not found"
check_cc_lib stdc++ stdcpp || die "libstdc++ not found"
fi
else
disable libx265_static
fi
# libvpx
if enabled libvpx; then
if disabled libvpx_static; then
check_pkg vpx ">=1.3.0" || die "vpx package not found"
fi
else
disable libvpx_static
fi
# libtheora
if enabled libtheora; then
if disabled libtheora_static; then
check_pkg theoraenc ">=1.1.1" || die "theoraenc package not found"
check_pkg theoradec ">=1.1.1" || die "theoradec package not found"
check_pkg theora ">=1.1.1" || die "theora package not found"
else
enable libogg_static
fi
else
disable libtheora_static
fi
# libvorbis
if enabled libvorbis; then
if disabled libvorbis_static; then
check_pkg vorbisfile ">=1.3.4" || die "vorbisfile package not found"
check_pkg vorbisenc ">=1.3.4" || die "vorbisenc package not found"
check_pkg vorbis ">=1.3.4" || die "vorbis package not found"
else
enable libogg_static
fi
else
disable libvorbis_static
fi
# libfdk-aac
if enabled libfdkaac; then
if disabled libfdkaac_static; then
check_pkg fdk-aac ">=0.1.3" || die "fdk-aac package not found"
fi
else
disable libfdkaac_static
fi
# nvenc
if enabled_or_auto nvenc; then
if check_cc_header nvEncodeAPI; then
enable nvenc
elif enabled nvenc; then
die "NVENC library (https://developer.nvidia.com/nvidia-video-codec-sdk) not found"
fi
fi
# qsv
if enabled qsv; then
if disabled libmfx_static; then
check_pkg libmfx ">=1.16" || die "libmfx package not found"
else
check_bin autoreconf || die "autoreconf not found"
check_bin libtool || die "libtool not found"
check_bin libtoolize || die "libtoolize not found"
check_cc_lib stdc++ stdcpp || die "libstdc++ not found"
fi
enable vaapi
else
disable libmfx_static
fi
# vaapi
if enabled vaapi; then
check_pkg libva ">=0.38.0" || \
die "vaapi (Video Acceleration (VA) API for Linux) not found"
check_pkg libva-x11 ">=0.38.0" || die "libva-x11 not found"
check_pkg libva-drm ">=0.38.0" || die "libva-drm not found"
fi
else
if enabled_or_auto libav; then
has_libav=true
check_pkg libavfilter ">=6.31.100" || has_libav=false
check_pkg libswresample ">=2.0.101" || has_libav=false
check_pkg libavresample ">=3.0.0" || has_libav=false
check_pkg libswscale ">=4.0.100" || has_libav=false
check_pkg libavformat ">=57.25.100" || has_libav=false
check_pkg libavcodec ">=57.24.102" || has_libav=false
check_pkg libavutil ">=55.17.103" || has_libav=false
if $has_libav; then
enable libav
else
echo "WARNING: none or old ffmpeg libraries were detected"
echo " * use --disable-libav or --enable-ffmpeg_static"
if enabled libav; then
die "ffmpeg development support not found"
fi
fi
fi
fi
#
# Inotify
#
if enabled_or_auto inotify; then
if check_cc_header "sys/inotify" inotify_h; then
enable inotify
elif enabled inotify; then
die "Inotify support not found (use --disable-inotify)"
fi
fi
#
# libdvbcsa, tvhcsa
#
if enabled cwc || enabled capmt || enabled constcw; then
enable tvhcsa
if enabled dvbcsa; then
(check_cc_header "dvbcsa/dvbcsa" dvbcsa_h &&\
check_cc_lib dvbcsa dvbcsa_l) ||\
die "Failed to find dvbcsa support (use --disable-dvbcsa)"
LDFLAGS="$LDFLAGS -ldvbcsa"
fi
fi
#
# libdvben50221
#
if enabled libdvben50221; then
LDFLAGS="$LDFLAGS -ldvben50221 -ldvbapi -lucsi"
enable linuxdvb_ca
fi
#
# Icon caching
#
if enabled_or_auto imagecache; then
enable imagecache
fi
#
# DVB scan
#
if enabled dvbscan; then
printf "${TAB}" "fetching dvb-scan files ..."
"${ROOTDIR}/support/getmuxlist"
if [ $? -ne 0 ]; then
echo "fail"
check_bin git || echo "FATAL: git binary not found (install the git package)"
die "Failed to fetch dvb-scan data (use --disable-dvbscan)"
fi
echo "ok"
fi
#
# epoll
#
if [ ${PLATFORM} = "linux" ]; then
enable epoll
fi
#
# kqueue
#
if [ ${PLATFORM} = "freebsd" ] || [ ${PLATFORM} = "darwin" ]; then
enable kqueue
fi
#
# MPEGTS support
#
disable mpegts
disable mpegts_dvb
if enabled linuxdvb || enabled iptv || enabled tsfile || enabled satip_client || \
enabled hdhomerun_client || enabled satip_server;
then
enable mpegts
fi
if enabled linuxdvb || enabled satip_client || enabled hdhomerun_client || enabled satip_server; then
enable mpegts_dvb
fi
#
# DBus
#
if enabled_or_auto dbus_1; then
if check_pkg dbus-1; then
enable dbus_1
elif enabled dbus-1; then
die "DBus-1 development support not found (use --disable-dbus-1)"
fi
fi
#
# TSDebug
#
if enabled_or_auto tsdebug; then
enable mpegts_dvb
fi
#
# systemd
#
if enabled_or_auto libsystemd_daemon; then
if check_pkg libsystemd-daemon; then
enable libsystemd_daemon
elif enabled libsystemd_daemon; then
die "libsystemd-daemon development support not found (use --disable-systemd_daemon)"
fi
fi
# ###########################################################################
# Write config
# ###########################################################################
# Write config
write_config
cat >> "${CONFIG_H}" <<EOF
#define TVHEADEND_DATADIR "$(eval echo ${datadir})/tvheadend"
EOF
# Output config
print_config
echo "Final Binary:"
echo " $BUILDDIR/tvheadend"
echo ""
echo "Tvheadend Data Directory:"
echo " $(eval echo ${datadir}/tvheadend)"
echo ""