added automatically generated bash-completion; closes #191
[youtube-dl] / Makefile
1 all: compile exe readme man-page bash-completion update-latest
2
3 update-latest:
4         ./youtube-dl --version > LATEST_VERSION
5
6 readme:
7         @options=$$(COLUMNS=80 ./youtube-dl --help | sed -e '1,/.*General Options.*/ d' -e 's/^\W\{2\}\(\w\)/## \1/') && \
8                 header=$$(sed -e '/.*# OPTIONS/,$$ d' README.md) && \
9                 footer=$$(sed -e '1,/.*# FAQ/ d' README.md) && \
10                 echo "$${header}" > README.md && \
11                 echo >> README.md && \
12                 echo '# OPTIONS' >> README.md && \
13                 echo "$${options}" >> README.md&& \
14                 echo >> README.md && \
15                 echo '# FAQ' >> README.md && \
16                 echo "$${footer}" >> README.md
17
18 man-page:
19         pandoc -s -w man README.md -o youtube-dl.1
20
21 bash-completion:
22         @options=`egrep -o '(--[a-z-]+) ' README.md | sort -u | xargs echo` && \
23                 content=`sed "s/opts=\"[^\"]*\"/opts=\"$${options}\"/g" youtube-dl.bash-completion` && \
24                 echo "$${content}" > youtube-dl.bash-completion
25
26 compile:
27         zip --quiet --junk-paths youtube-dl youtube_dl/*.py
28         echo '#!/usr/bin/env python' > youtube-dl
29         cat youtube-dl.zip >> youtube-dl
30         rm youtube-dl.zip
31
32 exe:
33         bash devscripts/wine-py2exe.sh build_exe.py
34
35 install:
36         install -m 755 --owner root --group root youtube-dl /usr/local/bin/
37         install -m 644 --owner root --group root youtube-dl.1 /usr/local/man/man1
38         install -m 644 --owner root --group root youtube-dl.bash-completion /etc/bash_completion.d/youtube-dl
39
40 .PHONY: all update-latest readme man-page bash-completion compile exe install