stm32f746zg-template/Makefile

87 lines
2.4 KiB
Makefile

################################Shimatta Makefile####################################
#CPU: STM32F746ZGT
#Compiler: arm-none-eabi
#####################################################################################
#Add Files and Folders below#########################################################
CFILES = main.c syscalls/syscalls.c setup/system_init.c startup/startup_stm32f746.c
ASFILES =
INCLUDEPATH = -Iinclude
target = project
LIBRARYPATH = -Lstartup -Ldsp
LIBRARIES = -larm_cortexM7lfsp_math
DEFINES = -DSTM32F746xx -DSTM32F7XX -DARM_MATH_CM7
mapfile = memmap
##Custom Files###
#TODO
###################################################################################
CC=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy
OBJDUMP=arm-none-eabi-objdump
SIZE=arm-none-eabi-size
LFLAGS = -mlittle-endian -mthumb -mcpu=cortex-m7 -mthumb-interwork
LFLAGS += -mfloat-abi=hard -mfpu=fpv5-sp-d16 --disable-newlib-supplied-syscalls -nostartfiles
LFLAGS += -Tstm32f746zgt-axim.ld -Wl,-Map=$(mapfile).map -Wl,--gc-sections
CFLAGS = -c -fmessage-length=0 -mlittle-endian -mthumb -mcpu=cortex-m7 -mthumb-interwork
CFLAGS += -mfloat-abi=hard -mfpu=fpv5-sp-d16 -nostartfiles -Wall
####################################################################################
OBJ = $(CFILES:%.c=%.c.o)
ASOBJ = $(ASFILES:%.S=%.S.o)
default: $(target).elf
%.bin: %.elf
$(OBJCOPY) -O binary $^ $@
%.hex: %.elf
$(OBJCOPY) -O ihex $^ $@
#Linking
$(target).elf: $(OBJ) $(ASOBJ)
$(CC) $(LFLAGS) $(LIBRARYPATH) -o $@ $^ $(LIBRARIES)
$(SIZE) $@
#Compiling
%.c.o: %.c
$(CC) $(CFLAGS) $(INCLUDEPATH) $(DEFINES) -o $@ $<
%.S.o: %.S
$(CC) $(CFLAGS) $(INCLUDEPATH) $(DEFINES) -o $@ $<
.PHONY: qtproject clean mrproper objcopy disassemble
disassemble: $(target).elf
$(OBJDUMP) -D -s $< > $(target).lss
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
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