forked from DeqingSun/ch55xduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (44 loc) · 1.58 KB
/
Makefile
File metadata and controls
63 lines (44 loc) · 1.58 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
BASENAME=$(shell basename $$(pwd))
EXECUTEABLE=$(BASENAME).ihx
#SDCCBASE=/usr/local
SDCCBASE=/opt/sdcc
BINDIR=$(SDCCBASE)/bin
CC=$(BINDIR)/sdcc
LD=$(BINDIR)/sdld
SDBASE=../../sduino/hardware/sduino/stm8
LIBBASE=$(SDBASE)/STM8S_StdPeriph_Driver
SDUINO=$(SDBASE)/cores/sduino
CPPFLAGS=-DF_CPU=16000000L -DSTM8S103 -Ddouble=float \
-I. -I$(SDUINO) -I$(SDBASE)/variants/standard \
-I$(LIBBASE)/inc -I$(LIBBASE)/src \
-I$(SDCCBASE)/share/sdcc/include/
CFLAGS= -mstm8 #--debug
LDFLAGS=-L$(LIBBASE)/lib -L$(SDCCBASE)/share/sdcc/lib/stm8 -lSTM8S103
SRCS=pinmode-c.c pinmode-asm.c main.c
BUILDDIR=build
OBJECTS=$(SRCS:%.c=$(BUILDDIR)/%.rel)
.PHONY: all clean flash statistics sim
all: $(EXECUTEABLE) statistics sim
$(EXECUTEABLE): $(OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
$(OBJECTS) : $(BUILDDIR)/%.rel : %.c
mkdir -p $(BUILDDIR)
$(CC) -c $(CPPFLAGS) $(CFLAGS) $^ -o $@
flash: $(EXECUTABLE)
stm8flash -cstlinkv2 -pstm8s103?3 -w $^
readopt:
stm8flash -c stlinkv2 -p stm8s103?3 -s opt -r opt.bin
# lists the length of functions and constants defined in the primary source
# file
statistics: $(OBJECTS)
cd $(BUILDDIR); awk '/ CODE/ {print FILENAME "\t" strtonum("0x"$$4)}' *.sym
sim: $(EXECUTEABLE)
@. ./sim
# @. ./sim | grep "0x0001 00 00 00 00 00 00"
# . ./sim | grep "0x0001 00 00 00 00 00 00" || echo "fail"
# grep "[0-9] _" $(BASENAME).rst |\
# awk 'BEGIN {print "length\tfunction\n------\t----------";}{ a=strtonum("0x"$$1);if (name) print a-s "\t" name; s=a; name=$$3}'
clean:
rm -rf *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \
*.cdb *.adb *~ *.bak build
rm -f $(EXECUTABLE)