diff --git a/Makefile b/Makefile index 65ae7f7..9bf007c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ Q ?= @ BUILD_DIR = target +NAME = voord define object_for $(addprefix $(BUILD_DIR)/,$(addsuffix .o,$(basename $(1)))) @@ -15,17 +16,22 @@ 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 $< @@ -33,13 +39,17 @@ $(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 $<"