Debian Codegraph @

Makefile

raw ◀ ▶
1 Debian patch touch this file
1 # ********************************* WARNING *********************************
2 # This Makefile is not supposed to be used outside of certain usecases like
3 # compiling the driver ("make driver") in this repository or installing the
4 # files as part of distribution packaging.
5 #
6 # Please never run the install targets manually (unless you really know what
7 # you're doing) as they're not intended to be used like that!
8 #
9 # You're in nearly all cases better off following the build instructions
10 # that you can find in the wiki.
11 # ***************************************************************************
12
13 # PREFIX is used to prefix where the files will be installed under DESTDIR
14 PREFIX?=/usr
•15 # UDEVDIR is specifically a prefix for udev files
16 UDEVDIR?=$(shell pkg-config --variable=udevdir udev)
17 # DESTDIR is used to install into a different root directory
18 DESTDIR?=/
19 # Specify the kernel directory to use
20 KERNELDIR?=/lib/modules/$(shell uname -r)/build
21 # Need the absolute directory do the driver directory to build kernel modules
22 DRIVERDIR?=$(shell pwd)/driver
23
24 # Where kernel drivers are going to be installed
25 MODULEDIR?=/lib/modules/$(shell uname -r)/kernel/drivers/hid
26
27 DKMS_NAME?=openrazer-driver
28 DKMS_VER?=3.12.4
29
30
31 # Build all target
32 all: driver
33
34 # Driver compilation
35 driver:
36 @echo -e "\n::\033[32m Compiling OpenRazer kernel modules\033[0m"
37 @echo "========================================"
38 $(MAKE) -C $(KERNELDIR) M=$(DRIVERDIR) modules
39
40 driver_clean:
41 @echo -e "\n::\033[32m Cleaning OpenRazer kernel modules\033[0m"
42 @echo "========================================"
43 $(MAKE) -C "$(KERNELDIR)" M="$(DRIVERDIR)" clean
44
45 # Install kernel modules and then update module dependencies
46 driver_install:
47 @echo -e "\n::\033[34m Installing OpenRazer kernel modules\033[0m"
48 @echo "====================================================="
49 @cp -v $(DRIVERDIR)/*.ko $(DESTDIR)/$(MODULEDIR)
50 @chown -v root:root $(DESTDIR)/$(MODULEDIR)/*.ko
51 depmod
52
53 # Just use for packaging openrazer, not for installing manually
54 driver_install_packaging:
55 @echo -e "\n::\033[34m Installing OpenRazer kernel modules\033[0m"
56 @echo "====================================================="
57 @cp -v $(DRIVERDIR)/*.ko $(DESTDIR)/$(MODULEDIR)
58
59 # Razer Daemon
60 daemon_install:
61 @echo -e "\n::\033[34m Installing OpenRazer Daemon\033[0m"
62 @echo "====================================================="
63 make --no-print-directory -C daemon install
64
65 ubuntu_daemon_install:
66 @echo -e "\n::\033[34m Installing OpenRazer Daemon\033[0m"
67 @echo "====================================================="
68 make --no-print-directory -C daemon ubuntu_install
69
70 # Python Library
71 python_library_install:
72 @echo -e "\n::\033[34m Installing OpenRazer python library\033[0m"
73 @echo "====================================================="
74 @make --no-print-directory -C pylib install
75
76 ubuntu_python_library_install:
77 @echo -e "\n::\033[34m Installing OpenRazer python library\033[0m"
78 @echo "====================================================="
79 @make --no-print-directory -C pylib ubuntu_install
80
81 # Legacy XDG autostart
82 xdg_install:
83 @mkdir -p $(DESTDIR)/etc/xdg/autostart
84 @cp -v ./install_files/desktop/openrazer-daemon.desktop $(DESTDIR)/etc/xdg/autostart/openrazer-daemon.desktop
85
86 install-systemd:
87 @make --no-print-directory -C daemon install-systemd
88
89 # Clean target
90 clean: driver_clean
91
92 setup_dkms:
93 @echo -e "\n::\033[34m Installing DKMS files\033[0m"
94 @echo "====================================================="
95 install -m 644 -v -D Makefile $(DESTDIR)$(PREFIX)/src/$(DKMS_NAME)-$(DKMS_VER)/Makefile
96 install -m 644 -v -D install_files/dkms/dkms.conf $(DESTDIR)$(PREFIX)/src/$(DKMS_NAME)-$(DKMS_VER)/dkms.conf
97 install -m 755 -v -d driver $(DESTDIR)$(PREFIX)/src/$(DKMS_NAME)-$(DKMS_VER)/driver
98 install -m 644 -v -D driver/Makefile $(DESTDIR)$(PREFIX)/src/$(DKMS_NAME)-$(DKMS_VER)/driver/Makefile
99 install -m 644 -v driver/*.c $(DESTDIR)$(PREFIX)/src/$(DKMS_NAME)-$(DKMS_VER)/driver/
100 install -m 644 -v driver/*.h $(DESTDIR)$(PREFIX)/src/$(DKMS_NAME)-$(DKMS_VER)/driver/
101 rm -fv $(DESTDIR)$(PREFIX)/src/$(DKMS_NAME)-$(DKMS_VER)/driver/*.mod.c
102
103 remove_dkms:
104 @echo -e "\n::\033[34m Removing DKMS files\033[0m"
105 @echo "====================================================="
106 rm -rf $(DESTDIR)$(PREFIX)/src/$(DKMS_NAME)-$(DKMS_VER)
107
108 udev_install:
109 @echo -e "\n::\033[34m Installing OpenRazer udev rules\033[0m"
110 @echo "====================================================="
•111 install -m 644 -v -D install_files/udev/99-razer.rules $(DESTDIR)$(UDEVDIR)/rules.d/99-razer.rules
112 install -m 755 -v -D install_files/udev/razer_mount $(DESTDIR)$(UDEVDIR)/razer_mount
113
114 appstream_install:
115 @echo -e "\n::\033[34m Installing OpenRazer AppStream metadata\033[0m"
116 @echo "====================================================="
117 install -m 644 -v -D install_files/appstream/io.github.openrazer.openrazer.metainfo.xml $(DESTDIR)$(PREFIX)/share/metainfo/io.github.openrazer.openrazer.metainfo.xml
118
119 # Install for Ubuntu
120 # WARNING: do not use this target manually, it is just meant for Debian packaging! Read the warning on top of the file!
121 ubuntu_install: setup_dkms udev_install ubuntu_daemon_install ubuntu_python_library_install appstream_install
122 @echo -e "\n::\033[34m Installing for Ubuntu\033[0m"
123 @echo "====================================================="
124
125 install_i_know_what_i_am_doing: all driver_install udev_install python_library_install
126 @make --no-print-directory -C daemon install DESTDIR=$(DESTDIR)
127
128 install: manual_install_msg ;
129
130 manual_install_msg:
131 @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."
132 @echo "Exiting."
133
134 .PHONY: driver