Use a precomputed CRC table for xmodem
[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
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,_io_ports=0x1000 \
15           -Wl,-defsym,_switch_input=0x1800 \
16           -Wl,-defsym,_misc_input=0x2000 \
17           -Wl,-defsym,_home_sensors=0x2800 \
18           -Wl,-defsym,_changer_output=0x3000 \
19           -Wl,-defsym,_misc_output=0x3800 \
20           -Wl,-defsym,_uart_regs=0x4000
21
22 OBJCOPY_FLAGS=--only-section=.text \
23               --only-section=.rodata \
24               --only-section=.vectors \
25               --only-section=.data
26
27
28 DEVC_PREFIX = m68hc11-
29 CC = $(DEVC_PREFIX)gcc
30 AS = $(DEVC_PREFIX)as
31 AR = $(DEVC_PREFIX)ar
32 SIZE = $(DEVC_PREFIX)size
33 OBJCOPY = $(DEVC_PREFIX)objcopy
34 OBJDUMP = $(DEVC_PREFIX)objdump
35 LD = $(DEVC_PREFIX)ld
36
37 all: rom2.b rom2.elf rom2.s19
38
39 rom2.elf: $(OBJS) memory.x
40         $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBADD)
41         $(SIZE) $@
42
43 clean:
44         rm -f *.o *.elf *.s19 *.b *.a rom.tar.bz2 romsrc.c crctab.h
45
46 #
47 # Some useful rules
48 #
49 dump:   rom2.elf
50         $(OBJDUMP) -d $<
51
52 size:   rom2.s19
53         $(SIZE) $<
54
55 rom.tar.bz2:
56         rm -f romsrc.c crctab.h
57         tar cjf rom.tar.bz2 README Makefile *.c *.h *.s *.x
58
59 romsrc.c: rom.tar.bz2
60         perl -w src2c.pl < $< > $@
61
62 xmodem.c: crctab.h
63
64 gencrctab: gencrctab.c
65         gcc -o $@ $<
66
67 crctab.h: gencrctab
68         ./gencrctab > $@
69
70 #
71 # Implicit rules
72 #
73 # .elf is for the simulator and gdb
74 # .s19 is for some downloader and the simulator
75 # .b   is a binary dump
76 #
77 .SUFFIXES: .elf .s19 .b
78
79 .elf.s19:
80         $(OBJCOPY) --output-target=srec $(OBJCOPY_FLAGS) $< $*.s19
81
82 .elf.b:
83         $(OBJCOPY) --output-target=binary --gap-fill=255 \
84                    $(OBJCOPY_FLAGS) $< $*.b

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