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

View File

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