Advertisement
tomycz

sc makefile

Dec 1st, 2011
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.69 KB | None | 0 0
  1. #
  2. # Softcam plugin to VDR
  3. #
  4. # This code is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This code is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. # Or, point your browser to http://www.gnu.org/copyleft/gpl.html
  18.  
  19. # The official name of this plugin.
  20. # This name will be used in the '-P...' option of VDR to load the plugin.
  21. # By default the main source file also carries this name.
  22. #
  23. PLUGIN = sc
  24.  
  25. ### The version number of this plugin
  26.  
  27. DISTFILE = .distvers
  28. HGARCHIVE = .hg_archival.txt
  29. RELEASE := $(shell grep 'define SC_RELEASE' version.h | awk '{ print $$3 }' | sed -e 's/[";]//g')
  30. SUBREL := $(shell if test -d .hg; then \
  31. echo -n "HG-"; (hg identify 2>/dev/null || echo -n "Unknown") | sed -e 's/ .*//'; \
  32. elif test -r $(HGARCHIVE); then \
  33. echo -n "AR-"; grep "^node" $(HGARCHIVE) | awk '{ printf "%.12s",$$2 }'; \
  34. elif test -r $(DISTFILE); then \
  35. cat $(DISTFILE); \
  36. else \
  37. echo -n "Unknown"; \
  38. fi)
  39. VERSION := $(RELEASE)-$(SUBREL)
  40. SCAPIVERS := $(shell sed -ne '/define SCAPIVERS/ s/^.[a-zA-Z ]*\([0-9]*\).*$$/\1/p' version.h)
  41.  
  42. ### The directory environment:
  43.  
  44. VDRDIR = ../../..
  45. LIBDIR = ../../lib
  46. SYSDIR = ./systems
  47. PREDIR = ./systems-pre
  48. TMPDIR = /tmp
  49.  
  50. ### The C++ compiler and options:
  51.  
  52. CXX ?= g++
  53. CXXFLAGS ?= -O2 -g -fPIC -Wall -Woverloaded-virtual
  54.  
  55. ### Includes and Defines
  56.  
  57. INCLUDES = -I$(VDRDIR)/include
  58. DEFINES = -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
  59. SHAREDDEFINES = -DAPIVERSNUM=$(APIVERSNUM) -D_GNU_SOURCE
  60. LIBS = -lcrypto
  61. SHAREDLIBS =
  62.  
  63. ### Allow user defined options to overwrite defaults:
  64.  
  65. -include $(VDRDIR)/Make.config
  66. -include Make.config
  67.  
  68. ### The version number of VDR (taken from VDR's "config.h"):
  69.  
  70. VDRVERSION := $(shell sed -ne '/define VDRVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
  71. APIVERSION := $(shell sed -ne '/define APIVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
  72. ifeq ($(strip $(APIVERSION)),)
  73. APIVERSION = $(VDRVERSION)
  74. endif
  75. VDRVERSNUM := $(shell sed -ne '/define VDRVERSNUM/ s/^.[a-zA-Z ]*\([0-9]*\) .*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
  76. APIVERSNUM := $(shell sed -ne '/define APIVERSNUM/ s/^.[a-zA-Z ]*\([0-9]*\) .*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
  77. ifeq ($(strip $(APIVERSNUM)),)
  78. APIVERSNUM = $(VDRVERSNUM)
  79. endif
  80.  
  81. ### The object files (add further files here):
  82.  
  83. OBJS = $(PLUGIN).o data.o filter.o system.o misc.o cam.o device.o version.o \
  84. smartcard.o network.o crypto.o system-common.o parse.o log.o \
  85. override.o
  86.  
  87. ### Internationalization (I18N):
  88.  
  89. PODIR = po
  90. I18Npot = $(PODIR)/$(PLUGIN).pot
  91. I18Nmo = vdr-$(PLUGIN).mo
  92. I18Nmsgs = $(addprefix $(LOCALEDIR)/,$(addsuffix /LC_MESSAGES/$(I18Nmo),$(notdir $(foreach file, $(wildcard $(PODIR)/*.po), $(basename $(file))))))
  93. LOCALEDIR = $(VDRDIR)/locale
  94.  
  95. ### VDR version dependant
  96.  
  97. # test VDR version
  98. BYVERS = $(strip $(shell if test $(APIVERSNUM) -ge 010703; then echo "*"; fi))
  99. # test if PlayTsVideo() exists (e.g. TSplay patch)
  100. BYTSPL = $(strip $(shell grep -l 'PlayTsVideo' $(VDRDIR)/include/vdr/device.h))
  101.  
  102. ifneq ($(BYVERS)$(BYTSPL),)
  103. SHAREDDEFINES += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  104. endif
  105.  
  106. #
  107. # generic stuff
  108. #
  109.  
  110. # smartcard default port (dropped)
  111. ifdef DEFAULT_PORT
  112. $(error DEFAULT_PORT support was removed, use cardslot.conf)
  113. endif
  114.  
  115. ifdef WITH_PCSC
  116. DEFINES += -DWITH_PCSC
  117. LIBS += -lpcsclite
  118. endif
  119.  
  120. HAVE_SD := $(wildcard ../dvbsddevice/dvbsddevice.c)
  121. ifneq ($(strip $(HAVE_SD)),)
  122. DEFINES += -DWITH_SDDVB
  123. DEVPLUGTARGETS += $(LIBDIR)/libsc-dvbsddevice-$(SCAPIVERS).so.$(APIVERSION)
  124. endif
  125. DEVPLUGOBJS += device-sd.o
  126. HAVE_HD := $(wildcard ../dvbhddevice/dvbhddevice.c)
  127. ifneq ($(strip $(HAVE_HD)),)
  128. HDVERS := $(shell sed -ne '/*VERSION/ s/^.*=.*"\(.*\)".*$$/\1/p' ../dvbhddevice/dvbhddevice.c)
  129. ifeq ($(findstring dag,$(HDVERS)),)
  130. DEFINES += -DWITH_HDDVB
  131. DEVPLUGTARGETS += $(LIBDIR)/libsc-dvbhddevice-$(SCAPIVERS).so.$(APIVERSION)
  132. endif
  133. endif
  134. DEVPLUGOBJS += device-hd.o
  135.  
  136. # max number of CAIDs per slot
  137. MAXCAID := $(shell sed -ne '/define MAXCASYSTEMIDS/ s/^.[a-zA-Z ]*\([0-9]*\).*$$/\1/p' $(VDRDIR)/ci.c)
  138. ifneq ($(strip $(MAXCAID)),)
  139. DEFINES += -DVDR_MAXCAID=$(MAXCAID)
  140. endif
  141.  
  142. # FFdeCSA
  143. CPUOPT ?= native
  144. PARALLEL ?= PARALLEL_128_SSE2
  145. CSAFLAGS ?= -O3 -msse4.1 -fexpensive-optimizations -fomit-frame-pointer -funroll-loops
  146. FFDECSADIR = FFdecsa
  147. FFDECSA = $(FFDECSADIR)/FFdecsa.o
  148. FFDECSATEST = $(FFDECSADIR)/FFdecsa_test.done
  149.  
  150. # SASC
  151. ifdef SASC
  152. DEFINES += -DSASC
  153. FFDECSA =
  154. FFDECSATEST =
  155. endif
  156.  
  157. # export for system makefiles
  158. export SCAPIVERS
  159. export APIVERSION
  160. export INCLUDES
  161. export SHAREDDEFINES
  162. export SHAREDLIBS
  163. export CXX
  164. export CXXFLAGS
  165.  
  166. ### Targets:
  167.  
  168. ifdef STATIC
  169. BUILDTARGETS = $(LIBDIR)/libvdr-$(PLUGIN).a
  170. SHAREDDEFINES += -DSTATICBUILD
  171. else
  172. BUILDTARGETS = $(LIBDIR)/libvdr-$(PLUGIN).so.$(APIVERSION) systems-pre $(DEVPLUGTARGETS)
  173. endif
  174. BUILDTARGETS += $(FFDECSATEST) systems i18n
  175.  
  176. all: $(BUILDTARGETS)
  177. .PHONY: i18n systems systems-pre contrib clean clean-core clean-systems clean-pre dist srcdist
  178.  
  179. # Dependencies:
  180.  
  181. MAKEDEP = g++ -MM -MG
  182. DEPFILE = .dependencies
  183. DEPFILES = $(subst i18n.c,,$(subst version.c,,$(OBJS:%.o=%.c)))
  184. $(DEPFILE): $(DEPFILES) $(wildcard *.h)
  185. @$(MAKEDEP) $(DEFINES) $(SHAREDDEFINES) $(INCLUDES) $(DEPFILES) > $@
  186.  
  187. -include $(DEPFILE)
  188.  
  189. # Rules
  190.  
  191. %.o: %.c
  192. $(CXX) $(CXXFLAGS) -c $(DEFINES) $(SHAREDDEFINES) $(INCLUDES) $<
  193.  
  194. libvdr-$(PLUGIN).so: $(OBJS) $(FFDECSA)
  195. $(CXX) $(CXXFLAGS) -shared $(OBJS) $(FFDECSA) $(LIBS) $(SHAREDLIBS) -o $@
  196.  
  197. $(LIBDIR)/libvdr-$(PLUGIN).so.$(APIVERSION): libvdr-$(PLUGIN).so
  198. @cp -p $< $@
  199.  
  200. $(LIBDIR)/libvdr-$(PLUGIN).a: $(OBJS)
  201. $(AR) r $@ $(OBJS)
  202.  
  203. libsc-dvbsddevice.so: device-sd.o
  204. $(CXX) $(CXXFLAGS) -shared $< $(SHAREDLIBS) -o $@
  205.  
  206. $(LIBDIR)/libsc-dvbsddevice-$(SCAPIVERS).so.$(APIVERSION): libsc-dvbsddevice.so
  207. @cp -p $< $@
  208.  
  209. libsc-dvbhddevice.so: device-hd.o
  210. $(CXX) $(CXXFLAGS) -shared $< $(SHAREDLIBS) -o $@
  211.  
  212. $(LIBDIR)/libsc-dvbhddevice-$(SCAPIVERS).so.$(APIVERSION): libsc-dvbhddevice.so
  213. @cp -p $< $@
  214.  
  215. $(FFDECSA) $(FFDECSATEST): $(FFDECSADIR)/*.c $(FFDECSADIR)/*.h
  216. @$(MAKE) COMPILER="$(CXX)" FLAGS="$(CSAFLAGS) -march=$(CPUOPT)" PARALLEL_MODE=$(PARALLEL) -C $(FFDECSADIR) all
  217.  
  218. $(I18Npot): $(shell grep -rl '\(tr\|trNOOP\)(\".*\")' *.c $(SYSDIR))
  219. xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='<[email protected]>' -o $@ `ls $^`
  220.  
  221. %.po: $(I18Npot)
  222. msgmerge -U --no-wrap --no-location --backup=none -q $@ $<
  223. @touch $@
  224.  
  225. %.mo: %.po
  226. msgfmt -c -o $@ $<
  227.  
  228. $(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/$(I18Nmo): $(PODIR)/%.mo
  229. @mkdir -p $(dir $@)
  230. cp $< $@
  231.  
  232. i18n: $(I18Nmsgs)
  233.  
  234. version.c: FORCE
  235. @echo >[email protected] "/* generated file, do not edit */"; \
  236. echo >>[email protected] 'const char *ScVersion =' '"'$(VERSION)'";'; \
  237. if test -s [email protected]; then mv -f [email protected] $@; fi; \
  238.  
  239. systems:
  240. @for i in `ls -A -I ".*" $(SYSDIR)`; do $(MAKE) -f ../../Makefile.system -C "$(SYSDIR)/$$i" all || exit 1; done
  241.  
  242. systems-pre:
  243. @for i in `ls -A -I ".*" $(PREDIR) | grep -- '-$(SCAPIVERS).so.$(APIVERSION)$$'`; do cp -p "$(PREDIR)/$$i" "$(LIBDIR)"; done
  244.  
  245. contrib:
  246. @$(MAKE) -C contrib all
  247.  
  248. clean-systems:
  249. @for i in `ls -A -I ".*" $(SYSDIR)`; do $(MAKE) -f ../../Makefile.system -C "$(SYSDIR)/$$i" clean; done
  250.  
  251. clean-core:
  252. @$(MAKE) -C testing clean
  253. @$(MAKE) -C contrib clean
  254. @if test -d $(FFDECSADIR); then $(MAKE) -C $(FFDECSADIR) clean; fi
  255. @-rm -f $(LIBDIR)/libsc-*-$(SCAPIVERS).so.$(APIVERSION)
  256. @-rm -f $(LIBDIR)/libvdr-$(PLUGIN).a $(LIBDIR)/libsc-*.a
  257. @-rm -f $(OBJS) $(DEVPLUGOBJS) $(DEPFILE) version.c *.so *.tar.gz core* *~
  258. @-rm -f $(PODIR)/*.mo
  259.  
  260. clean-pre:
  261. @-find "$(PREDIR)" -type f -not -name ".empty" -not -iname "*-$(SCAPIVERS).so.*" | xargs rm -f
  262.  
  263. clean: clean-core clean-systems
  264.  
  265. dist: ARCHIVE := $(PLUGIN)-$(RELEASE)
  266. dist: clean-core
  267. @for i in `ls -A -I ".*" $(SYSDIR)`; do $(MAKE) -f ../../Makefile.system -C "$(SYSDIR)/$$i" dist; done
  268. @-rm -rf $(TMPDIR)/$(ARCHIVE)
  269. @mkdir $(TMPDIR)/$(ARCHIVE)
  270. @cp -a * $(TMPDIR)/$(ARCHIVE)
  271. @echo -n "release" >$(TMPDIR)/$(ARCHIVE)/$(DISTFILE)
  272. @path="$(TMPDIR)/$(ARCHIVE)/$(notdir $(SYSDIR))";\
  273. 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
  274. @strip --strip-unneeded --preserve-dates $(TMPDIR)/$(ARCHIVE)/$(notdir $(PREDIR))/* || true
  275. @tar czf vdr-$(ARCHIVE).tar.gz -C $(TMPDIR) $(ARCHIVE)
  276. @-rm -rf $(TMPDIR)/$(ARCHIVE)
  277. @echo Distribution package created as vdr-$(ARCHIVE).tar.gz
  278.  
  279. copy: ARCHIVE := $(PLUGIN)-$(VERSION)
  280. copy: clean clean-pre
  281. @-rm -rf $(TMPDIR)/$(ARCHIVE)
  282. @mkdir $(TMPDIR)/$(ARCHIVE)
  283. @cp -a .hgtags .hgignore * $(TMPDIR)/$(ARCHIVE)
  284. @echo -n $(SUBREL) | sed -e 's/HG-/CP-/' >$(TMPDIR)/$(ARCHIVE)/$(DISTFILE)
  285. @tar czf vdr-$(ARCHIVE).tar.gz -C $(TMPDIR) $(ARCHIVE)
  286. @-rm -rf $(TMPDIR)/$(ARCHIVE)
  287. @echo Full copy package created as vdr-$(ARCHIVE).tar.gz
  288.  
  289. FORCE:
  290.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement