1
0
mirror of https://github.com/MatMoul/g810-led.git synced 2024-12-22 17:06:10 +00:00

Merge branch 'BuildLibrary' of https://github.com/pearsonk/g810-led into pearsonk-BuildLibrary

This commit is contained in:
MatMoul 2017-04-10 22:25:22 +02:00
commit f22fa6dcb8
5 changed files with 68 additions and 7 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
g810-led.*
bin/*
lib/*
.

View File

@ -45,5 +45,8 @@
* Add wireshark dump effects
* Improve makefile
## [pearsonk](https://github.com/pearsonk) :
* Implement underlying device IO as a shared library
## [wextia](https://github.com/wextia) :
* Fixed incorrect markdown formatting in README.md

View File

@ -38,6 +38,14 @@ Fedora :</br>
`make` # for hidapi</br>
`make LIB=libusb` # for libusb</br>
`sudo make install`</br>
`make install-lib` to install the libg810-led library.</br>
`make install-dev` to install the libg810-led library and headers for development.</br>
## Building the library :</br>
The library is built by default when running the `make` (default target "all").</br>
To specifically build the library as a standalone component: </br>
`make lib`</br>
## Update :</br>
Same as install, but your profile and reboot files are preserved.</br>

View File

@ -56,3 +56,13 @@ Linux led controller for Logitech G410, G610, G810 and G910 Keyboards.</br>
## Samples with pipe (for effects) :</br>
`g810-led -pp < profilefile # Load a profile`</br>
`echo -e "k w ff0000\nk a ff0000\nk s ff0000\nk d ff0000\nc" | g810-led -pp # Set multiple keys`</br>
## Building and linking against the libg810-led library :</br>
Include in implementing source files.</br>
```cpp
#include <g810-led/Keyboard.h>
```
To link, simply provide `-lg810-led` to the build flags.</br>
To build the g810-led application as a dynamically-linked variant, run the target:</br>
`make bin-linked`</br>

View File

@ -8,22 +8,46 @@ else
CPPFLAGS=-Dhidapi
LDFLAGS=-lhidapi-hidraw
endif
PROGN=g810-led
SYSTEMDDIR?=/usr/lib/systemd
.PHONY: all debug clean setup install uninstall
prefix?=$(DESTDIR)/usr
libdir?=$(prefix)/lib
includedir?=$(prefix)/include
all: bin/$(PROGN)
# Program & versioning information
PROGN=g810-led
MAJOR=0
MINOR=1
MICRO=6
bin/$(PROGN): src/main.cpp src/helpers/*.cpp src/helpers/*.h src/classes/*.cpp src/classes/*.h
APPSRCS=src/main.cpp src/helpers/*.cpp src/helpers/*.h
LIBSRCS=src/classes/*.cpp src/classes/*.h
.PHONY: all debug clean setup install uninstall lib install-lib install-dev
all: lib/lib$(PROGN).so bin/$(PROGN)
bin/$(PROGN): $(APPSRCS) $(LIBSRCS)
@mkdir -p bin
$(CC) $(CPPFLAGS) $(CFLAGS) $^ -o $@ $(LDFLAGS)
debug: CFLAGS += -g -Wextra -pedantic
debug: bin/$(PROGN)
lib/lib$(PROGN).so: $(LIBSRCS)
@mkdir -p lib
$(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -shared -Wl,-soname,lib$(PROGN).so -o lib/lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) $^ $(LDFLAGS)
@ln -sf lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) lib/lib$(PROGN).so
bin-linked: lib/lib$(PROGN).so
@mkdir -p bin
$(CC) $(CPPFLAGS) $(CFLAGS) $(APPSRCS) -o bin/$(PROGN) $(LDFLAGS) -L./lib -l$(PROGN)
lib: lib/lib$(PROGN).so
clean:
@rm -rf bin
@rm -rf lib
setup:
@install -m 755 -d \
@ -40,7 +64,16 @@ setup:
install -m 755 -d $(DESTDIR)$(SYSTEMDDIR)/system && \
cp systemd/$(PROGN).service $(DESTDIR)$(SYSTEMDDIR)/system && \
cp systemd/$(PROGN)-reboot.service $(DESTDIR)$(SYSTEMDDIR)/system
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)
install: setup
@test -s /etc/$(PROGN)/profile || \
cp /etc/$(PROGN)/samples/group_keys /etc/$(PROGN)/profile
@ -52,7 +85,13 @@ install: setup
systemctl start $(PROGN) && \
systemctl enable $(PROGN) && \
systemctl enable $(PROGN)-reboot
uninstall-lib:
@rm -f $(libdir)/lib$(PROGN).so*
uninstall-dev:
@rm -rf $(includedir)/$(PROGN)
uninstall:
@test -s /usr/bin/systemd-run && \
systemctl disable $(PROGN) && \