Makefile

Download
makefile 40 lines 877 B
 1# Makefile for Student Management System
 2# Demonstrates: Modern C++17, proper dependency tracking, clean builds
 3
 4CXX = g++
 5CXXFLAGS = -std=c++17 -Wall -Wextra -Wpedantic -O2
 6TARGET = student_manager
 7OBJS = main.o student.o database.o
 8
 9# Default target
10all: $(TARGET)
11
12# Link object files to create executable
13$(TARGET): $(OBJS)
14	$(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJS)
15	@echo "Build complete: $(TARGET)"
16
17# Compile main.cpp
18main.o: main.cpp database.h student.h
19	$(CXX) $(CXXFLAGS) -c main.cpp
20
21# Compile database.cpp
22database.o: database.cpp database.h student.h
23	$(CXX) $(CXXFLAGS) -c database.cpp
24
25# Compile student.cpp
26student.o: student.cpp student.h
27	$(CXX) $(CXXFLAGS) -c student.cpp
28
29# Run the program
30run: $(TARGET)
31	./$(TARGET)
32
33# Clean build artifacts
34clean:
35	rm -f $(OBJS) $(TARGET)
36	@echo "Clean complete"
37
38# Phony targets (not actual files)
39.PHONY: all clean run