Update Makefile

Update makefile to use better syntax.
This commit is contained in:
Mario Hüttel 2022-08-02 14:32:30 +02:00
parent 22be779d75
commit decd6ba84c
1 changed files with 16 additions and 26 deletions

View File

@ -1,5 +1,5 @@
################################Shimatta Makefile####################################
#CPU: STM32F030
#CPU: STM32F030F4P6
#Compiler: arm-none-eabi
#####################################################################################
@ -31,10 +31,11 @@ mapfile = memmap
###################################################################################
CC=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy
OBJDUMP=arm-none-eabi-objdump
SIZE=arm-none-eabi-size
CROSS_COMPILE ?= arm-none-eabi-
CC := $(CROSS_COMPILE)gcc
OBJCOPY := $(CROSS_COMPILE)objcopy
OBJDUMP := $(CROSS_COMPILE)objdump
SIZE := $(CROSS_COMPILE)size
LFLAGS = -mlittle-endian -mthumb -mcpu=cortex-m0 -mthumb-interwork
LFLAGS += -mfloat-abi=soft --disable-newlib-supplied-syscalls -nostartfiles
@ -50,8 +51,6 @@ ASOBJ = $(ASFILES:%.S=$(OBJDIR)/%.S.o)
default: $(target).elf
binary: $(target).bin $(target).hex
%.bin: %.elf
$(OBJCOPY) -O binary $^ $@
%.hex: %.elf
@ -65,18 +64,16 @@ $(target).elf: $(OBJ) $(ASOBJ)
#Compiling
$(OBJ):
@echo Compiling $@
$(eval OUTPATH=$(dir $@))
@mkdir -p $(OUTPATH)
@echo [CC] $@
@mkdir -p $(@D)
$(QUIET)$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ $(@:$(OBJDIR)/%.c.o=%.c)
$(ASOBJ):
@echo Compiling $@
$(eval OUTPATH=$(dir $@))
@mkdir -p $(OUTPATH)
@echo [AS] $@
@mkdir -p $(@D)
$(QUIET)$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ $(@:$(OBJDIR)/%.S.o=%.S)
.PHONY: qtproject clean mrproper objcopy disassemble
.PHONY: clean mrproper objcopy disassemble binary
disassemble: $(target).elf
$(OBJDUMP) -D -s $< > $(target).lss
@ -86,19 +83,12 @@ objcopy: $(target).bin $(target).hex
mrproper:
rm -f $(target).pro
clean:
rm -f $(target).elf $(target).bin $(target).hex $(OBJ) $(ASOBJ) $(mapfile).map $(target).lss
rm -rfv $(OBJDIR)
binary: $(target).bin $(target).hex
qtproject:
echo -e "TEMPLATE = app\nCONFIG -= console app_bundle qt" > $(target).pro
echo -e "SOURCES += $(CFILES) $(ASFILES)" >> $(target).pro
echo -ne "INCLUDEPATH += " >> $(target).pro
echo "$(INCLUDEPATH)" | sed "s!-I!./!g" >> $(target).pro
echo -ne "HEADERS += " >> $(target).pro
find -name "*.h" | tr "\\n" " " >> $(target).pro
echo -ne "\nDEFINES += " >> $(target).pro
echo "$(DEFINES)" | sed "s/-D//g" >> $(target).pro
clean:
@echo [CLEAN] $(OBJDIR)
@rm -f $(target).elf $(target).bin $(target).hex $(OBJ) $(ASOBJ) $(mapfile).map $(target).lss
@rm -rf $(OBJDIR)/*
-include $(CFILES:%.c=$(OBJDIR)/%.c.d) $(ASFILES:%.S=$(OBJDIR)/%.S.d)