2018-08-30 23:25:29 +00:00
|
|
|
CXX?=g++
|
2018-09-09 03:15:17 +00:00
|
|
|
CXXFLAGS?=-Wall -O2
|
2017-01-21 21:45:48 +00:00
|
|
|
LIB?=hidapi
|
|
|
|
ifeq ($(LIB),libusb)
|
|
|
|
CPPFLAGS=-Dlibusb
|
2018-09-09 03:15:17 +00:00
|
|
|
LIBS=-lusb-1.0
|
2017-01-21 21:45:48 +00:00
|
|
|
else
|
|
|
|
CPPFLAGS=-Dhidapi
|
2018-09-09 03:15:17 +00:00
|
|
|
LIBS=-lhidapi-hidraw
|
2017-01-21 21:45:48 +00:00
|
|
|
endif
|
2017-01-15 04:39:05 +00:00
|
|
|
SYSTEMDDIR?=/usr/lib/systemd
|
2016-06-12 20:16:07 +00:00
|
|
|
|
2018-08-30 23:25:29 +00:00
|
|
|
PREFIX?=$(DESTDIR)/usr
|
|
|
|
libdir?=$(PREFIX)/lib
|
|
|
|
includedir?=$(PREFIX)/include
|
2017-04-10 18:12:13 +00:00
|
|
|
|
|
|
|
# Program & versioning information
|
|
|
|
PROGN=g810-led
|
2017-04-26 14:07:00 +00:00
|
|
|
MAJOR=0
|
2020-04-28 00:21:29 +00:00
|
|
|
MINOR=4
|
2020-05-05 23:20:11 +00:00
|
|
|
MICRO=1
|
2017-04-10 18:12:13 +00:00
|
|
|
|
2018-09-09 03:15:17 +00:00
|
|
|
CXXFLAGS+=-std=gnu++11 -DVERSION=\"$(MAJOR).$(MINOR).$(MICRO)\"
|
2019-08-28 08:22:52 +00:00
|
|
|
APPSRCS=src/main.cpp src/helpers/*.cpp
|
|
|
|
LIBSRCS=src/classes/*.cpp
|
2017-04-10 18:12:13 +00:00
|
|
|
|
2017-05-06 23:34:37 +00:00
|
|
|
.PHONY: all bin debug clean setup install uninstall lib install-lib install-dev
|
2016-06-16 18:14:52 +00:00
|
|
|
|
2017-04-10 18:12:13 +00:00
|
|
|
all: lib/lib$(PROGN).so bin/$(PROGN)
|
2016-06-12 20:16:07 +00:00
|
|
|
|
2017-05-06 23:34:37 +00:00
|
|
|
bin: bin/$(PROGN)
|
|
|
|
|
2017-04-10 18:12:13 +00:00
|
|
|
bin/$(PROGN): $(APPSRCS) $(LIBSRCS)
|
2016-06-16 18:14:52 +00:00
|
|
|
@mkdir -p bin
|
2018-09-09 03:15:17 +00:00
|
|
|
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS)
|
2017-01-21 08:15:18 +00:00
|
|
|
|
2018-08-30 23:25:29 +00:00
|
|
|
debug: CXXFLAGS += -g -Wextra -pedantic
|
2016-06-16 18:20:28 +00:00
|
|
|
debug: bin/$(PROGN)
|
2017-04-10 18:12:13 +00:00
|
|
|
|
|
|
|
lib/lib$(PROGN).so: $(LIBSRCS)
|
|
|
|
@mkdir -p lib
|
2018-09-09 03:15:17 +00:00
|
|
|
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -fPIC -shared -Wl,-soname,lib$(PROGN).so -o lib/lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) $^ $(LIBS)
|
2017-04-10 18:12:13 +00:00
|
|
|
@ln -sf lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) lib/lib$(PROGN).so
|
|
|
|
|
|
|
|
bin-linked: lib/lib$(PROGN).so
|
|
|
|
@mkdir -p bin
|
2018-09-09 03:15:17 +00:00
|
|
|
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(APPSRCS) -o bin/$(PROGN) $(LIBS) -L./lib -l$(PROGN)
|
2017-04-10 18:12:13 +00:00
|
|
|
|
|
|
|
lib: lib/lib$(PROGN).so
|
|
|
|
|
2016-06-12 20:16:07 +00:00
|
|
|
clean:
|
2016-12-28 00:45:34 +00:00
|
|
|
@rm -rf bin
|
2017-04-10 18:12:13 +00:00
|
|
|
@rm -rf lib
|
2017-01-22 03:32:30 +00:00
|
|
|
|
|
|
|
setup:
|
2017-01-22 22:44:11 +00:00
|
|
|
@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
|
2017-04-17 16:37:57 +00:00
|
|
|
@test -s $(DESTDIR)/usr/bin/g213-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g213-led
|
2017-01-15 04:39:05 +00:00
|
|
|
@test -s $(DESTDIR)/usr/bin/g410-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g410-led
|
2017-08-02 09:43:03 +00:00
|
|
|
@test -s $(DESTDIR)/usr/bin/g413-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g413-led
|
2018-08-01 21:37:29 +00:00
|
|
|
@test -s $(DESTDIR)/usr/bin/g512-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g512-led
|
|
|
|
@test -s $(DESTDIR)/usr/bin/g513-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g513-led
|
2017-01-15 04:39:05 +00:00
|
|
|
@test -s $(DESTDIR)/usr/bin/g610-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g610-led
|
2020-01-13 02:17:29 +00:00
|
|
|
@test -s $(DESTDIR)/usr/bin/g815-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g815-led
|
2017-01-15 04:39:05 +00:00
|
|
|
@test -s $(DESTDIR)/usr/bin/g910-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g910-led
|
2017-05-12 23:12:39 +00:00
|
|
|
@test -s $(DESTDIR)/usr/bin/gpro-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/gpro-led
|
2017-01-22 03:32:30 +00:00
|
|
|
@cp sample_profiles/* $(DESTDIR)/etc/$(PROGN)/samples
|
2017-01-22 22:44:11 +00:00
|
|
|
@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)-reboot.service $(DESTDIR)$(SYSTEMDDIR)/system
|
2017-04-10 18:12:13 +00:00
|
|
|
|
|
|
|
install-lib: lib
|
|
|
|
@install -m 755 -d $(libdir)
|
|
|
|
@install -m 644 lib/lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) $(libdir)/
|
|
|
|
@ln -sf lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) $(libdir)/lib$(PROGN).so
|
|
|
|
|
|
|
|
install-dev: install-lib
|
|
|
|
@mkdir -p $(includedir)/$(PROGN)/
|
|
|
|
@install -m 644 src/classes/*.h $(includedir)/$(PROGN)
|
|
|
|
|
2017-01-22 03:32:30 +00:00
|
|
|
install: setup
|
2017-01-22 22:44:11 +00:00
|
|
|
@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-04-14 01:05:50 +00:00
|
|
|
@$(PROGN) -p /etc/$(PROGN)/profile
|
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 enable $(PROGN)-reboot
|
2017-04-10 18:12:13 +00:00
|
|
|
|
|
|
|
uninstall-lib:
|
|
|
|
@rm -f $(libdir)/lib$(PROGN).so*
|
|
|
|
|
|
|
|
uninstall-dev:
|
|
|
|
@rm -rf $(includedir)/$(PROGN)
|
|
|
|
|
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)-reboot && \
|
|
|
|
rm $(SYSTEMDDIR)/system/$(PROGN)-reboot.service && \
|
|
|
|
systemctl daemon-reload && \
|
|
|
|
rm -R /etc/$(PROGN)
|
|
|
|
|
2017-04-17 16:37:57 +00:00
|
|
|
@rm /usr/bin/g213-led
|
2017-01-15 04:39:05 +00:00
|
|
|
@rm /usr/bin/g410-led
|
2017-08-02 09:43:03 +00:00
|
|
|
@rm /usr/bin/g413-led
|
2018-08-01 21:37:29 +00:00
|
|
|
@rm /usr/bin/g512-led
|
|
|
|
@rm /usr/bin/g513-led
|
2017-01-15 04:39:05 +00:00
|
|
|
@rm /usr/bin/g610-led
|
2020-01-13 02:17:29 +00:00
|
|
|
@rm /usr/bin/g815-led
|
2017-01-15 04:39:05 +00:00
|
|
|
@rm /usr/bin/g910-led
|
2017-05-12 19:29:12 +00:00
|
|
|
@rm /usr/bin/gpro-led
|
2017-01-15 04:39:05 +00:00
|
|
|
@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
|