ad-spi/host/Makefile

58 lines
1.1 KiB
Makefile
Raw Permalink Normal View History

2023-12-08 00:11:50 +01:00
CXX = /usr/bin/g++
CXXFLAGS = -std=c++20 -MMD -MP -Wall -Wpedantic -Wextra
LDFLAGS =
LDLIBS = -lserial
IFLAGS = -Iargparse/include
OBJECT_DIR = ../build
EXEC_NAME = spi-transfer
EXEC = ../$(EXEC_NAME)
SRC = $(wildcard *.cpp) $(wildcard */*.cpp)
# OBJECTS = $(SRC:%.cpp=$(OBJECT_DIR)/%.o)
OBJECTS = $($(notdir SRC):%.cpp=$(OBJECT_DIR)/%.o)
DEPENDS = ${OBJECTS:.o=.d}
CXXFLAGS += $(IFLAGS)
default: $(EXEC)
echo $(OBJECTS)
.PHONY: release install debug run clean
release: CXXFLAGS += -O3
release : default
# rule for the executable
$(EXEC): $(OBJECT_DIR) $(OBJECTS)
$(CXX) $(OBJECTS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(LDLIBS)
# include the makefiles generated by the -M flag
-include $(DEPENDS)
$(OBJECT_DIR)/%.o: %.cpp
$(CXX) -c $< -o $@ $(CXXFLAGS) $(LDFLAGS) $(LDLIBS)
$(OBJECT_DIR):
mkdir -p $@
# Extra Options
install:
install -D -m 751 $(EXEC) $(DESTDIR)/$(EXEC_NAME)
# with debug flags
debug: CXXFLAGS += -g
debug: default
# make with debug flags and run afterwards
run: CXXFLAGS += -g
run: default
./$(EXEC)
# remove all object and dependecy files
clean:
-rm -r $(OBJECT_DIR)
-rm $(EXEC)