Inlined STM8S SPL (STM8S103) for use with SDCC

Makefile 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #######
  2. # makefile for STM8S_StdPeriph_Lib and SDCC compiler
  3. #
  4. # Customized by MightyPork 1/2017
  5. #
  6. # usage:
  7. # 1. if SDCC not in PATH set path -> CC_ROOT
  8. # 2. set correct STM8 device -> DEVICE
  9. # 3. set project paths -> PRJ_ROOT, PRJ_SRC_DIR, PRJ_INC_DIR
  10. # 4. set SPL root path -> SPL_ROOT
  11. # 5. include required SPL modules -> SPL_SOURCE
  12. #
  13. #######
  14. # STM8 device (default is STM8 discovery board)
  15. DEVICE=STM8S103
  16. DEVICE_FLASH=stm8s103f3
  17. # set compiler path & parameters
  18. CC_ROOT =
  19. CC = sdcc
  20. CFLAGS = -mstm8 -lstm8 --opt-code-size --disable-warning 126 --disable-warning 110
  21. # -DUSE_FULL_ASSERT=1
  22. # set output folder and target name
  23. OUTPUT_DIR = ./Build
  24. TARGET = $(OUTPUT_DIR)/$(DEVICE).hex
  25. # set project folder and files (all *.c)
  26. PRJ_ROOT = .
  27. PRJ_SRC_DIR = $(PRJ_ROOT)/User
  28. PRJ_INC_DIR = $(PRJ_ROOT)/User
  29. # all project sources included by default
  30. PRJ_SOURCE = $(notdir $(wildcard $(PRJ_SRC_DIR)/*.c))
  31. PRJ_OBJECTS := $(addprefix $(OUTPUT_DIR)/, $(PRJ_SOURCE:.c=.rel))
  32. # set SPL paths
  33. #SPL_SRC_DIR = /usr/share/sdcc/lib/src/stm8/
  34. #SPL_INC_DIR = /usr/share/sdcc/include/stm8/
  35. LIB_INC_DIR = /usr/share/sdcc/include/
  36. #SPL_SRC_DIR = Libraries/SPL/src/
  37. SPL_INC_DIR = Library/SPL/
  38. # add all library sources used here
  39. SPL_SOURCE =
  40. #stm8s_flash.c
  41. SPL_OBJECTS := $(addprefix $(OUTPUT_DIR)/, $(SPL_SOURCE:.c=.rel))
  42. # collect all include folders
  43. INCLUDE = -I$(PRJ_SRC_DIR) -I$(SPL_INC_DIR) -I$(LIB_INC_DIR)
  44. # collect all source directories
  45. VPATH=$(PRJ_SRC_DIR):$(SPL_SRC_DIR)
  46. .PHONY: clean
  47. all: $(TARGET)
  48. $(OUTPUT_DIR)/%.rel: %.c
  49. $(CC) $(CFLAGS) -D$(DEVICE) $(INCLUDE) -c $?
  50. $(OUTPUT_DIR)/%.rel: %.c
  51. $(CC) $(CFLAGS) -D$(DEVICE) $(INCLUDE) -c $? -o $@
  52. $(TARGET): $(PRJ_OBJECTS) $(SPL_OBJECTS)
  53. $(CC) $(CFLAGS) -o $(TARGET) $^
  54. flash: $(TARGET)
  55. stm8flash -c stlinkv2 -p $(DEVICE_FLASH) -s flash -w $(TARGET)
  56. clean:
  57. rm $(OUTPUT_DIR)/*