-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
119 lines (95 loc) · 4.1 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
SHELL=/bin/bash
PREFIX=/usr
DESTDIR=
EXECUTABLE_NAME := $(shell grep ^EXECUTABLE_NAME src/systemd-zram.sh | cut -d\' -f2)
VERSION := $(shell grep ^VERSION src/$(EXECUTABLE_NAME).sh | cut -d\' -f2)
LICENSE := $(shell grep ^LICENSE src/$(EXECUTABLE_NAME).sh | cut -d\' -f2)
OSNAME := $(shell sed -e '/^ID=/s/^ID=\(.*\)/\1/' < /etc/os-release)
ARCHNAME := $(shell uname -m)
DOCS= ChangeLog README.md AUTHORS THANKS
MAN = $(patsubst %.rst,%.gz,$(wildcard man/*.rst))
DEBIANPKG = $(EXECUTABLE_NAME)_$(VERSION)_all.deb
ARCHPKG = $(EXECUTABLE_NAME)-$(VERSION)-1-any.pkg.tar.xz
default: man
man: $(MAN)
%.gz: %.rst
if [ ! -f /usr/bin/rst2man ] ; then sudo apt-get install python3-docutils; fi
rst2man $^ | gzip -c > $@
man_clean:
rm -f $(MAN)
install: $(DOCS)
#if [ $(OSNAME).$(ARCHNAME) == "ubuntu.aarch64" ] ; then if [ ! grep "zswap.enable" /boot/cmdline.txt ] ; then sudo echo 'swap.enable=1'i >> /boot/;fi;fi ; fi
if [ $(OSNAME).$(ARCHNAME) == "ubuntu.aarch64" ] ; then sudo apt install linux-modules-extra-raspi;fi
install -d -m 755 "$(DESTDIR)$(PREFIX)/share/doc/$(EXECUTABLE_NAME)"
install -Dm 644 $^ "$(DESTDIR)$(PREFIX)/share/doc/$(EXECUTABLE_NAME)"
install -Dm 755 src/$(EXECUTABLE_NAME).sh "$(DESTDIR)$(PREFIX)/bin/$(EXECUTABLE_NAME)"
install -d -m 755 "$(DESTDIR)$(PREFIX)/share/licenses/$(EXECUTABLE_NAME)"
install -Dm 644 LICENSE "$(DESTDIR)$(PREFIX)/share/licenses/$(EXECUTABLE_NAME)/COPYING"
install -Dm 644 src/$(EXECUTABLE_NAME).service "$(DESTDIR)/lib/systemd/system/$(EXECUTABLE_NAME).service"
install -Dm 644 man/$(EXECUTABLE_NAME).1.gz $(DESTDIR)$(PREFIX)/share/man/man1/$(EXECUTABLE_NAME).1.gz
cp /usr/share/systemd/tmp.mount /etc/systemd/system/
systemctl enable tmp.mount
arch_install: $(DOCS)
install -d -m 755 "$(DESTDIR)$(PREFIX)/share/doc/$(EXECUTABLE_NAME)"
install -Dm 644 $^ "$(DESTDIR)$(PREFIX)/share/doc/$(EXECUTABLE_NAME)"
install -Dm 755 src/$(EXECUTABLE_NAME).sh "$(DESTDIR)$(PREFIX)/bin/$(EXECUTABLE_NAME)"
install -d -m 755 "$(DESTDIR)$(PREFIX)/share/licenses/$(EXECUTABLE_NAME)"
install -Dm 644 LICENSE "$(DESTDIR)$(PREFIX)/share/licenses/$(EXECUTABLE_NAME)/COPYING"
install -Dm 644 src/$(EXECUTABLE_NAME).service "$(DESTDIR)$(PREFIX)/lib/systemd/system/$(EXECUTABLE_NAME).service"
install -Dm 644 man/$(EXECUTABLE_NAME).1.gz $(DESTDIR)$(PREFIX)/share/man/man1/$(EXECUTABLE_NAME).1.gz
systemctl enable tmp.mount
uninstall:
systemctl stop $(EXECUTABLE_NAME)
systemctl disable $(EXECUTABLE_NAME)
rm -f $(PREFIX)/bin/$(EXECUTABLE_NAME)
rm -f /lib/systemd/system/$(EXECUTABLE_NAME).service
rm -rf $(PREFIX)/share/licenses/$(EXECUTABLE_NAME)/
rm -rf $(PREFIX)/share/doc/$(EXECUTABLE_NAME)/
rm -f $(PREFIX)/share/man/man1/$(EXECUTABLE_NAME).1.gz
systemctl stop tmp.mount
systemctl disable tmp.mount
clean: arch_clean debian_clean man_clean
debian_pkg: $(DEBIANPKG)
debian:
mkdir -p $@
debian/changelog: ChangeLog debian
cp $< $@
debian/README: README.md debian
cp $< $@
debian/compat: dpkg/compat debian
cp $< $@
debian/rules: dpkg/rules debian
cp $< $@
debian/control: dpkg/control debian
cp $< $@
debian/copyright: debian/changelog debian/README debian/compat debian/rules debian/control
@echo Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ > $@
@echo Upstream-Name: $(EXECUTABLE_NAME) >> $@
@echo "Upstream-Contact: $(AUTHOR) <$(MAIL)>" >> $@
@echo Source: $(SOURCE) >> $@
@echo License: $(LICENSE) >> $@
@echo >> $@
sed s/@mail@/$(MAIL)/g copyright >> $@
$(DEBIANPKG): debian/compat debian/control debian/rules debian/changelog debian/README
#fakeroot debian/rules clean
#fakeroot debian/rules build
fakeroot debian/rules binary
mv ../$@ $@
@echo Package done!
@echo You can install it as root with:
@echo dpkg -i $@
debian_clean:
rm -rf debian
rm -f $(DEBIANPKG)
arch_pkg: $(ARCHPKG)
$(ARCHPKG): PKGBUILD $(EXECUTABLE_NAME).install
sed -i "s|_name=.*|_name=$(EXECUTABLE_NAME)|" PKGBUILD
sed -i "s|pkgver=.*|pkgver=$(VERSION)|" PKGBUILD
makepkg -d
@echo Package done!
@echo You can install it as root with:
@echo pacman -U $@
arch_clean:
rm -rf pkg
rm -f $(ARCHPKG)
.PHONY: clean arch_pkg arch_clean debian_pkg debian_clean man install arch_install uninstall