forked from thjaeger/easystroke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
156 lines (123 loc) · 4.95 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Copyright (c) 2008-2009, Thomas Jaeger <ThJaeger@gmail.com>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY
# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
DESTDIR =
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
ICONDIR = $(PREFIX)/share/icons/hicolor/scalable/apps
MENUDIR = $(PREFIX)/share/applications
LOCALEDIR= $(PREFIX)/share/locale
DFLAGS =
OFLAGS = -O2
AOFLAGS = -O3
STROKEFLAGS = -Wall -std=c11 $(DFLAGS)
CXXSTD = -std=c++11
INCLUDES = $(shell pkg-config gtkmm-3.0 dbus-glib-1 --cflags)
CXXFLAGS = $(CXXSTD) -Wall $(DFLAGS) -DLOCALEDIR=\"$(LOCALEDIR)\" $(INCLUDES)
CFLAGS = -std=c11 -Wall $(DFLAGS) -DLOCALEDIR=\"$(LOCALEDIR)\" $(INCLUDES) -DGETTEXT_PACKAGE='"easystroke"'
LDFLAGS = $(DFLAGS)
LIBS = $(DFLAGS) -lboost_serialization -lX11 -lXext -lXi -lXfixes -lXtst `pkg-config gtkmm-3.0 dbus-glib-1 --libs`
BINARY = easystroke
ICON = easystroke.svg
MENU = easystroke.desktop
MANPAGE = easystroke.1
CCFILES = $(wildcard *.cc)
HFILES = $(wildcard *.h)
OFILES = $(patsubst %.cc,%.o,$(CCFILES)) stroke.o cellrenderertextish.o gui.o desktop.o version.o
POFILES = $(wildcard po/*.po)
MOFILES = $(patsubst po/%.po,po/%/LC_MESSAGES/easystroke.mo,$(POFILES))
MODIRS = $(patsubst po/%.po,po/%,$(POFILES))
DEPFILES = $(wildcard *.Po)
GENFILES = gui.c desktop.c po/POTFILES.in easystroke.desktop
GZFILES = $(wildcard *.gz)
VERSION = $(shell test -e debian/changelog && grep '(.*)' debian/changelog | sed 's/.*(//' | sed 's/).*//' | head -n1 || (test -e version && cat version || git describe))
GIT = $(wildcard .git/index version)
DIST = easystroke-$(VERSION)
-include debug.mk
all: $(BINARY) $(MOFILES)
.PHONY: all clean translate update-translations compile-translations complete
clean:
$(RM) $(OFILES) $(BINARY) $(GENFILES) $(DEPFILES) $(MANPAGE) $(GZFILES) po/*.pot
$(RM) -r $(MODIRS)
include $(DEPFILES)
$(BINARY): $(OFILES)
$(CXX) $(LDFLAGS) -o $@ $(OFILES) $(LIBS)
stroke.o: stroke.c
$(CC) $(STROKEFLAGS) $(AOFLAGS) -MT $@ -MMD -MP -MF $*.Po -o $@ -c $<
%.o: %.c
$(CC) $(CFLAGS) $(OFLAGS) -MT $@ -MMD -MP -MF $*.Po -o $@ -c $<
%.o: %.cc
$(CXX) $(CXXFLAGS) $(OFLAGS) -MT $@ -MMD -MP -MF $*.Po -o $@ -c $<
version.o: $(GIT)
echo 'const char *version_string = "$(VERSION)";' | $(CXX) -o $@ -c -xc++ -
gui.c: gui.glade
echo "const char *gui_buffer = \"\\" > $@
sed 's/"GtkWindow"/"GtkApplicationWindow"/' $< | sed 's/"/\\"/g' | sed 's/ *\(.*\)/\1\\n\\/' >> $@
echo "\";" >> $@
easystroke.desktop: easystroke.desktop.in $(MOFILES)
intltool-merge po/ -d -u $< $@
desktop.c: easystroke.desktop
echo "const char *desktop_file = \"\\" > $@
sed 's/Exec=easystroke/Exec=%1$$s/' $< | sed 's/"/\\"/g' | sed 's/.*/&\\n\\/' >> $@
echo "\";" >> $@
po/POTFILES.in: $(CCFILES) $(HFILES)
$(RM) $@
for f in `grep -El "\<_\(" $^`; do echo $$f >> $@; done
echo gui.glade >> $@
echo easystroke.desktop.in >> $@
translate: po/POTFILES.in
cd po && XGETTEXT_ARGS="--package-name=easystroke --copyright-holder='Thomas Jaeger <ThJaeger@gmail.com>'" intltool-update --pot -g messages
compile-translations: $(MOFILES)
update-translations: po/POTFILES.in
cd po && for f in $(POFILES); do \
intltool-update `echo $$f | sed "s|po/\(.*\)\.po$$|\1|"`; \
done
strip-translations:
for f in $(POFILES); do \
grep -v '^#:' $$f > $$f.out; \
mv $$f.out $$f; \
done
po/%/LC_MESSAGES/easystroke.mo: po/%.po
mkdir -p po/$*/LC_MESSAGES
msgfmt -c $< -o $@
man: $(MANPAGE)
$(MANPAGE): $(BINARY)
help2man -N -n "X11 gesture recognition application" ./$(BINARY) > $@
install: all
install -Ds $(BINARY) $(DESTDIR)$(BINDIR)/$(BINARY)
install -D -m 644 $(ICON) $(DESTDIR)$(ICONDIR)/$(ICON)
install -D -m 644 $(MENU) $(DESTDIR)$(MENUDIR)/$(MENU)
for f in $(MOFILES); do \
install -D -m 644 $$f `echo $$f | sed "s|^po/|$(DESTDIR)$(LOCALEDIR)/|"`; \
done
uninstall:
$(RM) $(DESTDIR)$(BINDIR)/$(BINARY)
$(RM) $(DESTDIR)$(ICONDIR)/$(ICON)
$(RM) $(DESTDIR)$(MENUDIR)/$(MENU)
for f in $(MOFILES); do \
$(RM) `echo $$f | sed "s|^po/|$(DESTDIR)$(LOCALEDIR)/|"`; \
done
tarball: $(DIST).tar.gz
tmp/$(DIST): $(GIT)
$(RM) -r tmp
mkdir tmp
git archive --format=tar --prefix=$(DIST)/ HEAD | (cd tmp && tar x)
echo $(VERSION) > $@/version
$(RM) $@/.gitignore $@/release
$(DIST).tar.gz: tmp/$(DIST)
tar -czf $@ -C tmp/ $(DIST)
$(RM) -r tmp
complete: .clang_complete
.clang_complete: Makefile
@echo $(CXXSTD) > $@
@$(foreach inc,$(INCLUDES),echo $(inc) >> $@;)