getting version from git or failing
[youtube-dl] / Makefile
1 all: youtube-dl README.md youtube-dl.1 youtube-dl.bash-completion LATEST_VERSION
2 # TODO: re-add youtube-dl.exe, and make sure it's 1. safe and 2. doesn't need sudo
3
4 clean:
5         rm -f youtube-dl youtube-dl.exe youtube-dl.1 LATEST_VERSION
6
7 PREFIX=/usr/local
8 BINDIR=$(PREFIX)/bin
9 MANDIR=$(PREFIX)/man
10 SYSCONFDIR=/etc
11
12 install: youtube-dl youtube-dl.1 youtube-dl.bash-completion
13         install -d $(DESTDIR)$(BINDIR)
14         install -m 755 youtube-dl $(DESTDIR)$(BINDIR)
15         install -d $(DESTDIR)$(MANDIR)/man1
16         install -m 644 youtube-dl.1 $(DESTDIR)$(MANDIR)/man1
17         install -d $(DESTDIR)$(SYSCONFDIR)/bash_completion.d
18         install -m 644 youtube-dl.bash-completion $(DESTDIR)$(SYSCONFDIR)/bash_completion.d/youtube-dl
19
20 test:
21         nosetests2 --nocapture test
22
23 .PHONY: all clean install test README.md youtube-dl.bash-completion
24 # TODO un-phony README.md and youtube-dl.bash_completion by reading from .in files and generating from them
25
26
27 youtube-dl.exe: youtube_dl/*.py
28         bash devscripts/wine-py2exe.sh build_exe.py
29
30 README.md: youtube_dl/*.py
31         @options=$$(COLUMNS=80 python -m youtube_dl --help | sed -e '1,/.*General Options.*/ d' -e 's/^\W\{2\}\(\w\)/## \1/') && \
32                 header=$$(sed -e '/.*# OPTIONS/,$$ d' README.md) && \
33                 footer=$$(sed -e '1,/.*# CONFIGURATION/ d' README.md) && \
34                 echo "$${header}" > README.md && \
35                 echo >> README.md && \
36                 echo '# OPTIONS' >> README.md && \
37                 echo "$${options}" >> README.md&& \
38                 echo >> README.md && \
39                 echo '# CONFIGURATION' >> README.md && \
40                 echo "$${footer}" >> README.md
41
42 youtube-dl.1: README.md
43         pandoc -s -w man README.md -o youtube-dl.1
44
45 youtube-dl.bash-completion: README.md
46         @options=`egrep -o '(--[a-z-]+) ' README.md | sort -u | xargs echo` && \
47                 content=`sed "s/opts=\"[^\"]*\"/opts=\"$${options}\"/g" youtube-dl.bash-completion` && \
48                 echo "$${content}" > youtube-dl.bash-completion
49
50 LATEST_VERSION: youtube_dl/__init__.py
51         python -m youtube_dl --version > LATEST_VERSION