1
0
mirror of https://github.com/rene-dev/stmbl.git synced 2024-12-20 23:52:15 +00:00
stmbl/stm32f103/Makefile

160 lines
3.9 KiB
Makefile
Raw Permalink Normal View History

2016-01-09 16:09:19 +00:00
# Optimization level, can be [0, 1, 2, 3, s].
2015-12-30 07:14:51 +00:00
# 0 = turn off optimization. s = optimize for size.
2016-01-09 16:09:19 +00:00
#
2015-12-30 07:14:51 +00:00
OPT = -O1 -flto
# OPT = -O1 # for debugging
# Object files directory
# Warning: this will be removed by make clean!
#
2018-04-09 11:33:41 +00:00
OBJDIR = obj_f1
2015-12-30 07:14:51 +00:00
# Target file name (without extension)
TARGET = $(OBJDIR)/hv
# Define all C source files (dependencies are generated automatically)
INCDIRS += stm32f103/inc
INCDIRS += shared
SOURCES += stm32f103/src/main.c
2016-09-15 06:58:25 +00:00
SOURCES += stm32f103/src/version.c
2017-10-30 02:26:47 +00:00
SOURCES += shared/common_f1.c
2015-12-30 07:14:51 +00:00
# Standard peripheral library
CPPFLAGS += -DUSE_STDPERIPH_DRIVER
#CPPFLAGS += -DUSE_FULL_ASSERT
2016-01-09 16:09:19 +00:00
PERIPH_DRV_DIR = lib/STM32F10x_StdPeriph_Driver-V3.6.1
INCDIRS += $(PERIPH_DRV_DIR)/inc
2016-01-02 22:56:13 +00:00
INCDIRS += lib/CMSIS/Include
INCDIRS += lib/CMSIS/Device/ST/STM32F10x/Include
2016-01-09 16:09:19 +00:00
SOURCES += $(PERIPH_DRV_DIR)/src/misc.c
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f10x_rcc.c
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f10x_adc.c
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f10x_dma.c
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f10x_gpio.c
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f10x_tim.c
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f10x_flash.c
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f10x_usart.c
SOURCES += lib/CMSIS/Device/ST/STM32F10x/Source/system_stm32f10x.c
SOURCES += lib/CMSIS/Device/ST/STM32F10x/Source/startup_stm32f10x_ld.s
2015-12-30 07:14:51 +00:00
CPPFLAGS += -DSTM32F10X_LD
CPPFLAGS += -DHSE_VALUE=8000000
2015-12-30 07:14:51 +00:00
LDSCRIPT = stm32f103/stm32_flash.ld
#============================================================================
OBJECTS += $(addprefix $(OBJDIR)/,$(addsuffix .o,$(basename $(SOURCES))))
CPPFLAGS += $(addprefix -I,$(INCDIRS))
#---------------- Preprocessor Options ----------------
# -fsingle... make better use of the single-precision FPU
# -g generate debugging information
# -save-temps preserve .s and .i-files
#
CPPFLAGS += -fsingle-precision-constant
CPPFLAGS += -g
# CPPFLAGS += -save-temps=obj
#---------------- C Compiler Options ----------------
# -O* optimization level
# -f... tuning, see GCC documentation
# -Wall... warning level
#
CFLAGS += $(OPT)
CFLAGS += -std=gnu11
CFLAGS += -ffunction-sections
CFLAGS += -fdata-sections
CFLAGS += -Wall
CFLAGS += -fno-builtin ## from old
2016-02-15 14:28:30 +00:00
CFLAGS += -Wfatal-errors
2015-12-30 07:14:51 +00:00
CFLAGS += -nostartfiles
#CFLAGS += -Wstrict-prototypes
#CFLAGS += -Wextra
#CFLAGS += -Wpointer-arith
#CFLAGS += -Winline
#CFLAGS += -Wunreachable-code
#CFLAGS += -Wundef
# Use a friendly C dialect
CPPFLAGS += -fno-strict-aliasing
CPPFLAGS += -fwrapv
#---------------- C++ Compiler Options ----------------
#
CXXFLAGS += $(OPT)
CXXFLAGS += -ffunction-sections
CXXFLAGS += -fdata-sections
CXXFLAGS += -Wall
#---------------- Assembler Options ----------------
# -Wa,... tell GCC to pass this to the assembler
#
#---------------- Linker Options ----------------
# -Wl,... tell GCC to pass this to linker
# -Map create map file
# --cref add cross reference to map file
#
LDFLAGS += $(OPT)
LDFLAGS += -lm
LDFLAGS += -Wl,-Map=$(TARGET).map,--cref
LDFLAGS += -Wl,--gc-sections
# LDFLAGS += -specs=nano.specs -u _printf_float -u _scanf_float
LDFLAGS += -T$(LDSCRIPT)
#============================================================================
2016-09-15 06:58:25 +00:00
POSTLD = tools/add_version_info.py # -q
2015-12-30 07:14:51 +00:00
# Compiler flags to generate dependency files
#
GENDEPFLAGS = -MMD -MP
# Combine all necessary flags and optional flags
# Add target processor to flags.
#
2015-12-28 11:52:31 +00:00
CPU = -mthumb -mcpu=cortex-m3
2015-12-30 07:14:51 +00:00
CFLAGS += $(CPU)
CXXFLAGS += $(CPU)
ASFLAGS += $(CPU)
LDFLAGS += $(CPU)
2015-12-28 11:52:31 +00:00
2015-12-30 07:14:51 +00:00
# Default target
#
all: gccversion build showsize
2015-12-28 11:52:31 +00:00
build: elf hex bin lss sym hv_firmware.o
2015-12-28 11:52:31 +00:00
2015-12-30 07:14:51 +00:00
elf: $(TARGET).elf
hex: $(TARGET).hex
bin: $(TARGET).bin
lss: $(TARGET).lss
sym: $(TARGET).sym
# Target: clean project
#
clean:
@echo Cleaning project:
rm -rf $(OBJDIR)
2015-12-30 07:14:51 +00:00
# Include the base rules
#
include base.mak
include toolchain.mak
2015-12-30 07:14:51 +00:00
# Include the dependency files
#
-include $(OBJECTS:.o=.d)
# Listing of phony targets
#
.PHONY: all build flash clean \
elf lss sym \
showsize gccversion