File: makefile

package info (click to toggle)
g810-led 0.4.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 392 kB
  • sloc: cpp: 2,131; sh: 120; makefile: 114; python: 84; xml: 36
file content (122 lines) | stat: -rw-r--r-- 3,803 bytes parent folder | download | duplicates (2)
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
CXX?=g++
CXXFLAGS?=-Wall -O2
LIB?=hidapi
ifeq ($(LIB),libusb)
	CPPFLAGS+=-Dlibusb
	LIBS=-lusb-1.0
else
	CPPFLAGS+=-Dhidapi
	LIBS=-lhidapi-hidraw
endif
SYSTEMDDIR?=/usr/lib/systemd

PREFIX?=$(DESTDIR)/usr
libdir?=$(PREFIX)/lib
includedir?=$(PREFIX)/include

# Program & versioning information
PROGN=g810-led
MAJOR=0
MINOR=4
MICRO=3

CXXFLAGS+=-std=gnu++11 -DVERSION=\"$(MAJOR).$(MINOR).$(MICRO)\"
APPSRCS=src/main.cpp src/helpers/*.cpp
APPOBJS := src/main.o $(patsubst %.cpp,%.o,$(wildcard src/helpers/*.cpp))
LIBSRCS=src/classes/*.cpp
LIBOBJS := $(patsubst %.cpp,%.o,$(wildcard src/classes/*.cpp))

.PHONY: all bin debug clean setup install uninstall lib install-lib install-dev

all: lib/lib$(PROGN).so bin/$(PROGN)

bin: bin/$(PROGN)

bin/$(PROGN): $(APPOBJS) $(LIBOBJS)
	mkdir -p bin
	$(CXX) $(LDFLAGS) $^ -o $@ $(LIBS)

debug: CXXFLAGS += -g -Wextra -pedantic
debug: bin/$(PROGN)

src/classes/%.o: src/classes/%.cpp
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -fPIC -c $^ -o $@

lib/lib$(PROGN).so: $(LIBOBJS)
	mkdir -p lib
	$(CXX) $(LDFLAGS) -shared -Wl,-soname,lib$(PROGN).so.$(MAJOR) -o lib/lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) $^ $(LIBS)
	ln -sf lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) lib/lib$(PROGN).so.$(MAJOR)
	ln -sf lib$(PROGN).so.$(MAJOR) lib/lib$(PROGN).so

bin-linked: lib/lib$(PROGN).so $(APPOBJS)
	mkdir -p bin
	$(CXX) $(LDFLAGS) $(APPOBJS) -o bin/$(PROGN) $(LIBS) -L./lib -l$(PROGN)

lib: lib/lib$(PROGN).so

clean:
	rm -rf bin lib $(APPOBJS) $(LIBOBJS)

setup:
	install -m 755 -d \
		$(DESTDIR)/usr/bin \
		$(DESTDIR)/etc/$(PROGN)/samples
	cp bin/$(PROGN) $(DESTDIR)/usr/bin
	test -s $(DESTDIR)/usr/bin/g213-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g213-led
	test -s $(DESTDIR)/usr/bin/g410-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g410-led
	test -s $(DESTDIR)/usr/bin/g413-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g413-led
	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
	test -s $(DESTDIR)/usr/bin/g610-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g610-led
	test -s $(DESTDIR)/usr/bin/g815-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g815-led
	test -s $(DESTDIR)/usr/bin/g910-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g910-led
	test -s $(DESTDIR)/usr/bin/gpro-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/gpro-led
	cp sample_profiles/* $(DESTDIR)/etc/$(PROGN)/samples

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.$(MAJOR)
	ln -sf lib$(PROGN).so.$(MAJOR) $(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
	test -s /etc/$(PROGN)/reboot || \
		cp /etc/$(PROGN)/samples/all_off /etc/$(PROGN)/reboot
	udevadm control --reload-rules
	$(PROGN) -p /etc/$(PROGN)/profile
	test -s /usr/bin/systemd-run && \
		systemctl daemon-reload && \
		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)-reboot && \
		rm $(SYSTEMDDIR)/system/$(PROGN)-reboot.service && \
		systemctl daemon-reload && \
		rm -R /etc/$(PROGN)

	rm /usr/bin/g213-led
	rm /usr/bin/g410-led
	rm /usr/bin/g413-led
	rm /usr/bin/g512-led
	rm /usr/bin/g513-led
	rm /usr/bin/g610-led
	rm /usr/bin/g815-led
	rm /usr/bin/g910-led
	rm /usr/bin/gpro-led
	rm /usr/bin/$(PROGN)

	rm /etc/udev/rules.d/$(PROGN).rules
	udevadm control --reload-rules