From 70730fd0f0ffa7b6d8a8438bce8c40b8343501c6 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 | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/stm-firmware/Makefile b/stm-firmware/Makefile index 4be5345..c66e8c8 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 @@ -68,6 +68,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 @@ -95,7 +97,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 $< @@ -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 -rf $(OBJDIR)/* -qtproject: +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 @@ -122,5 +124,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)