Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Q ?= @
BUILD_DIR = target
NAME = voord

define object_for
$(addprefix $(BUILD_DIR)/,$(addsuffix .o,$(basename $(1))))
Expand All @@ -15,31 +16,40 @@ src = $(addprefix src/,\
score.cpp \
)

SFLAGS = -I. -Isrc -Os -Wall -MD -MP -ggdb3 -mthumb -mfloat-abi=hard -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16
SFLAGS += -fno-common -fdata-sections -ffunction-sections -fno-exceptions
CPPFLAGS = -std=c++11 -ffreestanding -fno-rtti -nostdinc -nostdlib -fno-threadsafe-statics
SFLAGS = -I. -Isrc -Os -Wall -MD -MP -ggdb3 -mthumb -mfloat-abi=hard -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16
SFLAGS += -fno-common -fdata-sections -ffunction-sections -ffreestanding -nostdinc -nostdlib
CFLAGS = -std=c11
CXXFLAGS = -std=c++11 -fno-exceptions -fno-rtti -fno-threadsafe-statics
LDFLAGS = -Wl,-Ur
LDFLAGS += --specs=nosys.specs -nostartfiles -lm
LDFLAGS += --specs=nosys.specs -nostartfiles
LDFLAGS_END = -lm

.PHONY: all
all: build

.PHONY: build
build: $(BUILD_DIR)/voord.bin
build: $(BUILD_DIR)/$(NAME).bin

.PHONY: run
run: $(BUILD_DIR)/voord.nwa
run: $(BUILD_DIR)/$(NAME).nwa
@echo "INSTALL $<"
$(Q) nwlink install-nwa $<

$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.nwa
@echo "BIN $@"
$(Q) nwlink link-nwa $< $@

$(BUILD_DIR)/voord.nwa: $(call object_for,$(src)) $(BUILD_DIR)/icon.o
$(BUILD_DIR)/$(NAME).nwa: $(call object_for,$(src)) $(BUILD_DIR)/icon.o
@echo "LD $@"
$(Q) arm-none-eabi-gcc $(LDFLAGS) $(SFLAGS) $^ -o $@
$(Q) arm-none-eabi-gcc $(LDFLAGS) $(SFLAGS) $^ $(LDFLAGS_END) -o $@

$(addprefix $(BUILD_DIR)/,%.o): %.c | $(BUILD_DIR)
@echo "C $^"
$(Q) arm-none-eabi-gcc $(CFLAGS) $(SFLAGS) -c $^ -o $@

$(addprefix $(BUILD_DIR)/,%.o): %.cpp | $(BUILD_DIR)
@echo "CXX $^"
$(Q) arm-none-eabi-g++ $(CPPFLAGS) $(SFLAGS) -c $^ -o $@
$(Q) arm-none-eabi-g++ $(CXXFLAGS) $(SFLAGS) -c $^ -o $@

$(BUILD_DIR)/icon.nwi: src/icon.png
@echo "NWI $<"
Expand Down