forked from systemofapwne/leetmouse
-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMakefile
More file actions
190 lines (156 loc) · 7.79 KB
/
Makefile
File metadata and controls
190 lines (156 loc) · 7.79 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
SHELL := /bin/bash
include version.mk
# DESTDIR is used to install into a different root directory
DESTDIR?=/
# Specify the kernel directory to use
KERNELDIR?=/lib/modules/$(shell uname -r)/build
# Need the absolute directory do the driver directory to build kernel modules
DRIVERDIR?=$(shell pwd)/driver
GUIDIR?=$(shell pwd)/gui
GUI_BINARY := YeetMouseGui
GUI_INSTALL_NAME := yeetmouse
DESKTOP_FILE := install_files/yeetmouse.desktop
ICON_FILE := media/yeetmouse.png
YEETMOUSECTLDIR=$(shell pwd)/tools/yeetmousectl
# Where kernel drivers are going to be installed
MODULEDIR?=/lib/modules/$(shell uname -r)/kernel/drivers/usb
DKMS_VER?=$(YEETMOUSE_VERSION)
# Detect architecture
ARCH := $(shell uname -m)
.PHONY: driver
.PHONY: GUI
.PHONY: userspace
.PHONY: install_userspace install_gui install_gui_files install_gui_optional remove_gui remove_userspace install_config install_service remove_service install_uninstaller remove_uninstaller
default: driver yeetmousectl
all: driver yeetmousectl
clean: driver_clean
GUI:
@echo -e "\n::\033[32m Building GUI application\033[0m"
@echo "========================================"
$(MAKE) -C "$(GUIDIR)" M="$(GUIDIR)"
@echo "DONE!"
yeetmousectl:
@echo -e "\n::\033[32m Building yeetmousectl\033[0m"
@echo "========================================"
$(MAKE) -C "$(YEETMOUSECTLDIR)" M="$(YEETMOUSECTLDIR)"
@echo "DONE!"
userspace: yeetmousectl
driver:
@echo -e "\n::\033[32m Compiling yeetmouse kernel module\033[0m"
@echo "========================================"
ifeq ($(ARCH),ppc64le)
@echo "PowerPC 64-bit Little Endian detected"
endif
$(MAKE) -C "$(KERNELDIR)" M="$(DRIVERDIR)" modules
driver_clean:
@echo -e "\n::\033[32m Cleaning yeetmouse kernel module\033[0m"
@echo "========================================"
$(MAKE) -C "$(KERNELDIR)" M="$(DRIVERDIR)" clean
# Install kernel modules and then update module dependencies
driver_install:
@echo -e "\n::\033[34m Installing yeetmouse kernel module\033[0m"
@echo "====================================================="
@mkdir -p $(DESTDIR)/$(MODULEDIR)
@cp -v $(DRIVERDIR)/yeetmouse.ko $(DESTDIR)/$(MODULEDIR)
@chown -v root:root $(DESTDIR)/$(MODULEDIR)/yeetmouse.ko
depmod
# Remove kernel modules
driver_uninstall:
@echo -e "\n::\033[34m Uninstalling yeetmouse kernel module\033[0m"
@echo "====================================================="
@rm -fv $(DESTDIR)/$(MODULEDIR)/yeetmouse.ko
setup_dkms:
@echo -e "\n::\033[34m Installing DKMS files\033[0m"
@echo "====================================================="
install -m 644 -v -D Makefile $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)/Makefile
install -m 644 -v -D version.mk $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)/version.mk
install -m 644 -v -D install_files/dkms/dkms.conf $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)/dkms.conf
install -m 755 -v -d $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)/driver
install -m 755 -v -d $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)/driver/FixedMath
install -m 644 -v -D driver/Makefile $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)/driver/Makefile
install -m 644 -v driver/*.c $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)/driver/
install -m 644 -v driver/*.h $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)/driver/
install -m 644 -v driver/FixedMath/*.h $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)/driver/FixedMath/
install -m 644 -v shared_definitions.h $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)/
$(if $(shell grep "AccelMode_" "$(DRIVERDIR)/config.h"),,@echo "\033[31mWARNING! Old config version detected, acceleration mode might be wrong!\033[0m")
@rm -fv $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)/driver/*.mod.c
install_gui_files:
@echo -e "\n::\033[34m Installing GUI application\033[0m"
@echo "====================================================="
install -m 755 -v -D gui/$(GUI_BINARY) $(DESTDIR)/usr/bin/$(GUI_INSTALL_NAME)
install -m 755 -v -d $(DESTDIR)/usr/share/applications
install -m 755 -v -d $(DESTDIR)/usr/share/icons/hicolor/256x256/apps
install -m 644 -v $(DESKTOP_FILE) $(DESTDIR)/usr/share/applications/yeetmouse.desktop
install -m 644 -v $(ICON_FILE) $(DESTDIR)/usr/share/icons/hicolor/256x256/apps/yeetmouse.png
install_gui: GUI install_gui_files
install_gui_optional:
@echo -e "\n::\033[34m Attempting optional GUI build/install\033[0m"
@echo "====================================================="
@if $(MAKE) GUI; then \
$(MAKE) install_gui_files; \
echo "GUI installed."; \
else \
echo ""; \
echo -e "\033[1m\033[1;31mWARNING: GUI was not installed.\033[0m"; \
echo "Missing GUI build dependencies are the most likely cause (look at the messages above)."; \
echo "The driver, yeetmousectl, config and service installation will continue."; \
echo "Install the GUI dependencies for your distribution and run:"; \
echo -e " make install_gui\n"; \
fi
remove_gui:
@echo -e "\n::\033[34m Removing GUI application\033[0m"
@echo "====================================================="
rm -f $(DESTDIR)/usr/bin/$(GUI_INSTALL_NAME)
rm -f $(DESTDIR)/usr/share/applications/yeetmouse.desktop
rm -f $(DESTDIR)/usr/share/icons/hicolor/256x256/apps/yeetmouse.png
install_userspace: yeetmousectl
@echo -e "\n::\033[34m Installing userspace tools\033[0m"
@echo "====================================================="
install -m 755 -v -D tools/yeetmousectl/yeetmousectl $(DESTDIR)/usr/bin/yeetmousectl
remove_userspace:
@echo -e "\n::\033[34m Removing userspace tools\033[0m"
@echo "====================================================="
rm -f $(DESTDIR)/usr/bin/yeetmousectl
install_uninstaller:
@echo -e "\n::\033[34m Installing uninstaller\033[0m"
@echo "====================================================="
install -m 755 -v -D install_files/yeetmouse-uninstall.sh $(DESTDIR)/usr/bin/yeetmouse-uninstall
remove_uninstaller:
@echo -e "\n::\033[34m Removing uninstaller\033[0m"
@echo "====================================================="
rm -f $(DESTDIR)/usr/bin/yeetmouse-uninstall
install_config:
@echo -e "\n::\033[34m Installing default configuration\033[0m"
@echo "====================================================="
install -m 755 -v -d $(DESTDIR)/etc
if [ ! -f $(DESTDIR)/etc/yeetmouse.conf ]; then \
install -m 644 -v install_files/yeetmouse.conf.sample $(DESTDIR)/etc/yeetmouse.conf; \
else \
echo "Keeping existing $(DESTDIR)/etc/yeetmouse.conf"; \
fi
install_service:
@echo -e "\n::\033[34m Installing systemd service\033[0m"
@echo "====================================================="
install -m 755 -v -d $(DESTDIR)/usr/lib/{systemd/system,sysusers.d}
install -m 644 -v install_files/systemd/yeetmouse.service $(DESTDIR)/usr/lib/systemd/system/yeetmouse.service
install -m 644 -v install_files/sysusers/yeetmouse.conf $(DESTDIR)/usr/lib/sysusers.d/yeetmouse.conf
remove_service:
@echo -e "\n::\033[34m Removing systemd service\033[0m"
@echo "====================================================="
rm -f $(DESTDIR)/usr/lib/systemd/system/yeetmouse.service
rm -f $(DESTDIR)/usr/lib/sysusers.d/yeetmouse.conf
remove_dkms:
@echo -e "\n::\033[34m Removing DKMS files\033[0m"
@echo "====================================================="
@rm -rf $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)
install_i_know_what_i_am_doing: all driver_install install_userspace install_config install_service install_uninstaller install_gui
install: manual_install_msg ;
-include pkg.mk
pkgarch: pkg_arch
@echo -e "\n::\033[34m Building installable arch package\033[0m"
@echo "====================================================="
@mv ./pkg/build/arch/yeetmouse*.zst .
manual_install_msg:
@echo "Please do not install the driver using this method. Use a distribution package as it tracks the files installed and can remove them afterwards. If you are 100% sure, you want to do this, find the correct target in the Makefile."
@echo "Exiting."
uninstall: driver_uninstall remove_userspace remove_service remove_gui remove_uninstaller