41 lines
882 B
Makefile
41 lines
882 B
Makefile
CXX = g++
|
|
BUILD = .build
|
|
TARGET = upload
|
|
OPT = g -g
|
|
|
|
CFLAGS = -Wall -Wextra -std=c++20 -O$(OPT) -flto -Iinclude -Ilibs/serial/include -Ilibs/CLI11/include
|
|
LDFLAGS = -Wall -Wextra -O$(OPT) -flto
|
|
|
|
SRC = \
|
|
src/main.cpp \
|
|
libs/serial/src/serial.cc \
|
|
libs/serial/src/impl/unix.cc \
|
|
libs/serial/src/impl/list_ports/list_ports_linux.cc \
|
|
|
|
OBJ_1 = $(notdir $(SRC:.cpp=.o))
|
|
OBJ_2 = $(notdir $(OBJ_1:.cc=.o))
|
|
OBJ = $(addprefix $(BUILD)/, $(OBJ_2))
|
|
# We can't use this as it will use the wrong main
|
|
# vpath %.c $(sort $(dir $(SRC)))
|
|
vpath %.cpp $(dir $(SRC))
|
|
vpath %.cc $(dir $(SRC))
|
|
|
|
.PHONY: all clean
|
|
|
|
all: $(BUILD) $(BUILD)/$(TARGET)
|
|
|
|
$(BUILD)/%.o: %.cpp Makefile | $(BUILD)
|
|
$(CXX) -c $(CFLAGS) $< -o $@
|
|
|
|
$(BUILD)/%.o: %.cc Makefile | $(BUILD)
|
|
$(CXX) -c $(CFLAGS) $< -o $@
|
|
|
|
$(BUILD)/$(TARGET): $(OBJ) Makefile
|
|
$(CXX) $(LDFLAGS) $(OBJ) -o $@
|
|
|
|
$(BUILD):
|
|
mkdir $@
|
|
|
|
clean:
|
|
rm -fr $(BUILD)
|