forked from vesim987/sommelier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
127 lines (109 loc) · 5.28 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
CC=gcc
SED=sed
CLANG_FORMAT=clang-format-3.9
CLANG_TIDY=clang-tidy-3.9
PREFIX = /usr
SYSCONFDIR = /etc
BINDIR = $(PREFIX)/bin
SRCFILES := sommelier.c version.h
XMLFILES := aura-shell.xml viewporter.xml xdg-shell-unstable-v6.xml linux-dmabuf-unstable-v1.xml drm.xml keyboard-extension-unstable-v1.xml gtk-shell.xml
AUXFILES := Makefile README LICENSE AUTHORS sommelier@.service.in sommelier-x@.service.in sommelierrc sommelier.sh
ALLFILES := $(SRCFILES) $(XMLFILES) $(AUXFILES)
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
DIST_VERSION := $(shell git describe --abbrev=0 --tags)
DIST_VERSION_BITS := $(subst ., ,$(DIST_VERSION))
DIST_VERSION_MAJOR := $(word 1,$(DIST_VERSION_BITS))
DIST_VERSION_MINOR := $(word 2,$(DIST_VERSION_BITS))
DIST_VERSION_MINOR_NEXT := $(shell expr $(DIST_VERSION_MINOR) + 1)
CFLAGS=-g -Wall `pkg-config --cflags xcb xcb-composite xcb-xfixes wayland-server wayland-client gbm pixman-1` -I. -D_GNU_SOURCE=1 -DWL_HIDE_DEPRECATED=1 -DXWAYLAND_PATH=\"$(PREFIX)/bin/Xwayland\"
LDFLAGS=-lpthread -lm `pkg-config --libs xcb xcb-composite xcb-xfixes wayland-server wayland-client gbm pixman-1 xkbcommon`
DEPS = xdg-shell-unstable-v6-client-protocol.h xdg-shell-unstable-v6-server-protocol.h aura-shell-client-protocol.h viewporter-client-protocol.h linux-dmabuf-unstable-v1-client-protocol.h drm-server-protocol.h keyboard-extension-unstable-v1-client-protocol.h gtk-shell-server-protocol.h
OBJECTS = sommelier.o xdg-shell-unstable-v6-protocol.o aura-shell-protocol.o viewporter-protocol.o linux-dmabuf-unstable-v1-protocol.o drm-protocol.o keyboard-extension-unstable-v1-protocol.o gtk-shell-protocol.o
all: sommelier sommelier@.service sommelier-x@.service
%.service: %.service.in
$(SED) \
-e 's|@bindir[@]|$(BINDIR)|g' \
-e 's|@sysconfdir[@]|$(SYSCONFDIR)|g' \
-e 's|@version[@]|$(DIST_VERSION)|g' \
$< > $@
sommelier: $(OBJECTS)
$(CC) $(OBJECTS) -o sommelier $(LDFLAGS)
%-protocol.c: %.xml
wayland-scanner code < $< > $@
%-client-protocol.h: %.xml
wayland-scanner client-header < $< > $@
%-server-protocol.h: %.xml
wayland-scanner server-header < $< > $@
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS)
$(OBJECTS): $(DEPS)
.PHONY: all install uninstall update-version dist deb version-clean clean style check-style tidy
install: all
install -D sommelier \
$(DESTDIR)$(PREFIX)/bin/sommelier
install -D sommelierrc $(DESTDIR)$(SYSCONFDIR)/sommelierrc
install -m 644 -D sommelier@.service \
$(DESTDIR)$(PREFIX)/lib/systemd/user/sommelier@.service
install -m 644 -D sommelier-x@.service \
$(DESTDIR)$(PREFIX)/lib/systemd/user/sommelier-x@.service
install -m 644 -D sommelier.sh $(DESTDIR)$(SYSCONFDIR)/profile.d/sommelier.sh
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/sommelier
rm -f $(DESTDIR)$(SYSCONFDIR)/sommelierrc
rm -f $(DESTDIR)$(PREFIX)/lib/systemd/user/sommelier@.service
rm -f $(DESTDIR)$(PREFIX)/lib/systemd/user/sommelier-x@.service
rm -f $(DESTDIR)$(SYSCONFDIR)/profile.d/sommelier.sh
update-version:
dch -v $(DIST_VERSION_MAJOR).$(DIST_VERSION_MINOR_NEXT)-1
git commit -m 'debian/changelog: bump to version $(DIST_VERSION_MAJOR).$(DIST_VERSION_MINOR_NEXT)' debian/changelog
$(SED) -i -e 's/VERSION "[0-9.]*"/VERSION "$(DIST_VERSION_MAJOR).$(DIST_VERSION_MINOR_NEXT)"/g' version.h
git tag $(DIST_VERSION_MAJOR).$(DIST_VERSION_MINOR_NEXT)
dist: $(DEPS)
mkdir -p sommelier-$(DIST_VERSION)
cp -r $(ALLFILES) $(DEPS) debian sommelier-$(DIST_VERSION)
tar czf sommelier-$(DIST_VERSION).tar.gz sommelier-$(DIST_VERSION)
rm -rf sommelier-$(DIST_VERSION)
deb: dist
ln -sf sommelier-$(DIST_VERSION).tar.gz sommelier_$(DIST_VERSION).orig.tar.gz
tar xzf sommelier-$(DIST_VERSION).tar.gz
cd sommelier-$(DIST_VERSION) && debuild -i -us -uc -b
rm -rf sommelier-$(DIST_VERSION) sommelier_$(DIST_VERSION).orig.tar.gz
clean:
rm -f *~ *-protocol.c *-protocol.h *.o sommelier sommelier@.service \
sommelier-x@.service sommelier-*.tar.gz sommelier*.deb \
sommelier_*.build sommelier_*.buildinfo sommelier_*.changes
style: $(DEPS)
@for src in $(SRCFILES) ; do \
echo "Formatting $$src..."; \
$(CLANG_FORMAT) -i "$$src"; \
$(CLANG_TIDY) -checks='-*,readability-identifier-naming' \
-config="{CheckOptions: [ \
{ key: readability-identifier-naming.StructCase, value: lower_case }, \
{ key: readability-identifier-naming.FunctionCase, value: lower_case }, \
{ key: readability-identifier-naming.VariableCase, value: lower_case }, \
{ key: readability-identifier-naming.GlobalConstantCase, value: lower_case }, \
{ key: readability-identifier-naming.EnumConstantCase, value: UPPER_CASE } \
]}" "$$src"; \
done
@echo "Done"
check-style:
@for src in $(SRCFILES) ; do \
var=`$(CLANG_FORMAT) "$$src" | diff "$$src" - | wc -l`; \
if [ $$var -ne 0 ] ; then \
echo "$$src does not respect the coding style (diff: $$var lines)"; \
exit 1; \
fi; \
done
@echo "Style check passed"
tidy: $(DEPS)
@for src in $(SRCFILES); do \
echo "Running tidy on $$src..."; \
$(CLANG_TIDY) -checks="-*,modernize-use-auto,modernize-use-nullptr, \
readability-else-after-return,readability-simplify-boolean-expr, \
readability-redundant-member-init,modernize-use-default-member-init, \
modernize-use-equals-default,modernize-use-equals-delete, \
modernize-use-using,modernize-loop-convert, \
cppcoreguidelines-no-malloc,misc-redundant-expression" \
"$$src"; \
done
@echo "Done"