1
0
mirror of https://github.com/MatMoul/g810-led.git synced 2024-12-24 09:46:11 +00:00
g810-led/makefile

72 lines
2.1 KiB
Makefile
Raw Normal View History

2016-06-12 20:16:07 +00:00
CC=g++
2016-08-07 18:36:13 +00:00
CFLAGS=-Wall -O2 -std=gnu++11
2017-01-21 21:45:48 +00:00
LIB?=hidapi
ifeq ($(LIB),libusb)
2017-03-25 02:20:29 +00:00
CPPFLAGS=-Dlibusb -lpthread
2017-01-21 21:45:48 +00:00
LDFLAGS=-lusb-1.0
else
2017-03-25 02:20:29 +00:00
CPPFLAGS=-Dhidapi -lpthread
2017-01-21 21:45:48 +00:00
LDFLAGS=-lhidapi-hidraw
endif
PROGN=g810-led
2017-01-15 04:39:05 +00:00
SYSTEMDDIR?=/usr/lib/systemd
2016-06-12 20:16:07 +00:00
.PHONY: all debug clean setup install uninstall
all: bin/$(PROGN)
2016-06-12 20:16:07 +00:00
2017-01-21 08:15:18 +00:00
bin/$(PROGN): src/main.cpp src/helpers/*.cpp src/helpers/*.h src/classes/*.cpp src/classes/*.h
@mkdir -p bin
2017-01-21 21:45:48 +00:00
$(CC) $(CPPFLAGS) $(CFLAGS) $^ -o $@ $(LDFLAGS)
2017-01-21 08:15:18 +00:00
debug: CFLAGS += -g -Wextra -pedantic
debug: bin/$(PROGN)
2017-01-21 08:15:18 +00:00
2016-06-12 20:16:07 +00:00
clean:
2016-12-28 00:45:34 +00:00
@rm -rf bin
setup:
@install -m 755 -d \
$(DESTDIR)/usr/bin \
$(DESTDIR)/etc/$(PROGN)/samples \
$(DESTDIR)/etc/udev/rules.d
2017-01-15 04:39:05 +00:00
@cp bin/$(PROGN) $(DESTDIR)/usr/bin
@test -s $(DESTDIR)/usr/bin/g410-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g410-led
@test -s $(DESTDIR)/usr/bin/g610-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g610-led
@test -s $(DESTDIR)/usr/bin/g910-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g910-led
@cp sample_profiles/* $(DESTDIR)/etc/$(PROGN)/samples
@cp udev/$(PROGN).rules $(DESTDIR)/etc/udev/rules.d
@test -s /usr/bin/systemd-run && \
install -m 755 -d $(DESTDIR)$(SYSTEMDDIR)/system && \
cp systemd/$(PROGN).service $(DESTDIR)$(SYSTEMDDIR)/system && \
cp systemd/$(PROGN)-reboot.service $(DESTDIR)$(SYSTEMDDIR)/system
install: setup
@test -s /etc/$(PROGN)/profile || \
cp /etc/$(PROGN)/samples/group_keys /etc/$(PROGN)/profile
@test -s /etc/$(PROGN)/reboot || \
cp /etc/$(PROGN)/samples/all_off /etc/$(PROGN)/reboot
2017-01-15 04:39:05 +00:00
@udevadm control --reload-rules
2017-01-21 23:47:38 +00:00
@test -s /usr/bin/systemd-run && \
2017-01-21 21:45:48 +00:00
systemctl daemon-reload && \
systemctl start $(PROGN) && \
systemctl enable $(PROGN) && \
systemctl enable $(PROGN)-reboot
2016-12-28 00:45:34 +00:00
uninstall:
2017-01-21 21:45:48 +00:00
@test -s /usr/bin/systemd-run && \
systemctl disable $(PROGN) && \
systemctl disable $(PROGN)-reboot && \
rm $(SYSTEMDDIR)/system/$(PROGN).service && \
rm $(SYSTEMDDIR)/system/$(PROGN)-reboot.service && \
systemctl daemon-reload && \
rm -R /etc/$(PROGN)
2017-01-15 04:39:05 +00:00
@rm /usr/bin/g410-led
@rm /usr/bin/g610-led
@rm /usr/bin/g910-led
@rm /usr/bin/$(PROGN)
2017-01-21 21:45:48 +00:00
2017-01-15 04:39:05 +00:00
@rm /etc/udev/rules.d/$(PROGN).rules
@udevadm control --reload-rules