Update makefile to use dependenccy files and create obj folder
This commit is contained in:
parent
3861b82515
commit
6d3afeb075
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
project.elf
|
project.elf
|
||||||
|
*.lss
|
||||||
*.o
|
*.o
|
||||||
*.map
|
*.map
|
||||||
*.bin
|
*.bin
|
||||||
@ -6,3 +7,4 @@ project.elf
|
|||||||
*.user
|
*.user
|
||||||
*.user*
|
*.user*
|
||||||
*.user.*
|
*.user.*
|
||||||
|
obj/*
|
||||||
|
59
Makefile
59
Makefile
@ -7,8 +7,9 @@ CFILES = main.c syscalls/syscalls.c setup/system_init.c startup/startup_stm32f7
|
|||||||
ASFILES =
|
ASFILES =
|
||||||
INCLUDEPATH = -Iinclude
|
INCLUDEPATH = -Iinclude
|
||||||
|
|
||||||
|
OBJDIR := obj
|
||||||
|
|
||||||
target = project
|
TARGET = project
|
||||||
LIBRARYPATH = -Lstartup -Ldsp
|
LIBRARYPATH = -Lstartup -Ldsp
|
||||||
LIBRARIES = -larm_cortexM7lfsp_math
|
LIBRARIES = -larm_cortexM7lfsp_math
|
||||||
|
|
||||||
@ -29,19 +30,19 @@ SIZE=arm-none-eabi-size
|
|||||||
LFLAGS = -mlittle-endian -mthumb -mcpu=cortex-m7 -mthumb-interwork
|
LFLAGS = -mlittle-endian -mthumb -mcpu=cortex-m7 -mthumb-interwork
|
||||||
LFLAGS += -mfloat-abi=hard -mfpu=fpv5-sp-d16 --disable-newlib-supplied-syscalls -nostartfiles
|
LFLAGS += -mfloat-abi=hard -mfpu=fpv5-sp-d16 --disable-newlib-supplied-syscalls -nostartfiles
|
||||||
LFLAGS += -Tstm32f746zgt-axim.ld -Wl,-Map=$(mapfile).map -Wl,--gc-sections
|
LFLAGS += -Tstm32f746zgt-axim.ld -Wl,-Map=$(mapfile).map -Wl,--gc-sections
|
||||||
|
LFLAGS += -Wl,--print-memory-usage
|
||||||
|
|
||||||
CFLAGS = -c -fmessage-length=0 -mlittle-endian -mthumb -mcpu=cortex-m7 -mthumb-interwork
|
CFLAGS = -fmessage-length=0 -mlittle-endian -mthumb -mcpu=cortex-m7 -mthumb-interwork
|
||||||
CFLAGS += -mfloat-abi=hard -mfpu=fpv5-sp-d16 -nostartfiles -Wall
|
CFLAGS += -mfloat-abi=hard -mfpu=fpv5-sp-d16 -nostartfiles -Wall
|
||||||
|
|
||||||
####################################################################################
|
####################################################################################
|
||||||
|
|
||||||
OBJ = $(CFILES:%.c=%.c.o)
|
OBJ = $(CFILES:%.c=$(OBJDIR)/%.c.o)
|
||||||
ASOBJ = $(ASFILES:%.S=%.S.o)
|
ASOBJ = $(ASFILES:%.S=$(OBJDIR)/%.S.o)
|
||||||
|
|
||||||
default: $(target).elf
|
|
||||||
|
|
||||||
|
|
||||||
|
DEPENDENCY_FILES = $(CFILES:%.c=$(OBJDIR)/%.c.d) $(ASFILES:%.S=$(OBJDIR)/%.S.d)
|
||||||
|
|
||||||
|
default: $(TARGET).elf
|
||||||
|
|
||||||
%.bin: %.elf
|
%.bin: %.elf
|
||||||
$(OBJCOPY) -O binary $^ $@
|
$(OBJCOPY) -O binary $^ $@
|
||||||
@ -50,37 +51,35 @@ default: $(target).elf
|
|||||||
|
|
||||||
|
|
||||||
#Linking
|
#Linking
|
||||||
$(target).elf: $(OBJ) $(ASOBJ)
|
$(TARGET).elf: $(OBJ) $(ASOBJ)
|
||||||
$(CC) $(LFLAGS) $(LIBRARYPATH) -o $@ $^ $(LIBRARIES)
|
@$(CC) $(LFLAGS) $(LIBRARYPATH) -o $@ $^ $(LIBRARIES)
|
||||||
$(SIZE) $@
|
@$(SIZE) $@
|
||||||
|
|
||||||
#Compiling
|
#Compiling
|
||||||
%.c.o: %.c
|
$(OBJ):
|
||||||
$(CC) $(CFLAGS) $(INCLUDEPATH) $(DEFINES) -o $@ $<
|
@echo [CC] $@
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ -c $(@:$(OBJDIR)/%.c.o=%.c)
|
||||||
|
|
||||||
%.S.o: %.S
|
$(ASOBJ):
|
||||||
$(CC) $(CFLAGS) $(INCLUDEPATH) $(DEFINES) -o $@ $<
|
@echo [AS] $@
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ -c $(@:$(OBJDIR)/%.S.o=%.S)
|
||||||
|
|
||||||
.PHONY: qtproject clean mrproper objcopy disassemble
|
.PHONY: clean mrproper objcopy disassemble
|
||||||
|
|
||||||
disassemble: $(target).elf
|
disassemble: $(TARGET).elf
|
||||||
$(OBJDUMP) -D -s $< > $(target).lss
|
$(OBJDUMP) -D -s $< > $(TARGET).lss
|
||||||
|
|
||||||
objcopy: $(target).bin $(target).hex
|
objcopy: $(TARGET).bin $(TARGET).hex
|
||||||
|
|
||||||
mrproper:
|
mrproper:
|
||||||
rm -f $(target).pro
|
rm -f $(TARGET).pro
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(target).elf $(target).bin $(target).hex $(OBJ) $(ASOBJ) $(mapfile).map $(target).lss
|
@echo [RM] in $(OBJDIR)
|
||||||
qtproject:
|
@rm -f $(TARGET).elf $(TARGET).bin $(TARGET).hex $(OBJ) $(ASOBJ) $(mapfile).map $(TARGET).lss $(DEPENDENCY_FILES)
|
||||||
echo -e "TEMPLATE = app\nCONFIG -= console app_bundle qt" > $(target).pro
|
@rm -rf $(OBJDIR)/*
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
|
# Include dependency files, if available
|
||||||
|
-include $(DEPENDENCY_FILES)
|
||||||
|
Loading…
Reference in New Issue
Block a user