forked from MartGB/BMSBattery_S_controllers_firmware
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile_windows
128 lines (107 loc) · 2.77 KB
/
Makefile_windows
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#Original Makefile template from Saeid Yazdani (c) 2016
#LICENSE: GNU-LGPL
.PHONY: all clean
#Compiler
CC = sdcc
OBJCOPY = stm8-objcopy
#Platform
PLATFORM = stm8
#Product name
PNAME = main
#Directory for helpers
IDIR = lib/inc
SDIR = lib/src
#.c files in src
SRC = src
#.h files in include/
INC = include
# In case you ever want a different name for the main source file
MAINSRC = $(SRC)/$(PNAME).c
ELF_SECTIONS_TO_REMOVE = -R DATA -R INITIALIZED -R SSEG -R .debug_line -R .debug_loc -R .debug_abbrev -R .debug_info -R .debug_pubnames -R .debug_frame
# These are the sources that must be compiled to .rel files:
EXTRASRCS = \
$(SDIR)/stm8s_itc.c \
$(SDIR)/stm8s_clk.c \
$(SDIR)/stm8s_iwdg.c \
$(SDIR)/stm8s_gpio.c \
$(SDIR)/stm8s_exti.c \
$(SDIR)/stm8s_uart2.c \
$(SDIR)/stm8s_tim1.c \
$(SDIR)/stm8s_tim2.c \
$(SDIR)/stm8s_adc1.c \
$(SDIR)/stm8s_flash.c \
$(SRC)/BOdisplay.c \
$(SRC)/ACAcontrollerState.c \
$(SRC)/ACAeeprom.c \
$(SRC)/ACAsetPoint.c \
$(SRC)/ACAcommons.c \
$(SRC)/gpio.c \
$(SRC)/cruise_control.c \
$(SRC)/uart.c \
$(SRC)/adc.c \
$(SRC)/brake.c \
$(SRC)/timers.c \
$(SRC)/pwm.c \
$(SRC)/motor.c \
$(SRC)/PAS.c \
$(SRC)/SPEED.c \
$(SRC)/display.c \
$(SRC)/display_lcd8.c \
$(SRC)/display_kingmeter.c
HEADERS = \
$(INC)/BOdisplay.h \
$(INC)/ACAcommons.h \
$(INC)/ACAsetPoint.h \
$(INC)/ACAcontrollerState.h \
$(INC)/ACAeeprom.h \
$(INC)/adc.h \
$(INC)/brake.h \
$(INC)/cruise_control.h \
$(INC)/gpio.h \
$(INC)/interrupts.h \
$(INC)/main.h \
$(INC)/motor.h \
$(INC)/pwm.h \
$(INC)/timers.h \
$(INC)/uart.h \
$(INC)/PAS.h \
$(INC)/SPEED.h \
# The list of .rel files can be derived from the list of their source files
RELS = $(EXTRASRCS:.c=.rel)
INCLUDES = -I$(IDIR) -I$(INC)
CFLAGS = -m$(PLATFORM) --std-c99
#--nolospre
ELF_FLAGS = --out-fmt-ihx
#--debug
LIBS =
# This just provides the conventional target name "all"; it is optional
# Note: I assume you set PNAME via some means not exhibited in your original file
all: $(PNAME)
# How to build the overall program
$(PNAME): $(MAINSRC) $(RELS)
$(CC) $(INCLUDES) $(CFLAGS) $(ELF_FLAGS) $(LIBS) $(MAINSRC) $(RELS)
# How to build any .rel file from its corresponding .c file
# GNU would have you use a pattern rule for this, but that's GNU-specific
%.rel: %.c $(HEADERS)
$(CC) -c $(INCLUDES) $(CFLAGS) $(ELF_FLAGS) $(LIBS) -o$< $<
# Suffixes appearing in suffix rules we care about.
# Necessary because .rel is not one of the standard suffixes.
.SUFFIXES: .c .rel
# hex:
#$(OBJCOPY) -O ihex $(ELF_SECTIONS_TO_REMOVE) $(PNAME).elf
#$(PNAME).ihx
flash:
stm8flash -cstlinkv2 -pstm8s105?6 -w$(PNAME).ihx
ENTF = cmd /C del /S
clean:
echo "Cleaning files..."
$(ENTF) *.asm
$(ENTF) *.rel
$(ENTF) *.lk
$(ENTF) *.lst
$(ENTF) *.rst
$(ENTF) *.sym
$(ENTF) *.cdb
$(ENTF) *.map
$(ENTF) *.adb
echo "Done."