Skip to content
Snippets Groups Projects
Forked from Configs / EC327 / Labs / Current
143 commits behind the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Makefile 1.07 KiB
# Makefile, generated with support of ChatGPT

# Compiler and flags
CXX = g++
CXXFLAGS = -Wall -std=c++17

# Source files
COMMON_SRCS = Support/Common.cpp
LAB0_SRCS = LabZero.cpp lab0.cpp $(COMMON_SRCS)
LAB1_SRCS = LabOne.cpp lab1.cpp $(COMMON_SRCS)

# Object files
COMM_OBJS = Support/Common.o
LAB0_OBJS = LabZero.o lab0.o $(COMM_OBJS)
LAB1_OBJS = LabOne.o lab1.o $(COMM_OBJS)

# Executable names
LAB0_EXEC = lab0
LAB1_EXEC = lab1

# Default target to build the executable
all: $(LAB0_EXEC) $(LAB1_EXEC)

# Rule to build the executable from object files
$(LAB0_EXEC): $(LAB0_OBJS) Makefile
	$(CXX) $(CXXFLAGS) -o $(LAB0_EXEC) $(LAB0_OBJS)
	./$(LAB0_EXEC)

$(LAB1_EXEC): $(LAB1_OBJS) Makefile
	$(CXX) $(CXXFLAGS) -o $(LAB1_EXEC) $(LAB1_OBJS)
	./$(LAB1_EXEC)

# Rules to build object files from source files, with dependency on the Common.h header
%.o: %.cpp Support/Common.h Makefile
	$(CXX) $(CXXFLAGS) -c $< -o $@

$(SUPPORT_DIR)/Common.o: Support/Common.cpp Support/Common.h
	$(CXX) $(CXXFLAGS) -c $(SUPPORT_DIR)/Common.cpp

# Clean target to remove compiled files
clean:
	rm -f $(OBJS) $(EXEC)