Message Integrity Checking
[uccvend-snackrom.git] / ROM2 / Makefile
1 # muchly stolen from m68hc1x's example.tar.gz's Makefile
2
3 OBJS = \
4         motors.o keypad.o display_basic.o coinmech.o chime.o \
5         helpers.o main_basic.o sci.o \
6         vectors.o start.o romsrc.o xmodem.o mic.o
7 INCLUDES = vend.h keypad.h chime.h asm.h display_basic.h ports.h types.h
8 # debugging doesn't get compiled into the ROM image
9 CFLAGS = -m68hc11 -mshort -Wall -O1 \
10         -msoft-reg-count=0 -ffixed-z -g #-fomit-frame-pointer
11
12 LDFLAGS = -m68hc11 -mshort -Wl,-m,m68hc11elfb \
13           -nostartfiles \
14           -Wl,-defsym,_nvram=0x0800 \
15           -Wl,-defsym,_io_ports=0x1000 \
16           -Wl,-defsym,_switch_input=0x1800 \
17           -Wl,-defsym,_misc_input=0x2000 \
18           -Wl,-defsym,_home_sensors=0x2800 \
19           -Wl,-defsym,_changer_output=0x3000 \
20           -Wl,-defsym,_misc_output=0x3800 \
21           -Wl,-defsym,_uart_regs=0x4000
22
23 OBJCOPY_FLAGS=--only-section=.text \
24               --only-section=.rodata \
25               --only-section=.vectors \
26               --only-section=.data
27
28
29 DEVC_PREFIX = m68hc11-
30 CC = $(DEVC_PREFIX)gcc
31 AS = $(DEVC_PREFIX)as
32 AR = $(DEVC_PREFIX)ar
33 SIZE = $(DEVC_PREFIX)size
34 OBJCOPY = $(DEVC_PREFIX)objcopy
35 OBJDUMP = $(DEVC_PREFIX)objdump
36 LD = $(DEVC_PREFIX)ld
37
38 all: rom2.b rom2.elf rom2.s19
39
40 rom2.elf: $(OBJS) memory.x check-romsrc.pl
41         $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBADD)
42         $(SIZE) $@
43         @perl -w check-romsrc.pl
44
45 clean:
46         rm -f *.o *.elf *.s19 *.b *.a rom.tar.bz2 romsrc.s crctab.h m68hc11-gdb gencrctab
47
48 #
49 # Some useful rules
50 #
51 dump:   rom2.elf
52         $(OBJDUMP) -d $<
53
54 size:   rom2.s19
55         $(SIZE) $<
56
57 rom.tar.bz2:
58         rm -f romsrc.s crctab.h
59         tar cjf rom.tar.bz2 README Makefile gdbsimrc *.pl *.c *.h *.s *.x
60
61 romsrc.s: rom.tar.bz2 src2asm.pl
62         perl -w src2asm.pl < $< > $@
63
64 xmodem.c: crctab.h
65
66 gencrctab: gencrctab.c
67         gcc -o $@ $<
68
69 crctab.h: gencrctab
70         ./gencrctab > $@
71
72 #
73 # Implicit rules
74 #
75 # .elf is for the simulator and gdb
76 # .s19 is for some downloader and the simulator
77 # .b   is a binary dump
78 #
79 .SUFFIXES: .elf .s19 .b
80
81 .elf.s19:
82         $(OBJCOPY) --output-target=srec $(OBJCOPY_FLAGS) $< $*.s19
83
84 .elf.b:
85         $(OBJCOPY) --output-target=binary --gap-fill=255 \
86                    $(OBJCOPY_FLAGS) $< $*.b
87         @perl -e '$$sum = 0;while(read STDIN, $$a, 1){$$sum += ord($$a); $$sum = $$sum&0xffff;} printf "Checksum is \%x\n", $$sum' < $@
88
89 m68hc11-gdb: /usr/bin/m68hc11-gdb
90         sed -e 's|m68hc11eepr/reg 0xb000 512|m68hc11eepr/reg 0x4000 1  |' < $< > $@
91         chmod 755 $@
92         
93 sim: m68hc11-gdb rom2.elf
94         ./m68hc11-gdb -x gdbsimrc rom2.elf

UCC git Repository :: git.ucc.asn.au