forked from medusalix/xow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (53 loc) · 1.93 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
BUILD := DEBUG
VERSION := $(shell git describe --tags)
FLAGS := -Wall -Wpedantic -std=c++11 -MMD -MP
DEBUG_FLAGS := -Og -g -DDEBUG
RELEASE_FLAGS := -O3
DEFINES := -DVERSION=\"$(VERSION)\"
CXXFLAGS += $(FLAGS) $($(BUILD)_FLAGS) $(DEFINES)
LDLIBS += -lpthread -lusb-1.0
SOURCES := $(wildcard *.cpp) $(wildcard */*.cpp)
OBJECTS := $(SOURCES:.cpp=.o) firmware.o
DEPENDENCIES := $(SOURCES:.cpp=.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)
$(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)
%.o: %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
firmware.o: firmware.bin
$(LD) -r -b binary -z noexecstack -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
.PHONY: install
install: xow
sed 's|#BINDIR#|$(BINDIR)|' install/service.in > 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)