-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
73 lines (53 loc) · 1.51 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
65
66
67
68
69
70
71
72
73
################################################################################
# BUILD OPTIONS
################################################################################
# Memory model of the target device ('medium' or 'large'). Devices with >32 KB
# of flash should typically use 'large'.
MODEL ?= medium
################################################################################
CC = sdcc
CFLAGS = -mstm8
ifeq ($(MODEL),large)
CFLAGS += --model-large
LIBSUFFIX = -large
endif
AR = sdar
AFLAGS = -c
ifeq ($(OS),Windows_NT)
RM = cmd.exe /C del /Q
MKDIR = mkdir
else
RM = rm -fr
MKDIR = mkdir -p
endif
LIBHEAD = lin_checksum.h
LIBSRC = lin_checksum.c
TESTHEAD = ucsim.h lin_checksum.h
TESTSRC = ucsim.c main.c
OBJDIR = obj
LIBOBJ = $(patsubst %.c,$(OBJDIR)/%.rel,$(LIBSRC))
TESTOBJ = $(patsubst %.c,$(OBJDIR)/%.rel,$(TESTSRC))
LIBDIR = lib
LIBRARY = $(LIBDIR)/stm8-lin-checksum$(LIBSUFFIX).lib
BINDIR = bin
BINARY = $(BINDIR)/test.ihx
.PHONY: library test all clean sim
all: library
library: $(LIBRARY)
test: $(BINARY)
$(LIBRARY): $(LIBOBJ) | $(LIBDIR)
$(AR) $(AFLAGS) -r $@ $(LIBOBJ)
$(BINARY): $(LIBRARY) $(TESTOBJ) | $(BINDIR)
$(CC) $(CFLAGS) --out-fmt-ihx -o $@ -l $(LIBRARY) $(TESTOBJ)
$(LIBOBJ): $(LIBHEAD) $(LIBSRC) | $(OBJDIR)
$(TESTOBJ): $(TESTHEAD) $(TESTSRC) | $(OBJDIR)
$(OBJDIR)/%.rel: %.c
$(CC) $(CFLAGS) -o $@ -c $<
$(OBJDIR) $(LIBDIR) $(BINDIR):
$(MKDIR) $@
clean:
$(RM) $(OBJDIR)
$(RM) $(LIBDIR)
$(RM) $(BINDIR)
sim:
ucsim_stm8 -G -t STM8S208 -X 16M -I if=rom[0x5800] $(BINARY)