Fixed Makefile

* CFLAGS where not used for main programm
This commit is contained in:
Steins7 2020-01-23 17:56:34 +01:00
parent 7730b983e3
commit d644e4d52e

View File

@ -12,6 +12,7 @@ EXE_PREFIX=main
# project folders, This Makefile should be in the same folder as the SRC folder # project folders, This Makefile should be in the same folder as the SRC folder
SRC=src SRC=src
BIN=bin BIN=bin
INC=include
LIB=lib LIB=lib
OBJ=${BIN}/obj OBJ=${BIN}/obj
DEP=${BIN}/dep DEP=${BIN}/dep
@ -25,10 +26,6 @@ LDSCRIPT=${SRC}/target/STM32F103XB.ld
UDEFS= UDEFS=
# Define ASM defines here # Define ASM defines here
UADEFS= UADEFS=
# List all user directories here
UINCDIR=.
# List the user directory to look for the libraries here
ULIBDIR=
# --- toolchain configuration # --- toolchain configuration
TARGET=arm-none-eabi- TARGET=arm-none-eabi-
@ -40,10 +37,10 @@ OBJDUMP=$(TARGET)objdump
# --- hardware settings # --- hardware settings
ARCH=armv7-m ARCH=armv7-m
FLOAT-ABI=soft FLOAT-ABI=soft #no FPU on stm32f103
CPU=cortex-m3 CPU=cortex-m3
CPUFLAGS=-mthumb CPUFLAGS=-mthumb
FPU=fpv4-sp-d16 FPU=fpv4-sp-d16 #"FLOAT-ABI=soft" disable that
##----------------------------------------------------------------------------- ##-----------------------------------------------------------------------------
# --- makefile pre-incantation # --- makefile pre-incantation
@ -52,12 +49,6 @@ FPU=fpv4-sp-d16
DDEFS=-march=$(ARCH) -mfloat-abi=$(FLOAT-ABI) -mcpu=$(CPU) -mfpu=$(FPU) $(CPUFLAGS) DDEFS=-march=$(ARCH) -mfloat-abi=$(FLOAT-ABI) -mcpu=$(CPU) -mfpu=$(FPU) $(CPUFLAGS)
# List all default ASM defines here, like -D_DEBUG=1 # List all default ASM defines here, like -D_DEBUG=1
DADEFS=-D__ASSEMBLY__ DADEFS=-D__ASSEMBLY__
# List all default directories to look for include files here
DINCDIR=
# List the default directory to look for the libraries here
DLIBDIR=
# List all default libraries here
DLIBS=
# --- deduce file names # --- deduce file names
MAIN_C_FILES=${wildcard ${SRC}/${strip ${EXE_PREFIX}}*.c} MAIN_C_FILES=${wildcard ${SRC}/${strip ${EXE_PREFIX}}*.c}
@ -78,7 +69,6 @@ LIBRARIES=${foreach dir,${wildcard ${LIB}/*},${wildcard ${LIB}/${dir}/*.a}}
DEFS =$(DDEFS) $(UDEFS) DEFS =$(DDEFS) $(UDEFS)
ADEFS =$(DADEFS) $(UADEFS) ADEFS =$(DADEFS) $(UADEFS)
ASFLAGS=$(INCDIR) $(DEFS) -Wa,--gdwarf2 $(ADEFS)
ifeq (${strip ${RELEASE}},0) ifeq (${strip ${RELEASE}},0)
CFLAGS=-g3 -O0 CFLAGS=-g3 -O0
@ -86,10 +76,10 @@ else
CFLAGS=-O3 CFLAGS=-O3
endif endif
ASFLAGS = $(INCDIR) $(DEFS) -Wa,--gdwarf2 $(ADEFS) ASFLAGS = $(LIB) $(DEFS) -Wa,--gdwarf2 $(ADEFS)
CFLAGS+=-std=c17 -Wall $(DEFS) -Wextra -Warray-bounds -Wno-unused-parameter -fomit-frame-pointer CFLAGS+=-std=c17 -Wall $(DEFS) -Wextra -Warray-bounds -Wno-unused-parameter -fomit-frame-pointer
LDFLAGS= -T$(LDSCRIPT) -lc -lgcc -lgcov -lm -Wl,-Map=$@.map,--gc-sections --specs=nosys.specs LDFLAGS= -T$(LDSCRIPT) -lc -lgcc -lgcov -lm -Wl,-Map=$@.map,--gc-sections --specs=nosys.specs
INC=-I${LIB} INCLUDE=-I${INC}
# --- Generate dependency information # --- Generate dependency information
#CFLAGS += -MD -MP -MF ${DEP}/$(@F0).d #CFLAGS += -MD -MP -MF ${DEP}/$(@F0).d
@ -114,9 +104,11 @@ ${BIN}/%.elf : ${MAIN_OBJECT_FILES} ${COMMON_OBJECT_FILES}
@echo @echo
@echo ==== linking $@ ==== @echo ==== linking $@ ====
@echo ${COMMON_OBJECT_FILES} @echo ${COMMON_OBJECT_FILES}
@echo ====================
@echo ${LIBRARIES}
@echo @echo
${DIR_GUARD} ${DIR_GUARD}
${CC} --verbose -o $@ ${filter-out %ld, $^} ${LIBRARIES} ${LDFLAGS} ${CC} ${CFLAGS} --verbose -o $@ ${filter-out %ld, $^} ${LIBRARIES} ${LDFLAGS}
${OBJDUMP} -h $@ ${OBJDUMP} -h $@
${SIZE} $@ ${SIZE} $@
@${SKIP_LINE} @${SKIP_LINE}
@ -138,7 +130,7 @@ ${OBJ}/%.o : ${SRC}/%.c
@echo ==== compiling [opt=${opt}] $< ==== @echo ==== compiling [opt=${opt}] $< ====
@echo @echo
${DIR_GUARD} ${DIR_GUARD}
${CC} ${INC} -c ${CFLAGS} $< -o $@ ${LIBRARIES} ${CC} ${INCLUDE} -c ${CFLAGS} $< -o $@ ${LIBRARIES}
@${SKIP_LINE} @${SKIP_LINE}
${BIN}/%.o : ${SRC}/%.c ${BIN}/%.o : ${SRC}/%.c
@ -146,7 +138,7 @@ ${BIN}/%.o : ${SRC}/%.c
@echo ==== compiling [opt=${opt}] $< ==== @echo ==== compiling [opt=${opt}] $< ====
@echo @echo
${DIR_GUARD} ${DIR_GUARD}
${CC} ${INC} -c ${CFLAGS} $< -o $@ ${LIBRARIES} ${CC} ${INCLUDE} -c ${CFLAGS} $< -o $@ ${LIBRARIES}
@${SKIP_LINE} @${SKIP_LINE}
${OBJ}/%.o : ${SRC}/%.s ${OBJ}/%.o : ${SRC}/%.s