Add qtproejct target to Makefile which generates a usable qtcreator project folder

This commit is contained in:
Mario Hüttel 2020-06-09 21:50:37 +02:00
parent e97092042b
commit 5fc4220ecf

View File

@ -5,7 +5,7 @@
#Add Files and Folders below######################################################### #Add Files and Folders below#########################################################
CFILES = main.c syscalls.c setup/system_stm32f4xx.c systick.c CFILES = main.c syscalls.c setup/system_stm32f4xx.c systick.c
ASFILES = boot/startup_stm32f4xx.S ASFILES = boot/startup_stm32f4xx.S
INCLUDEPATH = -Icmsis -Iinclude INCLUDEPATH = -Iinclude
OBJDIR = obj OBJDIR = obj
target = reflow-controller target = reflow-controller
@ -68,6 +68,8 @@ CFLAGS += -Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitia
OBJ = $(CFILES:%.c=$(OBJDIR)/%.c.o) OBJ = $(CFILES:%.c=$(OBJDIR)/%.c.o)
ASOBJ += $(ASFILES:%.S=$(OBJDIR)/%.S.o) ASOBJ += $(ASFILES:%.S=$(OBJDIR)/%.S.o)
all: default
default: $(target).elf default: $(target).elf
%.bin: %.elf %.bin: %.elf
@ -95,7 +97,7 @@ $(ASOBJ):
$(QUIET)$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ $(@:$(OBJDIR)/%.S.o=%.S) $(QUIET)$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ $(@:$(OBJDIR)/%.S.o=%.S)
.PHONY: qtproject clean mrproper objcopy disassemble program .PHONY: qtproject-legacy qtproject clean mrproper objcopy disassemble program
program: $(target).elf program: $(target).elf
./program-device.sh $< ./program-device.sh $<
@ -113,7 +115,7 @@ clean:
$(QUIET)rm -f $(target).elf $(target).bin $(target).hex $(OBJ) $(ASOBJ) $(mapfile).map $(CFILES:%.c=$(OBJDIR)/%.c.d) $(ASFILES:%.S=$(OBJDIR)/%.S.d) $(QUIET)rm -f $(target).elf $(target).bin $(target).hex $(OBJ) $(ASOBJ) $(mapfile).map $(CFILES:%.c=$(OBJDIR)/%.c.d) $(ASFILES:%.S=$(OBJDIR)/%.S.d)
$(QUIET)rm -rf $(OBJDIR)/* $(QUIET)rm -rf $(OBJDIR)/*
qtproject: qtproject-legacy:
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
echo -ne "INCLUDEPATH += " >> $(target).pro echo -ne "INCLUDEPATH += " >> $(target).pro
@ -123,4 +125,22 @@ 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
qtproject:
$(QUIET)rm -f $(target).files $(target).cflags $(target).config $(target).creator $(target).includes $(target).creator.user
echo "Generating source file list"
$(QUIET)echo "$(CFILES)" | tr ' ' '\n' > $(target).files
@echo -n "Appending found header files from folders "
@echo `echo $(INCLUDEPATH) | sed "s/-I//g"`
$(QUIET)for dir in `echo $(INCLUDEPATH) | sed "s/-I//g"`; do \
find `echo "$${dir}"` -name "*.h" >> $(target).files; \
done
@echo "Generating CFLAGS File"
$(QUIET)echo "" > $(target).cflags
@echo "Generating includes files"
$(QUIET)echo $(INCLUDEPATH) | sed "s/-I/,/g" | tr , '\n' | sed "/^$$/d" > $(target).includes;
@echo "Generating config file"
$(QUIET)echo $(DEFINES) | sed "s/-D/,#define /g" | tr , '\n' | sed "/^$$/d" > $(target).config
@echo "Generating creator file"
$(QUIET)echo "[GENERAL]" > $(target).creator
-include $(CFILES:%.c=$(OBJDIR)/%.c.d) $(ASFILES:%.S=$(OBJDIR)/%.S.d) -include $(CFILES:%.c=$(OBJDIR)/%.c.d) $(ASFILES:%.S=$(OBJDIR)/%.S.d)