forked from medusalix/xow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (54 loc) · 1.98 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
BUILD := DEBUG
VERSION := $(shell git describe --tags)
LOCK_FILE := /tmp/xow.lock
FLAGS := -Wall -Wpedantic -std=c++11 -MMD
DEBUG_FLAGS := -Og -g -DDEBUG
RELEASE_FLAGS := -O3
DEFINES := -DVERSION=\"$(VERSION)\" -DLOCK_FILE=\"$(LOCK_FILE)\"
CXXFLAGS += $(FLAGS) $($(BUILD)_FLAGS) $(DEFINES)
LDLIBS += -lstdc++ -lm -lpthread -lusb-1.0
SOURCES := $(wildcard *.cpp) $(wildcard */*.cpp)
OBJECTS := $(patsubst %.cpp,%.o,$(SOURCES)) firmware.o
DEPENDENCIES := $(OBJECTS:.o=.d)
DRIVER_URL := http://download.windowsupdate.com/c/msdownload/update/driver/drvs/2017/07/1cd6a87c-623f-4407-a52d-c31be49e925c_e19f60808bdcbfbd3c3df6be3e71ffc52e43261e.cab
FIRMWARE_HASH := 48084d9fa53b9bb04358f3bb127b7495dc8f7bb0b3ca1437bd24ef2b6eabdf66
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
xow: $(OBJECTS)
%.o: %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
firmware.bin:
curl -o driver.cab $(DRIVER_URL)
cabextract -F FW_ACC_00U.bin driver.cab
echo $(FIRMWARE_HASH) FW_ACC_00U.bin | sha256sum -c
mv FW_ACC_00U.bin firmware.bin
$(RM) driver.cab
firmware.o: firmware.bin
$(LD) -r -b binary -o $@ $<
xow.service: install/service.in
sed 's|#BINDIR#|$(BINDIR)|' $< > $@
.PHONY: install
install: xow xow.service
install -D -m 755 xow $(DESTDIR)$(BINDIR)/xow
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
$(RM) xow.service
.PHONY: uninstall
uninstall:
$(RM) $(DESTDIR)$(BINDIR)/xow
$(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)
-include $(DEPENDENCIES)