Skip to content

Commit 5f5962e

Browse files
authored
Create Makefile
1 parent 8f66ca3 commit 5f5962e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Makefile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Compiler and flags
2+
CXX = g++
3+
CXXFLAGS = -std=c++17 -Wall -Iinclude
4+
LDFLAGS = -pthread
5+
6+
# Directories
7+
SRCDIR = src
8+
OBJDIR = obj
9+
BINDIR = bin
10+
11+
# Find all .cpp files in the source directory
12+
SOURCES = $(wildcard $(SRCDIR)/*.cpp)
13+
# Replace the .cpp extension with .o and put them in the obj directory
14+
OBJECTS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SOURCES))
15+
16+
# Name of the final executable
17+
TARGET = $(BINDIR)/hybrid_cache
18+
19+
# Default target: build the executable
20+
all: $(TARGET)
21+
22+
# Rule to link the final executable
23+
$(TARGET): $(OBJECTS)
24+
@mkdir -p $(BINDIR)
25+
$(CXX) $(OBJECTS) -o $(TARGET) $(LDFLAGS)
26+
@echo "Linking complete. Executable is at $(TARGET)"
27+
28+
# Rule to compile source files into object files
29+
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
30+
@mkdir -p $(OBJDIR)
31+
$(CXX) $(CXXFLAGS) -c $< -o $@
32+
@echo "Compiled $< into $@"
33+
34+
# Clean up build files
35+
clean:
36+
@echo "Cleaning up build artifacts..."
37+
@rm -rf $(OBJDIR) $(BINDIR)
38+
39+
# Phony targets don't represent actual files
40+
.PHONY: all clean

0 commit comments

Comments
 (0)