-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (43 loc) · 1.5 KB
/
Makefile
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
INCDIR = ./inc
SRCDIR = ./src
OBJDIR = ./obj
HEXDIR = ./hex
LIBDIR =
TARGET = $(HEXDIR)/relax
# main.c first
#C_SRC = $(wildcard $(SRCDIR)/main.c) $(wildcard $(SRCDIR)/**/*.c)
C_SRC = $(SRCDIR)/main.c $(wildcard $(SRCDIR)/*.c) $(SRCDIR)/cordlib/cord_hw.c $(SRCDIR)/cordlib/cord_init.c $(SRCDIR)/cordlib/cord_connection.c $(SRCDIR)/cordlib/cord_protocol.c $(SRCDIR)/jsmn/jsmn.c
ASM_SRC =
C_SRC_FILE = $(patsubst $(SRCDIR)/%,%,$(C_SRC))
C_OBJ_FILE = $(C_SRC_FILE:%.c=%.c.rel)
OBJ = $(addprefix $(OBJDIR)/, $(C_OBJ_FILE))
# Memory Model (small, medium, large, huge)
MODEL = large
# Memory Layout
CODE_SIZE = --code-loc 0x0000 --code-size 65536
IRAM_SIZE = --idata-loc 0x0000 --iram-size 256
XRAM_SIZE = --xram-loc 0x0000 --xram-size 1024
# SDCC
CC = sdcc
AS = sdas8051
MCU_MODEL = mcs51
#LIBS =
#LIBPATH = -L $(LIBDIR)
#DEBUG = --debug
AFLAGS = -l -s
CFLAGS = -I./inc -I$(INCDIR) -m$(MCU_MODEL) --model-$(MODEL) --out-fmt-ihx --no-xinit-opt $(DEBUG)
LFLAGS = $(LIBPATH) $(LIBS) -m$(MCU_MODEL) --model-$(MODEL) $(CODE_SIZE) $(IRAM_SIZE) $(XRAM_SIZE) --out-fmt-ihx $(DEBUG)
.PHONY: all clean
all: $(TARGET).hex
$(HEXDIR)/%.hex: $(OBJDIR)/%.ihx
$(S) packihx $^ > $@
$(OBJDIR)/%.ihx: $(OBJ)
$(S) $(CC) -o $@ $(LFLAGS) $^
$(OBJ): $(OBJDIR)/%.c.rel: $(SRCDIR)/%.c
@mkdir -p $(@D)
$(S) $(CC) -o $@ $(CFLAGS) -c $^
$(OBJDIR)/%.asm.rel: $(SRCDIR)/%.asm
$(S) $(AS) $(AFLAGS) -o $@ $^
clean:
$(S) rm -rf $(OBJDIR)/*
$(S) rm -rf $(TARGET).hex