-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
115 lines (95 loc) · 3.12 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
CC=gcc
FLAGS_PROD=-Wall -std=c99
FLAGS_DEBUG=$(FLAGS_PROD) -ggdb
FLAGS_CUNIT=$(FLAGS_DEBUG) -lcunit
FLAGS_GCOV=$(FLAGS_DEBUG) --coverage
FILES_TEST=traverser.debug.o linked_list.debug.o heap.debug.o gc.debug.o stack_traverser.debug.o utilities.debug.o collector.debug.o
FILES_GCOV=gc_test.c gc.c heap.c linked_list.c traverser.c stack_traverser.c utilities.c collector.c
FILES_MAIN=gc.o collector.o heap.o traverser.o utilities.o linked_list.o
FILES_H=linked_list.h stack_traverser.h heap.h
DIR_RESOURCES=./resources/
all:
@echo "Not implemented yet."
#compile object files
%.o: %.c
$(CC) $(FLAGS_PROD) -o $@ -c $^
# compile object files with debugging information
%.debug.o: %.c
$(CC) $(FLAGS_DEBUG) -o $@ -c $^
#generate documentation with doxygen
doc: $(DIR_RESOURCES)gc.doxy
@doxygen $^
.PHONY: doc
#check if there are memory leaks
valgrind: gc_test
@valgrind --leak-check=full ./gc_test.run
.PHONY: valgrind
#check the unit-test coverage of every source file
gcov: gcov_clean $(FILES_GCOV)
@$(CC) $(FLAGS_GCOV) -o gcov.run $(FILES_GCOV) -lcunit #compile source files with gcov data
@./gcov.run >> /dev/null #create profile data, silence the output
@gcov $(FILES_GCOV)
.PHONY: gcov
#check the unit-test coverage of every source file with visual represenation created in cov/
lcov: gcov_clean gc_test $(FILES_GCOV)
@$(CC) $(FLAGS_GCOV) -o lcov.run $(FILES_GCOV) -lcunit #compile source files with gcov data
@./lcov.run >> /dev/null #create profile data, silence the output
@lcov --capture --directory . --output-file coverage.info
@genhtml coverage.info --output-directory cov
.PHONY: lcov
# this part is executed when testing on multiple machines. change dependency to your needs (ex: os_dump, valgrind, gcov)
# DEFAULT: run_test
# test: stack_c stack_test_c stack_run stack_test_run
test: run_test
.PHONY: test
# Flymake mode (Live syntax and error check)
# Insert the following lines in your .emacs file:
# (require 'flymake)
# (add-hook 'find-file-hook 'flymake-find-file-hook)
# To put in practical use: M-x flymake-mode RET
check-syntax:
gcc -o nul -S ${CHK_SOURCES}
# run tests
run_test: gc_test
@./gc_test.run
.PHONY: run_test
os_dump:
@echo "-s : $(shell uname -s)"; \
echo "-m : $(shell uname -m)"; \
echo "-o : $(shell uname -o)"; \
echo "-r : $(shell uname -r)"; \
echo "-p : $(shell uname -p)"; \
echo "-v : $(shell uname -v)"; \
#compile test
gc_test: $(FILES_TEST) gc_test.debug.o
$(CC) -o [email protected] $^ $(FLAGS_CUNIT)
.PHONY: gc_test
prestanda_data: $(FILES_MAIN) prestanda_h_alloc_data.c
$(CC) -o [email protected] $^ $(FLAGS_DEBUG)
prestanda_struct: $(FILES_MAIN) prestanda_h_alloc_struct.c
$(CC) -o [email protected] $^ $(FLAGS_DEBUG)
prestanda_malloc: $(FILES_MAIN) prestanda_malloc.c
$(CC) -o [email protected] $^ $(FLAGS_DEBUG)
#test with gui
test_gui: $(FILES_MAIN) gui.c
$(CC) $(FLAGS_PROD) -o [email protected] $^
#remove crap files.
clean: gcov_clean
@rm -rf *.run
@rm -rf *.o
@rm -rf ./doc/*
@rm -rf ./cov/*
@rm -rf ./*.dSYM
@rm -rf .DS_Store
@rm -rf *.zip
@rm -rf ./resources/*.zip
@rm -rf ./*~
@rm -rf *.run
@rm -rf *.out
@rm -rf *.info
@rm -rf ./resources/*.result.txt
@echo "All cleaned up!"
gcov_clean:
@rm -rf *.gc*
@rm -rf gcov.run