forked from aiolos/sasc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
263 lines (208 loc) · 8.46 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
#
# Softcam plugin to VDR
#
# This code 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 2
# of the License, or (at your option) any later version.
#
# This code 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Or, point your browser to http://www.gnu.org/copyleft/gpl.html
# The official name of this plugin.
# This name will be used in the '-P...' option of VDR to load the plugin.
# By default the main source file also carries this name.
#
PLUGIN = sc
### The version number of this plugin
DISTFILE = .distvers
HGARCHIVE = .hg_archival.txt
RELEASE := $(shell grep 'define SC_RELEASE' version.h | awk '{ print $$3 }' | sed -e 's/[";]//g')
SUBREL := $(shell if test -d .hg; then \
echo -n "HG-"; (hg identify 2>/dev/null || echo -n "Stable") | sed -e 's/ .*//'; \
elif test -r $(HGARCHIVE); then \
echo -n "AR-"; grep "^node" $(HGARCHIVE) | awk '{ printf "%.12s",$$2 }'; \
elif test -r $(DISTFILE); then \
cat $(DISTFILE); \
else \
echo -n "Stable"; \
fi)
VERSION := $(RELEASE)-$(SUBREL)
SCAPIVERS := $(shell sed -ne '/define SCAPIVERS/ s/^.[a-zA-Z ]*\([0-9]*\).*$$/\1/p' version.h)
### The directory environment:
VDRDIR = ../../..
LIBDIR = ../../lib
SYSDIR = ./systems
PREDIR = ./systems-pre
TMPDIR = /tmp
### The C++ compiler and options:
CXX ?= g++
CXXFLAGS ?= -O2 -g -fPIC -Wall -Woverloaded-virtual
### Includes and Defines
INCLUDES = -I$(VDRDIR)/include
DEFINES = -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
SHAREDDEFINES = -DAPIVERSNUM=$(APIVERSNUM) -D_GNU_SOURCE
LIBS = -lcrypto
SHAREDLIBS =
### Allow user defined options to overwrite defaults:
-include $(VDRDIR)/Make.config
-include Make.config
### The version number of VDR (taken from VDR's "config.h"):
VDRVERSION := $(shell sed -ne '/define VDRVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
APIVERSION := $(shell sed -ne '/define APIVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
ifeq ($(strip $(APIVERSION)),)
APIVERSION = $(VDRVERSION)
endif
VDRVERSNUM := $(shell sed -ne '/define VDRVERSNUM/ s/^.[a-zA-Z ]*\([0-9]*\) .*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
APIVERSNUM := $(shell sed -ne '/define APIVERSNUM/ s/^.[a-zA-Z ]*\([0-9]*\) .*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
ifeq ($(strip $(APIVERSNUM)),)
APIVERSNUM = $(VDRVERSNUM)
endif
### The object files (add further files here):
OBJS = $(PLUGIN).o data.o filter.o system.o misc.o cam.o device.o version.o \
smartcard.o network.o crypto.o system-common.o parse.o log.o \
override.o
### Internationalization (I18N):
PODIR = po
I18Npot = $(PODIR)/$(PLUGIN).pot
I18Nmo = vdr-$(PLUGIN).mo
I18Nmsgs = $(addprefix $(LOCALEDIR)/,$(addsuffix /LC_MESSAGES/$(I18Nmo),$(notdir $(foreach file, $(wildcard $(PODIR)/*.po), $(basename $(file))))))
LOCALEDIR = $(VDRDIR)/locale
### VDR version dependant
# test VDR version
BYVERS = $(strip $(shell if test $(APIVERSNUM) -ge 010703; then echo "*"; fi))
# test if PlayTsVideo() exists (e.g. TSplay patch)
BYTSPL = $(strip $(shell grep -l 'PlayTsVideo' $(VDRDIR)/include/vdr/device.h))
ifneq ($(BYVERS)$(BYTSPL),)
SHAREDDEFINES += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
endif
#
# generic stuff
#
# smartcard default port (dropped)
ifdef DEFAULT_PORT
$(error DEFAULT_PORT support was removed, use cardslot.conf)
endif
ifdef WITH_PCSC
DEFINES += -DWITH_PCSC
LIBS += -lpcsclite
endif
# max number of CAIDs per slot
MAXCAID := $(shell sed -ne '/define MAXCASYSTEMIDS/ s/^.[a-zA-Z ]*\([0-9]*\).*$$/\1/p' $(VDRDIR)/ci.c)
ifneq ($(strip $(MAXCAID)),)
DEFINES += -DVDR_MAXCAID=$(MAXCAID)
endif
# FFdeCSA
CPUOPT ?= pentium
PARALLEL ?= PARALLEL_32_INT
CSAFLAGS ?= -Wall -fPIC -g -O3 -mmmx -fomit-frame-pointer -fexpensive-optimizations -funroll-loops
FFDECSADIR = FFdecsa
FFDECSA = $(FFDECSADIR)/FFdecsa.o
FFDECSATEST = $(FFDECSADIR)/FFdecsa_test.done
# SASC
ifdef SASC
DEFINES += -DSASC
FFDECSA =
FFDECSATEST =
endif
# export for system makefiles
export SCAPIVERS
export APIVERSION
export INCLUDES
export SHAREDDEFINES
export SHAREDLIBS
export CXX
export CXXFLAGS
### Targets:
ifdef STATIC
BUILDTARGETS = $(LIBDIR)/libvdr-$(PLUGIN).a
SHAREDDEFINES += -DSTATICBUILD
else
BUILDTARGETS = $(LIBDIR)/libvdr-$(PLUGIN).so.$(APIVERSION) systems-pre
endif
BUILDTARGETS += $(FFDECSATEST) systems i18n
all: $(BUILDTARGETS)
.PHONY: i18n systems systems-pre contrib clean clean-core clean-systems clean-pre dist srcdist
# Dependencies:
MAKEDEP = g++ -MM -MG
DEPFILE = .dependencies
DEPFILES = $(subst i18n.c,,$(subst version.c,,$(OBJS:%.o=%.c)))
$(DEPFILE): $(DEPFILES) $(wildcard *.h)
@$(MAKEDEP) $(DEFINES) $(SHAREDDEFINES) $(INCLUDES) $(DEPFILES) > $@
-include $(DEPFILE)
# Rules
%.o: %.c
$(CXX) $(CXXFLAGS) -c $(DEFINES) $(SHAREDDEFINES) $(INCLUDES) $<
libvdr-$(PLUGIN).so: $(OBJS) $(FFDECSA)
$(CXX) $(CXXFLAGS) -shared $(OBJS) $(FFDECSA) $(LIBS) $(SHAREDLIBS) -o $@
$(LIBDIR)/libvdr-$(PLUGIN).so.$(APIVERSION): libvdr-$(PLUGIN).so
@cp -p $< $@
$(LIBDIR)/libvdr-$(PLUGIN).a: $(OBJS)
$(AR) r $@ $(OBJS)
$(FFDECSA) $(FFDECSATEST): $(FFDECSADIR)/*.c $(FFDECSADIR)/*.h
@$(MAKE) COMPILER="$(CXX)" FLAGS="$(CSAFLAGS) -march=$(CPUOPT)" PARALLEL_MODE=$(PARALLEL) -C $(FFDECSADIR) all
$(I18Npot): $(shell grep -rl '\(tr\|trNOOP\)(\".*\")' *.c $(SYSDIR))
xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='<[email protected]>' -o $@ `ls $^`
%.po: $(I18Npot)
msgmerge -U --no-wrap --no-location --backup=none -q $@ $<
@touch $@
%.mo: %.po
msgfmt -c -o $@ $<
$(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/$(I18Nmo): $(PODIR)/%.mo
@mkdir -p $(dir $@)
cp $< $@
i18n: $(I18Nmsgs)
version.c: FORCE
@echo >[email protected] "/* generated file, do not edit */"; \
echo >>[email protected] 'const char *ScVersion =' '"'$(VERSION)'";'; \
diff [email protected] $@ >[email protected] 2>&1; \
if test -s [email protected]; then mv -f [email protected] $@; fi; \
systems:
@for i in `ls -A -I ".*" $(SYSDIR)`; do $(MAKE) -f ../../Makefile.system -C "$(SYSDIR)/$$i" all || exit 1; done
systems-pre:
@for i in `ls -A -I ".*" $(PREDIR) | grep -- '-$(SCAPIVERS).so.$(APIVERSION)$$'`; do cp -p "$(PREDIR)/$$i" "$(LIBDIR)"; done
contrib:
@$(MAKE) -C contrib all
clean-systems:
@for i in `ls -A -I ".*" $(SYSDIR)`; do $(MAKE) -f ../../Makefile.system -C "$(SYSDIR)/$$i" clean; done
clean-core:
@$(MAKE) -C testing clean
@$(MAKE) -C contrib clean
@if test -d $(FFDECSADIR); then $(MAKE) -C $(FFDECSADIR) clean; fi
@-rm -f $(LIBDIR)/libsc-*-$(SCAPIVERS).so.$(APIVERSION)
@-rm -f $(LIBDIR)/libvdr-$(PLUGIN).a $(LIBDIR)/libsc-*.a
@-rm -f $(OBJS) $(DEPFILE) version.c *.so *.tar.gz core* *~
@-rm -f $(PODIR)/*.mo
clean-pre:
@-find "$(PREDIR)" -type f -not -name ".empty" -not -iname "*-$(SCAPIVERS).so.*" | xargs rm -f
clean: clean-core clean-systems
dist: ARCHIVE := $(PLUGIN)-$(RELEASE)
dist: clean-core
@for i in `ls -A -I ".*" $(SYSDIR)`; do $(MAKE) -f ../../Makefile.system -C "$(SYSDIR)/$$i" dist; done
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@mkdir $(TMPDIR)/$(ARCHIVE)
@cp -a * $(TMPDIR)/$(ARCHIVE)
@echo -n "release" >$(TMPDIR)/$(ARCHIVE)/$(DISTFILE)
@path="$(TMPDIR)/$(ARCHIVE)/$(notdir $(SYSDIR))";\
for i in `ls -A -I ".*" $$path`; do if [ -f "$$path/$$i/nonpublic.mk" ]; then rm -rf "$$path/$$i"; fi; if [ -f "$$path/$$i/nonpublic.sh" ]; then (cd $$path/$$i ; source ./nonpublic.sh ; rm ./nonpublic.sh); fi; done
@strip --strip-unneeded --preserve-dates $(TMPDIR)/$(ARCHIVE)/$(notdir $(PREDIR))/* || true
@tar czf vdr-$(ARCHIVE).tar.gz -C $(TMPDIR) $(ARCHIVE)
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@echo Distribution package created as vdr-$(ARCHIVE).tar.gz
copy: ARCHIVE := $(PLUGIN)-$(VERSION)
copy: clean clean-pre
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@mkdir $(TMPDIR)/$(ARCHIVE)
@cp -a .hgtags .hgignore * $(TMPDIR)/$(ARCHIVE)
@echo -n $(SUBREL) | sed -e 's/HG-/CP-/' >$(TMPDIR)/$(ARCHIVE)/$(DISTFILE)
@tar czf vdr-$(ARCHIVE).tar.gz -C $(TMPDIR) $(ARCHIVE)
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@echo Full copy package created as vdr-$(ARCHIVE).tar.gz
FORCE: