-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
102 lines (81 loc) · 2.72 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.0
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
PKG_CONFIG = pkg-config
CXXSTD = -std=gnu++20
CXXFLAGS = $(OPT) $(DEBUG) $(CXXFLAGS-$@) $(WARN)
CPPFLAGS = $(INCLUDES) $(DEFINES)
LDFLAGS = $(LDFLAGS-$@)
DEFINES =
INCLUDES = $(shell $(PKG_CONFIG) --cflags $(DEPPKGS))
OPT = -O0
DEBUG = -g3
WARN = -Wall
LIBS = -lcpprest $(shell $(PKG_CONFIG) --libs $(DEPPKGS)) -lpthread
prefix = /usr
includedir = $(prefix)/include/keylightpp-$(VERSION)
bindir = $(prefix)/bin
libdir = $(prefix)/$(shell $(CXX) -print-file-name=libc.so | $(GAWK) -v FS='/' '{ print($$(NF-1)) }')
pcdir= $(libdir)/pkgconfig
IFACEPKGS =
DEPPKGS = avahi-client libcrypto
ALLPKGS = $(IFACEPKGS) $(DEPPKGS)
all: keylight libkeylightpp.a libkeylightpp.so
.cc.os:
$(COMPILE.cc) -fpic -o $@ $<
keylight: cli.o libkeylightpp.a
$(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
libkeylightpp.a: keylightpp.o
$(AR) rcs $@ $^
libkeylightpp.so: keylightpp.os
$(LINK.cc) -shared -Wl,-h,libkeylightpp.so.$(ABI) -o $@ $^ $(LIBS)
cli.o keylightpp.o keylightpp.os: keylightpp.hh
keylightpp.pc: Makefile
$(CAT) > $@-tmp <<EOF
prefix=$(prefix)
includedir=$(includedir)
libdir=$(libdir)
Name: KeyLight++
Description: C++ Library to interace with KeyLight devices
Version: $(VERSION)
URL: https://github.com/drepper/keylightpp
Requires: $(IFACEPKGS)
Requires.private: $(DEPPKGS)
Cflags: -I$(includedir)
Libs: -L$(libdir) -lkeylightpp
EOF
$(MV_F) $@-tmp $@
keylightpp.spec: keylightpp.spec.in Makefile
$(SED) 's/@VERSION@/$(VERSION)/;s/@ABI@/$(ABI)/' $< > $@-tmp
$(MV_F) $@-tmp $@
install: libkeylightpp.a keylightpp.pc
$(INSTALL) -D -c -m 755 keylight $(DESTDIR)$(bindir)/keylight
$(INSTALL) -D -c -m 755 libkeylightpp.so $(DESTDIR)$(libdir)/libkeylightpp-$(VERSION).so
$(LN_FS) libkeylightpp-$(VERSION).so $(DESTDIR)$(libdir)/libkeylightpp.so.$(ABI)
$(LN_FS) libkeylightpp.so.$(ABI) $(DESTDIR)$(libdir)/libkeylightpp.so
$(INSTALL) -D -c -m 644 libkeylightpp.a $(DESTDIR)$(libdir)/libkeylightpp.a
$(INSTALL) -D -c -m 644 keylightpp.pc $(DESTDIR)$(pcdir)/keylightpp.pc
$(INSTALL) -D -c -m 644 keylightpp.hh $(DESTDIR)$(includedir)/keylightpp.hh
dist: keylightpp.spec
$(LN_FS) . keylightpp-$(VERSION)
$(TAR) achf keylightpp-$(VERSION).tar.xz keylightpp-$(VERSION)/{Makefile,keylightpp.hh,keylightpp.cc,cli.cc,README.md,keylightpp.spec,keylightpp.spec.in}
$(RM_F) keylightpp-$(VERSION)
srpm: dist
$(RPMBUILD) -ts keylightpp-$(VERSION).tar.xz
rpm: dist
$(RPMBUILD) -tb keylightpp-$(VERSION).tar.xz
clean:
$(RM_F) keylight cli.o libkeylightpp.a libkeylightpp.so keylightpp.o keylightpp.os \
keylightpp.spec keylightpp.pc
.PHONY: all install dist srpm rpm clean
.SUFFIXES: .os
.ONESHELL: