-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.am
More file actions
146 lines (121 loc) · 4.12 KB
/
Makefile.am
File metadata and controls
146 lines (121 loc) · 4.12 KB
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
# Point to our macro directory and pick up user flags from the environment
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
# -- Library -------------------------
lib_LTLIBRARIES = libcangjie.la
libcangjie_la_LDFLAGS = -version-info $(CANGJIE_SO_VERSION) $(GCOV_LDFLAGS)
libcangjie_la_SOURCES = \
src/cangjie.c \
src/cangjiechar.c \
src/cangjiecharlist.c \
$(NULL)
libcangjie_la_LIBADD = $(sqlite3_LIBS)
libcangjie_la_include_HEADERS = \
src/cangjie.h \
src/cangjiechar.h \
src/cangjiecharlist.h \
src/cangjiecommon.h \
src/cangjieerrors.h \
$(NULL)
libcangjie_la_includedir = $(includedir)/cangjie
# -- Tools ---------------------------
bin_PROGRAMS = \
bin/libcangjie_bench \
bin/libcangjie_cli \
bin/libcangjie_dbbuilder \
$(NULL)
bin_libcangjie_bench_SOURCES = src/bench.c
bin_libcangjie_bench_LDADD = libcangjie.la
bin_libcangjie_dbbuilder_SOURCES = src/dbbuilder.c
bin_libcangjie_dbbuilder_LDADD = $(sqlite3_LIBS)
bin_libcangjie_cli_SOURCES = src/cli.c
bin_libcangjie_cli_LDADD = libcangjie.la
# -- Data ----------------------------
data/cangjie.db: bin/libcangjie_dbbuilder data/table.txt
$(AM_V_GEN)rm -f $@; \
$(MKDIR_P) data; \
$^ $@ >/dev/null
libcangjie_data_DATA = data/cangjie.db
libcangjie_datadir = $(pkgdatadir)
pkgconfig_DATA = data/cangjie.pc
pkgconfigdir = $(libdir)/pkgconfig
# -- Unit tests ----------------------
if GCOV_ENABLED
gcov-report.txt: gcov-clean
$(AM_V_GEN)(rm -f $@; \
echo -e "\nTest coverage for libcangjie\n=============================\n" >> $@; \
echo -e "Details\n-------\n" >> $@; \
total_covered=0; total_actual=0; \
for file in $(filter %.c,$(libcangjie_la_SOURCES)); do \
file=`basename $$file`; \
gcda=$${file/.c/.gcda}; \
gcov -o .libs/$$gcda $$file > /dev/null; \
if test -f $$file.gcov; then \
actual=`grep -v ' -:' $$file.gcov | wc -l`; \
uncovered=`grep '#####:' $$file.gcov | wc -l`; \
covered=$$((actual - uncovered)); \
total_covered=$$((total_covered + covered)); \
total_actual=$$((total_actual + actual)); \
echo "$$file: $$covered $$actual $$((($$covered * 100) / $$actual))" \
| $(AWK) '{ printf "%-20s %3s / %3s (%3s%%)\n", $$1, $$2, $$3, $$4 }'; \
fi \
done >> $@; \
cd $(abs_srcdir); \
echo -e "\nTotal\n-----\n" >> $@; \
echo -e "Source lines: $$total_actual" >> $@; \
echo -e "Covered statements: $$total_covered" >> $@; \
echo -e "$$((($$total_covered * 100) / $$total_actual))" \
| awk '{ printf "Total coverage: %3s%%\n", $$1 }' >> $@)
gcov: gcov-report.txt
@cat gcov-report.txt
gcov-clean:
@find . -name "*.gcda" -o -name "*.gcov" -delete
else
gcov-report.txt:
@true
gcov-clean:
@true
gcov:
@echo "Need to reconfigure with --enable-gcov"
endif # GCOV_ENABLED
check-local: gcov
check_PROGRAMS = \
tests/test_cangjie \
tests/test_cangjiechar \
tests/test_cangjiecharlist \
$(NULL)
# FIXME: Find a way to pass this as an envvar for all the tests
tests_test_cangjie_CFLAGS = -DCANGJIE_DB='"$(builddir)/data/cangjie.db"'
tests_test_cangjie_LDADD = libcangjie.la
tests_test_cangjiechar_LDADD = libcangjie.la
tests_test_cangjiecharlist_LDADD = libcangjie.la
TESTS = $(check_PROGRAMS)
# -- Common --------------------------
AM_CPPFLAGS = -I$(top_srcdir)/src
AM_CFLAGS = -DCANGJIE_DB='"$(libcangjie_datadir)/cangjie.db"' $(GCOV_CFLAGS)
AUTHORS:
@if test -d "$(srcdir)/.git"; then \
echo Creating $@ && \
( cd "$(top_srcdir)" && \
echo -e '# Generated by Makefile. Do not edit.\n#'; \
echo -e '# libcangjie was written by these people:\n'; \
git log --no-merges --pretty=format:"%an <%ae>" \
| sort | uniq; \
echo -e "\n# libcangjie would not have been possible without Wan Leung Wong's work on the"; \
echo -e '# original libcangjie: https://github.com/wanleung/libcangjie'; \
) > $@.tmp && mv -f $@.tmp $@ \
|| ( rm -f $@.tmp ; echo Failed to generate $@ >&2 ); \
fi
CLEANFILES = \
AUTHORS \
data/cangjie.db \
data/cangjie.pc \
$(NULL)
EXTRA_DIST = \
autogen.sh \
data/README.table.rst \
data/table.txt \
$(wildcard docs/*.md) \
INSTALL.md \
README.md \
$(NULL)
.PHONY: AUTHORS gcov gcov-clean gcov-report.txt