This repository was archived by the owner on Oct 9, 2025. It is now read-only.
forked from Lymes/cxg-e60wt
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile.include
More file actions
80 lines (61 loc) · 1.77 KB
/
Makefile.include
File metadata and controls
80 lines (61 loc) · 1.77 KB
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
#export PATH := $(PATH):$(HOME)/local/sdcc/bin
SHELL = cmd.exe
MCU = stm8s103k3
ARCH = stm8
F_CPU ?= 16000000
TARGET ?= main.ihx
LIBDIR =
SRCS := $(wildcard *.c $(LIBDIR)/*.c)
ASRCS := $(wildcard *.s $(LIBDIR)/*.s)
#OBJS = $(SRCS:.c=.rel)
#OBJS += $(ASRCS:.s=.rel)
OBJ_DIR = obj
OBJS := $(patsubst %.c,$(OBJ_DIR)/%.rel,$(SRCS))
OBJS += $(patsubst %.s,$(OBJ_DIR)/%.rel,$(ASRCS))
CC = sdcc
LD = sdld
AS = sdasstm8
OBJCOPY = sdobjcopy
ASFLAGS = -plosgff
CFLAGS = -m$(ARCH) -p$(MCU) --std-sdcc11
CFLAGS += -DF_CPU=$(F_CPU)UL -I. -I$(LIBDIR)
CFLAGS += --stack-auto --noinduction --use-non-free
//CFLAGS += -DLEFTLESS
//CFLAGS += -DDISABLESLEEP
CFLAGS += -DDEEPSLEEPWAKEUP
//CFLAGS += -DDEBUG
//CFLAGS += -DRESETCALIBRATION
## Disable lospre (workaround for bug 2673)
#CFLAGS += --nolospre
## Extra optimization rules - use with care
#CFLAGS += --peep-file $(LIBDIR)/util/extra.def
LDFLAGS = -m$(ARCH) -l$(ARCH) --out-fmt-ihx
MKDIR_P = mkdir -p
all: directories $(TARGET) hex size
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) -o $@
$(OBJ_DIR)/%.rel: %.c
$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
$(OBJ_DIR)/%.rel: %.s
$(AS) $(ASFLAGS) $<
directories: ${OBJ_DIR}
hex: $(TARGET)
packihx $(TARGET) > main.hex
${OBJ_DIR}:
${MKDIR_P} ${OBJ_DIR}
size:
@$(OBJCOPY) -I ihex --output-target=binary $(TARGET) $(TARGET).bin
# @echo "----------"
# @stat -L -f "Image size: %z bytes." $(TARGET).bin
@echo --------------------
@for %%I in ($(TARGET).bin) do @echo Image size: %%~zI bytes.
@echo --------------------
flash: $(TARGET)
stm8flash -c stlinkv2 -p $(MCU) -w $(TARGET)
serial: $(TARGET)
stm8gal -p /dev/ttyUSB0 -w $(TARGET)
clean:
del /q *.map *.ihx *.lk *.cdb *.bin *.hex
rd /s /q $(OBJ_DIR)
rd /s /q -p
.PHONY: clean all flash directories