diff options
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..184f7c0 --- /dev/null +++ b/Makefile | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | BUILD := build | ||
| 2 | |||
| 3 | override PACKAGES := fmt | ||
| 4 | |||
| 5 | WARNINGS := -Wall -Werror | ||
| 6 | OPTIMIZE := -O3 -flto | ||
| 7 | DEBUG := -g | ||
| 8 | |||
| 9 | CXX := g++ | ||
| 10 | CXXFLAGS := $(WARNINGS) $(OPTIMIZE) $(DEBUG) | ||
| 11 | |||
| 12 | XXD := xxd | ||
| 13 | |||
| 14 | override CXXFLAGS += -std=c++20 | ||
| 15 | |||
| 16 | override COMPILE_FLAGS := -MMD -MP -I. | ||
| 17 | override LINK_FLAGS := | ||
| 18 | |||
| 19 | ifneq "$(strip $(PACKAGES))" "" | ||
| 20 | override COMPILE_FLAGS += $(shell pkg-config --cflags $(PACKAGES)) | ||
| 21 | override LINK_FLAGS += -Wl,--start-group $(shell pkg-config --libs $(PACKAGES)) -Wl,--end-group | ||
| 22 | endif | ||
| 23 | |||
| 24 | default: $(BUILD)/procmodel | ||
| 25 | .PHONY: default | ||
| 26 | |||
| 27 | clean: | ||
| 28 | rm -rf $(BUILD) | ||
| 29 | .PHONY: clean | ||
| 30 | |||
| 31 | .SUFFIXES: | ||
| 32 | |||
| 33 | override SOURCES := $(shell find -\( -name build -prune -\) -o -\( -name \*.cpp -print -\)) | ||
| 34 | |||
| 35 | override OBJECTS := $(addprefix $(BUILD)/, $(addsuffix .o, $(basename $(SOURCES)))) | ||
| 36 | override DEPENDS := $(addprefix $(BUILD)/, $(addsuffix .d, $(basename $(SOURCES)))) | ||
| 37 | |||
| 38 | -include $(DEPENDS) | ||
| 39 | |||
| 40 | $(BUILD)/%.o: %.cpp | ||
| 41 | @mkdir -p $(dir $@) | ||
| 42 | $(CXX) $(CXXFLAGS) $(COMPILE_FLAGS) -c -o $@ $< | ||
| 43 | |||
| 44 | $(BUILD)/procmodel: $(OBJECTS) | ||
| 45 | @mkdir -p $(dir $@) | ||
| 46 | $(CXX) $(CXXFLAGS) -o $@ -Wl,--start-group $+ -Wl,--end-group $(LINK_FLAGS) | ||
| 47 | |||
| 48 | $(BUILD)/%.bin: %.hex | ||
| 49 | @mkdir -p $(dir $@) | ||
| 50 | $(XXD) -r -p $< $@ | ||
