-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
102 lines (83 loc) · 3.03 KB
/
Makefile
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
VERSION = 1.8
ABI = 1
CXX = g++ $(CXXSTD)
GAWK = gawk
INSTALL = install
CAT = cat
LN_FS = ln -fs
SED = sed
TAR = tar
MV_F = mv -f
RM_F = rm -f
RPMBUILD = rpmbuild
CXXSTD = -std=gnu++20
DEFINES =
DEBUG = -g
OPTS = -O0
WARN = -Wall
INCLUDES = $(INCLUDES-$@)
CPPFLAGS = $(INCLUDES) $(DEFINES)
CXXFLAGS = $(DEBUG) $(OPTS) $(CXXFLAGS-$@) $(WARN)
LDFLAGS = $(LDFLAGS-$@)
LIBS = $(LIBS-$@)
prefix = /usr
includedir = $(prefix)/include/streamdeckpp-$(VERSION)
libdir = $(prefix)/$(shell $(CXX) -print-file-name=libc.so | $(GAWK) -v FS='/' '{ print($$(NF-1)) }')
pcdir= $(libdir)/pkgconfig
IFACEPKGS = hidapi-libusb
DEPPKGS = Magick++
ALLPKGS = $(IFACEPKGS) $(DEPPKGS)
INCLUDES-main.o = $(shell pkg-config --cflags $(ALLPKGS))
INCLUDES-streamdeckpp.o = $(shell pkg-config --cflags $(ALLPKGS))
INCLUDES-streamdeckpp.os = $(shell pkg-config --cflags $(ALLPKGS))
LIBS-streamdeck = $(shell pkg-config --libs $(ALLPKGS))
LIBS-libstreamdeckpp.so = $(shell pkg-config --libs $(ALLPKGS))
all: streamdeck libstreamdeckpp.so libstreamdeckpp.a
.cc.os:
$(COMPILE.cc) -fpic -o $@ $<
streamdeck: main.o libstreamdeckpp.a
$(LINK.cc) -o $@ $^ $(LIBS)
main.o streamdeckpp.o streamdeckpp.os: streamdeckpp.hh
libstreamdeckpp.a: streamdeckpp.o
$(AR) $(ARFLAGS) $@ $?
libstreamdeckpp.so: streamdeckpp.os libstreamdeckpp.map
$(LINK.cc) -shared -Wl,-h,libstreamdeckpp.so.$(ABI) -o $@ $(filter %.os,$^) $(LIBS) -Wl,-version-script,libstreamdeckpp.map
streamdeckpp.pc: Makefile
$(CAT) > $@-tmp <<EOF
prefix=$(prefix)
includedir=$(includedir)
libdir=$(libdir)
Name: StreamDeck++
Description: C++ Library to interace with StreamDeck devices
Version: $(VERSION)
URL: https://github.com/drepper/streamdeckpp
Requires: $(IFACEPKGS)
Requires.private: $(DEPPKGS)
Cflags: -I$(includedir)
Libs: -lstreamdeckpp
EOF
$(MV_F) $@-tmp $@
streamdeckpp.spec: streamdeckpp.spec.in Makefile
$(SED) 's/@VERSION@/$(VERSION)/;s/@ABI@/$(ABI)/' $< > $@-tmp
$(MV_F) $@-tmp $@
install: libstreamdeckpp.a streamdeckpp.pc
$(INSTALL) -D -c -m 755 libstreamdeckpp.so $(DESTDIR)$(libdir)/libstreamdeckpp-$(VERSION).so
$(LN_FS) libstreamdeckpp-$(VERSION).so $(DESTDIR)$(libdir)/libstreamdeckpp.so.$(ABI)
$(LN_FS) libstreamdeckpp.so.$(ABI) $(DESTDIR)$(libdir)/libstreamdeckpp.so
$(INSTALL) -D -c -m 644 libstreamdeckpp.a $(DESTDIR)$(libdir)/libstreamdeckpp.a
$(INSTALL) -D -c -m 644 streamdeckpp.pc $(DESTDIR)$(pcdir)/streamdeckpp.pc
$(INSTALL) -D -c -m 644 streamdeckpp.hh $(DESTDIR)$(includedir)/streamdeckpp.hh
dist: streamdeckpp.spec
$(LN_FS) . streamdeckpp-$(VERSION)
$(TAR) achf streamdeckpp-$(VERSION).tar.xz streamdeckpp-$(VERSION)/{Makefile,streamdeckpp.hh,streamdeckpp.cc,main.cc,libstreamdeckpp.map,README.md,streamdeckpp.spec,streamdeckpp.spec.in}
$(RM_F) streamdeckpp-$(VERSION)
srpm: dist
$(RPMBUILD) -ts streamdeckpp-$(VERSION).tar.xz
rpm: dist
$(RPMBUILD) -tb streamdeckpp-$(VERSION).tar.xz
clean:
$(RM_F) streamdeck main.o streamdeckpp.os libstreamdeckpp.so streamdeckpp.o libstreamdeckpp.a \
streamdeckpp.pc streamdeckpp.spec
.PHONY: all install dist srpm rpm clean
.SUFFIXES: .os
.ONESHELL: