summaryrefslogtreecommitdiff
path: root/Makefile
blob: 00d2423b1b29bfcf6f217f98468e5cca0dd06e6a (plain)
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
# prefix for non-VDR stuff
PREFIX ?= /usr/local
# VDR directory
VDRDIR ?= /usr/src/vdr-1.6.0
# VDR's library directory
VDRPLUGINDIR ?= $(VDRDIR)/PLUGINS/lib
# VDR's plugin conf directory
VDRPLUGINCONFDIR ?= /video/plugins
# VDR's locale directory
VDRLOCALEDIR ?= $(VDRDIR)/locale

VERSION := $(shell grep VERSION src/libwebvi/webvi/version.py | cut -d \' -f 2)

TMPDIR = /tmp
ARCHIVE = webvideo-$(VERSION)
PACKAGE = vdr-$(ARCHIVE)

APIVERSION := $(shell sed -ne '/define APIVERSION/s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h 2> /dev/null)
LIBDIR = $(VDRPLUGINDIR)

# Default target compiles everything but does not install anything.
all-noinstall: libwebvi vdr-plugin

# This target is used by VDR's make plugins. It compiles everything
# and installs VDR plugin.
all: libwebvi vdr-plugin $(LIBDIR)/libvdr-webvideo.so.$(APIVERSION) webvi.conf

vdr-plugin: libwebvi
	$(MAKE) -C src/vdr-plugin LOCALEDIR=./locale LIBDIR=. VDRDIR=$(VDRDIR) CXXFLAGS="-fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses $(CXXFLAGS)"

libwebvi: build-python
	$(MAKE) -C src/libwebvi all libwebvi.a

build-python: webvi.conf
	python setup.py build

webvi.conf webvi.plugin.conf: %.conf: examples/%.conf
	sed 's_templatepath = /usr/local/share/webvi/templates_templatepath = $(PREFIX)/share/webvi/templates_g' < $< > $@

$(DESTDIR)$(VDRPLUGINDIR)/libvdr-webvideo.so.$(APIVERSION): vdr-plugin
ifeq ($(APIVERSION),)
	@echo "No APIVERSION in $(VDRDIR)/config.h"
	@exit 1
else
	mkdir -p $(DESTDIR)$(VDRPLUGINDIR)
	cp -f src/vdr-plugin/libvdr-webvideo.so.$(APIVERSION) $(DESTDIR)$(VDRPLUGINDIR)/libvdr-webvideo.so.$(APIVERSION)
endif

install-vdr-plugin: $(DESTDIR)$(VDRPLUGINDIR)/libvdr-webvideo.so.$(APIVERSION)
	mkdir -p $(DESTDIR)$(VDRLOCALEDIR)
	cp -rf src/vdr-plugin/locale/* $(DESTDIR)$(VDRLOCALEDIR)
	mkdir -p $(DESTDIR)$(VDRPLUGINCONFDIR)/webvideo
	cp -f src/vdr-plugin/mime.types $(DESTDIR)$(VDRPLUGINCONFDIR)/webvideo

install-libwebvi: libwebvi
	$(MAKE) -C src/libwebvi install

install-python: uninstall-deprecated-templates
	python setup.py install --skip-build --prefix $(PREFIX) $${DESTDIR:+--root $(DESTDIR)}

install-conf: webvi.conf webvi.plugin.conf
	mkdir -p $(DESTDIR)/etc
	cp -f webvi.conf $(DESTDIR)/etc
	mkdir -p $(DESTDIR)$(VDRPLUGINCONFDIR)/webvideo
	cp -f webvi.plugin.conf $(DESTDIR)$(VDRPLUGINCONFDIR)/webvideo

install-webvi: install-libwebvi install-python

install: install-vdr-plugin install-webvi install-conf

# Template directories were renamed in 0.4.0. Remove old templates.
uninstall-deprecated-templates:
	rm -rf $(DESTDIR)$(PREFIX)/share/webvi/templates/youtube
	rm -rf $(DESTDIR)$(PREFIX)/share/webvi/templates/svtplay
	rm -rf $(DESTDIR)$(PREFIX)/share/webvi/templates/moontv
	rm -rf $(DESTDIR)$(PREFIX)/share/webvi/templates/metacafe
	rm -rf $(DESTDIR)$(PREFIX)/share/webvi/templates/vimeo
	rm -rf $(DESTDIR)$(PREFIX)/share/webvi/templates/katsomo
	rm -rf $(DESTDIR)$(PREFIX)/share/webvi/templates/subtv
	rm -rf $(DESTDIR)$(PREFIX)/share/webvi/templates/ruutufi
	rm -rf $(DESTDIR)$(PREFIX)/share/webvi/templates/google
	rm -rf $(DESTDIR)$(PREFIX)/share/webvi/templates/yleareena

dist: clean
	@-rm -rf $(TMPDIR)/$(ARCHIVE)
	@mkdir $(TMPDIR)/$(ARCHIVE)
	@cp -a * $(TMPDIR)/$(ARCHIVE)
	@tar czf $(PACKAGE).tgz -C $(TMPDIR) $(ARCHIVE)
	@-rm -rf $(TMPDIR)/$(ARCHIVE)
	@echo Distribution package created as $(PACKAGE).tgz

check:
	make -C src/unittest check

test: check

clean:
	$(MAKE) -C src/vdr-plugin clean
	$(MAKE) -C src/libwebvi clean
	$(MAKE) -C src/unittest clean
	rm -rf src/vdr-plugin/locale webvi.conf
	python setup.py clean -a
	find . -name "*~" -exec rm {} \;
	find . -name "*.pyc" -exec rm {} \;

.PHONY: vdr-plugin libwebvi build-python install install-vdr-plugin install-webvi dist clean check test