-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
29 lines (24 loc) · 725 Bytes
/
Makefile
File metadata and controls
29 lines (24 loc) · 725 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
# Lesson 06: Separate src/ and include/ Directories
#
# Real projects don't put everything in one folder.
# Headers go in include/, source files in src/.
#
# Two key mechanisms:
# -Iinclude tells the compiler where to find headers
# VPATH = src tells Make where to find .cpp files
# when a pattern rule needs them
CXX = g++
CXXFLAGS = -std=c++20 -Wall -Wextra -Iinclude
TARGET = main
SRCS = main.cpp counter.cpp
OBJS = $(SRCS:.cpp=.o)
# Tell Make to search src/ for .cpp files
VPATH = src
$(TARGET): $(OBJS)
$(CXX) -o $@ $^
# Note: header deps are not tracked here — see lesson 07
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
.PHONY: clean
clean:
rm -f $(TARGET) $(OBJS)