-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (93 loc) · 3.17 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
.PHONY: clean build move_exec move_o rebuild
# Variables
CPPVERSION = -std=c++11
CPPFLAGS = -Wall -Wextra -Werror
# Source Code Files
FILES_Person = Person.cpp Person.h
FILES_BasicManager = BasicManager.cpp BasicManager.h
FILES_Student = Student.cpp Student.h
FILES_Manager = Manager.cpp Manager.h
FILES_Consultant = Consultant.cpp Consultant.h
FILES_run_test = run_test.cpp run_test.h
# Unit test files
TEST_Person = PersonTest.cpp Person.o run_test.o
TEST_BasicManager = BasicManagerTest.cpp BasicManager.o Person.o run_test.o
TEST_Manager = ManagerTest.cpp Manager.o BasicManager.o Person.o run_test.o
TEST_Consultant = ConsultantTest.cpp Consultant.o Manager.o BasicManager.o Person.o run_test.o
TEST_Student = StudentTest.cpp Student.o Person.o run_test.o
# Custom path to search directories
vpath %.cpp src/ tests/ util/
vpath %.h include/ util/
vpath %.o obj/
build:
make Person.o
make BasicManager.o
make Student.o
make Manager.o
make Consultant.o
make run_test.o
make PersonTest
make BasicManagerTest
make ManagerTest
make StudentTest
make ConsultantTest
make move_o
make move_exec
rebuild:
make clean
make build
ConsultantTest: $(TEST_Consultant)
@echo "\nBuilding test executable file for Consultant"
g++ $(CPPVERSION) $(CPPFLAGS) -c $<
g++ Consultant.o Manager.o BasicManager.o Person.o run_test.o ConsultantTest.o -o $@
StudentTest: $(TEST_Student)
@echo "\nBuilding test executable file for Student"
g++ $(CPPVERSION) $(CPPFLAGS) -c $<
g++ Student.o Person.o run_test.o StudentTest.o -o $@
ManagerTest: $(TEST_Manager)
@echo "\nBuilding test executable file for Manager"
g++ $(CPPVERSION) $(CPPFLAGS) -c $<
g++ Manager.o BasicManager.o Person.o run_test.o ManagerTest.o -o $@
BasicManagerTest: $(TEST_BasicManager)
@echo "\nBuilding test executable file for BasicManager"
g++ $(CPPVERSION) $(CPPFLAGS) -c $<
g++ BasicManager.o Person.o run_test.o BasicManagerTest.o -o $@
PersonTest: $(TEST_Person)
@echo "\nBuilding test executable file for Person"
g++ $(CPPVERSION) $(CPPFLAGS) -c $<
g++ Person.o run_test.o PersonTest.o -o $@
run_test.o: $(FILES_run_test)
@echo "\nBuilding all the test utility files"
g++ $(CPPVERSION) $(CPPFLAGS) -c $<
Consultant.o: $(FILES_Consultant)
@echo "\nCompiling Consultant.cpp to its object file..."
g++ $(CPPVERSION) $(CPPFLAGS) -c $<
Manager.o: $(FILES_Manager)
@echo "\nCompiling Manager.cpp to its object file..."
g++ $(CPPVERSION) $(CPPFLAGS) -c $<
Student.o: $(FILES_Student)
@echo "\nCompiling Student.cpp to its object file..."
g++ $(CPPVERSION) $(CPPFLAGS) -c $<
BasicManager.o: $(FILES_BasicManager)
@echo "\nCompiling BasicManager.cpp to its object file..."
g++ $(CPPVERSION) $(CPPFLAGS) -c $<
Person.o: $(FILES_Person)
@echo "\nCompiling Person.cpp to its object file..."
g++ $(CPPVERSION) $(CPPFLAGS) -c $<
move_o:
@echo "\nMoving all object files to 'obj' folder"
mkdir obj/
mv *.o ./obj/
move_exec:
@echo "\nMoving all executables to 'build' folder"
mkdir build
mv ./PersonTest ./build/
mv ./BasicManagerTest ./build/
mv ./ManagerTest ./build/
mv ./StudentTest ./build/
mv ./ConsultantTest ./build/
clean:
@echo "\nRemoving all object files"
rm -rf obj/
@echo "\nRemoving all executable files"
rm -rf build/