-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
60 lines (50 loc) · 1.73 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
.PHONY: deb install uninstall clean help build
.EXPORT_ALL_VARIABLES:
# Package version; sync with debian/control
VERSION ?= 0.2
BINDIR ?= /usr/local/bin
RULES=70-bt-reload-headphones.rules
SCRIPT=bt-reload-headphones
CONFIG=bt-reload-headphones.conf
DEBDIR=_build/bt-reload-headphones_$(VERSION)-1/
build:
mkdir -p _build
sh src/rules.sh > _build/$(RULES)
cp src/$(SCRIPT) _build/
cp src/$(CONFIG) _build/
help:
@echo "Available targets:"
@echo " install - install script and udev rule (requires root)"
@echo " uninstall - uninstall, if previously installed (requires root)"
@echo " deb - create Debian package"
@echo " build - build script and udev rules (default target)"
@echo " clean - remove build files"
@echo " distclean - remove all generated files"
@echo " help - you're reading it right now"
clean:
rm -rf _build
distclean: clean
rm bt-reload-headphones_*-1.deb
install: build
install -o root -m 644 _build/$(RULES) /etc/udev/rules.d
install -o root -m 644 _build/$(CONFIG) /etc
install -o root -m 755 _build/$(SCRIPT) $(BINDIR)
udevadm control --reload-rules
uninstall:
rm /etc/udev/rules.d/$(RULES)
rm $(BINDIR)/$(SCRIPT)
echo "Leaving config file /etc/$(CONFIG) in place"
udevadm control --reload-rules
deb: export BINDIR=/usr/bin
deb: clean build
mkdir -p $(DEBDIR)/usr/bin
mkdir -p $(DEBDIR)/etc/udev/rules.d
mkdir -p $(DEBDIR)/DEBIAN
install -m 644 debian/control $(DEBDIR)/DEBIAN
install -m 644 debian/conffiles $(DEBDIR)/DEBIAN
install -m 755 debian/postinst $(DEBDIR)/DEBIAN
install -m 644 _build/$(RULES) $(DEBDIR)/etc/udev/rules.d
install -m 644 _build/$(CONFIG) $(DEBDIR)/etc
install -m 755 _build/$(SCRIPT) $(DEBDIR)/$(BINDIR)
dpkg-deb --build $(DEBDIR)
cp _build/*.deb ./