#
# $Id: makefile,v 1.19 2002/04/01 04:20:13 cjh Exp $
#
# Makefile for DB11 talkers
#
# (c) Copyright 2000 Clifford Heath.
# Any use allowed provided copyright notices are retained.
#

AS	=	m6811-elf-as
LD	=	m6811-elf-ld
#AS	=	m6811-elf-elf-as
#LD	=	m6811-elf-elf-ld

A_F_SERIES	=	talkram.s19 talkB700.s19 talkFE80.s19 talkE2.s19
K_SERIES	=	talkkram.s19 talkkB700.s19 talkkFE80.s19

all:	$(A_F_SERIES) $(K_SERIES)
clean:
	rm -f *.ext.* *.o *.s19 *.bin *.boo *.lst memory.x

# include dependencies:
eeboot.s:	config.s eeprom.s protocol.ext.s progrom.ext.s
eeprom.s:	protocol.ext.s progrom.ext.s
talkE2.o:	hc11a-f.s config.s eeprom.s protocol.ext.s progrom.ext.s
talkB700.o:	hc11a-f.s eeboot.s config.s eeprom.s protocol.ext.s \
		progrom.ext.s
talkFE80.o:	hc11a-f.s eeboot.s config.s eeprom.s protocol.ext.s \
		progrom.ext.s
talkkB700.o:	hc11k.s eeboot.s config.s eeprom.s protocol.ext.s progrom.ext.s
talkkFE80.o:	hc11k.s eeboot.s config.s eeprom.s protocol.ext.s progrom.ext.s
talkkram.o:	hc11k.s config.s ram.ext.s ramvec.s protocol.ext.s progrom.ext.s
talkram.o:	hc11a-f.s config.s protocol.s ram.s progrom.s ramvec.s

# "as" can't handle "bsr" correctly, so I explicitly used direct addressing
# Trouble is, the non-RAM versions need extended addressing, hence *.ext.s
# This obviously not a general solution, but works for now:
.SUFFIXES:	.ext.s
%.ext.s:	%.s
	@sed	-e 's/	\*INSCI/	INSCI/' \
		-e 's/	\*OUTSCI/	OUTSCI/' < $< > $@

#
# Make rules for assembling and linking:
#

# This assembly rule produces a listing file:
ASFLAGS	=	-al
%.o: %.s
	$(AS) $(ASFLAGS) -o $@ $< > $*.lst

# This link rule expects a memory map named TARGET.x, and renames it to memory.x
.SUFFIXES:	.x
%.s19: %.o %.x
	@cp -f $*.x memory.x
	$(LD) -m m68hc11elfb --oformat srec --defsym _start=0 -o $@ $<

# If you want .bin or .elf, here they are:

%.bin: %.o %.x
	@cp $*.x memory.x
	$(LD) -m m68hc11elfb --oformat binary --defsym _start=0 -o $@ $<

%.elf: %.o %.x
	@cp $*.x memory.x
	$(LD) -m m68hc11elfb --defsym _start=0 -o $@ $<
