-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
65 lines (48 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
#DEVICE = PFS154
DEVICE = PMS150C
TARGET_VDD_MV = 5000
# ---------------------------------------------------------------------
OUTPUT_NAME = TempPWMFan_$(DEVICE)
ifeq ($(DEVICE), PFS154)
ARCH = pdk14
else ifeq ($(DEVICE), PFS173)
ARCH = pdk15
else ifeq ($(DEVICE), PMS150C)
ARCH = pdk13
else ifeq ($(DEVICE), PMS15A)
ARCH = pdk13
else ifeq ($(DEVICE), PMS152)
ARCH = pdk14
else ifeq ($(DEVICE), PMS154C)
ARCH = pdk14
endif
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) -DTARGET_VDD_MV=$(TARGET_VDD_MV) -I.
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
clean:
rm -r -f $(BUILD_DIR) $(OUTPUT_DIR)