-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
178 lines (155 loc) · 6.06 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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# Makefile for CPSC2430, Seattle University, Spring 2018
#
# Flags:
CPP_FLAGS = -std=c++11 -Wall -Werror -pedantic -ggdb
LNK_FLAGS =
LIBS = -lgtest -lpthread
# Projects:
ifeq ($(shell pwd),/home/fac/lundeenk/cpsc2430/testmake)
SUBMIT = ~lundeenk/submit/test
else
SUBMIT = ~lundeenk/submit/18sq2430
endif
PROJECTS = tw1 tw2 tw3 lab1 lab2 p1
WORK = RandomList.cpp lab1.cpp CrowWorld.cpp tw2.cpp lab2.cpp InchWorm.cpp Menagerie.cpp tw3.cpp PQueueLL.h adt/PriorityQueue.h
GIVEN = CrowWorld.h InchWorm.h lab1_hints.cpp lab1_test.cpp lab2_test.cpp ListA.h ListLL.h PixelMatrix.h PixelMatrix.cpp QueueL.h RandomList.h RGB.cpp RGB.h Terminal.cpp Terminal.h Tower.cpp Tower.h tw1.cpp tw1_test.cpp tw2_hints.cpp p1.cpp Menagerie2.cpp Menagerie.h InchWorm2.cpp Pacer.cpp Pacer.h Cannon.cpp Cannon.h Cannonball.cpp Cannonball.h tw3_test.cpp RandomList_v2.h RandomList_v2.cpp
ADTS = adt/List.h adt/Stack.h adt/Queue.h adt/Critter.h adt/Display.h adt/Printable.h
DATA_FILES = data/Cities.txt data/Cousins.txt data/Latitude.txt data/Longitude.txt
TEST_FILES = test/lab2_input.txt
# make with no argument means just update Makefile from source
default: Makefile
@touch updated_makefile
# header dependencies for all .o files
Cannon.o : Cannon.h adt/Critter.h
Cannonball.o : Cannonball.h adt/Critter.h
CrowWorld.o : CrowWorld.h ListA.h adt/List.h
InchWorm.o : InchWorm.h adt/Critter.h PixelMatrix.o
InchWorm2.o : InchWorm.o
Menagerie.o : Menagerie.h Cannon.h InchWorm.h Cannonball.h Pacer.h ListA.h adt/List.h adt/Critter.h adt/Display.h QueueL.h adt/Queue.h
Menagerie2.o : Menagerie.o
Pacer.o : Pacer.h adt/Critter.h
PixelMatrix.o : RGB.o PixelMatrix.h
RGB.o : RGB.h ListA.h adt/List.h
RandomList.o : RandomList.h ListA.h adt/List.h
RandomList_v2.o : RandomList_v2.h ListA.h adt/List.h
Terminal.o : Terminal.h PixelMatrix.o adt/Display.h
Tower.o : Tower.h adt/Stack.h PixelMatrix.o
lab1.o : CrowWorld.o
lab1_test.o : lab1.o
lab2.o : InchWorm.o Terminal.o
lab2_test.o : lab2.o
p1.o : Menagerie.h ListA.h adt/List.h QueueL.h adt/Queue.h adt/Critter.h
tw1.o : RandomList.o
tw1_test.o : tw1.o
tw2.o : Tower.o Terminal.o QueueL.h adt/Queue.h
tw3.o : PQueueLL.h adt/PriorityQueue.h
tw3_test.o : PQueueLL.h adt/PriorityQueue.h
# TW1
tw1_prep : ListA.h adt/List.h RandomList.h tw1.cpp tw1_test.cpp
@touch $@
tw1: tw1_prep tw1.o RandomList.o
g++ $(LNK_FLAGS) $(filter %.o, $^) $(LIBS) -o $@
tw1_test: tw1 tw1_test.o RandomList.o
g++ $(LNK_FLAGS) $(filter %.o, $^) $(LIBS) -o $@_exe
valgrind ./$@_exe
# L1
lab1_prep: CrowWorld.h lab1_hints.cpp lab1_test.cpp data/Cities.txt data/Cousins.txt data/Longitude.txt data/Latitude.txt
@touch lab1_prep
lab1: lab1_prep lab1.o CrowWorld.o
g++ $(LNK_FLAGS) $(filter %.o, $^) $(LIBS) -o $@
lab1_test: lab1 lab1_test.o CrowWorld.o
g++ $(LNK_FLAGS) $(filter %.o, $^) $(LIBS) -o $@_exe
valgrind ./$@_exe
# L2
lab2_prep: InchWorm.h PixelMatrix.h PixelMatrix.cpp Terminal.h Terminal.cpp RGB.h RGB.cpp lab2_test.cpp test/lab2_input.txt adt/Display.h adt/Critter.h adt/Printable.h
@touch lab2_prep
L2_OBJ = InchWorm.o InchWorm2.o PixelMatrix.o Terminal.o RGB.o
lab2: lab2_prep lab2.o $(L2_OBJ)
g++ $(LNK_FLAGS) $(filter %.o, $^) $(LIBS) -lncurses -o $@
lab2_test: lab2 lab2_test.o $(L2_OBJ)
./lab2 < test/lab2_input.txt
g++ $(LNK_FLAGS) $(filter %.o, $^) $(LIBS) -lncurses -o $@_exe
valgrind ./$@_exe
# R3
reading_3: ListLL.h $(ADTS)
# TW2
tw2_prep: Tower.h QueueL.h Tower.cpp tw2_hints.cpp
@touch tw2_prep
tw2: tw2_prep tw2.o Tower.o Terminal.o PixelMatrix.o RGB.o
g++ $(LNK_FLAGS) $(filter %.o, $^) $(LIBS) -lncurses -o $@
tw2_test: tw2
@echo "There is no internal testing for tw2."
# P1
-include p1_make_extra
ifndef P1_EXTRA
P1_EXTRA =
endif
p1_prep: InchWorm.h PixelMatrix.h PixelMatrix.cpp Terminal.h Terminal.cpp RGB.h RGB.cpp InchWorm2.cpp Pacer.h Pacer.cpp adt/Display.h Cannon.h Cannon.cpp Cannonball.h Cannonball.cpp Menagerie.h Menagerie2.cpp p1.cpp adt/Printable.h
@touch p1_prep
P1_CORE = Menagerie.o Menagerie2.o InchWorm.o InchWorm2.o Pacer.o Cannon.o Cannonball.o PixelMatrix.o RGB.o
p1: p1_prep p1.o $(P1_CORE) $(P1_EXTRA) Terminal.o
g++ $(LNK_FLAGS) $(filter %.o, $^) $(LIBS) -lncurses -o $@
p1_test: p1
@echo "There is not yet internal testing for p1."
# TW3
tw3_prep: adt/Queue.h QueueL.h adt/List.h ListLL.h tw3_test.cpp RandomList_v2.cpp RandomList_v2.h ListA.h adt/List.h
@touch tw3_prep
tw3: tw3_prep tw3.o
g++ $(LNK_FLAGS) $(filter %.o, $^) $(LIBS) -o $@
tw3_test: tw3 tw3_test.o RandomList_v2.o
g++ $(LNK_FLAGS) $(filter %.o, $^) $(LIBS) -o $@_exe
valgrind ./$@_exe
# General Stuff
$(GIVEN) Makefile : % : $(SUBMIT)/files/%
@if [ `pwd` != "/home/fac/lundeenk/cpsc2430" ];then \
echo "Provide/update $@ (from $<)" ; \
cp -f $< $@ ; \
else \
echo "Doh! You're in dev directory. $< newer than $@." ; \
fi
SUBMIT_EXTRA ?=
$(foreach proj, $(PROJECTS), $(proj)_submit) : %_submit: %
$(SUBMIT)/script/$<_runme $(SUBMIT_EXTRA)
$(WORK) : % :
@echo "Student-provided file, $@, not found"
@false
$(ADTS): adt/%.h : $(SUBMIT)/files/adt/%.h
@if [ `pwd` != "/home/fac/lundeenk/cpsc2430" ];then \
echo "Provide/update $@ (from $<)" ; \
if [ ! -d "./adt" ];then \
mkdir ./adt; \
fi ; \
cp -f $< $@ ; \
else \
echo "Doh! You're in dev directory. $< newer than $@." ; \
fi
$(DATA_FILES): data/% : $(SUBMIT)/files/data/%
@if [ `pwd` != "/home/fac/lundeenk/cpsc2430" ];then \
echo "Provide/update $@ (from $<)" ; \
if [ ! -d "./data" ];then \
mkdir ./data; \
fi ; \
cp -f $< $@ ; \
else \
echo "Doh! You're in dev directory. $< newer than $@." ; \
fi
$(TEST_FILES): test/% : $(SUBMIT)/files/test/%
@if [ `pwd` != "/home/fac/lundeenk/cpsc2430" ];then \
echo "Provide/update $@ (from $<)" ; \
if [ ! -d "./test" ];then \
mkdir ./test; \
fi ; \
cp -f $< $@ ; \
else \
echo "Doh! You're in dev directory. $< newer than $@." ; \
fi
%.o: %.cpp
g++ $(CPP_FLAGS) -c $< -o $@
clean:
rm -f $(GIVEN) $(ADTS) $(DATA_FILES) $(TEST_FILES)
rm -f *.o
rm -f $(PROJECTS)
rm -f $(foreach proj, $(PROJECTS), $(proj)_prep)
rm -f $(foreach proj, $(PROJECTS), $(proj)_test)
rm -f $(foreach proj, $(PROJECTS), $(proj)_test_exe)
# release: cp -ruvi * $CS/files