Build System Changes
* Compiler now puts all objects in a separate directory. * Add support for dependency files * Add obj directory to .gitignore
This commit is contained in:
parent
1a3c6e02a8
commit
9c0f97e12d
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
|||||||
*.elf
|
*.elf
|
||||||
*.c.o
|
|
||||||
memmap.map
|
memmap.map
|
||||||
|
obj/
|
||||||
|
36
Makefile
36
Makefile
@ -2,12 +2,20 @@
|
|||||||
#CPU: STM32F030
|
#CPU: STM32F030
|
||||||
#Compiler: arm-none-eabi
|
#Compiler: arm-none-eabi
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
|
|
||||||
|
ifneq ($(VERBOSE),true)
|
||||||
|
QUIET=@
|
||||||
|
else
|
||||||
|
QUIET=
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
#Add Files and Folders below#########################################################
|
#Add Files and Folders below#########################################################
|
||||||
CFILES = main.c syscalls/syscalls.c setup/system_init.c startup/startup_stm32f0xx.c
|
CFILES = main.c syscalls/syscalls.c setup/system_init.c startup/startup_stm32f0xx.c
|
||||||
ASFILES =
|
ASFILES =
|
||||||
INCLUDEPATH = -Iinclude -Iinclude/cmsis
|
INCLUDEPATH = -Iinclude -Iinclude/cmsis
|
||||||
|
|
||||||
|
OBJDIR=obj
|
||||||
target = project
|
target = project
|
||||||
LIBRARYPATH = -Lstartup
|
LIBRARYPATH = -Lstartup
|
||||||
LIBRARIES =
|
LIBRARIES =
|
||||||
@ -35,8 +43,8 @@ CFLAGS += -mfloat-abi=soft -nostartfiles -Wall -g
|
|||||||
|
|
||||||
####################################################################################
|
####################################################################################
|
||||||
|
|
||||||
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
|
default: $(target).elf
|
||||||
|
|
||||||
@ -49,15 +57,22 @@ binary: $(target).bin $(target).hex
|
|||||||
|
|
||||||
#Linking
|
#Linking
|
||||||
$(target).elf: $(OBJ) $(ASOBJ)
|
$(target).elf: $(OBJ) $(ASOBJ)
|
||||||
$(CC) $(LFLAGS) $(LIBRARYPATH) -o $@ $^ $(LIBRARIES)
|
@echo Linking $@
|
||||||
$(SIZE) $@
|
$(QUIET)$(CC) $(LFLAGS) $(LIBRARYPATH) -o $@ $^ $(LIBRARIES)
|
||||||
|
$(QUIET)$(SIZE) $@
|
||||||
|
|
||||||
#Compiling
|
#Compiling
|
||||||
%.c.o: %.c
|
$(OBJ):
|
||||||
$(CC) $(CFLAGS) $(INCLUDEPATH) $(DEFINES) -o $@ $<
|
@echo Compiling $@
|
||||||
|
$(eval OUTPATH=$(dir $@))
|
||||||
|
@mkdir -p $(OUTPATH)
|
||||||
|
$(QUIET)$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ $(@:$(OBJDIR)/%.c.o=%.c)
|
||||||
|
|
||||||
%.S.o: %.S
|
$(ASOBJ):
|
||||||
$(CC) $(CFLAGS) $(INCLUDEPATH) $(DEFINES) -o $@ $<
|
@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
|
.PHONY: qtproject clean mrproper objcopy disassemble
|
||||||
|
|
||||||
@ -71,6 +86,8 @@ mrproper:
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(target).elf $(target).bin $(target).hex $(OBJ) $(ASOBJ) $(mapfile).map $(target).lss
|
rm -f $(target).elf $(target).bin $(target).hex $(OBJ) $(ASOBJ) $(mapfile).map $(target).lss
|
||||||
|
rm -rfv $(OBJDIR)
|
||||||
|
|
||||||
qtproject:
|
qtproject:
|
||||||
echo -e "TEMPLATE = app\nCONFIG -= console app_bundle qt" > $(target).pro
|
echo -e "TEMPLATE = app\nCONFIG -= console app_bundle qt" > $(target).pro
|
||||||
echo -e "SOURCES += $(CFILES) $(ASFILES)" >> $(target).pro
|
echo -e "SOURCES += $(CFILES) $(ASFILES)" >> $(target).pro
|
||||||
@ -81,4 +98,5 @@ qtproject:
|
|||||||
echo -ne "\nDEFINES += " >> $(target).pro
|
echo -ne "\nDEFINES += " >> $(target).pro
|
||||||
echo "$(DEFINES)" | sed "s/-D//g" >> $(target).pro
|
echo "$(DEFINES)" | sed "s/-D//g" >> $(target).pro
|
||||||
|
|
||||||
|
-include $(CFILES:%.c=$(OBJDIR)/%.c.d) $(ASFILES:%.S=($OBJDIR)/%.S.d)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user