This repository has been archived by the owner on Nov 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
115 lines (96 loc) · 2.14 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
# This makefile builds and manages the project.
PROGRAM_NAME = main
# Compilation flags
CFLAGS = -std=c99
CFLAGS += -g
CFLAGS += -Wall
CFLAGS += -Wextra
CFLAGS += -pedantic
CFLAGS += -Werror
# Test flags
TEST_FLAGS = -std=c99
TEST_FLAGS += -Wall
TEST_FLAGS += -I./test
# Valgrind flags
VFLAGS = --quiet
VFLAGS += --tool=memcheck
VFLAGS += --leak-check=full
VFLAGS += --error-exitcode=1
SOURCE := $(shell find ./src -name '*.c' -not -name 'main.c')
MAIN := 'src/main.c'
UNITY := $(shell find ./test/Unity/src -name '*.c')
TESTS := $(shell find ./test -name '*.c' -not -path '*Unity*')
.PHONY: usage
usage:
@echo "b|uild Build the executable"
@echo "c|lean Remove any temporary products"
@echo "cl|obber Remove any generated files"
@echo "cu|cumber Run the feature tests"
@echo "m|emcheck Check for memory leaks"
@echo "r|un Run 'build', then run the resulting executable"
@echo "t|est Run the unit tests"
@echo "tr|ee Output the project directory using 'tree'"
.PHONY: memcheck
memcheck: build/test
ifeq ( , $(shell which valgrind))
$(error Please install valgrind to run this command)
else
@valgrind $(VFLAGS) ./build/test
@echo "Memory check passed"
endif
.PHONY: m
m: memcheck
.PHONY: build
build: $(SOURCE)
mkdir -p build
$(CC) $(CC_FLAGS) $(SOURCE) $(MAIN) -o ./build/$(PROGRAM_NAME)
.PHONY: b
b: build
.PHONY: clean
clean:
rm -rf *.o *.out *.out.dSYM tmp*
.PHONY: c
c: clean
.PHONY: clobber
clobber: clean
rm -rf build/
.PHONY: cl
cl: clobber
.PHONY: run
run: clean build
./build/$(PROGRAM_NAME)
.PHONY: r
r: run
.PHONY: test
test: build/test
./build/test
PHONY: t
t: test
build/test: $(TESTS) build
$(CC) $(CFLAGS) $(TESTS) $(SOURCE) $(UNITY) -o build/test
.PHONY: tree
tree:
ifeq ( , $(shell which tree))
$(error Please install tree to run this command)
else
tree -a -I 'Unity|.git'
endif
PHONY: tr
tr: tree
# --- >8 ---
.PHONY: cucumber
cucumber: build bundle
bundle exec cucumber
rm -rf tmp
.PHONY: cu
cu: cucumber
bundle: gem
bundle
gem: ruby
ifeq ( , $(shell which bundle))
gem install bundle
endif
ruby:
ifeq ( , $(shell which ruby))
$(error Please install Ruby to run the aruba/cucumber tests)
endif