aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile.am
blob: b1548bcb20f0e2d572b5a4838e66274616375497 (plain)
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
## Autotools settings

ACLOCAL_AMFLAGS = -I m4

AM_DISTCHECK_CONFIGURE_FLAGS = \
	--enable-examples \
	--enable-cmocka \
	--disable-leg \
	--disable-valgrind


## File listings

EXTRA_DIST = \
	autogen.sh \
	README.md \
	src/source-grammar.leg \
	src/template-grammar.leg \
	$(NULL)

CLEANFILES = \
	$(NULL)

noinst_HEADERS = \
	src/source-grammar.h \
	src/template-grammar.h \
	src/utils/utils.h \
	$(NULL)

noinst_LTLIBRARIES = \
	libblogc.la \
	$(NULL)

noinst_PROGRAMS = \
	$(NULL)

bin_PROGRAMS = \
	blogc \
	$(NULL)

check_PROGRAMS = \
	$(NULL)


libblogc_la_SOURCES = \
	src/source-grammar.c \
	src/template-grammar.c \
	src/utils/slist.c \
	src/utils/strings.c \
	src/utils/trie.c \
	$(NULL)

libblogc_la_CFLAGS = \
	$(AM_CFLAGS) \
	-I$(top_srcdir)/src \
	$(NULL)

libblogc_la_LIBADD = \
	$(NULL)

if USE_LEG
src/%-grammar.c: src/%-grammar.leg
	$(AM_V_GEN)$(LEG) -o $@ $<
endif

blogc_SOURCES = \
	src/main.c \
	$(NULL)

blogc_CFLAGS = \
	$(AM_CFLAGS) \
	-I$(top_srcdir)/src \
	$(NULL)

blogc_LDADD = \
	libblogc.la \
	$(NULL)


## Build rules: examples

if BUILD_EXAMPLES

noinst_PROGRAMS += \
	$(NULL)

endif


## Build rules: tests

if USE_CMOCKA

check_PROGRAMS += \
	tests/check_source_grammar \
	tests/check_template_grammar \
	tests/check_utils \
	$(NULL)

tests_check_source_grammar_SOURCES = \
	tests/check_source_grammar.c \
	$(NULL)

tests_check_source_grammar_CFLAGS = \
	$(CMOCKA_CFLAGS) \
	$(NULL)

tests_check_source_grammar_LDFLAGS = \
	-no-install \
	$(NULL)

tests_check_source_grammar_LDADD = \
	$(CMOCKA_LIBS) \
	libblogc.la \
	$(NULL)

tests_check_template_grammar_SOURCES = \
	tests/check_template_grammar.c \
	$(NULL)

tests_check_template_grammar_CFLAGS = \
	$(CMOCKA_CFLAGS) \
	$(NULL)

tests_check_template_grammar_LDFLAGS = \
	-no-install \
	$(NULL)

tests_check_template_grammar_LDADD = \
	$(CMOCKA_LIBS) \
	libblogc.la \
	$(NULL)

tests_check_utils_SOURCES = \
	tests/check_utils.c \
	$(NULL)

tests_check_utils_CFLAGS = \
	$(CMOCKA_CFLAGS) \
	$(NULL)

tests_check_utils_LDFLAGS = \
	-no-install \
	$(NULL)

tests_check_utils_LDADD = \
	$(CMOCKA_LIBS) \
	libblogc.la \
	$(NULL)

endif

TESTS = \
	$(check_PROGRAMS)


## Helpers: Valgrind runners

if USE_VALGRIND
valgrind: all
	$(MAKE) check TESTS_ENVIRONMENT=" \
		G_SLICE=always-malloc \
		G_DEBUG=gc-friendly \
		$(LIBTOOL) \
			--mode=execute \
			$(VALGRIND) \
				--tool=memcheck \
				--leak-check=full \
				--leak-resolution=high \
				--num-callers=20 \
				--show-possibly-lost=no"

valgrind-ci: all clean-local
	$(MAKE) check TESTS_ENVIRONMENT=" \
		G_SLICE=always-malloc \
		G_DEBUG=gc-friendly \
		$(LIBTOOL) \
			--mode=execute \
			$(VALGRIND) \
				--tool=memcheck \
				--xml=yes \
				--xml-file=valgrind-%p.xml \
				--leak-check=full \
				--leak-resolution=high \
				--num-callers=20 \
				--show-possibly-lost=no"
endif


# Helpers: Cleanup of helper files

clean-local:
	-rm -rf $(top_builddir)/valgrind-*.xml