-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
40 lines (26 loc) · 1.03 KB
/
Copy pathMakefile
File metadata and controls
40 lines (26 loc) · 1.03 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
# the executable this build produces, named in one place so the build and clean steps cannot disagree
TARGET = testing
# every .cpp file under src/ is compiled, so a new source is picked up without editing this file
SOURCES = $(wildcard src/*.cpp)
# every header under src/ is a prerequisite too, so editing one triggers a rebuild instead of running a stale executable
HEADERS = $(wildcard src/*.h src/*.hpp)
# warnings are on by default, so a project started from this template does not hide them
CXXFLAGS = -Wall -Wextra
all: $(TARGET)
$(TARGET): $(SOURCES) $(HEADERS)
@echo "---"
@echo "Compiling $(SOURCES)"
g++ $(CXXFLAGS) $(SOURCES) -o $(TARGET)
@echo "Finished compiling $(SOURCES)"
clean:
@echo "---"
@echo "Removing $(TARGET)"
rm -f ./$(TARGET)
@echo "Finished removing $(TARGET)"
# run the executable, building it first if it is missing or out of date, so nothing outside this file needs its name
run: $(TARGET)
@echo "---"
@echo "Running $(TARGET)"
./$(TARGET)
@echo "Finished running $(TARGET)"
.PHONY: all clean run