microscope-ring-light/firmware/Makefile

95 lines
2.4 KiB
Makefile
Raw Permalink Normal View History

2021-03-12 18:53:53 +01:00
################################Shimatta Makefile####################################
#CPU: STM32F030F4P6
2021-03-12 18:53:53 +01:00
#Compiler: arm-none-eabi
#####################################################################################
ifneq ($(VERBOSE),true)
QUIET=@
else
QUIET=
endif
#Add Files and Folders below#########################################################
CFILES = main.c syscalls/syscalls.c setup/system_init.c startup/startup_stm32f0xx.c
CFILES += temp-adc.c
2022-06-21 20:33:23 +02:00
CFILES += dmx.c
2021-03-12 22:28:00 +01:00
ASFILES = sk6812.S
2021-03-12 18:53:53 +01:00
INCLUDEPATH = -Iinclude -Iinclude/cmsis
OBJDIR=obj
target = project
LIBRARYPATH = -Lstartup
LIBRARIES =
DEFINES = -DSTM32F030x6 -DSTM32F0XX
mapfile = memmap
##Custom Files###
#TODO
###################################################################################
CROSS_COMPILE ?= arm-none-eabi-
CC := $(CROSS_COMPILE)gcc
OBJCOPY := $(CROSS_COMPILE)objcopy
OBJDUMP := $(CROSS_COMPILE)objdump
SIZE := $(CROSS_COMPILE)size
2021-03-12 18:53:53 +01:00
LFLAGS = -mlittle-endian -mthumb -mcpu=cortex-m0 -mthumb-interwork
LFLAGS += -mfloat-abi=soft --disable-newlib-supplied-syscalls -nostartfiles
LFLAGS += -Tstartup/stm32f030.ld -Wl,-Map=$(mapfile).map -Wl,--gc-sections -Wl,--print-memory-usage -g
2021-03-12 18:53:53 +01:00
CFLAGS = -c -fmessage-length=0 -mlittle-endian -mthumb -mcpu=cortex-m0 -mthumb-interwork
CFLAGS += -mfloat-abi=soft -nostartfiles -Wall -g3 -O0
2021-03-12 18:53:53 +01:00
####################################################################################
OBJ = $(CFILES:%.c=$(OBJDIR)/%.c.o)
ASOBJ = $(ASFILES:%.S=$(OBJDIR)/%.S.o)
default: $(target).elf
%.bin: %.elf
$(OBJCOPY) -O binary $^ $@
%.hex: %.elf
$(OBJCOPY) -O ihex $^ $@
#Linking
$(target).elf: $(OBJ) $(ASOBJ)
@echo Linking $@
$(QUIET)$(CC) $(LFLAGS) $(LIBRARYPATH) -o $@ $^ $(LIBRARIES)
$(QUIET)$(SIZE) $@
#Compiling
$(OBJ):
@echo [CC] $@
@mkdir -p $(@D)
2021-03-12 18:53:53 +01:00
$(QUIET)$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ $(@:$(OBJDIR)/%.c.o=%.c)
$(ASOBJ):
@echo [AS] $@
@mkdir -p $(@D)
2021-03-12 18:53:53 +01:00
$(QUIET)$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ $(@:$(OBJDIR)/%.S.o=%.S)
.PHONY: clean mrproper objcopy disassemble binary
2021-03-12 18:53:53 +01:00
disassemble: $(target).elf
$(OBJDUMP) -D -s $< > $(target).lss
objcopy: $(target).bin $(target).hex
mrproper:
rm -f $(target).pro
binary: $(target).bin $(target).hex
2021-03-12 18:53:53 +01:00
clean:
@echo [CLEAN] $(OBJDIR)
@rm -f $(target).elf $(target).bin $(target).hex $(OBJ) $(ASOBJ) $(mapfile).map $(target).lss
@rm -rf $(OBJDIR)/*
2021-03-12 18:53:53 +01:00
-include $(CFILES:%.c=$(OBJDIR)/%.c.d) $(ASFILES:%.S=$(OBJDIR)/%.S.d)