all: test
	echo All up to date

test: 6809dasm
	asm6809 -B -o cputest.bin -l cputest.lis -s cputest.sym cputest.asm
	./6809dasm --sbt cputest.bin cputest.dat > cputest.c; ecce cputest.c < makeexit.ecc > /dev/null 2>&1 ; cc -o cputest CPUtest.c
	./6809dasm --vectrex tests/armor.vec > tests/armor.asm.new
	./6809dasm --vectrex --sbt tests/armor.vec > tests/armor.c.new
	diff tests/armor.asm tests/armor.asm.new || echo -n ""
	diff tests/armor.c tests/armor.c.new || echo -n ""
	./6809dasm --vectrex tests/THRUST.vec tests/THRUST.dat > tests/THRUST.asm.new
	./6809dasm --vectrex --sbt tests/THRUST.vec tests/THRUST.dat > tests/THRUST.c.new
	diff tests/THRUST.asm tests/THRUST.asm.new || echo -n ""
	diff tests/THRUST.c tests/THRUST.c.new || echo -n ""
	./6809dasm tests/opcode-test.vec tests/opcode-test.dat > tests/opcode-test.asm.new
	./6809dasm --sbt tests/opcode-test.vec tests/opcode-test.dat > tests/opcode-test.c.new
	diff tests/opcode-test.asm tests/opcode-test.asm.new || echo -n ""
	diff tests/opcode-test.c tests/opcode-test.c.new || echo -n ""

clean:
	rm -f *~ *.o 6809dasm 6809.c.html 6809dasm.c.html vectrex-regs.c.html tests/*.new

6809dasm: 6809dasm.o 6809.o vectrex-regs.o dasm09/dasm09.o
	cc -g -o 6809dasm 6809dasm.o 6809.o vectrex-regs.o dasm09/dasm09.o

dasm09/dasm09.o: dasm09/dasm09.c
	cc -c -o dasm09/dasm09.o dasm09/dasm09.c
	ctohtml dasm09/dasm09.c > dasm09/dasm09.c.html

6809.o: 6809.c 6809.h
	cc -Wall -g -c 6809.c
	ctohtml 6809.c > 6809.c.html
	ctohtml 6809.h > 6809.h.html

vectrex-regs.o: vectrex-regs.c 6809.h
	cc -Wall -g -c vectrex-regs.c
	ctohtml vectrex-regs.c > vectrex-regs.c.html

6809dasm.o: 6809dasm.c 6809.h
	cc -Wall -g -c 6809dasm.c
	ctohtml 6809dasm.c > 6809dasm.c.html

update: 6809dasm
	scp 6809.c 6809.c.html gtoal@gtoal.com:gtoal.com/SBTPROJECT/6809sbt/
	scp 6809.h 6809.h.html gtoal@gtoal.com:gtoal.com/SBTPROJECT/6809sbt/
	scp vectrex-regs.c vectrex-regs.c.html gtoal@gtoal.com:gtoal.com/SBTPROJECT/6809sbt/
	scp 6809dasm.c 6809dasm.c.html gtoal@gtoal.com:gtoal.com/SBTPROJECT/6809sbt/
	scp dasm09/dasm09.c dasm09/dasm09.c.html gtoal@gtoal.com:gtoal.com/SBTPROJECT/6809sbt/dasm09/
	scp tests/* gtoal@gtoal.com:gtoal.com/SBTPROJECT/6809sbt/tests/
	ctohtml tests/THRUST.c.new > tests/THRUST.c.new.html
	ctohtml tests/armor.c.new > tests/armor.c.new.html
	grep -v "^  // " tests/armor.c.new > tests/armor.c
	ctohtml tests/armor.c > tests/armor.c.html
	scp tests/armor.c.html gtoal@gtoal.com:gtoal.com/SBTPROJECT/6809sbt/
	scp tests/THRUST.c.new.html gtoal@gtoal.com:gtoal.com/SBTPROJECT/6809sbt/sample-output.html
	scp tests/armor.c.new.html gtoal@gtoal.com:gtoal.com/SBTPROJECT/6809sbt/sample-output2.html
	cp tests/armor.asm.new tests/armor.asm
	cp tests/armor.c.new tests/armor.c
	cp tests/opcode-test.asm.new tests/opcode-test.asm
	cp tests/opcode-test.c.new tests/opcode-test.c
	cp tests/THRUST.asm.new tests/THRUST.asm
	cp tests/THRUST.c.new tests/THRUST.c
