-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
39 lines (30 loc) · 844 Bytes
/
Makefile
File metadata and controls
39 lines (30 loc) · 844 Bytes
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
# Lesson 08: Multiple Targets
#
# A Makefile can have multiple targets. The first target is
# the default (what `make` with no arguments builds).
#
# .PHONY declares targets that aren't files. Without it,
# if a file named "clean" existed, `make clean` would say
# "clean is up to date" and do nothing.
#
# Common conventions:
# all — build everything (default target)
# clean — remove build artifacts
# rebuild — clean + build from scratch
CXX = g++
CXXFLAGS = -std=c++20 -Wall -Wextra -Iinclude -MMD -MP
TARGET = app
SRCS = main.cpp logger.cpp
OBJS = $(SRCS:.cpp=.o)
DEPS = $(OBJS:.o=.d)
VPATH = src
.PHONY: all clean rebuild
all: $(TARGET)
$(TARGET): $(OBJS)
$(CXX) -o $@ $^
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
rm -f $(TARGET) $(OBJS) $(DEPS)
rebuild: clean all
-include $(DEPS)