-CFLAGS = -g -O2 -Wall
-CC = m68hc11-gcc
+# muchly stolen from m68hc1x's example.tar.gz's Makefile
-OBJS = motors.o keypad.o display.o coinmech.o helpers.o
+OBJS = \
+ motors.o keypad.o display.o coinmech.o helpers.o main.o \
+ vectors.o
+INCLUDES = vend.h
-all: rom
-rom: $(OBJS)
+CFLAGS = -O2 -Wall -m68hc11 -mshort -Wall -Wmissing-prototypes -Os -g0 \
+ -msoft-reg-count=0 -ffixed-z
+
+LDFLAGS = -m68hc11 -mshort -Wl,-m,m68hc11elfb \
+ -nostartfiles \
+ -Wl,-defsym,_io_ports=0x1000
+
+OBJCOPY_FLAGS=--only-section=.text \
+ --only-section=.rodata \
+ --only-section=.vectors \
+ --only-section=.data
+
+
+DEVC_PREFIX = m68hc11-
+CC = $(DEVC_PREFIX)gcc
+AS = $(DEVC_PREFIX)as
+AR = $(DEVC_PREFIX)ar
+SIZE = $(DEVC_PREFIX)size
+OBJCOPY = $(DEVC_PREFIX)objcopy
+OBJDUMP = $(DEVC_PREFIX)objdump
+LD = $(DEVC_PREFIX)ld
+
+all: rom2.b rom2.elf rom2.s19
+
+rom2.elf: $(OBJS) memory.x
+ $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBADD)
clean:
- rm -f $(OBJS)
+ rm -f $(OBJS) *.elf *.s19 *.b *.a
+
+#
+# Implicit rules
+#
+# .elf is for the simulator and gdb
+# .s19 is for some downloader and the simulator
+# .b is a binary dump
+#
+.SUFFIXES: .elf .s19 .b
+
+.elf.s19:
+ $(OBJCOPY) --output-target=srec $(OBJCOPY_FLAGS) $< $*.s19
+
+.elf.b:
+ $(OBJCOPY) --output-target=binary --gap-fill=255 \
+ --only-section=.data $(OBJCOPY_FLAGS) $< $*.b
+