-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
58 lines (40 loc) · 1.4 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
DEVICE = PFS173
F_CPU = 8000000
TARGET_VDD_MV = 3300
TARGET_VDD = 3.3
# ---------------------------------------------------------------------
OUTPUT_NAME = Serial_HelloWorld_$(DEVICE)
include arch-from-device.mk
ROOT_DIR = "."
BUILD_DIR = .build
OUTPUT_DIR = .output
OUTPUT = $(OUTPUT_DIR)/$(OUTPUT_NAME)
SOURCES = main.c
OBJECTS = $(patsubst %.c,$(BUILD_DIR)/%.rel,$(SOURCES))
# http://sdcc.sourceforge.net/doc/sdccman.pdf
COMPILE = sdcc -m$(ARCH) -c --std-sdcc11 --opt-code-size -D$(DEVICE) -DF_CPU=$(F_CPU) -DTARGET_VDD_MV=$(TARGET_VDD_MV) -I. -I$(ROOT_DIR)/include
LINK = sdcc -m$(ARCH)
EASYPDKPROG = easypdkprog
# symbolic targets:
all: size
print-%: ; @echo $* = $($*)
$(BUILD_DIR)/%.rel: %.c
@mkdir -p $(dir $@)
$(COMPILE) -o $@ $<
$(OUTPUT).ihx: $(OBJECTS)
@mkdir -p $(dir $(OUTPUT))
$(LINK) --out-fmt-ihx -o $(OUTPUT).ihx $(OBJECTS)
$(OUTPUT).bin: $(OUTPUT).ihx
makebin -p $(OUTPUT).ihx $(OUTPUT).bin
build: $(OUTPUT).bin
size: build
@echo '---------- Segments ----------'
@egrep '(ABS,CON)|(REL,CON)' $(OUTPUT).map | gawk --non-decimal-data '{dec = sprintf("%d","0x" $$2); print dec " " $$0}' | /usr/bin/sort -n -k1 | cut -f2- -d' '
@echo '------------------------------'
@stat -L --printf "Size of $(OUTPUT_NAME).bin: %s bytes\n" $(OUTPUT).bin
program: size
$(EASYPDKPROG) -n $(DEVICE) write $(OUTPUT).ihx
run:
$(EASYPDKPROG) -r $(TARGET_VDD) start
clean:
rm -r -f $(BUILD_DIR) $(OUTPUT_DIR)