From a3a118029b2e2457fff691fca4abdaa9a6e77f0a Mon Sep 17 00:00:00 2001 From: heck Date: Tue, 5 Sep 2023 13:54:33 +0200 Subject: [PATCH] makefile for cmsis --- libs/cmsis/Makefile | 33 +++++++++++++++++++++++++++++++++ src/Makefile | 12 ++---------- 2 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 libs/cmsis/Makefile diff --git a/libs/cmsis/Makefile b/libs/cmsis/Makefile new file mode 100644 index 0000000..68da9e7 --- /dev/null +++ b/libs/cmsis/Makefile @@ -0,0 +1,33 @@ +include ../../Makefile.conf + +TARGET=libcmsis.a + +# Includes +CFLAGS+= -I. +CFLAGS+= -I../hal + +C_SRC=$(wildcard *.c) +C_OBJ=$(subst .c,.o,$(C_SRC)) + +ASM_SRC=$(wildcard *.s) +ASM_OBJ=$(subst .s,.s.o,$(ASM_SRC)) +ASMFLAGS=-x assembler-with-cpp + +OBJ=$(C_OBJ) $(ASM_OBJ) + +.PHONY: all clean + +all: $(TARGET) + +$(TARGET): $(OBJ) + $(AR) -cr $@ $^ + +%.o: %.c + $(CC) $(CFLAGS) -o $@ -c $^ + +%.s.o: %.s + $(CC) $(CFLAGS) $(ASMFLAGS) -o $@ -c $^ + +clean: + mv $(OBJ) /tmp/ + mv $(TARGET) /tmp/ diff --git a/src/Makefile b/src/Makefile index 49ec6ec..53c0619 100644 --- a/src/Makefile +++ b/src/Makefile @@ -14,10 +14,10 @@ CFLAGS+=$(INC) CXXFLAGS+=$(INC) # lib objects +LIB_OBJ+=$(wildcard ../libs/cmsis/*.o) LIB_OBJ+=$(wildcard ../libs/hal/*.o) LIB_OBJ+=$(wildcard ../libs/st_usb/*.o) - C_SRC=$(wildcard *.c) C_OBJ=$(subst .c,.o,$(C_SRC)) DEPENDS+=$(subst .c,.d,$(C_SRC)) @@ -26,15 +26,10 @@ CXX_SRC=$(wildcard *.cc) CXX_OBJ=$(subst .cc,.o,$(CXX_SRC)) DEPENDS+=$(subst .cc,.d,$(CXX_SRC)) -ASM_SRC=$(wildcard *.s) -ASM_OBJ=$(subst .s,.os,$(ASM_SRC)) -ASMFLAGS=-x assembler-with-cpp - LDFLAGS+= -Wl,-gc-sections,--print-memory-usage,-Map=$(TARGET).map LDFLAGS+= -T STM32F407VGTX_FLASH.ld -OBJ=$(ASM_OBJ) $(C_OBJ) $(CXX_OBJ) - +OBJ=$(C_OBJ) $(CXX_OBJ) .PHONY: all clean @@ -49,9 +44,6 @@ $(TARGET_HEX): $(TARGET_ELF) $(TARGET_ELF): $(OBJ) $(LD) $(CXXFLAGS) $(LDFLAGS) $(OBJ) $(LIB_OBJ) -o $(TARGET_ELF) -%.os: %.s - $(CC) $(CFLAGS) $(ASMFLAGS) -o $@ -c $^ - clean: mv $(OBJ) /tmp/ mv $(TARGET_ELF) /tmp/