forked from CodersSquad/tmp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
31 lines (25 loc) · 849 Bytes
/
Makefile
File metadata and controls
31 lines (25 loc) · 849 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
# Define the compiler and compiler flags
CXX := g++
CXXFLAGS := -std=c++17 -Wall -g
# Define the names for the executable, source files, and object files
TARGET := main
SOURCES := person.cpp utils.cpp main.cpp
OBJECTS := $(SOURCES:.cpp=.o)
# Default rule to build the executable
all: $(TARGET)
# Rule to link the object files into the final executable
$(TARGET): $(OBJECTS)
$(CXX) $(CXXFLAGS) -o $@ $(OBJECTS)
# Generic rule to compile .cpp files into .o files
# $@ is the target, $< is the first prerequisite
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
# Rules for explicit header dependencies
# These rules tell make which object files depend on which header files.
main.o: main.cpp person.h utils.h
person.o: person.cpp person.h
utils.o: utils.cpp utils.h
# Rule to clean up generated files
.PHONY: clean
clean:
rm -f $(OBJECTS) $(TARGET)