Makefile revision 5821806d5e7f356e8fa4b058a389a808ea183019
1#
2# Makefile for the LCOV example program.
3#
4# Make targets:
5#   - example: compile the example program
6#   - output:  run test cases on example program and create HTML output
7#   - clean:   clean up directory
8#
9
10CC      := gcc
11CFLAGS  := -Wall -I. -fprofile-arcs -ftest-coverage
12
13LCOV    := ../bin/lcov
14GENHTML := ../bin/genhtml
15GENDESC := ../bin/gendesc
16GENPNG  := ../bin/genpng
17
18# Depending on the presence of the GD.pm perl module, we can use the
19# special option '--frames' for genhtml
20USE_GENPNG := $(shell $(GENPNG) --help >/dev/null 2>/dev/null; echo $$?)
21
22ifeq ($(USE_GENPNG),0)
23  FRAMES := --frames
24else
25  FRAMES :=
26endif
27
28.PHONY: clean output test_noargs test_2_to_2000 test_overflow
29
30all: output
31
32example: example.o iterate.o gauss.o
33	$(CC) example.o iterate.o gauss.o -o example -lgcov
34
35example.o: example.c iterate.h gauss.h
36	$(CC) $(CFLAGS) -c example.c -o example.o
37
38iterate.o: methods/iterate.c iterate.h
39	$(CC) $(CFLAGS) -c methods/iterate.c -o iterate.o
40
41gauss.o: methods/gauss.c gauss.h
42	$(CC) $(CFLAGS) -c methods/gauss.c -o gauss.o
43
44output: example descriptions test_noargs test_2_to_2000 test_overflow
45	@echo
46	@echo '*'
47	@echo '* Generating HTML output'
48	@echo '*'
49	@echo
50	$(GENHTML) trace_noargs.info trace_args.info trace_overflow.info \
51		   --output-directory output --title "Basic example" \
52		   --show-details --description-file descriptions $(FRAMES) \
53		   --legend
54	@echo
55	@echo '*'
56	@echo '* See '`pwd`/output/index.html
57	@echo '*'
58	@echo
59
60descriptions: descriptions.txt
61	$(GENDESC) descriptions.txt -o descriptions
62
63all_tests: example test_noargs test_2_to_2000 test_overflow
64
65test_noargs:
66	@echo
67	@echo '*'
68	@echo '* Test case 1: running ./example without parameters'
69	@echo '*'
70	@echo
71	$(LCOV) --zerocounters --directory .
72	./example
73	$(LCOV) --capture --directory . --output-file trace_noargs.info --test-name test_noargs
74
75test_2_to_2000:
76	@echo
77	@echo '*'
78	@echo '* Test case 2: running ./example 2 2000'
79	@echo '*'
80	@echo
81	$(LCOV) --zerocounters --directory .
82	./example 2 2000
83	$(LCOV) --capture --directory . --output-file trace_args.info --test-name test_2_to_2000
84
85test_overflow:
86	@echo
87	@echo '*'
88	@echo '* Test case 3: running ./example 0 100000 (causes an overflow)'
89	@echo '*'
90	@echo
91	$(LCOV) --zerocounters --directory .
92	./example 0 100000 || true
93	$(LCOV) --capture --directory . --output-file trace_overflow.info --test-name "test_overflow"
94
95clean:
96	rm -rf *.o *.bb *.bbg *.da *.gcno *.gcda *.info output example \
97	descriptions
98
99