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
|
||||
*.c.o
|
||||
memmap.map
|
||||
obj/
|
||||
|
36
Makefile
36
Makefile
@ -2,12 +2,20 @@
|
||||
#CPU: STM32F030
|
||||
#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_stm32f0xx.c
|
||||
ASFILES =
|
||||
INCLUDEPATH = -Iinclude -Iinclude/cmsis
|
||||
|
||||
|
||||
OBJDIR=obj
|
||||
target = project
|
||||
LIBRARYPATH = -Lstartup
|
||||
LIBRARIES =
|
||||
@ -35,8 +43,8 @@ CFLAGS += -mfloat-abi=soft -nostartfiles -Wall -g
|
||||
|
||||
####################################################################################
|
||||
|
||||
OBJ = $(CFILES:%.c=%.c.o)
|
||||
ASOBJ = $(ASFILES:%.S=%.S.o)
|
||||
OBJ = $(CFILES:%.c=$(OBJDIR)/%.c.o)
|
||||
ASOBJ = $(ASFILES:%.S=$(OBJDIR)/%.S.o)
|
||||
|
||||
default: $(target).elf
|
||||
|
||||
@ -49,15 +57,22 @@ binary: $(target).bin $(target).hex
|
||||
|
||||
#Linking
|
||||
$(target).elf: $(OBJ) $(ASOBJ)
|
||||
$(CC) $(LFLAGS) $(LIBRARYPATH) -o $@ $^ $(LIBRARIES)
|
||||
$(SIZE) $@
|
||||
@echo Linking $@
|
||||
$(QUIET)$(CC) $(LFLAGS) $(LIBRARYPATH) -o $@ $^ $(LIBRARIES)
|
||||
$(QUIET)$(SIZE) $@
|
||||
|
||||
#Compiling
|
||||
%.c.o: %.c
|
||||
$(CC) $(CFLAGS) $(INCLUDEPATH) $(DEFINES) -o $@ $<
|
||||
$(OBJ):
|
||||
@echo Compiling $@
|
||||
$(eval OUTPATH=$(dir $@))
|
||||
@mkdir -p $(OUTPATH)
|
||||
$(QUIET)$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ $(@:$(OBJDIR)/%.c.o=%.c)
|
||||
|
||||
%.S.o: %.S
|
||||
$(CC) $(CFLAGS) $(INCLUDEPATH) $(DEFINES) -o $@ $<
|
||||
$(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
|
||||
|
||||
@ -71,6 +86,8 @@ mrproper:
|
||||
|
||||
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
|
||||
@ -81,4 +98,5 @@ qtproject:
|
||||
echo -ne "\nDEFINES += " >> $(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