-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathMakefile
62 lines (50 loc) · 1.75 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
BUILD := DEBUG
VERSION := $(shell git describe --tags 2> /dev/null || echo unknown)
FIRMWARE := /lib/firmware/xow_dongle.bin
FLAGS := -Wall -Wpedantic -std=c++11 -MMD -MP
DEBUG_FLAGS := -Og -g -DDEBUG
RELEASE_FLAGS := -O3
DEFINES := -DVERSION=\"$(VERSION)\" -DFIRMWARE=\"$(FIRMWARE)\"
CXXFLAGS += $(FLAGS) $($(BUILD)_FLAGS) $(DEFINES)
LDLIBS += -lpthread -lusb-1.0
SOURCES := $(wildcard *.cpp) $(wildcard */*.cpp)
OBJECTS := $(SOURCES:.cpp=.o)
DEPENDENCIES := $(SOURCES:.cpp=.d)
PREFIX := /usr/local
BINDIR := $(PREFIX)/bin
UDEVDIR := /etc/udev/rules.d
MODLDIR := /etc/modules-load.d
MODPDIR := /etc/modprobe.d
SYSDDIR := /etc/systemd/system
.PHONY: all
all: xow firmware.sh xow.service
xow: $(OBJECTS)
$(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)
%.o: %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
firmware.sh: install/firmware.sh.in
sed "s|#FIRMWARE#|$(FIRMWARE)|" $< > $@
xow.service: install/service.in
sed 's|#BINDIR#|$(BINDIR)|' $< > $@
.PHONY: install
install: all
install -D -m 755 xow $(DESTDIR)$(BINDIR)/xow
install -D -m 755 firmware.sh $(DESTDIR)$(BINDIR)/xow-get-firmware.sh
install -D -m 644 install/udev.rules $(DESTDIR)$(UDEVDIR)/50-xow.rules
install -D -m 644 install/modules.conf $(DESTDIR)$(MODLDIR)/xow-uinput.conf
install -D -m 644 install/modprobe.conf $(DESTDIR)$(MODPDIR)/xow-blacklist.conf
install -D -m 644 xow.service $(DESTDIR)$(SYSDDIR)/xow.service
.PHONY: uninstall
uninstall:
$(RM) $(DESTDIR)$(BINDIR)/xow
$(RM) $(DESTDIR)$(BINDIR)/xow-get-firmware.sh
$(RM) $(DESTDIR)$(UDEVDIR)/50-xow.rules
$(RM) $(DESTDIR)$(MODLDIR)/xow-uinput.conf
$(RM) $(DESTDIR)$(MODPDIR)/xow-blacklist.conf
$(RM) $(DESTDIR)$(SYSDDIR)/xow.service
.PHONY: clean
clean:
$(RM) xow $(OBJECTS) $(DEPENDENCIES)
$(RM) firmware.sh
$(RM) xow.service
-include $(DEPENDENCIES)