forked from blmhemu/opengigabyte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
170 lines (134 loc) · 7.04 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
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
# 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
# Where kernel drivers are going to be installed
MODULEDIR?=/lib/modules/$(shell uname -r)/kernel/drivers/hid
# Python dir
PYTHONDIR?=$(shell python3 -c 'import sys; print(sys.path[-1])')
DKMS_NAME?=opengigabyte-driver
DKMS_VER?=0.0.2
# Build all target
all: driver
# Driver compilation
driver:
@echo -e "\n::\033[32m Compiling OpenGigabyte kernel modules\033[0m"
@echo "========================================"
$(MAKE) -C $(KERNELDIR) M=$(DRIVERDIR) modules
driver_clean:
@echo -e "\n::\033[32m Cleaning OpenGigabyte kernel modules\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 OpenGigabyte kernel modules\033[0m"
@echo "====================================================="
@cp -v $(DRIVERDIR)/*.ko $(DESTDIR)/$(MODULEDIR)
@chown -v root:root $(DESTDIR)/$(MODULEDIR)/*.ko
depmod
# Just use for packaging opengigabyte, not for installing manually
driver_install_packaging:
@echo -e "\n::\033[34m Installing OpenGigabyte kernel modules\033[0m"
@echo "====================================================="
@cp -v $(DRIVERDIR)/*.ko $(DESTDIR)/$(MODULEDIR)
# Remove kernel modules
driver_uninstall:
@echo -e "\n::\033[34m Uninstalling OpenGigabyte kernel modules\033[0m"
@echo "====================================================="
@rm -fv $(DESTDIR)/$(MODULEDIR)/gigabytekbd.ko
@rm -fv $(DESTDIR)/$(MODULEDIR)/gigabytemouse.ko
@rm -fv $(DESTDIR)/$(MODULEDIR)/gigabytefirefly.ko
@rm -fv $(DESTDIR)/$(MODULEDIR)/gigabytecore.ko
# Gigabyte Daemon
daemon_install:
@echo -e "\n::\033[34m Installing OpenGigabyte Daemon\033[0m"
@echo "====================================================="
make --no-print-directory -C daemon install
ubuntu_daemon_install:
@echo -e "\n::\033[34m Installing OpenGigabyte Daemon\033[0m"
@echo "====================================================="
make --no-print-directory -C daemon ubuntu_install
daemon_uninstall:
@echo -e "\n::\033[34m Uninstalling OpenGigabyte Daemon\033[0m"
@echo "====================================================="
make --no-print-directory -C daemon uninstall
# Python Library
python_library_install:
@echo -e "\n::\033[34m Installing OpenGigabyte python library\033[0m"
@echo "====================================================="
@make --no-print-directory -C pylib install
ubuntu_python_library_install:
@echo -e "\n::\033[34m Installing OpenGigabyte python library\033[0m"
@echo "====================================================="
@make --no-print-directory -C pylib ubuntu_install
python_library_uninstall:
@echo -e "\n::\033[34m Uninstalling OpenGigabyte python library\033[0m"
@echo "====================================================="
@make --no-print-directory -C pylib uninstall
# Legacy XDG autostart
xdg_install:
@mkdir -p $(DESTDIR)/etc/xdg/autostart
@cp -v ./install_files/desktop/opengigabyte-daemon.desktop $(DESTDIR)/etc/xdg/autostart/opengigabyte-daemon.desktop
xdg_uninstall:
@rm -fv $(DESTDIR)/etc/xdg/autostart/opengigabyte-daemon.desktop
install-systemd:
@make --no-print-directory -C daemon install-systemd
# Clean target
clean: driver_clean
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 install_files/dkms/dkms.conf $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)/dkms.conf
install -m 755 -v -d driver $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)/driver
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/
rm -fv $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)/driver/*.mod.c
remove_dkms:
@echo -e "\n::\033[34m Removing DKMS files\033[0m"
@echo "====================================================="
rm -rf $(DESTDIR)/usr/src/$(DKMS_NAME)-$(DKMS_VER)
udev_install:
@echo -e "\n::\033[34m Installing OpenGigabyte udev rules\033[0m"
@echo "====================================================="
install -m 644 -v -D install_files/udev/99-gigabyte.rules $(DESTDIR)/usr/lib/udev/rules.d/99-gigabyte.rules
install -m 755 -v -D install_files/udev/gigabyte_mount $(DESTDIR)/usr/lib/udev/gigabyte_mount
udev_uninstall:
@echo -e "\n::\033[34m Uninstalling OpenGigabyte udev rules\033[0m"
@echo "====================================================="
rm -f $(DESTDIR)/usr/lib/udev/rules.d/99-gigabyte.rules $(DESTDIR)/usr/lib/udev/gigabyte_mount
ubuntu_udev_install:
@echo -e "\n::\033[34m Installing OpenGigabyte udev rules\033[0m"
@echo "====================================================="
install -m 644 -v -D install_files/udev/99-gigabyte.rules $(DESTDIR)/lib/udev/rules.d/99-gigabyte.rules
install -m 755 -v -D install_files/udev/gigabyte_mount $(DESTDIR)/lib/udev/gigabyte_mount
ubuntu_udev_uninstall:
@echo -e "\n::\033[34m Uninstalling OpenGigabyte udev rules\033[0m"
@echo "====================================================="
rm -f $(DESTDIR)/lib/udev/rules.d/99-gigabyte.rules $(DESTDIR)/lib/udev/gigabyte_mount
appstream_install:
@echo -e "\n::\033[34m Installing OpenGigabyte AppStream metadata\033[0m"
@echo "====================================================="
install -m 644 -v -D install_files/appstream/io.github.blmhemu.opengigabyte.metainfo.xml $(DESTDIR)/usr/share/metainfo/io.github.blmhemu.opengigabyte.metainfo.xml
appstream_uninstall:
@echo -e "\n::\033[34m Uninstalling OpenGigabyte AppStream metadata\033[0m"
@echo "====================================================="
rm -f $(DESTDIR)/usr/share/metainfo/io.github.blmhemu.opengigabyte.metainfo.xml
# Install for Ubuntu
ubuntu_install: setup_dkms ubuntu_udev_install ubuntu_daemon_install ubuntu_python_library_install appstream_install
@echo -e "\n::\033[34m Installing for Ubuntu\033[0m"
@echo "====================================================="
mv $(DESTDIR)/usr/lib/python3.* $(DESTDIR)/usr/lib/python3
mv $(DESTDIR)/usr/lib/python3/site-packages $(DESTDIR)/usr/lib/python3/dist-packages
install_i_know_what_i_am_doing: all driver_install udev_install python_library_install
@make --no-print-directory -C daemon install DESTDIR=$(DESTDIR)
install: manual_install_msg ;
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 udev_uninstall python_library_uninstall
@make --no-print-directory -C daemon uninstall DESTDIR=$(DESTDIR)
.PHONY: driver