aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: a395a0eae8e94853200aa3a5687c7677f7998851 (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
107
108
109
110
111
112
113
all: hypervideo doc pypi-files
clean: clean-test clean-dist clean-cache
completions: completion-bash completion-fish completion-zsh
doc: README.md CONTRIBUTING.md
ot: offlinetest
tar: hypervideo.tar.gz

# Keep this list in sync with MANIFEST.in
# intended use: when building a source distribution,
# make pypi-files && python setup.py sdist
pypi-files: AUTHORS Changelog.md LICENSE README.md completions devscripts/* test/*

.PHONY: all clean install test tar pypi-files completions ot offlinetest codetest

clean-test:
	rm -rf *.3gp *.annotations.xml *.ape *.avi *.description *.dump *.flac *.flv *.frag *.frag.aria2 *.frag.urls \
	*.info.json *.jpeg *.jpg *.live_chat.json *.m4a *.m4v *.mkv *.mp3 *.mp4 *.ogg *.opus *.part* *.png *.sbv *.srt \
	*.swf *.swp *.ttml *.vtt *.wav *.webm *.webp *.ytdl test/testdata/player-*.js
clean-dist:
	rm -rf MANIFEST build/ dist/ .coverage cover/ hypervideo.tar.gz completions/ hypervideo_dl/extractor/lazy_extractors.py *.spec CONTRIBUTING.md.tmp hypervideo hypervideo.exe hypervideo_dl.egg-info/ AUTHORS .mailmap
clean-cache:
	find . -name "*.pyc" -o -name "*.class" -delete

completion-bash: completions/bash/hypervideo
completion-fish: completions/fish/hypervideo.fish
completion-zsh: completions/zsh/_hypervideo
lazy-extractors: hypervideo_dl/extractor/lazy_extractors.py

PREFIX ?= /usr/local
DESTDIR ?= .
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/man
SHAREDIR ?= $(PREFIX)/share
PYTHON ?= /usr/bin/env python3

# set SYSCONFDIR to /etc if PREFIX=/usr or PREFIX=/usr/local
SYSCONFDIR = $(shell if [ $(PREFIX) = /usr -o $(PREFIX) = /usr/local ]; then echo /etc; else echo $(PREFIX)/etc; fi)

install: hypervideo completions
	install -Dm755 hypervideo $(DESTDIR)$(BINDIR)
	install -Dm644 completions/bash/hypervideo $(DESTDIR)$(SHAREDIR)/bash-completion/completions/hypervideo
	install -Dm644 completions/zsh/_hypervideo $(DESTDIR)$(SHAREDIR)/zsh/site-functions/_hypervideo
	install -Dm644 completions/fish/hypervideo.fish $(DESTDIR)$(SHAREDIR)/fish/vendor_completions.d/hypervideo.fish

codetest:
	flake8 .

test:
	$(PYTHON) -m pytest
	$(MAKE) codetest

offlinetest: codetest
	$(PYTHON) -m pytest -k "not download"

hypervideo: hypervideo_dl/*.py hypervideo_dl/*/*.py
	mkdir -p zip
	for d in hypervideo_dl hypervideo_dl/downloader hypervideo_dl/extractor hypervideo_dl/postprocessor ; do \
	  mkdir -p zip/$$d ;\
	  cp -pPR $$d/*.py zip/$$d/ ;\
	done
	touch -t 200001010101 zip/hypervideo_dl/*.py zip/hypervideo_dl/*/*.py
	mv zip/hypervideo_dl/__main__.py zip/
	cd zip ; zip -q ../hypervideo hypervideo_dl/*.py hypervideo_dl/*/*.py __main__.py
	rm -rf zip
	echo '#!$(PYTHON)' > hypervideo
	cat hypervideo.zip >> hypervideo
	rm hypervideo.zip
	chmod a+x hypervideo

README.md: hypervideo_dl/*.py hypervideo_dl/*/*.py
	COLUMNS=80 $(PYTHON) hypervideo_dl/__main__.py --help | $(PYTHON) devscripts/make_readme.py

CONTRIBUTING.md: README.md
	$(PYTHON) devscripts/make_contributing.py README.md CONTRIBUTING.md

completions/bash/hypervideo: hypervideo_dl/*.py hypervideo_dl/*/*.py devscripts/bash-completion.in
	mkdir -p completions/bash
	$(PYTHON) devscripts/bash-completion.py

completions/zsh/_hypervideo: hypervideo_dl/*.py hypervideo_dl/*/*.py devscripts/zsh-completion.in
	mkdir -p completions/zsh
	$(PYTHON) devscripts/zsh-completion.py

completions/fish/hypervideo.fish: hypervideo_dl/*.py hypervideo_dl/*/*.py devscripts/fish-completion.in
	mkdir -p completions/fish
	$(PYTHON) devscripts/fish-completion.py

_EXTRACTOR_FILES = $(shell find hypervideo_dl/extractor -iname '*.py' -and -not -iname 'lazy_extractors.py')
hypervideo_dl/extractor/lazy_extractors.py: devscripts/make_lazy_extractors.py devscripts/lazy_load_template.py $(_EXTRACTOR_FILES)
	$(PYTHON) devscripts/make_lazy_extractors.py $@

hypervideo.tar.gz: all
	@tar -czf $(DESTDIR)/hypervideo.tar.gz --transform "s|^|hypervideo/|" --owner 0 --group 0 \
		--exclude '*.DS_Store' \
		--exclude '*.kate-swp' \
		--exclude '*.pyc' \
		--exclude '*.pyo' \
		--exclude '*~' \
		--exclude '__pycache__' \
		--exclude '.pytest_cache' \
		--exclude '.git' \
		-- \
		bin README.md Changelog.md LICENSE \
		CONTRIBUTING.md CONTRIBUTORS AUTHORS \
		Makefile MANIFEST.in README.md completions \
		setup.py setup.cfg hypervideo hypervideo_dl requirements.txt \
		devscripts test

AUTHORS: .mailmap
	git shortlog -s -n | cut -f2 | sort > AUTHORS

.mailmap:
	git shortlog -s -e -n | awk '!(out[$$NF]++) { $$1="";sub(/^[ \t]+/,""); print}' > .mailmap