ordle/Makefile

56 lines
1.1 KiB
Makefile
Raw Normal View History

2024-12-14 14:02:21 +01:00
CXX = g++
2024-12-14 14:16:38 +01:00
CXXFLAGS = -Wall -Wextra -Wpedantic -Wshadow -Wnon-virtual-dtor \
-Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wconversion \
-Wsign-conversion -Wnull-dereference -Wdouble-promotion -Wformat=2 -std=c++17
2025-01-04 14:05:14 +01:00
CXXFLAGS += -Wno-conversion
2024-12-26 16:00:26 +01:00
CXXFLAGS += -I.
2024-12-14 14:16:38 +01:00
ifeq ($(RELEASE),)
CFLAGS += -g -O0
BUILD_TYPE = Debug
else
CXXFLAGS += -O3
CXXFLAGS += -Werror
BUILD_TYPE = Release
endif
2024-12-14 14:02:21 +01:00
SRC = $(wildcard *.cc)
HDR = $(wildcard *.h)
OBJ = $(SRC:.cc=.o)
2024-12-26 16:00:26 +01:00
all: main.elf test.elf
test: test.elf
./test.elf
2024-12-14 14:02:21 +01:00
2024-12-26 16:00:26 +01:00
main.elf: $(OBJ) | words.txt
2024-12-14 14:02:21 +01:00
@echo "Building & linking $@"
@$(CXX) $(CXXFLAGS) $^ -o $@
2024-12-26 16:00:26 +01:00
test.elf: ordle.cc test/test.cc
@$(CXX) $(CXXFLAGS) $^ -o $@
2024-12-26 16:58:26 +01:00
words.txt: /usr/share/dict/words
cat $< > $@
2024-12-14 14:02:21 +01:00
%.o:%.cc
@echo "Building $@"
@$(CXX) -c $(CXXFLAGS) $< -o $@
lint: clang-tidy cppcheck clang-format
clang-tidy:
clang-tidy $(SRC) -- $(CXXFLAGS)
cppcheck:
cppcheck --enable=all --language=c++ --std=c++17 --suppress=missingIncludeSystem -I/usr/include $(SRC) $(HDR)
2024-12-14 14:04:38 +01:00
format:
2024-12-26 16:00:26 +01:00
clang-format -i $(SRC) $(HDR) **/*.cc
2024-12-14 14:02:21 +01:00
clean:
rm -f *.o *.elf words.txt
2024-12-26 16:58:26 +01:00
.PHONY: clean all lint clang-tidy cppcheck format