45 lines
1.1 KiB
Makefile
45 lines
1.1 KiB
Makefile
# Compiler
|
|
CXX = g++
|
|
|
|
# Compiler flags
|
|
# -Isrc: Add src directory to include path
|
|
# -Wall: Enable all warnings
|
|
# -Wextra: Enable extra warnings
|
|
# -std=c++17: Use C++17 standard
|
|
CXXFLAGS = -O3 -Isrc -Wall -Wextra -std=c++14
|
|
|
|
# Build directory
|
|
BUILD_DIR = build
|
|
|
|
# Find all .cpp files in src and its subdirectories
|
|
SRCS = $(shell find src -name '*.cpp')
|
|
|
|
# VPATH tells make where to look for prerequisites
|
|
VPATH = $(sort $(dir $(SRCS)))
|
|
|
|
# Object files in the build directory
|
|
OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(SRCS:.cpp=.o)))
|
|
|
|
# Name of the executable
|
|
TARGET = kyn
|
|
|
|
# The 'all' target is the default when you just run 'make'
|
|
all: $(TARGET)
|
|
|
|
# Link the object files to create the executable
|
|
# At this point, we do -lcurl to link curl for the request lib
|
|
$(TARGET): $(OBJS)
|
|
$(CXX) $(CXXFLAGS) -lcurl -o $(TARGET) $(OBJS)
|
|
|
|
# Compile .cpp files to .o files in the build directory
|
|
$(BUILD_DIR)/%.o: %.cpp
|
|
@mkdir -p $(BUILD_DIR)
|
|
$(CXX) $(CXXFLAGS) -c $< -o $@
|
|
|
|
# The 'clean' target removes generated files
|
|
clean:
|
|
rm -rf $(BUILD_DIR) $(TARGET)
|
|
|
|
# Phony targets are not files
|
|
.PHONY: all clean
|