move to a makefile based workflow
This commit is contained in:
84
Sensor Watch Starter Project/make/Makefile
Executable file
84
Sensor Watch Starter Project/make/Makefile
Executable file
@@ -0,0 +1,84 @@
|
||||
##############################################################################
|
||||
BUILD = build
|
||||
BIN = watch
|
||||
|
||||
##############################################################################
|
||||
.PHONY: all directory clean size
|
||||
|
||||
CC = arm-none-eabi-gcc
|
||||
OBJCOPY = arm-none-eabi-objcopy
|
||||
SIZE = arm-none-eabi-size
|
||||
UF2 = python uf2conv.py
|
||||
|
||||
ifeq ($(OS), Windows_NT)
|
||||
MKDIR = gmkdir
|
||||
else
|
||||
MKDIR = mkdir
|
||||
endif
|
||||
|
||||
CFLAGS += -W -Wall --std=gnu99 -Os
|
||||
CFLAGS += -fno-diagnostics-show-caret
|
||||
CFLAGS += -fdata-sections -ffunction-sections
|
||||
CFLAGS += -funsigned-char -funsigned-bitfields
|
||||
CFLAGS += -mcpu=cortex-m0plus -mthumb
|
||||
CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d
|
||||
|
||||
LDFLAGS += -mcpu=cortex-m0plus -mthumb
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += -Wl,--script=../linker/saml22j18.ld
|
||||
|
||||
INCLUDES += \
|
||||
-I../include \
|
||||
-I..
|
||||
|
||||
SRCS += \
|
||||
../main.c \
|
||||
../startup_saml22.c
|
||||
|
||||
DEFINES += \
|
||||
-D__SAML22J18A__ \
|
||||
-DDONT_USE_CMSIS_INIT \
|
||||
-DF_CPU=16000000
|
||||
|
||||
CFLAGS += $(INCLUDES) $(DEFINES)
|
||||
|
||||
OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS))))
|
||||
|
||||
all: directory $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin $(BUILD)/$(BIN).uf2 size
|
||||
|
||||
$(BUILD)/$(BIN).elf: $(OBJS)
|
||||
@echo LD $@
|
||||
@$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
|
||||
|
||||
$(BUILD)/$(BIN).hex: $(BUILD)/$(BIN).elf
|
||||
@echo OBJCOPY $@
|
||||
@$(OBJCOPY) -O ihex $^ $@
|
||||
|
||||
$(BUILD)/$(BIN).bin: $(BUILD)/$(BIN).elf
|
||||
@echo OBJCOPY $@
|
||||
@$(OBJCOPY) -O binary $^ $@
|
||||
|
||||
$(BUILD)/$(BIN).uf2: $(BUILD)/$(BIN).bin
|
||||
@echo UF2CONV $@
|
||||
@$(UF2) $^ -co $@
|
||||
|
||||
install:
|
||||
@$(UF2) -D $(BUILD)/$(BIN).uf2
|
||||
|
||||
%.o:
|
||||
@echo CC $@
|
||||
@$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@
|
||||
|
||||
directory:
|
||||
@$(MKDIR) -p $(BUILD)
|
||||
|
||||
size: $(BUILD)/$(BIN).elf
|
||||
@echo size:
|
||||
@$(SIZE) -t $^
|
||||
|
||||
clean:
|
||||
@echo clean
|
||||
@-rm -rf $(BUILD)
|
||||
|
||||
-include $(wildcard $(BUILD)/*.d)
|
||||
|
||||
Reference in New Issue
Block a user