CC=m68k-coff-gcc
LD=m68k-coff-ld 
AS=m68k-coff-as -m68010
NM=m68k-coff-nm
SIZE=m68k-coff-size
STRIP=m68k-coff-strip
OBJDUMP=m68k-coff-objdump
OBJCOPY=m68k-coff-objcopy

CFLAGS = -g -Os -m68000 -msoft-float  -fomit-frame-pointer
LDFLAGS= -M=fbug.map -nostdlib -Ttext 0x800000 -Tbss 0x1fe000

LD_LIBS= -L/home/holm/cross68k/lib/gcc/m68k-coff/3.4.6/msoft-float -lgcc
all: portbug

unixbug : coldunix.o main.o printunix.o getlineunix.o general.o \
	bf.o bm.o br.o bs.o dc.o he.o lo.o rd.o rm.o tm.o \
	mm.o md.o go.o tr.o sd.o as.o asm68.o disasm68.o asmcode68.o \
	handler.o fproutines.o 68def.o asmprocunix.o 
	$(CC) coldunix.o  68def.o \
	printunix.o getlineunix.o general.o asmprocunix.o main.o bf.o bm.o \
	bs.o dc.o he.o lo.o rd.o rm.o tm.o mm.o md.o go.o tr.o br.o \
	sd.o as.o disasm68.o asm68.o asmcode68.o handler.o fproutines.o \
	-g -o cbug040TT 

portbug : coldport.o main.o printport.o getlineport.o general.o \
	asmprocport.o \
	bf.o bm.o br.o bs.o da.o dc.o he.o lo.o rd.o rm.o tm.o \
	mm.o md.o go.o tr.o sd.o as.o asm68.o disasm68.o asmcode68.o \
	asmhandler.o handler.o  asmstartport.o conf.o fproutines.o \
	68def.o rtc.o
	
	rm -f *.map
	$(LD) $(LDFLAGS) asmstartport.o asmhandler.o coldport.o \
	printport.o getlineport.o general.o asmprocport.o main.o bf.o bm.o \
	bs.o da.o dc.o he.o lo.o rd.o rm.o tm.o mm.o md.o go.o tr.o br.o \
	sd.o as.o disasm68.o asm68.o asmcode68.o handler.o conf.o \
	fproutines.o  68def.o rtc.o \
	-o fbug000TT.coff $(LD_LIBS)
	 $(SIZE) fbug000TT.coff
	$(OBJDUMP) -S fbug000TT.coff >fbug000TT.disas
coldport.o :  textdef.h vardef.h userdef.h targetsys.h
coldunix.o :  textdef.h vardef.h userdef.h targetsys.h

asmstartport.o : textdef.h vardef.h userdef.h targetsys.h
		cpp asmstartport.s  > temp.s
		$(AS) -a=asmstartport.l  -o asmstartport.o temp.s
		rm temp.s
asmcode68.o : textdef.h vardef.h userdef.h targetsys.h
		cpp asmcode68.s  > temp.s
		$(AS) -a=asmcode68.l  -o asmcode68.o temp.s
		rm temp.s
asmhandler.o : textdef.h vardef.h userdef.h targetsys.h
		cpp asmhandler.s  > temp.s
		$(AS) -a=asmhandler.l  -o asmhandler.o temp.s
		rm temp.s
rtc.o : rtc.s textdef.h vardef.h userdef.h targetsys.h
		$(AS) $<  -a=$*.l  -o $*.o 
clean:
	rm -f *.o *.coff* *.l symbols *.debug *.map fbug000TT* 

asmclean:
	rm -f asmstartport.o asmcode68.o asmhandler.o temp.s

assemble: asmstartport.o asmcode68.o asmhandler.o

27256: portbug

	$(NM) fbug000TT >symbols
	$(STRIP) fbug000TT
#	c2bin fbug000TT fbug000TT.bin
#	make2rom 32768 fbug000TT.bin fbug000TT.even fbug000TT.odd
27512: portbug

	$(NM) fbug000TT.coff >symbols
#	$(STRIP) fbug000TT.coff
#	c2bin fbug000TT.coff fbug000TT.bin
	$(OBJCOPY) -O binary -S -Rbss --gap-fill 0xff fbug000TT.coff fbug000TT.rom
	make2rom 65536 fbug000TT.rom fbug000TT.even fbug000TT.odd
