You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
stm8-keypad/Makefile

78 lines
1.9 KiB

2 years ago
#######
# makefile for STM8S_StdPeriph_Lib and SDCC compiler
#
# Customized by MightyPork 1/2017
#
# usage:
# 1. if SDCC not in PATH set path -> CC_ROOT
# 2. set correct STM8 device -> DEVICE
# 3. set project paths -> PRJ_ROOT, PRJ_SRC_DIR, PRJ_INC_DIR
# 4. set SPL root path -> SPL_ROOT
# 5. include required SPL modules -> SPL_SOURCE
#
#######
# STM8 device (default is STM8 discovery board)
DEVICE=STM8S103
DEVICE_FLASH=stm8s103f3
# set compiler path & parameters
CC_ROOT =
CC = sdcc
CFLAGS = -mstm8 -lstm8 --opt-code-size --disable-warning 126 --disable-warning 110
# --opt-code-size
# -DUSE_FULL_ASSERT=1
# required for some examples for STM8S EVAL board
#CFLAGS += -DUSE_STM8_128_EVAL
# set output folder and target name
OUTPUT_DIR = ./Build
TARGET = $(OUTPUT_DIR)/$(DEVICE).hex
# set project folder and files (all *.c)
PRJ_ROOT = .
PRJ_SRC_DIR = $(PRJ_ROOT)/User
PRJ_INC_DIR = $(PRJ_ROOT)/User
# all project sources included by default
PRJ_SOURCE = $(notdir $(wildcard $(PRJ_SRC_DIR)/*.c))
PRJ_OBJECTS := $(addprefix $(OUTPUT_DIR)/, $(PRJ_SOURCE:.c=.rel))
LIB_INC_DIR = /usr/share/sdcc/include/
#SPL_SRC_DIR = Libraries/SPL/src/
SPL_INC_DIR = TinySPL_S103
# add all library sources used here
SPL_SOURCE =
#stm8s_uart1.c stm8s_clk.c stm8s_gpio.c
# SPL_OBJECTS := $(addprefix $(OUTPUT_DIR)/, $(SPL_SOURCE:.c=.rel))
# collect all include folders
INCLUDE = -I$(PRJ_SRC_DIR) -I$(LIB_INC_DIR) -I$(SPL_INC_DIR)
# collect all source directories
VPATH=$(PRJ_SRC_DIR):$(SPL_SRC_DIR)
.PHONY: clean unlock flash all
all: $(TARGET)
$(OUTPUT_DIR)/%.rel: %.c
$(CC) $(CFLAGS) -D$(DEVICE) $(INCLUDE) -c $?
$(OUTPUT_DIR)/%.rel: %.c
$(CC) $(CFLAGS) -D$(DEVICE) $(INCLUDE) -c $? -o $@
#$(SPL_OBJECTS)
$(TARGET): $(PRJ_OBJECTS)
$(CC) $(CFLAGS) -o $(TARGET) $^
flash: $(TARGET)
stm8flash -c stlinkv2 -p $(DEVICE_FLASH) -s flash -w $(TARGET)
unlock:
stm8flash -c stlinkv2 -p stm8s103f3 -u
clean:
rm $(OUTPUT_DIR)/*