# Compiler and flags
CXX := g++
CXXFLAGS := -std=c++11 -Wall -O2

# Executable name
TARGET := sorting_experiment

# Source files
# Automatically find all .cpp files in the current directory
SRCS := $(wildcard *.cpp)

# Object files
# Replace .cpp extension with .o
OBJS := $(SRCS:.cpp=.o)

# Default target
all: $(TARGET)

# Link the program
$(TARGET): $(OBJS)
	$(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJS)

# Compile source files into object files
%.o: %.cpp
	$(CXX) $(CXXFLAGS) -c $< -o $@

# Target to run the experiment
run: all
	@./$(TARGET)

# Clean up build files
clean:
	rm -f $(TARGET) $(OBJS)

# Phony targets
.PHONY: all clean run
