From 7553cfa3101ce4d038172ac18916fa4b0f373f11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Tue, 9 Jun 2020 21:50:37 +0200 Subject: [PATCH] Add qtproejct target to Makefile which generates a usable qtcreator project folder --- stm-firmware/Makefile | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/stm-firmware/Makefile b/stm-firmware/Makefile index fc35fde..461f493 100644 --- a/stm-firmware/Makefile +++ b/stm-firmware/Makefile @@ -5,7 +5,7 @@ #Add Files and Folders below######################################################### CFILES = main.c syscalls.c setup/system_stm32f4xx.c systick.c ASFILES = boot/startup_stm32f4xx.S -INCLUDEPATH = -Icmsis -Iinclude +INCLUDEPATH = -Iinclude OBJDIR = obj target = reflow-controller @@ -75,6 +75,8 @@ CFLAGS += -Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitia OBJ = $(CFILES:%.c=$(OBJDIR)/%.c.o) ASOBJ += $(ASFILES:%.S=$(OBJDIR)/%.S.o) +all: default + default: $(target).elf %.bin: %.elf @@ -102,7 +104,7 @@ $(ASOBJ): $(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-device.sh $< @@ -117,8 +119,10 @@ mrproper: clean clean: @echo "Cleaning up derived files..." - $(QUIET)rm -f $(target).elf $(target).bin $(target).hex $(OBJ) $(ASOBJ) $(mapfile).map $(CFILES:%.c=$(OBJDIR)/%.c.d) $(ASFILES:%.S=$(OBJDIR)/%.S.d) -qtproject: + $(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)/* + +qtproject-legacy: echo -e "TEMPLATE = app\nCONFIG -= console app_bundle qt" > $(target).pro echo -e "SOURCES += $(CFILES) $(ASFILES)" >> $(target).pro echo -ne "INCLUDEPATH += " >> $(target).pro @@ -127,5 +131,23 @@ qtproject: find -name "*.h" | tr "\\n" " " >> $(target).pro echo -ne "\nDEFINES += " >> $(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)