summaryrefslogtreecommitdiff
path: root/Makefile.am
blob: 39bfb425f0472afcfd647798efae055110ba6772 (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
#
# mmap-unifont - Global Makefile
# Copyright (c) 2012-2014 David Herrmann <dh.herrmann@gmail.com>
#

#
# Global Configurations and Initializations
#

ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
AM_MAKEFLAGS = --no-print-directory
AUTOMAKE_OPTIONS = color-tests

SUBDIRS = .

.DELETE_ON_ERROR:

include_HEADERS =
EXTRA_DIST = \
	README \
	COPYING \
	NEWS \
	DOCUMENTATION
CLEANFILES =
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA =
dist_pkgdata_DATA =
TPHONY =

TESTS =
MEMTESTS =
check_PROGRAMS =
bin_PROGRAMS =
lib_LTLIBRARIES =
noinst_LTLIBRARIES =

#
# Default CFlags
#

AM_CFLAGS = \
	-Wall \
	-pipe \
	-fno-common \
	-ffast-math \
	-fdiagnostics-show-option \
	-fno-strict-aliasing \
	-fvisibility=hidden \
	-ffunction-sections \
	-fdata-sections
AM_CPPFLAGS = \
	-include $(top_builddir)/config.h \
	-I $(srcdir)/src \
	'-DPKGDATADIR="$(pkgdatadir)"'
AM_LDFLAGS = \
	-Wl,--as-needed \
	-Wl,--gc-sections \
	-Wl,-z,relro \
	-Wl,-z,now

#
# mmap-unifont
#

pkgconfig_DATA += src/mmap-unifont.pc

EXTRA_DIST += \
	src/compile-unifont.py \
	src/mmap-unifont.pc.in \
	src/unifont.hex

dist_pkgdata_DATA += src/mmap-unifont.bin

src/mmap-unifont.bin: src/compile-unifont.py src/unifont.hex
	$(AM_V_GEN)cat $(top_srcdir)/src/unifont.hex | $(PYTHON) $< >$@

src/mmap-unifont.cmp: src/compile-unifont.py src/mmap-unifont.bin
	$(AM_V_GEN)cat $(top_srcdir)/src/mmap-unifont.bin | $(PYTHON) $< verify >$@

test-unifont: src/mmap-unifont.bin src/mmap-unifont.cmp
	@RET=`diff -u src/unifont.hex src/mmap-unifont.cmp | wc -l` ; \
		if test "x$$?" != "x0" -o "x$$RET" != "x0" ; then \
			echo "Generated Unifont-file differs from original; generator probably broken" ; \
			exit 1 ; \
		fi
	@echo "mmap-unifont.bin has been regenerated"

#
# Tests
# We add a separate "memcheck" target which runs valgrind on all tests in
# MEMTESTS. Note that we fail if _any_ leak is detected by valgrind. Thus, you
# need to have valgrind installed and libcheck running properly (without leaks)
# to make memcheck succeed.
# A separate memcheck-verify actually runs a faulty test and verifies the
# valgrind tests work properly.
#

if BUILD_HAVE_CHECK
MEMTESTS += \
	test-example
check_PROGRAMS += \
	$(MEMTESTS) \
	test-valgrind
TESTS += \
	$(MEMTESTS) \
	test-valgrind
endif

test_sources = \
	test/test-common.h
test_libs = \
	$(CHECK_LIBS)
test_cflags = \
	$(AM_CPPFLAGS) \
	$(CHECK_CFLAGS)
test_lflags = \
	$(AM_LDFLAGS)

test_example_SOURCES = test/test-example.c $(test_sources)
test_example_CPPFLAGS = $(test_cflags)
test_example_LDADD = $(test_libs)
test_example_LDFLAGS = $(test_lflags)

test_valgrind_SOURCES = test/test-valgrind.c $(test_sources)
test_valgrind_CPPFLAGS = $(test_cflags)
test_valgrind_LDADD = $(test_libs)
test_valgrind_LDFLAGS = $(test_lflags)

EXTRA_DIST += test.supp

VALGRIND = CK_FORK=no valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --leak-resolution=high --error-exitcode=1 --suppressions=$(top_builddir)/test.supp

# verify that test-valgrind actually leaks data
memcheck-verify: check
	$(AM_V_GEN)$(VALGRIND) --log-file=/dev/null ./test-valgrind >/dev/null ; test 1 = $$?

TPHONY += memcheck-verify

# run memcheck tests via valgrind
memcheck: memcheck-verify
	$(AM_V_GEN)for i in $(MEMTESTS) ; do \
		$(VALGRIND) --log-file=$(top_builddir)/$$i.memlog \
			$(top_builddir)/$$i >/dev/null || (echo "memcheck failed on: $$i" ; exit 1) ; \
	done

TPHONY += memcheck memcheck-verify

distcheck-hook: test-unifont memcheck

#
# Phony targets
#

.PHONY: $(TPHONY)

#
# Empty .SECONDARY target causes alle intermediate files to be treated as
# secondary files. That is, they don't get deleted after make finished.
#

.SECONDARY: