EEPROM-Sim/Makefile

39 lines
767 B
Makefile
Raw Permalink Normal View History

2024-01-17 15:10:59 +01:00
CXX = g++
CXXFLAGS = -std=c++20 -O3 -MMD -MP -Wall -Wpedantic
LDFLAGS = -lbcm2835
IFLAGS = -Iargparse/include
2024-01-17 12:47:10 +01:00
2024-01-17 15:10:59 +01:00
SRCDIR = src
BUILD_DIR = build
2024-01-17 12:47:10 +01:00
2024-01-17 15:10:59 +01:00
EXEC = eeprom-sim
2024-01-17 12:47:10 +01:00
2024-01-17 15:10:59 +01:00
SRC = $(wildcard $(SRCDIR)/*.cpp) $(wildcard $(SRCDIR)/*/*.cpp)
# OBJECTS = $(SRC:%.cpp=$(OBJECT_DIR)/%.o)
OBJECTS = $(patsubst $(SRCDIR)/%,$(BUILD_DIR)/%,$(patsubst %.cpp,%.o,$(SRC)))
DEPENDS = ${OBJECTS:.o=.d}
2024-01-17 12:47:10 +01:00
2024-01-17 15:10:59 +01:00
CXXFLAGS += $(IFLAGS)
.PHONY = default clean
default: $(EXEC)
print:
@echo $(SRC)
@echo $(OBJECTS)
-include $(DEPENDS)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(EXEC): $(OBJECTS)
$(CXX) $(OBJECTS) -o $@ $(CXXFLAGS) $(LDFLAGS)
$(BUILD_DIR)/%.o: $(SRCDIR)/%.cpp | $(BUILD_DIR)
$(CXX) -c $(CXXFLAGS) $(LDFLAGS) $< -o $@
2024-01-17 12:47:10 +01:00
clean:
2024-01-17 15:10:59 +01:00
-rm -r $(BUILD_DIR)
-rm $(EXEC)