-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.include
69 lines (41 loc) · 1.29 KB
/
Makefile.include
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
#######################################################
# toolchain
CC = sdcc
OBJCOPY = objcopy
PACK_HEX = packihx
WCHISP ?= wchisptool -g -f
#######################################################
FREQ_SYS ?= 24000000
XRAM_SIZE ?= 0x0400
XRAM_LOC ?= 0x0000
CODE_SIZE ?= 0x3800
ROOT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
OBJDIR = ./build
OBJECTS = \
$(OBJDIR)/debug.rel \
$(OBJDIR)/usb_gamepad.rel \
$(OBJDIR)/usb_host.rel
CFLAGS := -V -mmcs51 --model-small --stack-auto \
--xram-size $(XRAM_SIZE) --xram-loc $(XRAM_LOC) \
--code-size $(CODE_SIZE) \
-I/ -DFREQ_SYS=$(FREQ_SYS) \
$(EXTRA_FLAGS)
LFLAGS := $(CFLAGS)
RELS := $(C_FILES:.c=.rel)
print-% : ; @echo $* = $($*)
$(OBJDIR)/%.rel : %.c
$(CC) -c $(CFLAGS) -o $@ $<
$(OBJDIR)/$(TARGET).ihx: $(OBJECTS)
$(CC) $(OBJECTS) $(LFLAGS) -o $(OBJDIR)/$(TARGET).ihx
$(OBJDIR)/$(TARGET).hex: $(OBJDIR)/$(TARGET).ihx
$(PACK_HEX) $(OBJDIR)/$(TARGET).ihx > $(OBJDIR)/$(TARGET).hex
$(OBJDIR)/$(TARGET).bin: $(OBJDIR)/$(TARGET).ihx
$(OBJCOPY) -I ihex -O binary $(OBJDIR)/$(TARGET).ihx $(OBJDIR)/$(TARGET).bin
flash: $(OBJDIR)/$(TARGET).bin
$(WCHISP) -f $(OBJDIR)/$(TARGET).bin -g
.DEFAULT_GOAL := all
directories:
@mkdir -p $(OBJDIR)
all: directories $(OBJDIR)/$(TARGET).bin $(OBJDIR)/$(TARGET).hex
clean:
rm -f $(OBJDIR)/*