-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
138 lines (137 loc) · 5.14 KB
/
Makefile
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
define DESCR
Description: Playlist daemon
Playlist daemon for the Raspberry Pi using omxplayer for playback
endef
export DESCR
SHELL := bash
REL := .release
omxd: omxd.c omxd.h client.c player.c utils.c m_list.c Makefile omxd_help.h version.h
gcc -Wall -g -o omxd omxd.c client.c player.c utils.c m_list.c
omxd_help.h: README Makefile
sed -rn '1,/^\.$$/ s/^(.*)$$/"\1\\n"/p' README >omxd_help.h
%.h: %.txt Makefile
@sed -e 's/[ \t]*$$//g' -e 's/^/"/g' -e 's/$$/\\n"/g' <$< >$@
omxd.1: README Makefile
curl -F page=@README http://mantastic.herokuapp.com > omxd.1
install:
-./preinst
cp omxd $(DESTDIR)/usr/bin
cp omxd.1 $(DESTDIR)/usr/share/man/man1/
-mkdir -p $(DESTDIR)/usr/share/doc/omxd
cp init $(DESTDIR)/usr/share/doc/omxd/
cp omxd.service $(DESTDIR)/usr/share/doc/omxd/
cp logrotate $(DESTDIR)/usr/share/doc/omxd/
cp omxwd $(DESTDIR)/usr/bin
-perl -lne 'print unless /^omxd$$/' -i $(DESTDIR)/etc/rc.local # Auto migrate from rc.local
uninstall:
-./prerm
-perl -lne 'print unless /^omxd$$/' -i $(DESTDIR)/etc/rc.local # Auto migrate from rc.local
rm $(DESTDIR)/usr/bin/omxd
-rm $(DESTDIR)/usr/bin/rpyt
rm $(DESTDIR)/usr/share/man/man1/omxd.1
-rm $(DESTDIR)/usr/share/man/man1/rpyt.1
rm $(DESTDIR)/usr/share/doc/omxd/init
rm $(DESTDIR)/usr/share/doc/omxd/logrotate
rm $(DESTDIR)/usr/bin/omxwd
-./postrm
start:
-./postinst
stop:
-./prerm
-./postrm
-killall omxd
-killall omxplayer.bin
restart: stop install start
clean:
-rm omxd m_list utils omxplay omxlog omxctl omxd_help.h omxd.pid st version.h
-rm -rf .release
# Testing
m_list: test_m_list.c m_list.c utils.c omxd.h
gcc -g -o m_list test_m_list.c m_list.c utils.c
utils: utils.c test_utils.c omxd.h
gcc -g -o utils test_utils.c utils.c
debug: omxd stop
strace -p `./omxd -d | sed 's/.*PID //'` -o st &
ps:
pstree -pu | grep omx
# Release
tag:
@git status | grep -q 'nothing to commit' || ( echo Worktree dirty; exit 1 )
@echo 'Chose old tag to follow: '; \
select OLD in `git tag`; do break; done; \
export TAG; \
read -p 'Please Enter new tag name: ' TAG; \
sed -r -e "s/^omxd.*$$/omxd $$TAG/" \
-e 's/([0-9]{4}-)[0-9]*/\1'`date +%Y`/ \
-i version.txt || exit 1; \
git commit -a -m "version $$TAG"; \
echo Adding git tag $$TAG; \
echo "omxd ($$TAG)" > changelog; \
if [ -n "$$OLD" ]; then \
git log --pretty=format:" * %h %an %s" $$OLD.. >> changelog; \
echo >> changelog; \
else \
echo ' * Initial release' >> changelog; \
fi; \
echo " -- `git config user.name` <`git config user.email`> `date -R`" >> changelog; \
git tag -a -F changelog $$TAG HEAD; \
rm changelog
utag:
TAG=`git log --oneline --decorate | head -n1 | sed -rn 's/^.+ version (.+)/\1/p'`; \
[ "$$TAG" ] && git tag -d $$TAG && git reset --hard HEAD^
tarball: clean
export TAG=`sed -rn 's/^omxd (.+)$$/\1/p' version.txt`; \
$(MAKE) balls
balls:
mkdir -p $(REL)/omxd-$(TAG); \
cp -rt $(REL)/omxd-$(TAG) *; \
cd $(REL); \
tar -czf omxd_$(TAG).tar.gz omxd-$(TAG)
deb: tarball omxd
export TAG=`sed -rn 's/^omxd (.+)$$/\1/p' version.txt`; \
export DEB=$(REL)/omxd-$${TAG}/debian; \
$(MAKE) debs
debs:
-rm $(REL)/*.deb
cp -f $(REL)/omxd_$(TAG).tar.gz $(REL)/omxd_$(TAG).orig.tar.gz
mkdir -p $(DEB)
echo 'Source: omxd' >$(DEB)/control
echo 'Section: video' >>$(DEB)/control
echo 'Priority: optional' >>$(DEB)/control
sed -nr 's/^C.+ [-0-9]+ (.+)$$/Maintainer: \1/p' version.txt >>$(DEB)/control
echo 'Build-Depends: debhelper ' >>$(DEB)/control
echo 'Standards-version: 3.8.4' >>$(DEB)/control
echo >>$(DEB)/control
echo 'Package: omxd' >>$(DEB)/control
echo 'Architecture: any' >>$(DEB)/control
echo 'Depends: $${shlibs:Depends}, $${misc:Depends} omxplayer' >>$(DEB)/control
echo "$$DESCR" >>$(DEB)/control
grep Copyright version.txt >$(DEB)/copyright
echo 'License: GNU GPL v2' >>$(DEB)/copyright
echo ' See /usr/share/common-licenses/GPL-2' >>$(DEB)/copyright
echo 7 > $(DEB)/compat
for i in `git tag | grep '^[0-9]' | sort -rV`; do git show $$i | sed -n '/^omxd/,/^ --/p'; done \
| sed -r 's/^omxd \((.+)\)$$/omxd (\1-1) UNRELEASED; urgency=low/' \
| sed -r 's/^(.{,79}).*/\1/' \
> $(DEB)/changelog
echo '#!/usr/bin/make -f' > $(DEB)/rules
echo '%:' >> $(DEB)/rules
echo ' dh $$@' >> $(DEB)/rules
echo usr/bin > $(DEB)/omxd.dirs
echo usr/share/man/man1 >> $(DEB)/omxd.dirs
echo usr/share/doc/omxd >> $(DEB)/omxd.dirs
chmod 755 $(DEB)/rules
mkdir -p $(DEB)/source
echo '3.0 (quilt)' > $(DEB)/source/format
cp preinst postinst prerm postrm $(DEB)
@cd $(REL)/omxd-$(TAG) && \
echo && echo List of PGP keys for signing package: && \
gpg -K | grep uid && \
read -ep 'Enter key ID (part of name or alias): ' KEYID; \
if [ "$$KEYID" ]; then \
dpkg-buildpackage -k$$KEYID; \
else \
dpkg-buildpackage -us -uc; \
fi
fakeroot alien -kr --scripts $(REL)/*.deb; mv *.rpm $(REL)
release: tag deb