103 lines
2.8 KiB
Makefile
103 lines
2.8 KiB
Makefile
################################Shimatta Makefile####################################
|
|
#CPU: STM32L052
|
|
#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_stm32l052x8xx.c usb.c unique-id.c eeprom.c
|
|
ASFILES =
|
|
INCLUDEPATH = -Iinclude -Iinclude/cmsis
|
|
|
|
OBJDIR=obj
|
|
target = project
|
|
LIBRARYPATH = -Lstartup
|
|
LIBRARIES =
|
|
|
|
DEFINES = -DSTM32L052xx -DSTM32L0
|
|
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-m0plus -mthumb-interwork
|
|
LFLAGS += -mfloat-abi=soft --disable-newlib-supplied-syscalls -nostartfiles
|
|
LFLAGS += -Tstartup/stm32l052x8xx.ld -Wl,-Map=$(mapfile).map -Wl,--gc-sections -g -Wl,--print-memory-usage
|
|
|
|
CFLAGS = -c -fmessage-length=0 -mlittle-endian -mthumb -mcpu=cortex-m0plus -mthumb-interwork
|
|
CFLAGS += -mfloat-abi=soft -nostartfiles -Wall -g -O0
|
|
|
|
####################################################################################
|
|
|
|
OBJ = $(CFILES:%.c=$(OBJDIR)/%.c.o)
|
|
ASOBJ = $(ASFILES:%.S=$(OBJDIR)/%.S.o)
|
|
|
|
default: $(target).elf
|
|
|
|
binary: $(target).bin $(target).hex
|
|
|
|
%.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 Compiling $@
|
|
$(eval OUTPATH=$(dir $@))
|
|
@mkdir -p $(OUTPATH)
|
|
$(QUIET)$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ $(@:$(OBJDIR)/%.c.o=%.c)
|
|
|
|
$(ASOBJ):
|
|
@echo Compiling $@
|
|
$(eval OUTPATH=$(dir $@))
|
|
@mkdir -p $(OUTPATH)
|
|
$(QUIET)$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ $(@:$(OBJDIR)/%.S.o=%.S)
|
|
|
|
.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
|
|
rm -rfv $(OBJDIR)
|
|
|
|
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
|
|
|
|
-include $(CFILES:%.c=$(OBJDIR)/%.c.d) $(ASFILES:%.S=$(OBJDIR)/%.S.d)
|
|
|