forked from tvheadend/tvheadend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
418 lines (353 loc) · 9.93 KB
/
Makefile
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
#
# Tvheadend streaming server.
# Copyright (C) 2007-2009 Andreas Öman
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# Configuration
#
include $(dir $(lastword $(MAKEFILE_LIST))).config.mk
PROG := $(BUILDDIR)/tvheadend
#
# Common compiler flags
#
CFLAGS += -g -O2 -Wunused-result
CFLAGS += -Wall -Werror -Wwrite-strings -Wno-deprecated-declarations
CFLAGS += -Wmissing-prototypes
CFLAGS += -fms-extensions -funsigned-char -fno-strict-aliasing
CFLAGS += -D_FILE_OFFSET_BITS=64
CFLAGS += -I${BUILDDIR} -I${ROOTDIR}/src -I${ROOTDIR}
LDFLAGS += -ldl -lpthread -lm
ifeq ($(CONFIG_LIBICONV),yes)
LDFLAGS += -liconv
endif
ifeq ($(PLATFORM), darwin)
LDFLAGS += -framework CoreServices
else
LDFLAGS += -lrt
endif
ifeq ($(COMPILER), clang)
CFLAGS += -Wno-microsoft -Qunused-arguments -Wno-unused-function
CFLAGS += -Wno-unused-value -Wno-tautological-constant-out-of-range-compare
CFLAGS += -Wno-parentheses-equality -Wno-incompatible-pointer-types
endif
vpath %.c $(ROOTDIR)
vpath %.h $(ROOTDIR)
#
# Other config
#
BUNDLE_FLAGS-${CONFIG_ZLIB} = -z
BUNDLE_FLAGS = ${BUNDLE_FLAGS-yes}
#
# Binaries/Scripts
#
MKBUNDLE = $(PYTHON) $(ROOTDIR)/support/mkbundle
#
# Debug/Output
#
ifndef V
ECHO = printf "%-16s%s\n" $(1) $(2)
BRIEF = CC MKBUNDLE CXX
MSG = $(subst $(BUILDDIR)/,,$@)
$(foreach VAR,$(BRIEF), \
$(eval $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
endif
#
# Core
#
SRCS = src/version.c \
src/uuid.c \
src/main.c \
src/tvhlog.c \
src/idnode.c \
src/prop.c \
src/utils.c \
src/wrappers.c \
src/access.c \
src/dtable.c \
src/tcp.c \
src/udp.c \
src/url.c \
src/http.c \
src/notify.c \
src/file.c \
src/epg.c \
src/epgdb.c\
src/epggrab.c\
src/spawn.c \
src/packet.c \
src/streaming.c \
src/channels.c \
src/subscriptions.c \
src/service.c \
src/htsp_server.c \
src/htsmsg.c \
src/htsmsg_binary.c \
src/htsmsg_json.c \
src/htsmsg_xml.c \
src/misc/dbl.c \
src/misc/json.c \
src/settings.c \
src/htsbuf.c \
src/trap.c \
src/avg.c \
src/htsstr.c \
src/tvhpoll.c \
src/huffman.c \
src/filebundle.c \
src/config.c \
src/lang_codes.c \
src/lang_str.c \
src/imagecache.c \
src/tvhtime.c \
src/service_mapper.c \
src/input.c \
src/httpc.c \
src/rtsp.c \
src/fsmonitor.c \
src/cron.c \
src/esfilter.c \
src/intlconv.c
SRCS-${CONFIG_UPNP} += \
src/upnp.c
SRCS += \
src/api.c \
src/api/api_status.c \
src/api/api_idnode.c \
src/api/api_input.c \
src/api/api_channel.c \
src/api/api_service.c \
src/api/api_mpegts.c \
src/api/api_epg.c \
src/api/api_epggrab.c \
src/api/api_imagecache.c \
src/api/api_esfilter.c \
src/api/api_intlconv.c
SRCS += \
src/parsers/parsers.c \
src/parsers/bitstream.c \
src/parsers/parser_h264.c \
src/parsers/parser_latm.c \
src/parsers/parser_avc.c \
src/parsers/parser_teletext.c \
SRCS += src/epggrab/module.c\
src/epggrab/channel.c\
src/epggrab/module/pyepg.c\
src/epggrab/module/xmltv.c\
SRCS += src/plumbing/tsfix.c \
src/plumbing/globalheaders.c
SRCS += src/dvr/dvr_db.c \
src/dvr/dvr_rec.c \
src/dvr/dvr_autorec.c \
src/dvr/dvr_cutpoints.c \
SRCS += src/webui/webui.c \
src/webui/comet.c \
src/webui/extjs.c \
src/webui/simpleui.c \
src/webui/statedump.c \
src/webui/html.c\
src/webui/webui_api.c\
SRCS += src/muxer.c \
src/muxer/muxer_pass.c \
src/muxer/muxer_tvh.c \
src/muxer/tvh/ebml.c \
src/muxer/tvh/mkmux.c \
#
# Optional code
#
# MPEGTS core
SRCS-$(CONFIG_MPEGTS) += \
src/descrambler/descrambler.c \
src/input/mpegts.c \
src/input/mpegts/mpegts_input.c \
src/input/mpegts/mpegts_network.c \
src/input/mpegts/mpegts_mux.c \
src/input/mpegts/mpegts_service.c \
src/input/mpegts/mpegts_table.c \
src/input/mpegts/dvb_support.c \
src/input/mpegts/dvb_charset.c \
src/input/mpegts/dvb_psi.c \
src/input/mpegts/tsdemux.c \
src/input/mpegts/mpegts_mux_sched.c \
src/input/mpegts/mpegts_network_scan.c \
# MPEGTS DVB
SRCS-${CONFIG_MPEGTS_DVB} += \
src/input/mpegts/mpegts_network_dvb.c \
src/input/mpegts/mpegts_mux_dvb.c \
src/input/mpegts/scanfile.c
# MPEGTS EPG
SRCS-$(CONFIG_MPEGTS) += \
src/epggrab/otamux.c\
src/epggrab/module/eit.c \
src/epggrab/support/freesat_huffman.c \
src/epggrab/module/opentv.c \
# LINUX DVB
SRCS-${CONFIG_LINUXDVB} += \
src/input/mpegts/linuxdvb/linuxdvb.c \
src/input/mpegts/linuxdvb/linuxdvb_adapter.c \
src/input/mpegts/linuxdvb/linuxdvb_frontend.c \
src/input/mpegts/linuxdvb/linuxdvb_satconf.c \
src/input/mpegts/linuxdvb/linuxdvb_lnb.c \
src/input/mpegts/linuxdvb/linuxdvb_switch.c \
src/input/mpegts/linuxdvb/linuxdvb_rotor.c \
src/input/mpegts/linuxdvb/linuxdvb_en50494.c
# SATIP
SRCS-${CONFIG_SATIP_CLIENT} += \
src/input/mpegts/satip/satip.c \
src/input/mpegts/satip/satip_frontend.c \
src/input/mpegts/satip/satip_satconf.c \
src/input/mpegts/satip/satip_rtsp.c
# IPTV
SRCS-${CONFIG_IPTV} += \
src/input/mpegts/iptv/iptv.c \
src/input/mpegts/iptv/iptv_mux.c \
src/input/mpegts/iptv/iptv_service.c \
src/input/mpegts/iptv/iptv_http.c \
src/input/mpegts/iptv/iptv_udp.c \
# TSfile
SRCS-$(CONFIG_TSFILE) += \
src/input/mpegts/tsfile/tsfile.c \
src/input/mpegts/tsfile/tsfile_input.c \
src/input/mpegts/tsfile/tsfile_mux.c \
# Timeshift
SRCS-${CONFIG_TIMESHIFT} += \
src/timeshift.c \
src/timeshift/timeshift_filemgr.c \
src/timeshift/timeshift_writer.c \
src/timeshift/timeshift_reader.c \
# Inotify
SRCS-${CONFIG_INOTIFY} += \
src/dvr/dvr_inotify.c \
# Avahi
SRCS-$(CONFIG_AVAHI) += src/avahi.c
# Bonjour
SRCS-$(CONFIG_BONJOUR) += src/bonjour.c
# libav
SRCS-$(CONFIG_LIBAV) += src/libav.c \
src/muxer/muxer_libav.c \
src/plumbing/transcoding.c \
# Tvhcsa
SRCS-${CONFIG_TVHCSA} += \
src/descrambler/tvhcsa.c
# CWC
SRCS-${CONFIG_CWC} += \
src/descrambler/cwc.c \
# CAPMT
SRCS-${CONFIG_CAPMT} += \
src/descrambler/capmt.c
# FFdecsa
ifneq ($(CONFIG_DVBCSA),yes)
FFDECSA-$(CONFIG_CAPMT) = yes
FFDECSA-$(CONFIG_CWC) = yes
endif
ifeq ($(FFDECSA-yes),yes)
SRCS-yes += src/descrambler/ffdecsa/ffdecsa_interface.c \
src/descrambler/ffdecsa/ffdecsa_int.c
SRCS-${CONFIG_MMX} += src/descrambler/ffdecsa/ffdecsa_mmx.c
SRCS-${CONFIG_SSE2} += src/descrambler/ffdecsa/ffdecsa_sse2.c
${BUILDDIR}/src/descrambler/ffdecsa/ffdecsa_mmx.o : CFLAGS += -mmmx
${BUILDDIR}/src/descrambler/ffdecsa/ffdecsa_sse2.o : CFLAGS += -msse2
endif
# libaesdec
SRCS-${CONFIG_SSL} += src/descrambler/libaesdec/libaesdec.c
# DBUS
SRCS-${CONFIG_DBUS_1} += src/dbus.c
# File bundles
SRCS-${CONFIG_BUNDLE} += bundle.c
BUNDLES-yes += docs/html docs/docresources src/webui/static
BUNDLES-yes += data/conf
BUNDLES-${CONFIG_DVBSCAN} += data/dvb-scan
BUNDLES = $(BUNDLES-yes)
ALL-$(CONFIG_DVBSCAN) += check_dvb_scan
#
# Add-on modules
#
SRCS_EXTRA = src/extra/capmt_ca.c
#
# Variable transformations
#
SRCS += $(SRCS-yes)
OBJS = $(SRCS:%.c=$(BUILDDIR)/%.o)
OBJS_EXTRA = $(SRCS_EXTRA:%.c=$(BUILDDIR)/%.so)
DEPS = ${OBJS:%.o=%.d}
#
# Build Rules
#
# Default
all: $(ALL-yes) ${PROG}
# Special
.PHONY: clean distclean check_config reconfigure
# Check configure output is valid
check_config:
@test $(ROOTDIR)/.config.mk -nt $(ROOTDIR)/configure\
|| echo "./configure output is old, please re-run"
@test $(ROOTDIR)/.config.mk -nt $(ROOTDIR)/configure
# Recreate configuration
reconfigure:
$(ROOTDIR)/configure $(CONFIGURE_ARGS)
# Binary
${PROG}: check_config $(OBJS) $(ALLDEPS)
$(CC) -o $@ $(OBJS) $(CFLAGS) $(LDFLAGS)
# Object
${BUILDDIR}/%.o: %.c
@mkdir -p $(dir $@)
$(CC) -MD -MP $(CFLAGS) -c -o $@ $<
# Add-on
${BUILDDIR}/%.so: ${SRCS_EXTRA}
@mkdir -p $(dir $@)
${CC} -O -fbuiltin -fomit-frame-pointer -fPIC -shared -o $@ $< -ldl
# Clean
clean:
rm -rf ${BUILDDIR}/src ${BUILDDIR}/bundle*
find . -name "*~" | xargs rm -f
distclean: clean
rm -rf ${ROOTDIR}/build.*
rm -f ${ROOTDIR}/.config.mk
# Create version
$(BUILDDIR)/src/version.o: $(ROOTDIR)/src/version.c
$(ROOTDIR)/src/version.c: FORCE
@$(ROOTDIR)/support/version $@ > /dev/null
FORCE:
# Include dependency files if they exist.
-include $(DEPS)
# Include OS specific targets
include ${ROOTDIR}/support/${OSENV}.mk
# Bundle files
$(BUILDDIR)/bundle.o: $(BUILDDIR)/bundle.c
@mkdir -p $(dir $@)
$(CC) -I${ROOTDIR}/src -c -o $@ $<
$(BUILDDIR)/bundle.c:
@mkdir -p $(dir $@)
$(MKBUNDLE) -o $@ -d ${BUILDDIR}/bundle.d $(BUNDLE_FLAGS) $(BUNDLES:%=$(ROOTDIR)/%)
# linuxdvb git tree
$(ROOTDIR)/data/dvb-scan/.stamp:
@echo "Receiving data/dvb-scan/dvb-t from http://linuxtv.org/git/dtv-scan-tables.git"
@rm -rf $(ROOTDIR)/data/dvb-scan/*
@$(ROOTDIR)/support/getmuxlist $(ROOTDIR)/data/dvb-scan
@touch $(ROOTDIR)/data/dvb-scan/.stamp
.PHONY: check_dvb_scan
check_dvb_scan: $(ROOTDIR)/data/dvb-scan/.stamp
# dvb-s / enigma2 / satellites.xml
$(ROOTDIR)/data/dvb-scan/dvb-s/.stamp: $(ROOTDIR)/data/satellites.xml \
$(ROOTDIR)/data/dvb-scan/.stamp
@echo "Generating data/dvb-scan/dvb-s from data/satellites.xml"
@if ! test -s $(ROOTDIR)/data/satellites.xml ; then echo "Put your satellites.xml file to $(ROOTDIR)/data/satellites.xml"; exit 1; fi
@if ! test -d $(ROOTDIR)/data/dvb-scan/dvb-s ; then mkdir $(ROOTDIR)/data/dvb-scan/dvb-s ; fi
@rm -rf $(ROOTDIR)/data/dvb-scan/dvb-s/*
@$(ROOTDIR)/support/sat_xml_scan.py \
$(ROOTDIR)/data/satellites.xml $(ROOTDIR)/data/dvb-scan/dvb-s
@touch $(ROOTDIR)/data/dvb-scan/dvb-s/.stamp
.PHONY: satellites_xml
satellites_xml: $(ROOTDIR)/data/dvb-scan/dvb-s/.stamp