-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
60 lines (42 loc) · 2.4 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
export INSTALL_ROOT = "$(DESTDIR)"
export PREFIX = ${INSTALL_ROOT}/usr
export pkgname = thrash-protect
## can't do "thrash-protect.py --version" since it's unsupported in python versions lower than 2.7.
export version = $(shell grep '__version__.*=' thrash-protect.py | cut -f2 -d'"')
.PHONY: build install clean distclean rpm archlinux dist release ubuntu
all: build
build:
@echo "MAKE BUILD: so far this project consists of a python prototype, no build needed"
clean:
git clean -fd
distclean: clean
dist: distclean
tar czf ${pkgname}-${version}.tar.gz --transform='s,^,${pkgname}-${version}/,' *
ChangeLog.recent: ChangeLog
perl -pe 'if (/^\d\d\d\d-\d\d-\d\d/) { $$q++; exit if $$q>1; }' ChangeLog > ChangeLog.recent
install: thrash-protect.py
install "thrash-protect.py" "$(PREFIX)/sbin/thrash-protect"
if [ -d "$(INSTALL_ROOT)/lib/systemd/system" ]; then install systemd/thrash-protect.service "$(INSTALL_ROOT)/lib/systemd/system" ; \
elif [ -d "$(PREFIX)/lib/systemd/system" ]; then install systemd/thrash-protect.service "$(PREFIX)/lib/systemd/system" ; fi
if [ -d "$(INSTALL_ROOT)/etc/init" ]; then install upstart/thrash-protect.conf "$(INSTALL_ROOT)/etc/init/thrash-protect.conf" ; fi
if [ -x "$(INSTALL_ROOT)/sbin/openrc-run" ] ; then install openrc/thrash-protect "$(INSTALL_ROOT)/etc/init.d/thrash-protect" ; fi
[ -d "$(PREFIX)/lib/systemd/system" ] || [ -d "$(INSTALL_ROOT)/etc/init" ] || [ -d "$(INSTALL_ROOT)/lib/systemd/system" ] || [ -x "$(INSTALL_ROOT)/sbin/openrc-run" ] || install systemv/thrash-protect "$(INSTALL_ROOT)/etc/init.d/thrash-protect"
.tag.${version}: ChangeLog.recent
if ! git show --oneline -s "v${version}" > /dev/null 2>&1; then git status ; cat ChangeLog.recent ; git tag -s "v${version}" -F ChangeLog.recent ; git push origin "v${version}" ; fi
touch ".tag.${version}"
release: .tag.${version}
archlinux: .tag.${version} archlinux/PKGBUILD_ thrash-protect.py
${MAKE} -C $@ archlinux
rpm: .tag.${version} rpm/thrash-protect.spec thrash-protect.py dist
rsync ${pkgname}-${version}.tar.gz ${HOME}/rpmbuild/SOURCES/v${version}.tar.gz
touch .tag.${version}
${MAKE} -C $@ rpm
## TODO: debian target (with systemv)
## TODO: not tested
ubuntu: .tag.${version} debian/changelog
rm -f debian/${pkgname}.init
dpkg-buildpackage
debian: .tag.${version} debian/changelog
dpkg-buildpackage
debian/changelog: .tag.${version}
dch --distribution=UNRELEASED -v ${version} "version bump"