CC = g++ OPT = -O3 FLAGS = -std=c++20 -Wall -Wextra -pedantic LIBS = -lwiringPi TARGET = bbx-test SOURCEDIR = src BUILDDIR = build SOURCES = $(wildcard $(SOURCEDIR)/*.cpp) OBJECTS = $(patsubst $(SOURCEDIR)/%.cpp,$(BUILDDIR)/%.o,$(SOURCES)) .PHONY: all clean depend run all: $(TARGET) $(BUILDDIR): @mkdir -p $(BUILDDIR) $(TARGET): $(OBJECTS) $(CC) $(FLAGS) $(OPT) $^ -o $@ $(LIBS) $(OBJECTS): $(BUILDDIR)/%.o : $(SOURCEDIR)/%.cpp $(SOURCEDIR)/%.hpp | $(BUILDDIR) $(CC) $(FLAGS) $(OPT) -c $< -o $@ $(LIBS) depend: .depend .depend: $(SOURCES) rm -rf $(BUILDDIR)/.depend $(CXX) $(FLAGS) -MM $^ -MF $(BUILDDIR)/.depend clean: rm -rf $(BUILDDIR) rm -f $(TARGET) run: $(TARGET) sudo ./$(TARGET) -include $(BUILDDIR)/.depend