-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
70 lines (55 loc) · 1.93 KB
/
Copy pathmakefile
File metadata and controls
70 lines (55 loc) · 1.93 KB
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
###############################################################################
# -->Makefile<--
###############################################################################
###############################################################################
#
# Instructor : Clayton Price
# Course : CS328 Winter 2011
# Semester : Spring 2011
#
###############################################################################
###############################################################################
# This makefile will build an executable for the assignment.
###############################################################################
.PHONY: all clean
CXX = /usr/bin/g++
CXXFLAGS = -g -Wall -W -pedantic-errors
# The following 2 lines only work with gnu make.
# It's much nicer than having to list them out,
# and less error prone.
SOURCES = $(wildcard *.cpp)
HEADERS = $(wildcard *.h)
# With Sun's make it has to be done like this, instead of
# using wildcards.
# Well, I haven't figured out another way yet.
#SOURCES = signal.cpp tokentype.cpp token.cpp tokenlist.cpp driver.cpp
#HEADERS = signal.h tokentype.h token.h tokenlist.h
# Looks like it can be done like this, but won't work for gmake.
#SOURCES:sh = ls *.cpp
#HEADERS:sh = ls *.h
OBJECTS = $(SOURCES:%.cpp=%.o)
default: driver
%.o: %.cpp
@echo "Compiling $<"
@$(CXX) $(CXXFLAGS) -c $< -o $@
driver: $(OBJECTS)
@echo "Building $@"
@$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@
@echo ""
@echo "Everything worked :-) "
@echo ""
clean:
-@rm -f core
-@rm -f driver
-@rm -f $(OBJECTS)
-@rm -f depend
-@rm -f *~
# Automatically generate dependencies and include them in Makefile
depend: $(SOURCES) $(HEADERS)
@echo "Generating dependencies"
@$(CXX) -MM *.cpp > $@
-include depend
# Put a dash in front of include when using gnu make.
# It stops gmake from warning us that the file
# doesn't exist yet, even though it will be properly
# made and included when all is said and done.